+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * Copyright © 2006 Pierre Habouzit
+ */
+
+#ifndef MUTT_LIB_LIB_ARRAY_H
+#define MUTT_LIB_LIB_ARRAY_H
+
+#define DO_ARRAY_TYPE(type, prefix) \
+ typedef struct prefix##_array { \
+ type **arr; \
+ ssize_t len; \
+ ssize_t size; \
+ } prefix##_array
+
+#define DO_ARRAY_FUNCS(type, prefix, dtor) \
+ \
+ static inline void prefix##_array_init(prefix##_array *array) { \
+ p_clear(array, 1); \
+ } \
+ static inline void \
+ prefix##_array_wipe(prefix##_array *array) { \
+ while (array->len) { \
+ (dtor)(&array->arr[--array->len]); \
+ } \
+ p_delete(&array->arr); \
+ } \
+ \
+ static inline void \
+ prefix##_array_insert(prefix##_array *array, ssize_t pos, type *item) { \
+ __array_insert((__array *)array, pos, (void*)item); \
+ } \
+ static inline void \
+ prefix##_array_append(prefix##_array *array, type *item) { \
+ __array_insert((__array *)array, array->len, (void*)item); \
+ } \
+ static inline type * \
+ prefix##_array_take(prefix##_array *array, ssize_t pos) { \
+ return (type *)__array_take((__array *)array, pos); \
+ }
+
+DO_ARRAY_TYPE(void, _);
+void __array_insert(__array *array, ssize_t pos, void *item);
+void *__array_take(__array *array, ssize_t pos);
+
+#endif /* MUTT_LIB_LIB_ARRAY_H */