From: sgakerru Date: Tue, 17 Dec 2024 15:10:13 +0000 (+0400) Subject: lib/list.c: free_list(): Add function X-Git-Tag: 4.19.0-rc1~93 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=04cadad0938d3205db3779eab6ea96d930617ebe;p=thirdparty%2Fshadow.git lib/list.c: free_list(): Add function --- diff --git a/lib/list.c b/lib/list.c index 097d22a68..e411307d3 100644 --- a/lib/list.c +++ b/lib/list.c @@ -157,6 +157,17 @@ dup_list(char *const *list) return tmp; } +/* + * free_list - free input list + */ +void +free_list(char **list) +{ + for (size_t i = 0; list[i] != NULL; i++) + free(list[i]); + list[0] = NULL; +} + /* * Check if member is part of the input list * The input list is not modified, but in order to allow the use of this diff --git a/lib/prototypes.h b/lib/prototypes.h index 760225767..0a951f880 100644 --- a/lib/prototypes.h +++ b/lib/prototypes.h @@ -201,6 +201,7 @@ extern void setup_limits (const struct passwd *); extern /*@only@*/char **add_list (/*@returned@*/ /*@only@*/char **, const char *); extern /*@only@*/char **del_list (/*@returned@*/ /*@only@*/char **, const char *); extern /*@only@*/char **dup_list (char *const *); +extern void free_list (char **); extern bool is_on_list (char *const *list, const char *member); extern /*@only@*/char **comma_to_list (const char *);