Commit 1a6f0dbcc0fe79e7bbd35c6e995fec24d32968af
1 parent
832e9079
linux-user: add qemu_realloc() implementation to unbreak the build (Gerd Hoffman)
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6412 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
13 additions
and
0 deletions
linux-user/mmap.c
... | ... | @@ -123,6 +123,19 @@ void qemu_free(void *ptr) |
123 | 123 | munmap(p, *p); |
124 | 124 | } |
125 | 125 | |
126 | +void *qemu_realloc(void *ptr, size_t size) | |
127 | +{ | |
128 | + size_t old_size, copy; | |
129 | + void *new_ptr; | |
130 | + | |
131 | + old_size = *(size_t *)((char *)ptr - 16); | |
132 | + copy = old_size < size ? old_size : size; | |
133 | + new_ptr = qemu_malloc(size); | |
134 | + memcpy(new_ptr, ptr, copy); | |
135 | + qemu_free(ptr); | |
136 | + return new_ptr; | |
137 | +} | |
138 | + | |
126 | 139 | /* NOTE: all the constants are the HOST ones, but addresses are target. */ |
127 | 140 | int target_mprotect(abi_ulong start, abi_ulong len, int prot) |
128 | 141 | { | ... | ... |