2 * Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
3 * Redistribution and modifications are permitted subject to BSD license.
9 #define A_SET_OF(type) \
12 int count; /* Meaningful size */ \
13 int size; /* Allocated size */ \
14 void (*free)(decltype(*array)); \
17 #define A_SET_OF(type) \
20 int count; /* Meaningful size */ \
21 int size; /* Allocated size */ \
22 void (*free)(type *); \
30 #define ASN_SET_ADD(headptr, ptr) \
31 asn_set_add((headptr), (ptr))
33 /*******************************************
34 * Implementation of the SET OF structure.
38 * Add another structure into the set by its pointer.
40 * 0 for success and -1/errno for failure.
42 int asn_set_add(void *asn_set_of_x, void *ptr);
45 * Delete the element from the set by its number (base 0).
46 * This is a constant-time operation. The order of elements before the
47 * deleted ones is guaranteed, the order of elements after the deleted
48 * one is NOT guaranteed.
49 * If _do_free is given AND the (*free) is initialized, the element
50 * will be freed using the custom (*free) function as well.
52 void asn_set_del(void *asn_set_of_x, int number, int _do_free);
55 * Empty the contents of the set. Will free the elements, if (*free) is given.
56 * Will NOT free the set itself.
58 void asn_set_empty(void *asn_set_of_x);
61 * Cope with different conversions requirements to/from void in C and C++.
62 * This is mostly useful for support library.
64 typedef A_SET_OF(void) asn_anonymous_set_;
65 #define _A_SET_FROM_VOID(ptr) ((asn_anonymous_set_ *)(ptr))
66 #define _A_CSET_FROM_VOID(ptr) ((const asn_anonymous_set_ *)(ptr))
72 #endif /* ASN_SET_OF_H */