From patchwork Mon Dec 28 15:49:00 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: Allow usage of qemu_realloc(ptr, 0) X-Patchwork-Submitter: Aurelien Jarno X-Patchwork-Id: 41854 Message-Id: <20091228154900.GE4908@volta.aurel32.net> To: qemu-devel@nongnu.org Date: Mon, 28 Dec 2009 16:49:00 +0100 From: Aurelien Jarno List-Id: qemu-devel.nongnu.org realloc(ptr, 0) is always allowed by the standard. The return value is either NULL or a pointer that can be freed with free(). Allow usage of qemu_realloc(ptr, 0), and return NULL in that case, as free(NULL) should always be a nop. This fixes -kernel with stripped kernels. Signed-off-by: Aurelien Jarno --- qemu-malloc.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/qemu-malloc.c b/qemu-malloc.c index 5d9e34d..cf6a1f1 100644 --- a/qemu-malloc.c +++ b/qemu-malloc.c @@ -63,10 +63,10 @@ void *qemu_realloc(void *ptr, size_t size) { if (size) { return oom_check(realloc(ptr, size)); - } else if (allow_zero_malloc()) { - return oom_check(realloc(ptr, size ? size : 1)); + } else if (ptr) { + qemu_free(ptr); } - abort(); + return NULL; } void *qemu_mallocz(size_t size)