src/string.cpp
branchcustombridgeheads
changeset 5650 aefc131bf5ce
parent 5649 55c8267c933f
child 5860 7fdc9b423ba1
equal deleted inserted replaced
5649:55c8267c933f 5650:aefc131bf5ce
     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