skiplist: implement skiplist_notify_del()

Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
This commit is contained in:
Angus Salkeld 2011-11-25 11:19:11 +11:00
parent 52321a8185
commit fbdfd34f59

View File

@ -267,12 +267,40 @@ skiplist_notify_del(qb_map_t * m, const char *key,
qb_map_notify_fn fn, int32_t events)
{
struct skiplist *t = (struct skiplist *)m;
struct skiplist_node *n = skiplist_lookup(t, key);
struct skiplist_node *n;
struct qb_map_notifier *f;
struct qb_list_head *head = NULL;
struct qb_list_head *list;
struct qb_list_head *next;
int32_t found = QB_FALSE;
if (n) {
return 0;
if (key) {
n = skiplist_lookup(t, key);
if (n) {
head = &n->notifier_head;
}
} else {
head = &t->header->notifier_head;
}
if (head == NULL) {
return -ENOENT;
}
for (list = head->next;
list != head; list = next) {
f = qb_list_entry(list, struct qb_map_notifier, list);
next = list->next;
if (f->events == events && f->callback == fn) {
found = QB_TRUE;
qb_list_del(&f->list);
free(f);
}
}
if (found) {
return 0;
} else {
return -ENOENT;
}
return -ENOENT;
}
static void