diff options
author | Hector Martin | 2009-04-30 05:52:10 +0200 |
---|---|---|
committer | Hector Martin | 2009-04-30 05:52:10 +0200 |
commit | 49a8ef4fcbc8e76ca0f484e6b2d2d9eea70596b6 (patch) | |
tree | d42281bbc3b17af0f92daa5d35429f46bdd2130f /utils.h | |
parent | 53fb582e7729d5b7ed40ff04d912fcf5add7ce1c (diff) | |
download | usbmuxd-49a8ef4fcbc8e76ca0f484e6b2d2d9eea70596b6.tar.gz usbmuxd-49a8ef4fcbc8e76ca0f484e6b2d2d9eea70596b6.tar.bz2 |
too much stuff and it WORKS
Diffstat (limited to 'utils.h')
-rw-r--r-- | utils.h | 22 |
1 files changed, 21 insertions, 1 deletions
@@ -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 |