summaryrefslogtreecommitdiffstats
path: root/moon-abe/pbc-0.5.14/misc/darray.h
diff options
context:
space:
mode:
authorWuKong <rebirthmonkey@gmail.com>2015-09-04 09:25:34 +0200
committerWuKong <rebirthmonkey@gmail.com>2015-09-04 09:25:34 +0200
commit3baeb11a8fbcfcdbc31976d421f17b85503b3ecd (patch)
tree04891d88c1127148f1b390b5a24414e85b270aee /moon-abe/pbc-0.5.14/misc/darray.h
parent67c5b73910f5fc437429c356978081b252a59480 (diff)
init attribute-based encryption
Change-Id: Iba1a3d722110abf747a0fba366f3ebc911d25b25
Diffstat (limited to 'moon-abe/pbc-0.5.14/misc/darray.h')
-rw-r--r--moon-abe/pbc-0.5.14/misc/darray.h92
1 files changed, 92 insertions, 0 deletions
diff --git a/moon-abe/pbc-0.5.14/misc/darray.h b/moon-abe/pbc-0.5.14/misc/darray.h
new file mode 100644
index 00000000..ecbd04ad
--- /dev/null
+++ b/moon-abe/pbc-0.5.14/misc/darray.h
@@ -0,0 +1,92 @@
+// darray = "dynamic array"
+// A linked-list implementation using C arrays.
+
+#ifndef __PBC_DARRAY_H__
+#define __PBC_DARRAY_H__
+
+#pragma GCC visibility push(hidden)
+
+struct darray_s {
+ void **item;
+ int count;
+ int max;
+};
+
+typedef struct darray_s darray_t[1];
+typedef struct darray_s *darray_ptr;
+
+/*@manual darray
+Initialize a dynamic array 'a'. Must be called before 'a' is used.
+*/
+void darray_init(darray_t a);
+darray_ptr darray_new(void);
+
+void darray_free(darray_ptr a);
+
+/*@manual darray
+Clears a dynamic array 'a'. Should be called after 'a' is no longer needed.
+*/
+void darray_clear(darray_t a);
+
+/*@manual darray
+Appends 'p' to the dynamic array 'a'.
+*/
+void darray_append(darray_t a, void *p);
+
+/*@manual darray
+Returns the pointer at index 'i' in the dynamic array 'a'.
+*/
+static inline void *darray_at(darray_t a, int i) {
+ return a->item[i];
+}
+
+int darray_index_of(darray_ptr a, void *p);
+void darray_remove(darray_ptr a, void *p);
+void darray_remove_last(darray_ptr a);
+void darray_remove_with_test(darray_ptr a, int (*test)(void *));
+
+/*@manual darray
+Removes the pointer at index 'i' in the dynamic array 'a'.
+*/
+void darray_remove_index(darray_ptr a, int n);
+void darray_copy(darray_ptr dst, darray_ptr src);
+void darray_remove_all(darray_ptr d);
+void darray_forall(darray_t a, void (*func)(void *));
+void darray_forall2(darray_t a,
+ void (*func)(void *darray_item, void *scope_ptr),
+ void *scope_ptr);
+void darray_forall3(darray_t a,
+ void (*func)(void *darray_item,
+ void *scope_ptr1,
+ void *scope_ptr2),
+ void *scope_ptr1,
+ void *scope_ptr2);
+void darray_forall4(darray_t a,
+ void (*func)(void *darray_item,
+ void *scope_ptr1,
+ void *scope_ptr2,
+ void *scope_ptr3),
+ void *scope_ptr1,
+ void *scope_ptr2,
+ void *scope_ptr3);
+
+void *darray_at_test(darray_ptr a, int (*test)(void *,void *), void *scope_ptr);
+
+/*@manual darray
+Returns the number of pointers held in 'a'.
+*/
+static inline int darray_count(darray_ptr a) {
+ return a->count;
+}
+
+static inline int darray_is_empty(darray_ptr a) {
+ return !a->count;
+}
+
+static inline void *darray_last(darray_t a) {
+ return a->item[a->count - 1];
+}
+
+#pragma GCC visibility pop
+
+#endif //__PBC_DARRAY_H__