From: Paolo Bonzini <pbonzini@redhat.com>
To: Hannes Reinecke <hare@suse.de>
Cc: Stefan Hajnoczi <stefanha@gmail.com>,
qemu-devel@nongnu.org, nab@linux-iscsi.org, kraxel@redhat.com
Subject: [Qemu-devel] Re: [PATCH] scsi: Implement alloc_req_iov callback
Date: Tue, 23 Nov 2010 09:31:06 +0100 [thread overview]
Message-ID: <4CEB7BCA.5030001@redhat.com> (raw)
In-Reply-To: <4CEB7778.4010900@suse.de>
On 11/23/2010 09:12 AM, Hannes Reinecke wrote:
> qemu-malloc.c has:
>
> void qemu_free(void *ptr)
> {
> trace_qemu_free(ptr);
> free(ptr);
> }
>
>
> and 'free' doesn't normally do an error checking on the argument.
> Am I missing something?
It's not error checking: from free(3),
free() frees the memory space pointed to by ptr, which must have been
returned by a previous call to malloc(), calloc() or realloc().
Otherwise, or if free(ptr) has already been called before, undefined
behavior occurs. If ptr is NULL, no operation is performed.
Which means, that unless ptr is so often NULL that there is a measurable
overhead from the call (unlikely in any case, not just this one) the
"if" is actually going to be done by "free", and thus causing actually
worse performance.
Not that man pages are always right, but in this case they agree with
POSIX. :)
Paolo
prev parent reply other threads:[~2010-11-23 8:31 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-22 10:15 [Qemu-devel] [PATCH] scsi: Implement alloc_req_iov callback Hannes Reinecke
2010-11-22 21:48 ` [Qemu-devel] " Stefan Hajnoczi
2010-11-23 8:12 ` Hannes Reinecke
2010-11-23 8:31 ` Paolo Bonzini [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=4CEB7BCA.5030001@redhat.com \
--to=pbonzini@redhat.com \
--cc=hare@suse.de \
--cc=kraxel@redhat.com \
--cc=nab@linux-iscsi.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@gmail.com \
/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).