aboutsummaryrefslogtreecommitdiff
path: root/memory.c
diff options
context:
space:
mode:
Diffstat (limited to 'memory.c')
-rw-r--r--memory.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/memory.c b/memory.c
index aec3da2..14dddf5 100644
--- a/memory.c
+++ b/memory.c
@@ -1,3 +1,7 @@
+#define _GNU_SOURCE
+#include <stdio.h>
+#include <stdarg.h>
+#include <assert.h>
#include "global.h"
#include "memory.h"
@@ -14,3 +18,14 @@ void* check_after_allocation_str(const char *func,void *ptr){
}
return ptr;
}
+
+__attribute__((format (printf, 2, 3)))
+int memory_asprintf_wrapper(char **ret,const char *format,...){
+ assert(ret!=NULL);
+ va_list ap;
+ va_start(ap,format);
+ int len=vasprintf(ret,format,ap);
+ va_end(ap);
+ check_after_allocation_str("asprintf",*ret);
+ return len;
+}