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