提交 b2814b6a 编写于 作者: P Peter Krempa

virsh: Reimplement _vshCalloc using g_malloc0_n

Drop the dead code by using glib's allocator.
Signed-off-by: NPeter Krempa <pkrempa@redhat.com>
Reviewed-by: NJán Tomko <jtomko@redhat.com>
上级 24105768
......@@ -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. */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册