summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2013-09-30 15:25:17 +0200
committerGravatar Nikias Bassen2013-09-30 15:25:17 +0200
commit4847a1161c712e6e56287b367296cc837bcd6b0a (patch)
tree959607ac62c13c0e7cc21232fd915803a4cc6e62 /src
parent1b775742ecee394050eac12f71562acf9e7c1294 (diff)
downloadusbmuxd-4847a1161c712e6e56287b367296cc837bcd6b0a.tar.gz
usbmuxd-4847a1161c712e6e56287b367296cc837bcd6b0a.tar.bz2
utils: make FOREACH macro _iter variable unique
Diffstat (limited to 'src')
-rw-r--r--src/utils.h12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/utils.h b/src/utils.h
index 5aa2915..69a4259 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -54,12 +54,16 @@ void collection_remove(struct collection *col, void *element);
54int collection_count(struct collection *col); 54int collection_count(struct collection *col);
55void collection_free(struct collection *col); 55void collection_free(struct collection *col);
56 56
57#define MERGE_(a,b) a ## _ ## b
58#define LABEL_(a,b) MERGE_(a, b)
59#define UNIQUE_VAR(a) LABEL_(a, __LINE__)
60
57#define FOREACH(var, col) \ 61#define FOREACH(var, col) \
58 do { \ 62 do { \
59 int _iter; \ 63 int UNIQUE_VAR(_iter); \
60 for(_iter=0; _iter<(col)->capacity; _iter++) { \ 64 for(UNIQUE_VAR(_iter)=0; UNIQUE_VAR(_iter)<(col)->capacity; UNIQUE_VAR(_iter)++) { \
61 if(!(col)->list[_iter]) continue; \ 65 if(!(col)->list[UNIQUE_VAR(_iter)]) continue; \
62 var = (col)->list[_iter]; 66 var = (col)->list[UNIQUE_VAR(_iter)];
63 67
64#define ENDFOREACH \ 68#define ENDFOREACH \
65 } \ 69 } \