shared: strv - add strv_clear()

This frees the elements of the strv without freeing the strv itself.
This commit is contained in:
Tom Gundersen 2014-12-17 01:08:56 +01:00
parent 3542eac7f9
commit dd9c7723fa
2 changed files with 8 additions and 1 deletions

View File

@ -69,7 +69,7 @@ char *strv_find_startswith(char **l, const char *name) {
return NULL;
}
void strv_free(char **l) {
void strv_clear(char **l) {
char **k;
if (!l)
@ -78,6 +78,11 @@ void strv_free(char **l) {
for (k = l; *k; k++)
free(*k);
*l = NULL;
}
void strv_free(char **l) {
strv_clear(l);
free(l);
}

View File

@ -34,6 +34,8 @@ void strv_free(char **l);
DEFINE_TRIVIAL_CLEANUP_FUNC(char**, strv_free);
#define _cleanup_strv_free_ _cleanup_(strv_freep)
void strv_clear(char **l);
char **strv_copy(char * const *l);
unsigned strv_length(char * const *l) _pure_;