summaryrefslogtreecommitdiffstats
path: root/src/asprintf.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/asprintf.h')
-rw-r--r--src/asprintf.h23
1 files changed, 23 insertions, 0 deletions
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 @@
1#ifndef ASPRINTF_H
2#define ASPRINTF_H
3#ifndef vasprintf
4static inline int vasprintf(char **PTR, const char *TEMPLATE, va_list AP)
5{
6 int res;
7 *PTR = (char*)malloc(512);
8 res = vsnprintf(*PTR, 512, TEMPLATE, AP);
9 return res;
10}
11#endif
12#ifndef asprintf
13static inline int asprintf(char **PTR, const char *TEMPLATE, ...)
14{
15 int res;
16 va_list AP;
17 va_start(AP, TEMPLATE);
18 res = vasprintf(PTR, TEMPLATE, AP);
19 va_end(AP);
20 return res;
21}
22#endif
23#endif