Skip to contentSkip to conversation

unbreak linux-user builds

PATCH Applied Gerd Hoffmann 3 participants 3 messages Jan 23, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 unbreak linux-user builds

$subject says all

please apply,
Gerd

Quoted 1 line

From b0dbc4afae21c0f8fb9c6ec509fd07515307fc6d Mon Sep 17 00:00:00 2001

From: Gerd Hoffmann <[email protected]>
Date: Fri, 23 Jan 2009 12:49:00 +0100
Subject: [PATCH 1/3] linux-user: add qemu_realloc() implementation to unbreak the build.

---
 linux-user/mmap.c |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)
linux-user/mmap.c +13 -0
index 8e81cde..d0fc3e3 100644
@@ -123,6 +123,19 @@ void qemu_free(void *ptr)
     munmap(p, *p);
 }
 
+void *qemu_realloc(void *ptr, size_t size)
+{
+    size_t old_size, copy;
+    void *new_ptr;
+
+    old_size = *(size_t *)((char *)ptr - 16);
+    copy = old_size < size ? old_size : size;
+    new_ptr = qemu_malloc(size);
+    memcpy(new_ptr, ptr, copy);
+    qemu_free(ptr);
+    return new_ptr;
+}
+
 /* NOTE: all the constants are the HOST ones, but addresses are target. */
 int target_mprotect(abi_ulong start, abi_ulong len, int prot)
 {
Signature · 1 line
1.6.1
#1 lore raw
Quoted 5 lines · Gerd Hoffmann

$subject says all

please apply,
Gerd

Applied. Thanks.

Regards,

Anthony Liguori

#2 lore raw
Quoted 8 lines · Anthony Liguori
Quoted 5 lines · Gerd Hoffmann

$subject says all

please apply,
Gerd

Applied. Thanks.

This breaks the contract that qemu_realloc in qemu-malloc.c makes (by calling system realloc and lacking any documentation), namely that calling qemu_realloc with NULL ptr is equivavlent to malloc...

Signature · 1 line
mailto:[email protected]