summaryrefslogtreecommitdiffstats
path: root/utils.h
diff options
context:
space:
mode:
authorGravatar Hector Martin2009-04-30 05:52:10 +0200
committerGravatar Hector Martin2009-04-30 05:52:10 +0200
commit49a8ef4fcbc8e76ca0f484e6b2d2d9eea70596b6 (patch)
treed42281bbc3b17af0f92daa5d35429f46bdd2130f /utils.h
parent53fb582e7729d5b7ed40ff04d912fcf5add7ce1c (diff)
downloadusbmuxd-49a8ef4fcbc8e76ca0f484e6b2d2d9eea70596b6.tar.gz
usbmuxd-49a8ef4fcbc8e76ca0f484e6b2d2d9eea70596b6.tar.bz2
too much stuff and it WORKS
Diffstat (limited to 'utils.h')
-rw-r--r--utils.h22
1 files changed, 21 insertions, 1 deletions
diff --git a/utils.h b/utils.h
index 9a6d566..ad4ac9d 100644
--- a/utils.h
+++ b/utils.h
@@ -40,6 +40,26 @@ void fdlist_create(struct fdlist *list);
void fdlist_add(struct fdlist *list, enum fdowner owner, int fd, short events);
void fdlist_free(struct fdlist *list);
-#define MIN(X, Y) ((X) < (Y) ? (X) : (Y))
+struct collection {
+ void **list;
+ int capacity;
+};
+
+void collection_init(struct collection *col);
+void collection_add(struct collection *col, void *element);
+void collection_remove(struct collection *col, void *element);
+int collection_count(struct collection *col);
+void collection_free(struct collection *col);
+
+#define FOREACH(var, col) \
+ do { \
+ int _iter; \
+ for(_iter=0; _iter<(col)->capacity; _iter++) { \
+ if(!(col)->list[_iter]) continue; \
+ var = (col)->list[_iter];
+
+#define ENDFOREACH \
+ } \
+ } while(0);
#endif