aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/common/utils.c19
-rw-r--r--src/common/utils.h1
2 files changed, 20 insertions, 0 deletions
diff --git a/src/common/utils.c b/src/common/utils.c
index 692d1ce..1d4a678 100644
--- a/src/common/utils.c
+++ b/src/common/utils.c
@@ -74,6 +74,25 @@ bc_slist_prepend(bc_slist_t *l, void *data)
}
+bc_slist_t*
+bc_slist_remove(bc_slist_t *l, bc_slist_t *r, bc_free_func_t free_func)
+{
+ bc_slist_t *p = NULL;
+ for (bc_slist_t *tmp = l; tmp != NULL; p = tmp, tmp = tmp->next) {
+ if (tmp == r) {
+ if (p == NULL)
+ l = tmp->next;
+ else
+ p->next = tmp->next;
+ if ((free_func != NULL) && (l->data != NULL))
+ free_func(tmp->data);
+ free(tmp);
+ return l;
+ }
+ }
+}
+
+
void
bc_slist_free_full(bc_slist_t *l, bc_free_func_t free_func)
{
diff --git a/src/common/utils.h b/src/common/utils.h
index 94c3356..0e938a4 100644
--- a/src/common/utils.h
+++ b/src/common/utils.h
@@ -31,6 +31,7 @@ typedef struct _bc_slist_t {
bc_slist_t* bc_slist_append(bc_slist_t *l, void *data);
bc_slist_t* bc_slist_prepend(bc_slist_t *l, void *data);
+bc_slist_t* bc_slist_remove(bc_slist_t *l, bc_slist_t *r, bc_free_func_t free_func);
void bc_slist_free(bc_slist_t *l);
void bc_slist_free_full(bc_slist_t *l, bc_free_func_t free_func);
size_t bc_slist_length(bc_slist_t *l);