summaryrefslogtreecommitdiff
path: root/src/libudev/strv.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libudev/strv.c')
-rw-r--r--src/libudev/strv.c198
1 files changed, 0 insertions, 198 deletions
diff --git a/src/libudev/strv.c b/src/libudev/strv.c
index d2b083218a..041e20d700 100644
--- a/src/libudev/strv.c
+++ b/src/libudev/strv.c
@@ -28,18 +28,6 @@
#include "util.h"
#include "strv.h"
-char *strv_find(char **l, const char *name) {
- char **i;
-
- assert(name);
-
- STRV_FOREACH(i, l)
- if (streq(*i, name))
- return *i;
-
- return NULL;
-}
-
void strv_free(char **l) {
char **k;
@@ -154,170 +142,6 @@ char **strv_new(const char *x, ...) {
return r;
}
-char **strv_merge(char **a, char **b) {
- char **r, **k;
-
- if (!a)
- return strv_copy(b);
-
- if (!b)
- return strv_copy(a);
-
- r = new(char*, strv_length(a) + strv_length(b) + 1);
- if (!r)
- return NULL;
-
- for (k = r; *a; k++, a++) {
- *k = strdup(*a);
- if (!*k)
- goto fail;
- }
-
- for (; *b; k++, b++) {
- *k = strdup(*b);
- if (!*k)
- goto fail;
- }
-
- *k = NULL;
- return r;
-
-fail:
- strv_free(r);
- return NULL;
-}
-
-char **strv_split(const char *s, const char *separator) {
- char *state;
- char *w;
- size_t l;
- unsigned n, i;
- char **r;
-
- assert(s);
-
- n = 0;
- FOREACH_WORD_SEPARATOR(w, l, s, separator, state)
- n++;
-
- r = new(char*, n+1);
- if (!r)
- return NULL;
-
- i = 0;
- FOREACH_WORD_SEPARATOR(w, l, s, separator, state) {
- r[i] = strndup(w, l);
- if (!r[i]) {
- strv_free(r);
- return NULL;
- }
-
- i++;
- }
-
- r[i] = NULL;
- return r;
-}
-
-char **strv_split_quoted(const char *s) {
- char *state;
- char *w;
- size_t l;
- unsigned n, i;
- char **r;
-
- assert(s);
-
- n = 0;
- FOREACH_WORD_QUOTED(w, l, s, state)
- n++;
-
- r = new(char*, n+1);
- if (!r)
- return NULL;
-
- i = 0;
- FOREACH_WORD_QUOTED(w, l, s, state) {
- r[i] = cunescape_length(w, l);
- if (!r[i]) {
- strv_free(r);
- return NULL;
- }
- i++;
- }
-
- r[i] = NULL;
- return r;
-}
-
-char **strv_append(char **l, const char *s) {
- char **r, **k;
-
- if (!l)
- return strv_new(s, NULL);
-
- if (!s)
- return strv_copy(l);
-
- r = new(char*, strv_length(l)+2);
- if (!r)
- return NULL;
-
- for (k = r; *l; k++, l++) {
- *k = strdup(*l);
- if (!*k)
- goto fail;
- }
-
- k[0] = strdup(s);
- if (!k[0])
- goto fail;
-
- k[1] = NULL;
- return r;
-
-fail:
- strv_free(r);
- return NULL;
-}
-
-int strv_push(char ***l, char *value) {
- char **c;
- unsigned n;
-
- if (!value)
- return 0;
-
- n = strv_length(*l);
- c = realloc(*l, sizeof(char*) * (n + 2));
- if (!c)
- return -ENOMEM;
-
- c[n] = value;
- 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;
@@ -354,25 +178,3 @@ char **strv_remove(char **l, const char *s) {
*t = NULL;
return l;
}
-
-char **strv_split_nulstr(const char *s) {
- const char *i;
- char **r = NULL;
-
- NULSTR_FOREACH(i, s)
- if (strv_extend(&r, i) < 0) {
- strv_free(r);
- return NULL;
- }
-
- if (!r)
- return strv_new(NULL, NULL);
-
- return r;
-}
-
-static int str_compare(const void *_a, const void *_b) {
- const char **a = (const char**) _a, **b = (const char**) _b;
-
- return strcmp(*a, *b);
-}