From c820c3d4830b2c5db1c026ee332f2d773c366247 Mon Sep 17 00:00:00 2001 From: Benjamin Franzke Date: Sat, 24 Sep 2011 12:54:31 +0200 Subject: Add a general element finding routine to util.c And use this to implement find_user and find_channel as inline functions. --- src/util.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 src/util.c (limited to 'src/util.c') diff --git a/src/util.c b/src/util.c new file mode 100644 index 0000000..a98731b --- /dev/null +++ b/src/util.c @@ -0,0 +1,18 @@ +#include "util.h" +#include + +gpointer +cmumble_find_by_id(GList *list, gsize member_offset, guint id) +{ + gpointer el = NULL; + GList *l; + + for (l = list; l; l = l->next) { + if (G_STRUCT_MEMBER(uint32_t, l, member_offset) == id) { + el = l->data; + break; + } + } + + return el; +} -- cgit