6539ec912c7068f83a449ee3203baa2fe1e049c3
[deliverable/linux.git] / tools / perf / util / evsel.c
1 #include "evsel.h"
2 #include "util.h"
3
4 struct perf_evsel *perf_evsel__new(u32 type, u64 config, int idx)
5 {
6 struct perf_evsel *evsel = zalloc(sizeof(*evsel));
7
8 if (evsel != NULL) {
9 evsel->idx = idx;
10 evsel->attr.type = type;
11 evsel->attr.config = config;
12 INIT_LIST_HEAD(&evsel->node);
13 }
14
15 return evsel;
16 }
17
18 int perf_evsel__alloc_fd(struct perf_evsel *evsel, int ncpus, int nthreads)
19 {
20 evsel->fd = xyarray__new(ncpus, nthreads, sizeof(int));
21 return evsel->fd != NULL ? 0 : -ENOMEM;
22 }
23
24 void perf_evsel__free_fd(struct perf_evsel *evsel)
25 {
26 xyarray__delete(evsel->fd);
27 evsel->fd = NULL;
28 }
29
30 void perf_evsel__delete(struct perf_evsel *evsel)
31 {
32 assert(list_empty(&evsel->node));
33 xyarray__delete(evsel->fd);
34 free(evsel);
35 }
This page took 0.030644 seconds and 4 git commands to generate.