summaryrefslogtreecommitdiff
path: root/src/util.c
diff options
context:
space:
mode:
authorBenjamin Franzke <benjaminfranzke@googlemail.com>2011-09-24 12:54:31 +0200
committerBenjamin Franzke <benjaminfranzke@googlemail.com>2011-09-24 12:59:42 +0200
commitc820c3d4830b2c5db1c026ee332f2d773c366247 (patch)
tree993f5622d79236cdec2b86aa05f115ea2875c057 /src/util.c
parent99961ccd710e5300de5fb749aa10619632ac96e9 (diff)
downloadcmumble-c820c3d4830b2c5db1c026ee332f2d773c366247.tar.gz
cmumble-c820c3d4830b2c5db1c026ee332f2d773c366247.tar.bz2
cmumble-c820c3d4830b2c5db1c026ee332f2d773c366247.zip
Add a general element finding routine to util.c
And use this to implement find_user and find_channel as inline functions.
Diffstat (limited to 'src/util.c')
-rw-r--r--src/util.c18
1 files changed, 18 insertions, 0 deletions
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 <glib.h>
+
+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;
+}