From 4e518231cf5ff4485fdaf4d52c4f51aa48e5255d Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Sat, 10 Sep 2011 19:49:16 +0200 Subject: Add asprintf replacement for systems lacking it --- src/asprintf.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/asprintf.h (limited to 'src/asprintf.h') diff --git a/src/asprintf.h b/src/asprintf.h new file mode 100644 index 0000000..6f1250d --- /dev/null +++ b/src/asprintf.h @@ -0,0 +1,23 @@ +#ifndef ASPRINTF_H +#define ASPRINTF_H +#ifndef vasprintf +static inline int vasprintf(char **PTR, const char *TEMPLATE, va_list AP) +{ + int res; + *PTR = (char*)malloc(512); + res = vsnprintf(*PTR, 512, TEMPLATE, AP); + return res; +} +#endif +#ifndef asprintf +static inline int asprintf(char **PTR, const char *TEMPLATE, ...) +{ + int res; + va_list AP; + va_start(AP, TEMPLATE); + res = vasprintf(PTR, TEMPLATE, AP); + va_end(AP); + return res; +} +#endif +#endif -- cgit v1.1-32-gdbae