qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] Introduce QEMU_NEW()
@ 2011-07-25  8:51 Avi Kivity
  2011-07-25  9:32 ` Alexander Graf
                   ` (3 more replies)
  0 siblings, 4 replies; 50+ messages in thread
From: Avi Kivity @ 2011-07-25  8:51 UTC (permalink / raw)
  To: qemu-devel; +Cc: kvm

qemu_malloc() is type-unsafe as it returns a void pointer.  Introduce
QEMU_NEW() (and QEMU_NEWZ()), which return the correct type.

Signed-off-by: Avi Kivity <avi@redhat.com>
---

This is part of my memory API patchset, but doesn't really belong there.

 qemu-common.h |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/qemu-common.h b/qemu-common.h
index ba55719..66effa3 100644
--- a/qemu-common.h
+++ b/qemu-common.h
@@ -186,6 +186,9 @@ void qemu_free(void *ptr);
 char *qemu_strdup(const char *str);
 char *qemu_strndup(const char *str, size_t size);
 
+#define QEMU_NEW(type) ((type *)(qemu_malloc(sizeof(type))))
+#define QEMU_NEWZ(type) ((type *)(qemu_mallocz(sizeof(type))))
+
 void qemu_mutex_lock_iothread(void);
 void qemu_mutex_unlock_iothread(void);
 
-- 
1.7.5.3

^ permalink raw reply related	[flat|nested] 50+ messages in thread

end of thread, other threads:[~2011-08-01 10:49 UTC | newest]

Thread overview: 50+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-07-25  8:51 [Qemu-devel] [PATCH] Introduce QEMU_NEW() Avi Kivity
2011-07-25  9:32 ` Alexander Graf
2011-07-25  9:37   ` Sasha Levin
2011-07-25  9:43     ` Alexander Graf
2011-07-25  9:49       ` Avi Kivity
2011-07-25  9:48   ` Peter Maydell
2011-07-25  9:52     ` Avi Kivity
2011-07-25  9:56       ` Alexander Graf
2011-07-25 10:02         ` Avi Kivity
2011-07-25 10:04           ` Alexander Graf
2011-07-25 10:09             ` Avi Kivity
2011-07-25 10:19               ` Alexander Graf
2011-07-25 10:46                 ` malc
2011-07-25 10:59               ` Markus Armbruster
2011-07-25 11:11                 ` Alexander Graf
2011-07-25 12:19                   ` Anthony Liguori
2011-07-25 14:16               ` Blue Swirl
2011-07-25 14:20                 ` Avi Kivity
2011-07-25 12:30       ` Anthony Liguori
2011-07-25 11:35   ` Avi Kivity
2011-07-25 10:06 ` Stefan Hajnoczi
2011-07-25 10:12   ` Avi Kivity
2011-07-25 10:25   ` Kevin Wolf
2011-07-25 10:28     ` Stefan Hajnoczi
2011-07-25 11:02     ` Markus Armbruster
2011-07-25 11:45       ` Avi Kivity
2011-07-25 15:10   ` Jes Sorensen
2011-07-25 15:15     ` Anthony Liguori
2011-07-25 15:17       ` Jes Sorensen
2011-07-25 15:20         ` Avi Kivity
2011-07-25 15:21           ` Jes Sorensen
2011-07-25 15:24             ` Avi Kivity
2011-07-25 15:28               ` Jes Sorensen
2011-07-25 15:35                 ` Avi Kivity
2011-07-25 12:11 ` Anthony Liguori
2011-07-25 12:18   ` Avi Kivity
2011-07-25 12:21     ` Anthony Liguori
2011-07-25 12:41       ` Avi Kivity
2011-07-25 14:23       ` Blue Swirl
2011-07-25 14:25         ` Anthony Liguori
2011-07-25 14:30           ` Max Filippov
2011-07-25 14:43             ` Anthony Liguori
2011-07-25 14:47               ` malc
2011-07-25 14:50                 ` Avi Kivity
2011-07-25 14:58                   ` malc
2011-07-25 14:59                     ` Avi Kivity
2011-07-25 14:51         ` Paolo Bonzini
2011-07-25 14:56           ` Blue Swirl
2011-07-25 15:21             ` Paolo Bonzini
2011-08-01 10:49 ` Richard W.M. Jones

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).