From: Niels Möller Date: Wed, 23 Mar 2011 11:58:48 +0000 (+0100) Subject: (xalloc): New function. X-Git-Tag: nettle_2.2_release_20110711~111 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8a9d1fa9ff37f00983a5ac89ea5f293d55c30c91;p=thirdparty%2Fnettle.git (xalloc): New function. Rev: nettle/tools/misc.c:1.3 Rev: nettle/tools/misc.h:1.3 --- diff --git a/tools/misc.c b/tools/misc.c index d86d7b15..bd20842f 100644 --- a/tools/misc.c +++ b/tools/misc.c @@ -50,6 +50,19 @@ werror(const char *format, ...) va_end(args); } +void * +xalloc(size_t size) +{ + void *p = malloc(size); + if (!p) + { + fprintf(stderr, "Virtual memory exhausted.\n"); + abort(); + } + + return p; +} + const char sexp_token_chars[0x80] = { diff --git a/tools/misc.h b/tools/misc.h index ee5afcd1..b0ddb61a 100644 --- a/tools/misc.h +++ b/tools/misc.h @@ -43,6 +43,9 @@ werror(const char *format, ...) #endif ; +void * +xalloc(size_t size); + enum sexp_mode { SEXP_CANONICAL = 0,