astobj2: Eliminate usage of legacy ao2_container_alloc routine.

Replace usage of ao2_container_alloc with ao2_container_alloc_hash or
ao2_container_alloc_list.

ao2_container_alloc is now restricted to modules only and is being
removed from Asterisk 17.

Change-Id: I0907d78bc66efc775672df37c8faad00f2f6c088
This commit is contained in:
Corey Farrell
2018-11-19 15:10:15 -05:00
parent 0e096aefac
commit ed7a5664b6
67 changed files with 321 additions and 219 deletions

View File

@@ -93,7 +93,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
@@ -109,7 +110,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() --
@@ -936,20 +937,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
@@ -1297,6 +1286,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.
@@ -1316,17 +1309,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