diff options
Diffstat (limited to 'tools/lib')
-rw-r--r-- | tools/lib/traceevent/plugin_function.c | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/tools/lib/traceevent/plugin_function.c b/tools/lib/traceevent/plugin_function.c index 87acf9c77948..aad92ad5e96f 100644 --- a/tools/lib/traceevent/plugin_function.c +++ b/tools/lib/traceevent/plugin_function.c | |||
@@ -43,11 +43,17 @@ static void add_child(struct func_stack *stack, const char *child, int pos) | |||
43 | if (pos < stack->size) | 43 | if (pos < stack->size) |
44 | free(stack->stack[pos]); | 44 | free(stack->stack[pos]); |
45 | else { | 45 | else { |
46 | if (!stack->stack) | 46 | char **ptr; |
47 | stack->stack = malloc_or_die(sizeof(char *) * STK_BLK); | 47 | |
48 | else | 48 | ptr = realloc(stack->stack, sizeof(char *) * |
49 | stack->stack = realloc(stack->stack, sizeof(char *) * | 49 | (stack->size + STK_BLK)); |
50 | (stack->size + STK_BLK)); | 50 | if (!ptr) { |
51 | warning("could not allocate plugin memory\n"); | ||
52 | return; | ||
53 | } | ||
54 | |||
55 | stack->stack = ptr; | ||
56 | |||
51 | for (i = stack->size; i < stack->size + STK_BLK; i++) | 57 | for (i = stack->size; i < stack->size + STK_BLK; i++) |
52 | stack->stack[i] = NULL; | 58 | stack->stack[i] = NULL; |
53 | stack->size += STK_BLK; | 59 | stack->size += STK_BLK; |
@@ -64,10 +70,15 @@ static int add_and_get_index(const char *parent, const char *child, int cpu) | |||
64 | return 0; | 70 | return 0; |
65 | 71 | ||
66 | if (cpu > cpus) { | 72 | if (cpu > cpus) { |
67 | if (fstack) | 73 | struct func_stack *ptr; |
68 | fstack = realloc(fstack, sizeof(*fstack) * (cpu + 1)); | 74 | |
69 | else | 75 | ptr = realloc(fstack, sizeof(*fstack) * (cpu + 1)); |
70 | fstack = malloc_or_die(sizeof(*fstack) * (cpu + 1)); | 76 | if (!ptr) { |
77 | warning("could not allocate plugin memory\n"); | ||
78 | return 0; | ||
79 | } | ||
80 | |||
81 | fstack = ptr; | ||
71 | 82 | ||
72 | /* Account for holes in the cpu count */ | 83 | /* Account for holes in the cpu count */ |
73 | for (i = cpus + 1; i <= cpu; i++) | 84 | for (i = cpus + 1; i <= cpu; i++) |