From: Anthony Liguori <anthony@codemonkey.ws>
To: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 2 of 5] [UPDATE] implementing qemu_reallocz
Date: Fri, 21 Nov 2008 12:03:57 -0600 [thread overview]
Message-ID: <4926F80D.30401@codemonkey.ws> (raw)
In-Reply-To: <4926EAD3.6020507@eu.citrix.com>
Stefano Stabellini wrote:
> Adding a qemu_reallocz implementation.
>
> +void *qemu_reallocz(void *ptr, size_t size)
> +{
> + void *res;
> + res = realloc(ptr, size);
> + if (!res)
> + return NULL;
> + memset(res, 0, size);
> + return res;
> +}
> +
>
I think this interface is pretty non-intuitive. My first expectation is
that only the grown region would be zero'd, not the whole thing.
In general, if you don't care about the old memory, free()/malloc()
would be a better combination. You're just doing extra work by using
realloc() here.
Regards,
Anthony Liguori
> char *qemu_strdup(const char *str)
> {
> char *ptr;
>
>
>
prev parent reply other threads:[~2008-11-21 18:04 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-21 17:07 [Qemu-devel] [PATCH 2 of 5] [UPDATE] implementing qemu_reallocz Stefano Stabellini
2008-11-21 18:03 ` Anthony Liguori [this message]
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=4926F80D.30401@codemonkey.ws \
--to=anthony@codemonkey.ws \
--cc=qemu-devel@nongnu.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).