[tip:perf/core] perf tools: Introduce xzalloc() for detecting out of memory conditions

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: tip-bot for Masami Hiramatsu
Date: Wednesday, March 17, 2010 - 4:27 am

Commit-ID:  a1d37d5285bcda07f9c0b80a2634ca20ab545297
Gitweb:     http://git.kernel.org/tip/a1d37d5285bcda07f9c0b80a2634ca20ab545297
Author:     Masami Hiramatsu <mhiramat@redhat.com>
AuthorDate: Tue, 16 Mar 2010 18:05:21 -0400
Committer:  Ingo Molnar <mingo@elte.hu>
CommitDate: Wed, 17 Mar 2010 11:32:29 +0100

perf tools: Introduce xzalloc() for detecting out of memory conditions

Introducing xzalloc() which wrapping zalloc() for detecting out
of memory conditions.

Signed-off-by: Masami Hiramatsu <mhiramat@redhat.com>
Cc: systemtap <systemtap@sources.redhat.com>
Cc: DLE <dle-develop@lists.sourceforge.net>
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>
LKML-Reference: <20100316220521.32050.85155.stgit@localhost6.localdomain6>
[ -v2: small cleanups in surrounding code ]
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
 tools/perf/util/util.h |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h
index 0f5b2a6..5270108 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 = xmalloc(size);
+
+	return memset(buf, 0, size);
+}
+
 static inline void *zalloc(size_t size)
 {
 	return calloc(1, size);
@@ -309,6 +316,7 @@ static inline int has_extension(const char *filename, const char *ext)
 {
 	size_t len = strlen(filename);
 	size_t extlen = strlen(ext);
+
 	return len > extlen && !memcmp(filename + len - extlen, ext, extlen);
 }
 
@@ -322,6 +330,7 @@ static inline int has_extension(const char *filename, const char *ext)
 #undef isalnum
 #undef tolower
 #undef toupper
+
 extern unsigned char sane_ctype[256];
 #define GIT_SPACE		0x01
 #define GIT_DIGIT		0x02
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH -tip 04/10] perf probe: Rename session to param, Masami Hiramatsu, (Tue Mar 16, 3:05 pm)
[PATCH -tip 06/10] perf probe: Introduce die_find_child() ..., Masami Hiramatsu, (Tue Mar 16, 3:05 pm)
[PATCH -tip 07/10] perf probe: Add --dry-run option, Masami Hiramatsu, (Tue Mar 16, 3:06 pm)
[tip:perf/core] perf tools: Introduce xzalloc() for detect ..., tip-bot for Masami H ..., (Wed Mar 17, 4:27 am)
[tip:perf/core] perf probe: Move add-probe routine to util/, tip-bot for Masami H ..., (Wed Mar 17, 4:28 am)
[tip:perf/core] perf probe: Rename session to param, tip-bot for Masami H ..., (Wed Mar 17, 4:28 am)
[tip:perf/core] perf probe: Rename some die_get_* functions, tip-bot for Masami H ..., (Wed Mar 17, 4:28 am)
[tip:perf/core] perf probe: Introduce die_find_child() fun ..., tip-bot for Masami H ..., (Wed Mar 17, 4:29 am)
[tip:perf/core] perf probe: Add --dry-run option, tip-bot for Masami H ..., (Wed Mar 17, 4:29 am)
[tip:perf/core] perf probe: Introduce kprobe_trace_event a ..., tip-bot for Masami H ..., (Wed Mar 17, 4:29 am)
[tip:perf/core] perf probe: List probes with line number a ..., tip-bot for Masami H ..., (Wed Mar 17, 4:29 am)
[tip:perf/core] perf probe: Add data structure member acce ..., tip-bot for Masami H ..., (Wed Mar 17, 4:30 am)
[tip:perf/core] perf probe: Fix !dwarf build, tip-bot for Ingo Molnar, (Wed Mar 17, 4:30 am)
Re: [tip:perf/core] perf probe: Fix !dwarf build, Masami Hiramatsu, (Wed Mar 17, 7:14 am)
Re: [PATCH -tip 10/10] perf probe: Accessing members in da ..., Masami Hiramatsu, (Wed Mar 17, 12:14 pm)
Re: [PATCH -tip 10/10] perf probe: Accessing members in da ..., Frederic Weisbecker, (Wed Mar 17, 8:28 pm)
[tip:perf/core] perf events: Fix false positive build warn ..., tip-bot for Ingo Molnar, (Thu Mar 18, 10:38 am)
Re: [tip:perf/core] perf events: Fix false positive build ..., Masami Hiramatsu, (Thu Mar 18, 1:03 pm)
Re: [PATCH -tip 10/10] perf probe: Accessing members in da ..., Arnaldo Carvalho de Melo, (Tue Mar 23, 9:27 am)