From d0d58489ff8b4458719e4bceb6a5d7290c99588a Mon Sep 17 00:00:00 2001 From: Aaron Griffin Date: Tue, 6 Nov 2007 22:50:21 -0600 Subject: Add STRDUP macro to mirror MALLOC/CALLOC Signed-off-by: Aaron Griffin --- lib/libalpm/util.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'lib/libalpm') diff --git a/lib/libalpm/util.h b/lib/libalpm/util.h index 5d0b3693..85735287 100644 --- a/lib/libalpm/util.h +++ b/lib/libalpm/util.h @@ -28,6 +28,7 @@ #include "config.h" #include +#include #include #include #include /* struct stat */ @@ -44,6 +45,7 @@ #define MALLOC(p, s, action) do { p = calloc(1, s); if(p == NULL) { ALLOC_FAIL(s); action; } } while(0) #define CALLOC(p, l, s, action) do { p = calloc(l, s); if(p == NULL) { ALLOC_FAIL(s); action; } } while(0) +#define STRDUP(r, s, action) do { r = strdup(s); if(r == NULL) { ALLOC_FAIL(strlen(s)); action; } } while(0) #define FREE(p) do { if(p) { free(p); p = NULL; } } while(0) -- cgit v1.2.3-70-g09d2