summaryrefslogtreecommitdiffstats
path: root/src/malloc.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2008-10-05 04:34:17 +0200
committerLennart Poettering <lennart@poettering.net>2008-10-05 04:34:17 +0200
commit91a3b19597b4c24d937e7e5668f18dcaa08a486b (patch)
tree89d9bfce72fff5da766d03aa823cb05fda0fead9 /src/malloc.c
parente1b2be31a79dd229b60ceea121d6933b154c3bc0 (diff)
implement ca_memdup()
Diffstat (limited to 'src/malloc.c')
-rw-r--r--src/malloc.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/malloc.c b/src/malloc.c
index 9592af4..4586d4d 100644
--- a/src/malloc.c
+++ b/src/malloc.c
@@ -22,12 +22,25 @@
#include <config.h>
#endif
+#include <string.h>
#include <stdio.h>
#include <stdarg.h>
#include "malloc.h"
#include "macro.h"
+void* ca_memdup(const void* p, size_t size) {
+ void *r;
+
+ ca_assert(p);
+
+ if (!(r = ca_malloc(size)))
+ return NULL;
+
+ memcpy(r, p, size);
+ return r;
+}
+
char *ca_sprintf_malloc(const char *format, ...) {
size_t size = 100;
char *c = NULL;