strv: introduce strv_find_prefix()

This commit is contained in:
Lennart Poettering
2010-06-16 05:06:02 +02:00
parent d3782d60cd
commit a4bfb3990b
2 changed files with 14 additions and 1 deletions
+12 -1
View File
@@ -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;
+2
View File
@@ -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);