From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30566 invoked by alias); 17 Mar 2010 11:28:38 -0000 Received: (qmail 30558 invoked by uid 22791); 17 Mar 2010 11:28:37 -0000 X-SWARE-Spam-Status: No, hits=-1.7 required=5.0 tests=AWL,BAYES_00,SARE_MSGID_LONG40,SARE_SUB_OBFU_Z X-Spam-Check-By: sourceware.org Received: from hera.kernel.org (HELO hera.kernel.org) (140.211.167.34) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 17 Mar 2010 11:28:33 +0000 Received: from hera.kernel.org (localhost [127.0.0.1]) by hera.kernel.org (8.14.3/8.14.3) with ESMTP id o2HBRfMP022750 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 17 Mar 2010 11:27:41 GMT Received: (from hpa@localhost) by hera.kernel.org (8.14.3/8.14.2/Submit) id o2HBRZDw022690; Wed, 17 Mar 2010 11:27:35 GMT Date: Wed, 17 Mar 2010 11:28:00 -0000 From: tip-bot for Masami Hiramatsu Cc: linux-kernel@vger.kernel.org, paulus@samba.org, acme@redhat.com, hpa@zytor.com, mingo@redhat.com, a.p.zijlstra@chello.nl, efault@gmx.de, dle-develop@lists.sourceforge.net, fweisbec@gmail.com, tglx@linutronix.de, mhiramat@redhat.com, mingo@elte.hu, systemtap@sources.redhat.com Reply-To: mingo@redhat.com, hpa@zytor.com, acme@redhat.com, paulus@samba.org, linux-kernel@vger.kernel.org, a.p.zijlstra@chello.nl, efault@gmx.de, dle-develop@lists.sourceforge.net, fweisbec@gmail.com, tglx@linutronix.de, mhiramat@redhat.com, systemtap@sources.redhat.com, mingo@elte.hu In-Reply-To: <20100316220521.32050.85155.stgit@localhost6.localdomain6> References: <20100316220521.32050.85155.stgit@localhost6.localdomain6> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf tools: Introduce xzalloc() for detecting out of memory conditions Message-ID: Git-Commit-ID: a1d37d5285bcda07f9c0b80a2634ca20ab545297 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-IsSubscribed: yes Mailing-List: contact systemtap-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: systemtap-owner@sourceware.org X-SW-Source: 2010-q1/txt/msg00690.txt.bz2 Commit-ID: a1d37d5285bcda07f9c0b80a2634ca20ab545297 Gitweb: http://git.kernel.org/tip/a1d37d5285bcda07f9c0b80a2634ca20ab545297 Author: Masami Hiramatsu AuthorDate: Tue, 16 Mar 2010 18:05:21 -0400 Committer: Ingo Molnar 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 Cc: systemtap Cc: DLE Cc: Frederic Weisbecker Cc: Arnaldo Carvalho de Melo Cc: Paul Mackerras Cc: Mike Galbraith Cc: Peter Zijlstra LKML-Reference: <20100316220521.32050.85155.stgit@localhost6.localdomain6> [ -v2: small cleanups in surrounding code ] Signed-off-by: Ingo Molnar --- 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