(void *)filter);
}
+int perf_evsel__set_filter(struct perf_evsel *evsel, const char *filter)
+{
+ char *new_filter = strdup(filter);
+
+ if (new_filter != NULL) {
+ free(evsel->filter);
+ evsel->filter = new_filter;
+ return 0;
+ }
+
+ return -1;
+}
+
int perf_evsel__enable(struct perf_evsel *evsel, int ncpus, int nthreads)
{
return perf_evsel__run_ioctl(evsel, ncpus, nthreads,
void perf_evsel__set_sample_id(struct perf_evsel *evsel,
bool use_sample_identifier);
+int perf_evsel__set_filter(struct perf_evsel *evsel, const char *filter);
int perf_evsel__apply_filter(struct perf_evsel *evsel, int ncpus, int nthreads,
const char *filter);
int perf_evsel__enable(struct perf_evsel *evsel, int ncpus, int nthreads);
return -1;
}
- last->filter = strdup(str);
- if (last->filter == NULL) {
+ if (perf_evsel__set_filter(last, str) < 0) {
fprintf(stderr, "not enough memory to hold filter string\n");
return -1;
}