chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
3542eac
)
shared: strv - add strv_clear()
author
Tom Gundersen
<teg@jklm.no>
Wed, 17 Dec 2014 00:08:56 +0000
(
01:08
+0100)
committer
Tom Gundersen
<teg@jklm.no>
Wed, 17 Dec 2014 00:09:16 +0000
(
01:09
+0100)
This frees the elements of the strv without freeing the strv itself.
src/shared/strv.c
patch
|
blob
|
history
src/shared/strv.h
patch
|
blob
|
history
diff --git
a/src/shared/strv.c
b/src/shared/strv.c
index fdb658c0a33696a0e5d644f1c2636748ce0c3a5e..f86dddaf811223b0df1caa8f71c6f0c316440f7b 100644
(file)
--- a/
src/shared/strv.c
+++ b/
src/shared/strv.c
@@
-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);
}
diff --git
a/src/shared/strv.h
b/src/shared/strv.h
index 2c0280b71307ccab1624ef2ff196cb62c1f8ba47..9e5b1bb8b0de69e465f755927a0df69d3b04bef3 100644
(file)
--- a/
src/shared/strv.h
+++ b/
src/shared/strv.h
@@
-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_;