|
From: | Paolo Bonzini |
Subject: | [Qemu-devel] Re: [PATCH] scsi: Implement alloc_req_iov callback |
Date: | Tue, 23 Nov 2010 09:31:06 +0100 |
User-agent: | Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.12) Gecko/20101103 Fedora/1.0-0.33.b2pre.fc14 Lightning/1.0b3pre Mnenhy/0.8.3 Thunderbird/3.1.6 |
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 in Thread] | Current Thread | [Next in Thread] |