index : pacman | |
Archlinux32 fork of pacman | gitolite user |
summaryrefslogtreecommitdiff |
author | Dan McGee <dan@archlinux.org> | 2007-10-29 01:00:52 -0500 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2007-10-29 01:00:52 -0500 |
commit | cc754bc6e3be0f37ca0eaca4b6b90f033433fb1a (patch) | |
tree | a9940053625e4b4e9b5d345eb1ac441a911f6efa /lib/libalpm/util.h | |
parent | fe3a461703a5d90937c0c6f1ce0c3d802c0f8630 (diff) |
-rw-r--r-- | lib/libalpm/util.h | 7 |
diff --git a/lib/libalpm/util.h b/lib/libalpm/util.h index d8e6cbd8..3b8fd83d 100644 --- a/lib/libalpm/util.h +++ b/lib/libalpm/util.h @@ -39,7 +39,12 @@ #define _(s) s #endif -#define FREE(p) do { if (p) { free(p); p = NULL; } } while(0) +#define ALLOC_FAIL(s) do { _alpm_log(PM_LOG_ERROR, _("alloc failure: could not allocate %d bytes\n"), s); } while(0) + +#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 FREE(p) do { if(p) { free(p); p = NULL; } } while(0) #define ASSERT(cond, action) do { if(!(cond)) { action; } } while(0) |