1
0
mirror of https://github.com/OpenTTD/OpenTTD.git synced 2025-08-24 23:19:09 +00:00

(svn r2754) Move str_fmt into string.[ch]

This commit is contained in:
tron
2005-07-29 21:52:20 +00:00
parent 1736566e22
commit 3a162799fd
4 changed files with 20 additions and 17 deletions

View File

@@ -3,6 +3,8 @@
#include "stdafx.h"
#include "string.h"
#include <stdarg.h>
void ttd_strlcat(char *dst, const char *src, size_t size)
{
assert(size > 0);
@@ -39,3 +41,19 @@ char* strecpy(char* dst, const char* src, const char* last)
*dst = '\0';
return dst;
}
char* CDECL str_fmt(const char* str, ...)
{
char buf[4096];
va_list va;
int len;
char* p;
va_start(va, str);
len = vsprintf(buf, str, va);
va_end(va);
p = malloc(len + 1);
if (p != NULL) memcpy(p, buf, len + 1);
return p;
}