This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
[PATCH -tip 01/10] perf tools: Introduce xzalloc() for detecting out of memory
- From: Masami Hiramatsu <mhiramat at redhat dot com>
- To: Ingo Molnar <mingo at elte dot hu>, lkml<linux-kernel at vger dot kernel dot org>
- Cc: systemtap<systemtap at sources dot redhat dot com>, DLE<dle-develop at lists dot sourceforge dot net>, Masami Hiramatsu <mhiramat at redhat dot com>, Ingo Molnar <mingo at elte dot hu>, Frederic Weisbecker <fweisbec at gmail dot com>, Arnaldo Carvalho de Melo <acme at redhat dot com>, Paul Mackerras <paulus at samba dot org>, Mike Galbraith <efault at gmx dot de>, Peter Zijlstra <a dot p dot zijlstra at chello dot nl>
- Date: Tue, 16 Mar 2010 18:05:21 -0400
- Subject: [PATCH -tip 01/10] perf tools: Introduce xzalloc() for detecting out of memory
- References: <20100316220515.32050.82185.stgit@localhost6.localdomain6>
Introducing xzalloc() which wrapping zalloc() for detecting out of memory.
Signed-off-by: Masami Hiramatsu <mhiramat@redhat.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
---
tools/perf/util/util.h | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h
index 0f5b2a6..630902e 100644
--- a/tools/perf/util/util.h
+++ b/tools/perf/util/util.h
@@ -295,6 +295,13 @@ extern void *xmemdupz(const void *data, size_t len);
extern char *xstrndup(const char *str, size_t len);
extern void *xrealloc(void *ptr, size_t size) __attribute__((weak));
+static inline void *xzalloc(size_t size)
+{
+ void *buf;
+ buf = xmalloc(size);
+ return memset(buf, 0, size);
+}
+
static inline void *zalloc(size_t size)
{
return calloc(1, size);
--
Masami Hiramatsu
e-mail: mhiramat@redhat.com