chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
systemctl: drop usage of "internally loaded modules"
[elogind.git]
/
src
/
shared
/
strv.c
diff --git
a/src/shared/strv.c
b/src/shared/strv.c
index 60c47625723296b624a0c6394a2d54424e6c3f56..a5ce7e9593652f9f095b1801454fd061caf69034 100644
(file)
--- a/
src/shared/strv.c
+++ b/
src/shared/strv.c
@@
-64,15
+64,7
@@
void strv_free(char **l) {
free(l);
}
free(l);
}
-void strv_freep(char ***l) {
- if (!l)
- return;
-
- strv_free(*l);
- *l = NULL;
-}
-
-char **strv_copy(char **l) {
+char **strv_copy(char * const *l) {
char **r, **k;
k = r = new(char*, strv_length(l) + 1);
char **r, **k;
k = r = new(char*, strv_length(l) + 1);
@@
-92,7
+84,7
@@
char **strv_copy(char **l) {
return r;
}
return r;
}
-unsigned strv_length(char **l) {
+unsigned strv_length(char *
const
*l) {
unsigned n = 0;
if (!l)
unsigned n = 0;
if (!l)
@@
-395,32
+387,43
@@
fail:
return NULL;
}
return NULL;
}
-int strv_
extend(char ***l, const
char *value) {
+int strv_
push(char ***l,
char *value) {
char **c;
char **c;
- char *v;
unsigned n;
if (!value)
return 0;
unsigned n;
if (!value)
return 0;
- v = strdup(value);
- if (!v)
- return -ENOMEM;
-
n = strv_length(*l);
c = realloc(*l, sizeof(char*) * (n + 2));
n = strv_length(*l);
c = realloc(*l, sizeof(char*) * (n + 2));
- if (!c) {
- free(v);
+ if (!c)
return -ENOMEM;
return -ENOMEM;
- }
- c[n] = v;
+ c[n] = v
alue
;
c[n+1] = NULL;
*l = c;
return 0;
}
c[n+1] = NULL;
*l = c;
return 0;
}
+int strv_extend(char ***l, const char *value) {
+ char *v;
+ int r;
+
+ if (!value)
+ return 0;
+
+ v = strdup(value);
+ if (!v)
+ return -ENOMEM;
+
+ r = strv_push(l, v);
+ if (r < 0)
+ free(v);
+
+ return r;
+}
+
char **strv_uniq(char **l) {
char **i;
char **strv_uniq(char **l) {
char **i;