src/string.cpp
changeset 5587 167d9a91ef02
parent 5584 1111b4d36e35
child 5609 dc6a58930ba4
equal deleted inserted replaced
5586:2d4126d81ebb 5587:167d9a91ef02
     4 #include "openttd.h"
     4 #include "openttd.h"
     5 #include "functions.h"
     5 #include "functions.h"
     6 #include "string.h"
     6 #include "string.h"
     7 #include "macros.h"
     7 #include "macros.h"
     8 #include "table/control_codes.h"
     8 #include "table/control_codes.h"
       
     9 #include "helpers.hpp"
     9 
    10 
    10 #include <stdarg.h>
    11 #include <stdarg.h>
    11 #include <ctype.h> // required for tolower()
    12 #include <ctype.h> // required for tolower()
    12 
    13 
    13 void ttd_strlcat(char *dst, const char *src, size_t size)
    14 void ttd_strlcat(char *dst, const char *src, size_t size)
    61 	char* p;
    62 	char* p;
    62 
    63 
    63 	va_start(va, str);
    64 	va_start(va, str);
    64 	len = vsnprintf(buf, lengthof(buf), str, va);
    65 	len = vsnprintf(buf, lengthof(buf), str, va);
    65 	va_end(va);
    66 	va_end(va);
    66 	p = malloc(len + 1);
    67 	MallocT(&p, len + 1);
    67 	if (p != NULL) memcpy(p, buf, len + 1);
    68 	if (p != NULL) memcpy(p, buf, len + 1);
    68 	return p;
    69 	return p;
    69 }
    70 }
    70 
    71 
    71 
    72