astobj2: Create function to copy weak proxied objects from container.

Create ao2_container_dup_weakproxy_objs to perform a similar function to
ao2_container_dup.  This function expects the source container to have
weakproxy objects, inserts the associated non-weak objects into the
destination container.  Orphaned weakproxy objects are ignored.

Create test for this new function and for ao2_weakproxy_find.

Change-Id: I898387f058057e08696fe9070f8cd94ef3a27482
This commit is contained in:
Corey Farrell
2018-11-14 06:02:20 -05:00
parent 0e096aefac
commit 0d2b39065f
3 changed files with 233 additions and 0 deletions

View File

@@ -1433,6 +1433,28 @@ int ao2_container_count(struct ao2_container *c);
*/
int ao2_container_dup(struct ao2_container *dest, struct ao2_container *src, enum search_flags flags);
/*!
* \brief Copy object references associated with src container weakproxies into the dest container.
*
* \param dest Container to copy src strong object references into.
* \param src Container to copy all weak object references from.
* \param flags OBJ_NOLOCK if a lock is already held on both containers.
* Otherwise, the src container is locked first.
*
* \pre The dest container must be empty. If the duplication fails, the
* dest container will be returned empty.
*
* \note This can potentially be expensive because a malloc is
* needed for every object in the src container.
*
* \note Every object inside the container is locked by \ref ao2_weakproxy_get_object.
* Any weakproxy in \ref src with no associated object is ignored.
*
* \retval 0 on success.
* \retval -1 on error.
*/
int ao2_container_dup_weakproxy_objs(struct ao2_container *dest, struct ao2_container *src, enum search_flags flags);
/*!
* \brief Create a clone/copy of the given container.
* \since 11.0