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