diff options
Diffstat (limited to 'tools/perf/util/evsel.c')
-rw-r--r-- | tools/perf/util/evsel.c | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index 8083d5126fca..662596afd7f1 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c | |||
@@ -41,8 +41,18 @@ int perf_evsel__alloc_fd(struct perf_evsel *evsel, int ncpus, int nthreads) | |||
41 | 41 | ||
42 | int perf_evsel__alloc_id(struct perf_evsel *evsel, int ncpus, int nthreads) | 42 | int perf_evsel__alloc_id(struct perf_evsel *evsel, int ncpus, int nthreads) |
43 | { | 43 | { |
44 | evsel->id = xyarray__new(ncpus, nthreads, sizeof(struct perf_sample_id)); | 44 | evsel->sample_id = xyarray__new(ncpus, nthreads, sizeof(struct perf_sample_id)); |
45 | return evsel->id != NULL ? 0 : -ENOMEM; | 45 | if (evsel->sample_id == NULL) |
46 | return -ENOMEM; | ||
47 | |||
48 | evsel->id = zalloc(ncpus * nthreads * sizeof(u64)); | ||
49 | if (evsel->id == NULL) { | ||
50 | xyarray__delete(evsel->sample_id); | ||
51 | evsel->sample_id = NULL; | ||
52 | return -ENOMEM; | ||
53 | } | ||
54 | |||
55 | return 0; | ||
46 | } | 56 | } |
47 | 57 | ||
48 | int perf_evsel__alloc_counts(struct perf_evsel *evsel, int ncpus) | 58 | int perf_evsel__alloc_counts(struct perf_evsel *evsel, int ncpus) |
@@ -60,7 +70,9 @@ void perf_evsel__free_fd(struct perf_evsel *evsel) | |||
60 | 70 | ||
61 | void perf_evsel__free_id(struct perf_evsel *evsel) | 71 | void perf_evsel__free_id(struct perf_evsel *evsel) |
62 | { | 72 | { |
63 | xyarray__delete(evsel->id); | 73 | xyarray__delete(evsel->sample_id); |
74 | evsel->sample_id = NULL; | ||
75 | free(evsel->id); | ||
64 | evsel->id = NULL; | 76 | evsel->id = NULL; |
65 | } | 77 | } |
66 | 78 | ||
@@ -79,7 +91,8 @@ void perf_evsel__exit(struct perf_evsel *evsel) | |||
79 | { | 91 | { |
80 | assert(list_empty(&evsel->node)); | 92 | assert(list_empty(&evsel->node)); |
81 | xyarray__delete(evsel->fd); | 93 | xyarray__delete(evsel->fd); |
82 | xyarray__delete(evsel->id); | 94 | xyarray__delete(evsel->sample_id); |
95 | free(evsel->id); | ||
83 | } | 96 | } |
84 | 97 | ||
85 | void perf_evsel__delete(struct perf_evsel *evsel) | 98 | void perf_evsel__delete(struct perf_evsel *evsel) |