From: Lennart Poettering Date: Wed, 16 Jun 2010 03:06:02 +0000 (+0200) Subject: strv: introduce strv_find_prefix() X-Git-Tag: v1~191 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a4bfb3990be698b1f5c691a73823c040ffe919d5;p=systemd strv: introduce strv_find_prefix() --- diff --git a/src/strv.c b/src/strv.c index a749096f..2ebd0ee5 100644 --- a/src/strv.c +++ b/src/strv.c @@ -31,7 +31,6 @@ char *strv_find(char **l, const char *name) { char **i; - assert(l); assert(name); STRV_FOREACH(i, l) @@ -41,6 +40,18 @@ char *strv_find(char **l, const char *name) { return NULL; } +char *strv_find_prefix(char **l, const char *name) { + char **i; + + assert(name); + + STRV_FOREACH(i, l) + if (startswith(*i, name)) + return *i; + + return NULL; +} + void strv_free(char **l) { char **k; diff --git a/src/strv.h b/src/strv.h index 11d2ea12..2d24b4e3 100644 --- a/src/strv.h +++ b/src/strv.h @@ -28,6 +28,8 @@ #include "macro.h" char *strv_find(char **l, const char *name); +char *strv_find_prefix(char **l, const char *name); + void strv_free(char **l); char **strv_copy(char **l) _malloc_; unsigned strv_length(char **l);