Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
SCUMM: Replace use of strdup with Common::String
  • Loading branch information
csnover authored and sev- committed Aug 18, 2018
1 parent f7e05a6 commit 072a52a
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions engines/scumm/smush/smush_font.cpp
Expand Up @@ -22,6 +22,7 @@




#include "common/file.h" #include "common/file.h"
#include "common/str.h"
#include "scumm/scumm.h" #include "scumm/scumm.h"
#include "scumm/util.h" #include "scumm/util.h"


Expand Down Expand Up @@ -226,11 +227,11 @@ void SmushFont::drawStringWrap(const char *str, byte *buffer, int dst_width, int
debugC(DEBUG_SMUSH, "SmushFont::drawStringWrap(%s, %d, %d, %d, %d, %d)", str, x, y, left, right, center); debugC(DEBUG_SMUSH, "SmushFont::drawStringWrap(%s, %d, %d, %d, %d, %d)", str, x, y, left, right, center);


const int width = right - left; const int width = right - left;
char *s = strdup(str); Common::String s(str);
char *words[MAX_WORDS]; char *words[MAX_WORDS];
int word_count = 0; int word_count = 0;


char *tmp = s; Common::String::iterator tmp = s.begin();
while (tmp) { while (tmp) {
assert(word_count < MAX_WORDS); assert(word_count < MAX_WORDS);
words[word_count++] = tmp; words[word_count++] = tmp;
Expand Down Expand Up @@ -293,8 +294,6 @@ void SmushFont::drawStringWrap(const char *str, byte *buffer, int dst_width, int
y += getStringHeight(substrings[i]); y += getStringHeight(substrings[i]);
} }
} }

free(s);
} }


} // End of namespace Scumm } // End of namespace Scumm

0 comments on commit 072a52a

Please sign in to comment.