@ -92,7 +92,8 @@ parameters. At the moment, this is done as follows:
struct ao2_container * c ;
c = ao2_container_alloc ( MAX_BUCKETS , my_hash_fn , my_cmp_fn ) ;
c = ao2_container_alloc_hash ( AO2_ALLOC_OPT_LOCK_MUTEX , 0 , MAX_BUCKETS ,
my_hash_fn , NULL , my_cmp_fn ) ;
\ endcode
where
@ -108,7 +109,7 @@ A container knows little or nothing about the objects it stores,
other than the fact that they have been created by ao2_alloc ( ) .
All knowledge of the ( user - defined ) internals of the objects
is left to the ( user - supplied ) functions passed as arguments
to ao2_container_alloc ( ) .
to ao2_container_alloc _hash ( ) .
If we want to insert an object in a container , we should
initialize its fields - - especially , those used by my_hash_fn ( ) - -
@ -856,20 +857,8 @@ and perform various operations on them.
Internally , objects are stored in lists , hash tables or other
data structures depending on the needs .
\ note NOTA BENE : at the moment the only container we support is the
hash table and its degenerate form , the list .
Operations on container include :
- c = \ b ao2_container_alloc ( size , hash_fn , cmp_fn )
allocate a container with desired size and default compare
and hash function
- The compare function returns an int , which
can be 0 for not found , CMP_STOP to stop end a traversal ,
or CMP_MATCH if they are equal
- The hash function returns an int . The hash function
takes two argument , the object pointer and a flags field ,
- \ b ao2_find ( c , arg , flags )
returns zero or more elements matching a given criteria
( specified as arg ) . ' c ' is the container pointer . Flags
@ -1217,6 +1206,10 @@ typedef int (ao2_sort_fn)(const void *obj_left, const void *obj_right, int flags
/*@{ */
struct ao2_container ;
# ifndef AST_IN_CORE
/* These macros are removed from Asterisk 17. They are still available to modules
* but should only be used by third party modules that have not been updated . */
/*!
* \ deprecated
* \ brief Allocate and initialize a hash container with the desired number of buckets .
@ -1236,17 +1229,13 @@ struct ao2_container;
* \ note Destructor is set implicitly .
* \ note This is legacy container creation that is mapped to the new method .
*/
# define ao2_container_alloc(n_buckets, hash_fn, cmp_fn) \
ao2_container_alloc_hash ( AO2_ALLOC_OPT_LOCK_MUTEX , 0 , ( n_buckets ) , ( hash_fn ) , NULL , ( cmp_fn ) )
# ifndef AST_IN_CORE
/* These macros are removed from Asterisk 17. They are still available to modules
* but should only be used by third party modules that have not been updated . */
# define ao2_t_container_alloc_options(options, n_buckets, hash_fn, cmp_fn, tag) \
ao2_t_container_alloc_hash ( ( options ) , 0 , ( n_buckets ) , ( hash_fn ) , NULL , ( cmp_fn ) , ( tag ) )
# define ao2_container_alloc_options(options, n_buckets, hash_fn, cmp_fn) \
ao2_container_alloc_hash ( ( options ) , 0 , ( n_buckets ) , ( hash_fn ) , NULL , ( cmp_fn ) )
# define ao2_container_alloc(n_buckets, hash_fn, cmp_fn) \
ao2_container_alloc_hash ( AO2_ALLOC_OPT_LOCK_MUTEX , 0 , ( n_buckets ) , ( hash_fn ) , NULL , ( cmp_fn ) )
# define ao2_t_container_alloc(n_buckets, hash_fn, cmp_fn, tag) \
ao2_t_container_alloc_hash ( AO2_ALLOC_OPT_LOCK_MUTEX , 0 , ( n_buckets ) , ( hash_fn ) , NULL , ( cmp_fn ) , ( tag ) )
# endif