From: Wei Liu Date: Mon, 16 Mar 2015 09:52:39 +0000 (+0000) Subject: xl: introduce xcalloc X-Git-Tag: 4.6.0-rc1~945 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=2c98821af0e63a78733ba270a4d7799171327d7b;p=xen.git xl: introduce xcalloc Signed-off-by: Wei Liu Cc: Ian Campbell Cc: Ian Jackson Acked-by: Ian Campbell --- diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c index 04faf98426..1de98045f1 100644 --- a/tools/libxl/xl_cmdimpl.c +++ b/tools/libxl/xl_cmdimpl.c @@ -289,6 +289,16 @@ static void *xmalloc(size_t sz) { return r; } +static void *xcalloc(size_t n, size_t sz) __attribute__((unused)); +static void *xcalloc(size_t n, size_t sz) { + void *r = calloc(n, sz); + if (!r) { + fprintf(stderr,"xl: Unable to calloc %zu bytes.\n", sz*n); + exit(-ERROR_FAIL); + } + return r; +} + static void *xrealloc(void *ptr, size_t sz) { void *r; if (!sz) { free(ptr); return 0; }