mirror of https://gitee.com/openkylin/libvirt.git
virsh: Reimplement _vshCalloc using g_malloc0_n
Drop the dead code by using glib's allocator. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
241057681a
commit
b2814b6a6f
12
tools/vsh.c
12
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
|
||||
|
|
|
@ -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. */
|
||||
|
||||
|
|
Loading…
Reference in New Issue