Commit 3dfbea99 authored by Bernhard Link's avatar Bernhard Link

add strlist_remove

parent 03ee2d6d
......@@ -321,3 +321,21 @@ char *strlist_concat(const struct strlist *list, const char *prefix, const char
*n = '\0';
return c;
}
void strlist_remove(struct strlist *strlist, const char *element) {
int i, j;
assert(strlist != NULL);
assert(element != NULL);
j = 0;
for( i = 0 ; i < strlist->count ; i++ ) {
if( strcmp(strlist->values[i], element) != 0 ) {
if( i != j )
strlist->values[j] = strlist->values[i];
j++;
} else
free(strlist->values[i]);
}
strlist->count = j;
}
......@@ -51,4 +51,7 @@ bool *strlist_preparefoundlist(const struct strlist *);
/* concatenate <prefix> <values separated by infix> <suffix> */
char *strlist_concat(const struct strlist *, const char *prefix, const char *infix, const char *suffix);
/* remove all strings equal to the argument */
void strlist_remove(struct strlist *, const char *);
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment