diff options
author | Keir Fraser <keir.fraser@citrix.com> | 2008-01-17 15:06:30 +0000 |
---|---|---|
committer | Keir Fraser <keir.fraser@citrix.com> | 2008-01-17 15:06:30 +0000 |
commit | f3b3ce4ae7975a5f16e749bf77d2012320ab9e35 (patch) | |
tree | faa450f0d3e8b354192faacf7b41c28b2639e060 /extras/mini-os/lib | |
parent | 22e39d084eaa3b058ec34964156511fe963ce4d4 (diff) | |
download | xen-f3b3ce4ae7975a5f16e749bf77d2012320ab9e35.tar.gz xen-f3b3ce4ae7975a5f16e749bf77d2012320ab9e35.tar.bz2 xen-f3b3ce4ae7975a5f16e749bf77d2012320ab9e35.zip |
minios: add realloc
Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>
Signed-off-by: Tim Deegan <tim.deegan@eu.citrix.com>
Diffstat (limited to 'extras/mini-os/lib')
-rw-r--r-- | extras/mini-os/lib/xmalloc.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/extras/mini-os/lib/xmalloc.c b/extras/mini-os/lib/xmalloc.c index 3246d57b32..de0001b31d 100644 --- a/extras/mini-os/lib/xmalloc.c +++ b/extras/mini-os/lib/xmalloc.c @@ -223,3 +223,24 @@ void xfree(const void *p) /* spin_unlock_irqrestore(&freelist_lock, flags); */ } +void *_realloc(void *ptr, size_t size) +{ + void *new; + struct xmalloc_hdr *hdr; + + if (ptr == NULL) + return _xmalloc(size, 4); + + hdr = (struct xmalloc_hdr *)ptr - 1; + if (hdr->size >= size) + return ptr; + + new = _xmalloc(size, 4); + if (new == NULL) + return NULL; + + memcpy(new, ptr, hdr->size); + xfree(ptr); + + return new; +} |