summary refs log tree commit diff stats
path: root/qemu-malloc.c
diff options
context:
space:
mode:
authorJes Sorensen <Jes.Sorensen@redhat.com>2010-10-26 10:39:26 +0200
committerBlue Swirl <blauwirbel@gmail.com>2010-10-30 08:02:39 +0000
commitb152aa84d52882bb1846485a89baf13aa07c86bc (patch)
treeef36c582e3567543bed0f8d81c5622d2f4e8052a /qemu-malloc.c
parentbc4a957c46acd8f4b2f2ffe6b2f90512325924dd (diff)
downloadfocaccia-qemu-b152aa84d52882bb1846485a89baf13aa07c86bc.tar.gz
focaccia-qemu-b152aa84d52882bb1846485a89baf13aa07c86bc.zip
Consolidate oom_check() functions
This consolidates the duplicated oom_check() functions, as well as
splitting them into OS dependant versions to avoid the #ifdef
grossness that was present in the old osdep.c version.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
Diffstat (limited to 'qemu-malloc.c')
-rw-r--r--qemu-malloc.c14
1 files changed, 3 insertions, 11 deletions
diff --git a/qemu-malloc.c b/qemu-malloc.c
index ecffb676e2..28fb05a481 100644
--- a/qemu-malloc.c
+++ b/qemu-malloc.c
@@ -25,14 +25,6 @@
 #include "trace.h"
 #include <stdlib.h>
 
-static void *oom_check(void *ptr)
-{
-    if (ptr == NULL) {
-        abort();
-    }
-    return ptr;
-}
-
 void qemu_free(void *ptr)
 {
     trace_qemu_free(ptr);
@@ -54,7 +46,7 @@ void *qemu_malloc(size_t size)
     if (!size && !allow_zero_malloc()) {
         abort();
     }
-    ptr = oom_check(malloc(size ? size : 1));
+    ptr = qemu_oom_check(malloc(size ? size : 1));
     trace_qemu_malloc(size, ptr);
     return ptr;
 }
@@ -65,7 +57,7 @@ void *qemu_realloc(void *ptr, size_t size)
     if (!size && !allow_zero_malloc()) {
         abort();
     }
-    newptr = oom_check(realloc(ptr, size ? size : 1));
+    newptr = qemu_oom_check(realloc(ptr, size ? size : 1));
     trace_qemu_realloc(ptr, size, newptr);
     return newptr;
 }
@@ -75,7 +67,7 @@ void *qemu_mallocz(size_t size)
     if (!size && !allow_zero_malloc()) {
         abort();
     }
-    return oom_check(calloc(1, size ? size : 1));
+    return qemu_oom_check(calloc(1, size ? size : 1));
 }
 
 char *qemu_strdup(const char *str)