shared: strv - add strv_clear()
This frees the elements of the strv without freeing the strv itself.
This commit is contained in:
parent
3542eac7f9
commit
dd9c7723fa
|
@ -69,7 +69,7 @@ char *strv_find_startswith(char **l, const char *name) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void strv_free(char **l) {
|
void strv_clear(char **l) {
|
||||||
char **k;
|
char **k;
|
||||||
|
|
||||||
if (!l)
|
if (!l)
|
||||||
|
@ -78,6 +78,11 @@ void strv_free(char **l) {
|
||||||
for (k = l; *k; k++)
|
for (k = l; *k; k++)
|
||||||
free(*k);
|
free(*k);
|
||||||
|
|
||||||
|
*l = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void strv_free(char **l) {
|
||||||
|
strv_clear(l);
|
||||||
free(l);
|
free(l);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,8 @@ void strv_free(char **l);
|
||||||
DEFINE_TRIVIAL_CLEANUP_FUNC(char**, strv_free);
|
DEFINE_TRIVIAL_CLEANUP_FUNC(char**, strv_free);
|
||||||
#define _cleanup_strv_free_ _cleanup_(strv_freep)
|
#define _cleanup_strv_free_ _cleanup_(strv_freep)
|
||||||
|
|
||||||
|
void strv_clear(char **l);
|
||||||
|
|
||||||
char **strv_copy(char * const *l);
|
char **strv_copy(char * const *l);
|
||||||
unsigned strv_length(char * const *l) _pure_;
|
unsigned strv_length(char * const *l) _pure_;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue