diff options
Diffstat (limited to 'tools/perf/util/counts.c')
-rw-r--r-- | tools/perf/util/counts.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/tools/perf/util/counts.c b/tools/perf/util/counts.c index 88be9c4365e0..f94e1a23dad6 100644 --- a/tools/perf/util/counts.c +++ b/tools/perf/util/counts.c @@ -19,6 +19,15 @@ struct perf_counts *perf_counts__new(int ncpus, int nthreads) } counts->values = values; + + values = xyarray__new(ncpus, nthreads, sizeof(bool)); + if (!values) { + xyarray__delete(counts->values); + free(counts); + return NULL; + } + + counts->loaded = values; } return counts; @@ -27,6 +36,7 @@ struct perf_counts *perf_counts__new(int ncpus, int nthreads) void perf_counts__delete(struct perf_counts *counts) { if (counts) { + xyarray__delete(counts->loaded); xyarray__delete(counts->values); free(counts); } @@ -34,21 +44,22 @@ void perf_counts__delete(struct perf_counts *counts) static void perf_counts__reset(struct perf_counts *counts) { + xyarray__reset(counts->loaded); xyarray__reset(counts->values); } -void perf_evsel__reset_counts(struct perf_evsel *evsel) +void perf_evsel__reset_counts(struct evsel *evsel) { perf_counts__reset(evsel->counts); } -int perf_evsel__alloc_counts(struct perf_evsel *evsel, int ncpus, int nthreads) +int perf_evsel__alloc_counts(struct evsel *evsel, int ncpus, int nthreads) { evsel->counts = perf_counts__new(ncpus, nthreads); return evsel->counts != NULL ? 0 : -ENOMEM; } -void perf_evsel__free_counts(struct perf_evsel *evsel) +void perf_evsel__free_counts(struct evsel *evsel) { perf_counts__delete(evsel->counts); evsel->counts = NULL; |