From 5fc46419e728a7f30e4166c7a61b7863243fc56a Mon Sep 17 00:00:00 2001 From: handa Date: Mon, 3 Sep 2007 00:35:52 +0000 Subject: [PATCH] (MTABLE_CALLOC_SAFE, MSTRUCT_CALLOC_SAFE): New macros. --- src/internal.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/internal.h b/src/internal.h index 8b2ce78..18888ab 100644 --- a/src/internal.h +++ b/src/internal.h @@ -117,6 +117,9 @@ extern int mdebug_hook (); MEMORY_FULL (err); \ } while (0) +#define MTABLE_CALLOC_SAFE(p, size) \ + ((p) = (void *) calloc (sizeof (*(p)), (size))) + /** The macro MTABLE_REALLOC () changes the size of memory block pointed to by P to a size suitable for an array of SIZE objects. @@ -162,6 +165,8 @@ extern int mdebug_hook (); #define MSTRUCT_CALLOC(p, err) MTABLE_CALLOC ((p), 1, (err)) +#define MSTRUCT_CALLOC_SAFE(p) MTABLE_CALLOC_SAFE ((p), 1) + #define USE_SAFE_ALLOCA \ int sa_must_free = 0, sa_size = 0 -- 1.7.10.4