All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nolan <nolan@sigbus.net>
To: "qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Subject: [Qemu-devel] [PATCH] oom_check qemu_memalign
Date: Thu, 19 Mar 2009 17:20:43 -0700	[thread overview]
Message-ID: <1237508443.15350.149.camel@voxel> (raw)

As suggested by Avi on the KVM list, this patch adds oom_check to
qemu_memalign, in the interests of symmetry with qemu_malloc*.

See also:
http://article.gmane.org/gmane.comp.emulators.kvm.devel/29510

Signed-off-by: Nolan Leake <nolan <at> sigbus.net>

Index: qemu-malloc.c
===================================================================
--- qemu-malloc.c	(revision 6858)
+++ qemu-malloc.c	(working copy)
@@ -24,7 +24,7 @@
 #include "qemu-common.h"
 #include <stdlib.h>
 
-static void *oom_check(void *ptr)
+void *qemu_oom_check(void *ptr)
 {
     if (ptr == NULL)
         abort();
@@ -43,13 +43,13 @@
 
 void *qemu_malloc(size_t size)
 {
-    return oom_check(malloc(size));
+    return qemu_oom_check(malloc(size));
 }
 
 void *qemu_realloc(void *ptr, size_t size)
 {
     if (size)
-        return oom_check(realloc(ptr, size));
+        return qemu_oom_check(realloc(ptr, size));
     else
         return realloc(ptr, size);
 }
Index: qemu-common.h
===================================================================
--- qemu-common.h	(revision 6858)
+++ qemu-common.h	(working copy)
@@ -126,6 +126,7 @@
 #define qemu_isascii(c)		isascii((unsigned char)(c))
 #define qemu_toascii(c)		toascii((unsigned char)(c))
 
+void *qemu_oom_check(void *ptr);
 void *qemu_malloc(size_t size);
 void *qemu_realloc(void *ptr, size_t size);
 void *qemu_mallocz(size_t size);
Index: osdep.c
===================================================================
--- osdep.c	(revision 6858)
+++ osdep.c	(working copy)
@@ -186,11 +186,11 @@
     ret = posix_memalign(&ptr, alignment, size);
     if (ret != 0)
         return NULL;
-    return ptr;
+    return qemu_oom_check(ptr);
 #elif defined(HOST_BSD)
-    return valloc(size);
+    return qemu_oom_check(valloc(size));
 #else
-    return memalign(alignment, size);
+    return qemu_oom_check(memalign(alignment, size));
 #endif
 }
 

             reply	other threads:[~2009-03-20  0:20 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-20  0:20 Nolan [this message]
2009-03-20  1:08 ` [Qemu-devel] [PATCH] oom_check qemu_memalign malc

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1237508443.15350.149.camel@voxel \
    --to=nolan@sigbus.net \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.