From: Peter Krempa Date: Thu, 24 Oct 2019 07:02:24 +0000 (+0200) Subject: virsh: Reimplement _vshCalloc using g_malloc0_n X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=b2814b6a6f29103a3eba55e03c6e062d3f555b51;p=libvirt.git virsh: Reimplement _vshCalloc using g_malloc0_n Drop the dead code by using glib's allocator. Signed-off-by: Peter Krempa Reviewed-by: Ján Tomko --- diff --git a/tools/vsh.c b/tools/vsh.c index ec46b822c5..89ba9a487f 100644 --- a/tools/vsh.c +++ b/tools/vsh.c @@ -129,17 +129,9 @@ _vshMalloc(vshControl *ctl, size_t size, const char *filename, int line) } void * -_vshCalloc(vshControl *ctl, size_t nmemb, size_t size, const char *filename, - int line) +vshCalloc(vshControl *ctl G_GNUC_UNUSED, size_t nmemb, size_t size) { - char *x; - - if (!xalloc_oversized(nmemb, size) && - VIR_ALLOC_N(x, nmemb * size) == 0) - return x; - vshError(ctl, _("%s: %d: failed to allocate %d bytes"), - filename, line, (int) (size*nmemb)); - exit(EXIT_FAILURE); + return g_malloc0_n(nmemb, size); } int diff --git a/tools/vsh.h b/tools/vsh.h index ad783e24b7..b6ac070f10 100644 --- a/tools/vsh.h +++ b/tools/vsh.h @@ -468,10 +468,7 @@ char * vshReadline(vshControl *ctl, const char *prompt); void *_vshMalloc(vshControl *ctl, size_t sz, const char *filename, int line); #define vshMalloc(_ctl, _sz) _vshMalloc(_ctl, _sz, __FILE__, __LINE__) -void *_vshCalloc(vshControl *ctl, size_t nmemb, size_t sz, - const char *filename, int line); -#define vshCalloc(_ctl, _nmemb, _sz) \ - _vshCalloc(_ctl, _nmemb, _sz, __FILE__, __LINE__) +void *vshCalloc(vshControl *ctl, size_t nmemb, size_t sz); /* Macros to help dealing with mutually exclusive options. */