summaryrefslogtreecommitdiffstats
path: root/shared/array.h
diff options
context:
space:
mode:
Diffstat (limited to 'shared/array.h')
-rw-r--r--shared/array.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/shared/array.h b/shared/array.h
new file mode 100644
index 0000000..b88482f
--- /dev/null
+++ b/shared/array.h
@@ -0,0 +1,22 @@
+#pragma once
+
+#include <stddef.h>
+
+/*
+ * Declaration of struct array is in header because we may want to embed the
+ * structure into another, so we need to know its size
+ */
+struct array {
+ void **array;
+ size_t count;
+ size_t total;
+ size_t step;
+};
+
+void array_init(struct array *array, size_t step);
+int array_append(struct array *array, const void *element);
+int array_append_unique(struct array *array, const void *element);
+void array_pop(struct array *array);
+void array_free_array(struct array *array);
+void array_sort(struct array *array, int (*cmp)(const void *a, const void *b));
+int array_remove_at(struct array *array, unsigned int pos);