strv: Add _cleanup_strv_free_erase_ and _cleanup_string_free_erase_

This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2015-10-19 23:13:07 +02:00
committed by Lennart Poettering
parent 1602b00853
commit ab84f5b95e
9 changed files with 43 additions and 48 deletions
+9
View File
@@ -86,6 +86,15 @@ char **strv_free(char **l) {
return NULL;
}
char **strv_free_erase(char **l) {
char **i;
STRV_FOREACH(i, l)
string_erase(*i);
return strv_free(l);
}
char **strv_copy(char * const *l) {
char **r, **k;
+4
View File
@@ -35,6 +35,10 @@ char **strv_free(char **l);
DEFINE_TRIVIAL_CLEANUP_FUNC(char**, strv_free);
#define _cleanup_strv_free_ _cleanup_(strv_freep)
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_clear(char **l);
char **strv_copy(char * const *l);
+5 -4
View File
@@ -6817,9 +6817,10 @@ void string_erase(char *x) {
memory_erase(x, strlen(x));
}
void strv_erase(char **l) {
char **i;
char *string_free_erase(char *s) {
if (!s)
return NULL;
STRV_FOREACH(i, l)
string_erase(*i);
string_erase(s);
return mfree(s);
}
+4 -1
View File
@@ -946,4 +946,7 @@ bool oom_score_adjust_is_valid(int oa);
#define memory_erase(p, l) memset((p), 'x', (l))
void string_erase(char *x);
void strv_erase(char **l);
char *string_free_erase(char *s);
DEFINE_TRIVIAL_CLEANUP_FUNC(char *, string_free_erase);
#define _cleanup_string_free_erase_ _cleanup_(string_free_erasep)