ARM: dts: kirkwood: gpio-leds fixes for linkstation ls-wvl/vl
[linux/fpc-iii.git] / tools / perf / util / counts.c
blobe3fde313deb27371de3782eaa76e1e2ee232fdf8
1 #include <stdlib.h>
2 #include "evsel.h"
3 #include "counts.h"
5 struct perf_counts *perf_counts__new(int ncpus, int nthreads)
7 struct perf_counts *counts = zalloc(sizeof(*counts));
9 if (counts) {
10 struct xyarray *values;
12 values = xyarray__new(ncpus, nthreads, sizeof(struct perf_counts_values));
13 if (!values) {
14 free(counts);
15 return NULL;
18 counts->values = values;
21 return counts;
24 void perf_counts__delete(struct perf_counts *counts)
26 if (counts) {
27 xyarray__delete(counts->values);
28 free(counts);
32 static void perf_counts__reset(struct perf_counts *counts)
34 xyarray__reset(counts->values);
37 void perf_evsel__reset_counts(struct perf_evsel *evsel)
39 perf_counts__reset(evsel->counts);
42 int perf_evsel__alloc_counts(struct perf_evsel *evsel, int ncpus, int nthreads)
44 evsel->counts = perf_counts__new(ncpus, nthreads);
45 return evsel->counts != NULL ? 0 : -ENOMEM;
48 void perf_evsel__free_counts(struct perf_evsel *evsel)
50 perf_counts__delete(evsel->counts);
51 evsel->counts = NULL;