lkml.org 
[lkml]   [2013]   [Nov]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 20/29] tools lib traceevent: Remove malloc_or_die from plugin_function.c
Date
Removing malloc_or_die calls from plugin_function.c,
replacing them with standard malloc and error path.

Suggested-by: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Jiri Olsa <jolsa@redhat.com>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: David Ahern <dsahern@gmail.com>
---
tools/lib/traceevent/plugin_function.c | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/tools/lib/traceevent/plugin_function.c b/tools/lib/traceevent/plugin_function.c
index 87acf9c..328d17d 100644
--- a/tools/lib/traceevent/plugin_function.c
+++ b/tools/lib/traceevent/plugin_function.c
@@ -44,10 +44,16 @@ static void add_child(struct func_stack *stack, const char *child, int pos)
free(stack->stack[pos]);
else {
if (!stack->stack)
- stack->stack = malloc_or_die(sizeof(char *) * STK_BLK);
+ stack->stack = malloc(sizeof(char *) * STK_BLK);
else
stack->stack = realloc(stack->stack, sizeof(char *) *
(stack->size + STK_BLK));
+
+ if (!stack->stack) {
+ warning("could not allocate plugin memory\n");
+ return;
+ }
+
for (i = stack->size; i < stack->size + STK_BLK; i++)
stack->stack[i] = NULL;
stack->size += STK_BLK;
@@ -67,7 +73,12 @@ static int add_and_get_index(const char *parent, const char *child, int cpu)
if (fstack)
fstack = realloc(fstack, sizeof(*fstack) * (cpu + 1));
else
- fstack = malloc_or_die(sizeof(*fstack) * (cpu + 1));
+ fstack = malloc(sizeof(*fstack) * (cpu + 1));
+
+ if (!fstack) {
+ warning("could not allocate plugin memory\n");
+ return 0;
+ }

/* Account for holes in the cpu count */
for (i = cpus + 1; i <= cpu; i++)
--
1.8.3.1


\
 
 \ /
  Last update: 2013-11-28 13:01    [W:0.151 / U:0.872 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site