diff options
Diffstat (limited to 'tools/perf/util/header.c')
-rw-r--r-- | tools/perf/util/header.c | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index 4c7c2d73251f..6e618ba21382 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c | |||
@@ -31,21 +31,16 @@ static const char **header_argv; | |||
31 | 31 | ||
32 | int perf_header__push_event(u64 id, const char *name) | 32 | int perf_header__push_event(u64 id, const char *name) |
33 | { | 33 | { |
34 | struct perf_trace_event_type *nevents; | ||
35 | |||
34 | if (strlen(name) > MAX_EVENT_NAME) | 36 | if (strlen(name) > MAX_EVENT_NAME) |
35 | pr_warning("Event %s will be truncated\n", name); | 37 | pr_warning("Event %s will be truncated\n", name); |
36 | 38 | ||
37 | if (!events) { | 39 | nevents = realloc(events, (event_count + 1) * sizeof(*events)); |
38 | events = malloc(sizeof(struct perf_trace_event_type)); | 40 | if (nevents == NULL) |
39 | if (events == NULL) | 41 | return -ENOMEM; |
40 | return -ENOMEM; | 42 | events = nevents; |
41 | } else { | ||
42 | struct perf_trace_event_type *nevents; | ||
43 | 43 | ||
44 | nevents = realloc(events, (event_count + 1) * sizeof(*events)); | ||
45 | if (nevents == NULL) | ||
46 | return -ENOMEM; | ||
47 | events = nevents; | ||
48 | } | ||
49 | memset(&events[event_count], 0, sizeof(struct perf_trace_event_type)); | 44 | memset(&events[event_count], 0, sizeof(struct perf_trace_event_type)); |
50 | events[event_count].event_id = id; | 45 | events[event_count].event_id = id; |
51 | strncpy(events[event_count].name, name, MAX_EVENT_NAME - 1); | 46 | strncpy(events[event_count].name, name, MAX_EVENT_NAME - 1); |