From f35ed4bbc2b05f1b83476b60948d64375f77f1b4 Mon Sep 17 00:00:00 2001 From: rubidium Date: Wed, 10 Jan 2007 18:56:51 +0000 Subject: (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b. --- src/newgrf_text.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/newgrf_text.cpp') diff --git a/src/newgrf_text.cpp b/src/newgrf_text.cpp index e859f6e6c..af1dc688a 100644 --- a/src/newgrf_text.cpp +++ b/src/newgrf_text.cpp @@ -20,6 +20,7 @@ #include "newgrf.h" #include "newgrf_text.h" #include "table/control_codes.h" +#include "helpers.hpp" #define GRFTAB 28 #define TABSIZE 11 @@ -157,7 +158,8 @@ static byte _currentLangID = GRFLX_ENGLISH; //by default, english is used. char *TranslateTTDPatchCodes(const char *str) { - char *tmp = malloc(strlen(str) * 10 + 1); /* Allocate space to allow for expansion */ + char *tmp; + MallocT(&tmp, strlen(str) * 10 + 1); /* Allocate space to allow for expansion */ char *d = tmp; bool unicode = false; WChar c; @@ -253,7 +255,8 @@ char *TranslateTTDPatchCodes(const char *str) } *d = '\0'; - return realloc(tmp, strlen(tmp) + 1); + ReallocT(&tmp, strlen(tmp) + 1); + return tmp; } @@ -295,7 +298,7 @@ StringID AddGRFString(uint32 grfid, uint16 stringid, byte langid_to_add, bool ne translatedtext = TranslateTTDPatchCodes(text_to_add); - newtext = malloc(sizeof(*newtext) + strlen(translatedtext) + 1); + newtext = (GRFText*)malloc(sizeof(*newtext) + strlen(translatedtext) + 1); newtext->next = NULL; newtext->langid = langid_to_add; strcpy(newtext->text, translatedtext); -- cgit v1.2.3-54-g00ecf