From: "Steven Rostedt (VMware)" <rostedt@xxxxxxxxxxx> Add tracefs_list_size() that returns a the size of a list created by tracefs_list_add(). Signed-off-by: Steven Rostedt (VMware) <rostedt@xxxxxxxxxxx> --- include/tracefs.h | 1 + src/tracefs-utils.c | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/include/tracefs.h b/include/tracefs.h index 266c513e4116..6b9a76c4c40a 100644 --- a/include/tracefs.h +++ b/include/tracefs.h @@ -65,6 +65,7 @@ int tracefs_error_clear(struct tracefs_instance *instance); void tracefs_list_free(char **list); char **tracefs_list_add(char **list, const char *string); +int tracefs_list_size(char **list); /** * tracefs_trace_on_get_fd - Get a file descriptor of "tracing_on" in given instance diff --git a/src/tracefs-utils.c b/src/tracefs-utils.c index ec5ecb08ed2e..6750336c9ef6 100644 --- a/src/tracefs-utils.c +++ b/src/tracefs-utils.c @@ -447,3 +447,19 @@ char **tracefs_list_add(char **list, const char *string) return list; } + +/** + * tracefs_list_size - Return the number of strings in the list + * @list: The list to determine the size. + * + * Returns the number of elements in the list. + * If @list is NULL, then zero is returned. + */ +int tracefs_list_size(char **list) +{ + if (!list) + return 0; + + list--; + return (int)*(unsigned long *)list; +} -- 2.30.2