From e3f3f8b3d84a4f953d7540304edc0705f0df36d5 Mon Sep 17 00:00:00 2001 From: Rocco Rutte Date: Wed, 13 May 2009 14:19:26 +0200 Subject: [PATCH] Add mutt_find_list() to lookup data in lists --- mutt.h | 1 + muttlib.c | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/mutt.h b/mutt.h index 5ee1f1ba6..06cdab8b3 100644 --- a/mutt.h +++ b/mutt.h @@ -552,6 +552,7 @@ int mutt_matches_ignore (const char *, LIST *); /* add an element to a list */ LIST *mutt_add_list (LIST *, const char *); LIST *mutt_add_list_n (LIST*, const void *, size_t); +LIST *mutt_find_list (LIST *, const char *); void mutt_init (int, LIST *); diff --git a/muttlib.c b/muttlib.c index a031941cc..590bef7a8 100644 --- a/muttlib.c +++ b/muttlib.c @@ -252,6 +252,21 @@ LIST *mutt_add_list_n (LIST *head, const void *data, size_t len) return head; } +LIST *mutt_find_list (LIST *l, const char *data) +{ + LIST *p = l; + + while (p) + { + if (data == p->data) + return p; + if (data && p->data && mutt_strcmp (p->data, data) == 0) + return p; + p = p->next; + } + return NULL; +} + void mutt_free_list (LIST **list) { LIST *p; -- 2.40.0