Merge branch 'kn/ref-filter-branch-list' into maint
[gitweb.git] / string-list.c
index 003ca1879ef560b3db0ad9e1af8022c38800b500..c650500c6e51d983dc45a4be3b8dad98f1dece92 100644 (file)
@@ -64,6 +64,24 @@ struct string_list_item *string_list_insert(struct string_list *list, const char
        return list->items + index;
 }
 
+void string_list_remove(struct string_list *list, const char *string,
+                       int free_util)
+{
+       int exact_match;
+       int i = get_entry_index(list, string, &exact_match);
+
+       if (exact_match) {
+               if (list->strdup_strings)
+                       free(list->items[i].string);
+               if (free_util)
+                       free(list->items[i].util);
+
+               list->nr--;
+               memmove(list->items + i, list->items + i + 1,
+                       (list->nr - i) * sizeof(struct string_list_item));
+       }
+}
+
 int string_list_has_string(const struct string_list *list, const char *string)
 {
        int exact_match;