]> Pileus Git - wmpus/blob - util.h
Initial code for x11/wmii
[wmpus] / util.h
1 #define MAX(a,b) ((a) > (b) ? (a) : (b))
2 #define MIN(a,b) ((a) < (b) ? (a) : (b))
3
4 #define new0(type) (calloc(1, sizeof(type)))
5
6 #define countof(x) (sizeof(x)/sizeof((x)[0]))
7
8 #define map_get(map, key) ({ \
9         int i; \
10         for (i = 0; i < countof(map) && \
11                 *((typeof(key)*)&map[i]) != key; i++); \
12         i < countof(map) ? &map[i] : NULL ; \
13 })