generic array list helper
[taskasaur.git] / headers / utils.h
diff --git a/headers/utils.h b/headers/utils.h
new file mode 100644 (file)
index 0000000..0d23060
--- /dev/null
@@ -0,0 +1,21 @@
+
+#ifndef __UTILS_H__
+#define __UTILS_H__
+
+#define \
+array_length(type, array)               \
+({                                      \
+    type* m_arr;                        \
+    int m_len;                          \
+                                        \
+    m_arr = (type*)array;               \
+    m_len = 0;                          \
+                                        \
+    while (m_arr[m_len] != 0) {         \
+        m_len += 1;                     \
+    }                                   \
+                                        \
+    m_len;                              \
+})
+
+#endif