1 /*****************************************************************************
3 # Copyright 2019 AT&T Intellectual Property *
5 # Licensed under the Apache License, Version 2.0 (the "License"); *
6 # you may not use this file except in compliance with the License. *
7 # You may obtain a copy of the License at *
9 # http://www.apache.org/licenses/LICENSE-2.0 *
11 # Unless required by applicable law or agreed to in writing, software *
12 # distributed under the License is distributed on an "AS IS" BASIS, *
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
14 # See the License for the specific language governing permissions and *
15 # limitations under the License. *
17 ******************************************************************************/
20 * Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
21 * Redistribution and modifications are permitted subject to BSD license.
27 #define A_SET_OF(type) \
30 int count; /* Meaningful size */ \
31 int size; /* Allocated size */ \
32 void (*free)(decltype(*array)); \
35 #define A_SET_OF(type) \
38 int count; /* Meaningful size */ \
39 int size; /* Allocated size */ \
40 void (*free)(type *); \
48 #define ASN_SET_ADD(headptr, ptr) \
49 asn_set_add((headptr), (ptr))
51 /*******************************************
52 * Implementation of the SET OF structure.
56 * Add another structure into the set by its pointer.
58 * 0 for success and -1/errno for failure.
60 int asn_set_add(void *asn_set_of_x, void *ptr);
63 * Delete the element from the set by its number (base 0).
64 * This is a constant-time operation. The order of elements before the
65 * deleted ones is guaranteed, the order of elements after the deleted
66 * one is NOT guaranteed.
67 * If _do_free is given AND the (*free) is initialized, the element
68 * will be freed using the custom (*free) function as well.
70 void asn_set_del(void *asn_set_of_x, int number, int _do_free);
73 * Empty the contents of the set. Will free the elements, if (*free) is given.
74 * Will NOT free the set itself.
76 void asn_set_empty(void *asn_set_of_x);
79 * Cope with different conversions requirements to/from void in C and C++.
80 * This is mostly useful for support library.
82 typedef A_SET_OF(void) asn_anonymous_set_;
83 #define _A_SET_FROM_VOID(ptr) ((asn_anonymous_set_ *)(ptr))
84 #define _A_CSET_FROM_VOID(ptr) ((const asn_anonymous_set_ *)(ptr))
90 #endif /* ASN_SET_OF_H */