From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Xen-devel <xen-devel@lists.xen.org>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
Ian Jackson <Ian.Jackson@eu.citrix.com>,
Ian Campbell <Ian.Campbell@citrix.com>
Subject: [PATCH 1/2] tools/libxl: Correct libxl__zalloc() to take an unsigned number of bytes
Date: Thu, 27 Mar 2014 17:41:54 +0000 [thread overview]
Message-ID: <1395942115-13698-1-git-send-email-andrew.cooper3@citrix.com> (raw)
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 <andrew.cooper3@citrix.com>
CC: Ian Campbell <Ian.Campbell@citrix.com>
CC: Ian Jackson <Ian.Jackson@eu.citrix.com>
---
tools/libxl/libxl_internal.c | 6 +++---
tools/libxl/libxl_internal.h | 4 ++--
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/tools/libxl/libxl_internal.c b/tools/libxl/libxl_internal.c
index 1db48b6..6c105de 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 b3a200d..be325bb 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;
--
1.7.10.4
next reply other threads:[~2014-03-27 17:41 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-27 17:41 Andrew Cooper [this message]
2014-03-27 17:41 ` [PATCH 2/2] tools/libxl: Introduce libxl__malloc() Andrew Cooper
2014-04-01 10:51 ` [PATCH 1/2] tools/libxl: Correct libxl__zalloc() to take an unsigned number of bytes Ian Campbell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1395942115-13698-1-git-send-email-andrew.cooper3@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=Ian.Campbell@citrix.com \
--cc=Ian.Jackson@eu.citrix.com \
--cc=xen-devel@lists.xen.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).