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