summaryrefslogtreecommitdiffstats
path: root/common/list.c
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@nokia.com>2006-09-27 16:24:26 +0000
committerJohan Hedberg <johan.hedberg@nokia.com>2006-09-27 16:24:26 +0000
commit247635fe3905e4cc084a167c6db6e53dd7b0554d (patch)
treef04ebede4f19760416493440d945453d791c4ab6 /common/list.c
parent30e40ae987f4723deda3949879a6c0cd45fec92a (diff)
Support for prioritized watches
Diffstat (limited to 'common/list.c')
-rw-r--r--common/list.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/common/list.c b/common/list.c
index a887bcdd..579d9574 100644
--- a/common/list.c
+++ b/common/list.c
@@ -70,6 +70,36 @@ struct slist *slist_prepend(struct slist *list, void *data)
return entry;
}
+struct slist *slist_insert_before(struct slist *list, struct slist *sibling, void *data)
+{
+ struct slist *entry, *prev, *cur;
+
+ entry = malloc(sizeof(struct slist));
+ if (!entry)
+ return list;
+
+ entry->data = data;
+ entry->next = NULL;
+
+ if (!list)
+ return entry;
+
+ for (cur = list, prev = NULL; cur != NULL; prev = cur, cur = prev->next) {
+ if (cur == sibling)
+ break;
+ }
+
+ if (!prev) {
+ entry->next = list;
+ return entry;
+ }
+
+ entry->next = prev->next;
+ prev->next = entry;
+
+ return list;
+}
+
struct slist *slist_remove(struct slist *list, void *data)
{
struct slist *l, *next, *prev = NULL, *match = NULL;