From: Andrew Cooper Date: Thu, 27 Mar 2014 17:41:54 +0000 (+0000) Subject: tools/libxl: Correct libxl__zalloc() to take an unsigned number of bytes X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~5322 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=76805ae56e4a8f389a3146b9d4816a8bbaf0150b;p=xen.git tools/libxl: Correct libxl__zalloc() to take an unsigned number of bytes Convert 'int bytes' to 'size_t size' to mirror malloc(3) which it is imitating, and calloc(3) which it is actually using. Signed-off-by: Andrew Cooper Acked-by: Ian Campbell CC: Ian Jackson --- diff --git a/tools/libxl/libxl_internal.c b/tools/libxl/libxl_internal.c index 1db48b6dfb..6c105decbe 100644 --- a/tools/libxl/libxl_internal.c +++ b/tools/libxl/libxl_internal.c @@ -78,10 +78,10 @@ void libxl__free_all(libxl__gc *gc) gc->alloc_maxsize = 0; } -void *libxl__zalloc(libxl__gc *gc, int bytes) +void *libxl__zalloc(libxl__gc *gc, size_t size) { - void *ptr = calloc(bytes, 1); - if (!ptr) libxl__alloc_failed(CTX, __func__, bytes, 1); + void *ptr = calloc(size, 1); + if (!ptr) libxl__alloc_failed(CTX, __func__, size, 1); libxl__ptr_add(gc, ptr); return ptr; diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index b3a200d9c2..be325bbcfe 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -504,8 +504,8 @@ static inline int libxl__gc_is_real(const libxl__gc *gc) _hidden void libxl__ptr_add(libxl__gc *gc_opt, void *ptr /* may be NULL */) NN1; /* if this is the outermost libxl callframe then free all pointers in @gc */ _hidden void libxl__free_all(libxl__gc *gc); -/* allocate and zero @bytes. (similar to a gc'd malloc(3)+memzero()) */ -_hidden void *libxl__zalloc(libxl__gc *gc_opt, int bytes) NN1; +/* allocate and zero @size. (similar to a gc'd malloc(3)+memzero()) */ +_hidden void *libxl__zalloc(libxl__gc *gc_opt, size_t size) NN1; /* allocate and zero memory for an array of @nmemb members of @size each. * (similar to a gc'd calloc(3)). */ _hidden void *libxl__calloc(libxl__gc *gc_opt, size_t nmemb, size_t size) NN1;