strv: add strv_free_many() to be used with CLEANUP_ARRAY()
This commit is contained in:
@@ -88,6 +88,15 @@ char** strv_free_erase(char **l) {
|
||||
return mfree(l);
|
||||
}
|
||||
|
||||
void strv_free_many(char ***strvs, size_t n) {
|
||||
assert(strvs || n == 0);
|
||||
|
||||
FOREACH_ARRAY (i, strvs, n)
|
||||
strv_free(*i);
|
||||
|
||||
free(strvs);
|
||||
}
|
||||
|
||||
char** strv_copy_n(char * const *l, size_t m) {
|
||||
_cleanup_strv_free_ char **result = NULL;
|
||||
char **k;
|
||||
|
||||
@@ -32,6 +32,8 @@ char** strv_free_erase(char **l);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(char**, strv_free_erase);
|
||||
#define _cleanup_strv_free_erase_ _cleanup_(strv_free_erasep)
|
||||
|
||||
void strv_free_many(char ***strvs, size_t n);
|
||||
|
||||
char** strv_copy_n(char * const *l, size_t n);
|
||||
static inline char** strv_copy(char * const *l) {
|
||||
return strv_copy_n(l, SIZE_MAX);
|
||||
|
||||
Reference in New Issue
Block a user