]> Pileus Git - wmpus/blobdiff - util.h
Initial code for x11/wmii
[wmpus] / util.h
diff --git a/util.h b/util.h
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..a572a0aabd01d9528b751777ccb241e1c0584536 100644 (file)
--- a/util.h
+++ b/util.h
@@ -0,0 +1,13 @@
+#define MAX(a,b) ((a) > (b) ? (a) : (b))
+#define MIN(a,b) ((a) < (b) ? (a) : (b))
+
+#define new0(type) (calloc(1, sizeof(type)))
+
+#define countof(x) (sizeof(x)/sizeof((x)[0]))
+
+#define map_get(map, key) ({ \
+       int i; \
+       for (i = 0; i < countof(map) && \
+               *((typeof(key)*)&map[i]) != key; i++); \
+       i < countof(map) ? &map[i] : NULL ; \
+})