Permalink
Browse files

LURE: Replace use of strdup with Common::String

  • Loading branch information...
csnover authored and sev- committed Dec 6, 2017
1 parent 0851a30 commit bc3c8bd8d251b7a0631e1993e6365719382eacf6
Showing with 5 additions and 7 deletions.
  1. +3 −4 engines/lure/room.cpp
  2. +2 −3 engines/lure/surface.cpp
@@ -491,18 +491,17 @@ void Room::update() {
if (_hotspotId != 0)
s.writeString(0, 0, _hotspotName, false);
} else {
// Word wrap (if necessary) the status line and dispaly it
char *statusLineCopy = strdup(_statusLine);
// Word wrap (if necessary) the status line and display it
Common::String statusLineCopy(_statusLine);
char **lines;
uint8 numLines;
int16 yPos = 0;
s.wordWrap(statusLineCopy, s.width(), lines, numLines);
s.wordWrap(statusLineCopy.begin(), s.width(), lines, numLines);
for (int lineNum = 0; lineNum < numLines; ++lineNum) {
s.writeString(0, yPos, lines[lineNum], false, white);
yPos += FONT_HEIGHT;
}
Memory::dealloc(lines);
Memory::dealloc(statusLineCopy);
}

// Debug - if the bottle object is on layer 0FEh, then display it's surface
@@ -479,16 +479,15 @@ Surface *Surface::newDialog(uint16 width, uint8 numLines, const char **lines, bo

Surface *Surface::newDialog(uint16 width, const char *line, int color) {
char **lines;
char *lineCopy = strdup(line);
Common::String lineCopy(line);
uint8 numLines;
wordWrap(lineCopy, width - (Surface::textX() * 2), lines, numLines);
wordWrap(lineCopy.begin(), width - (Surface::textX() * 2), lines, numLines);

// Create the dialog
Surface *result = newDialog(width, numLines, const_cast<const char **>(lines), true, color);

// Deallocate used resources
free(lines);
free(lineCopy);

return result;
}

0 comments on commit bc3c8bd

Please sign in to comment.