From: handa Date: Mon, 3 Sep 2007 00:35:52 +0000 (+0000) Subject: (MTABLE_CALLOC_SAFE, MSTRUCT_CALLOC_SAFE): New macros. X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5fc46419e728a7f30e4166c7a61b7863243fc56a;p=m17n%2Fm17n-lib.git (MTABLE_CALLOC_SAFE, MSTRUCT_CALLOC_SAFE): New macros. --- 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