diff options
| author | 2009-04-30 05:52:10 +0200 | |
|---|---|---|
| committer | 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); | |||
| 40 | void fdlist_add(struct fdlist *list, enum fdowner owner, int fd, short events); | 40 | void fdlist_add(struct fdlist *list, enum fdowner owner, int fd, short events); |
| 41 | void fdlist_free(struct fdlist *list); | 41 | void fdlist_free(struct fdlist *list); |
| 42 | 42 | ||
| 43 | #define MIN(X, Y) ((X) < (Y) ? (X) : (Y)) | 43 | struct collection { |
| 44 | void **list; | ||
| 45 | int capacity; | ||
| 46 | }; | ||
| 47 | |||
| 48 | void collection_init(struct collection *col); | ||
| 49 | void collection_add(struct collection *col, void *element); | ||
| 50 | void collection_remove(struct collection *col, void *element); | ||
| 51 | int collection_count(struct collection *col); | ||
| 52 | void collection_free(struct collection *col); | ||
| 53 | |||
| 54 | #define FOREACH(var, col) \ | ||
| 55 | do { \ | ||
| 56 | int _iter; \ | ||
| 57 | for(_iter=0; _iter<(col)->capacity; _iter++) { \ | ||
| 58 | if(!(col)->list[_iter]) continue; \ | ||
| 59 | var = (col)->list[_iter]; | ||
| 60 | |||
| 61 | #define ENDFOREACH \ | ||
| 62 | } \ | ||
| 63 | } while(0); | ||
| 44 | 64 | ||
| 45 | #endif | 65 | #endif |
