diff options
author | tron <tron@openttd.org> | 2005-07-29 21:52:20 +0000 |
---|---|---|
committer | tron <tron@openttd.org> | 2005-07-29 21:52:20 +0000 |
commit | e91cb150a4f0edbf810490886a4734f5bc308160 (patch) | |
tree | 816549a247008ddd1c215593f389850ff7aec406 /string.c | |
parent | f287f2ff8d9306912196a3a23b2d9aaf3acd44e1 (diff) | |
download | openttd-e91cb150a4f0edbf810490886a4734f5bc308160.tar.xz |
(svn r2754) Move str_fmt into string.[ch]
Diffstat (limited to 'string.c')
-rw-r--r-- | string.c | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -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; +} |