trace-cmd: implement a new API, tep_list_events_copy()
PATCH 1/1 trace-cmd: implement a new API, tep_list_events_copy()
Existing API tep_list_events() is not thread safe, it uses the internal array sort_events to keep cache of the sorted events and reuses it. This patch implements a new API, tep_list_events_copy(), which allocates new sorted array each time it is called. It could be used when a sorted events functionality is needed in thread safe use cases. It is up to the caller to free the array.
Signed-off-by Tzvetomir Stoyanov <[email protected]>
--- include/traceevent/event-parse.h | 5 +- lib/traceevent/event-parse.c | 109 ++++++++++++++++++++++++------- 2 files changed, 91 insertions(+), 23 deletions(-)
include/traceevent/event-parse.h +4 -1
@@ -528,7 +528,10 @@ void tep_event_info(struct trace_seq *s, struct tep_event *event,int tep_strerror (struct tep_handle *pevent,enum tep_errno errnum,char *buf,size_t buflen); -struct tep_event **tep_list_events (struct tep_handle *pevent,enum tep_event_sort_type ); +struct tep_event **tep_list_events (struct tep_handle *tep, +enum tep_event_sort_type ); +struct tep_event **tep_list_events_copy (struct tep_handle *tep, +enum tep_event_sort_type );struct tep_format_field **tep_event_common_fields (struct tep_event *event);struct tep_format_field **tep_event_fields (struct tep_event *event);
lib/traceevent/event-parse.c +87 -22
130 lines not on this page · raw message
Signature · 1 line
2.19.2