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-21 08:47:27 -05:00
parent b7af9c8b19
commit bc7f4f4db3
3 changed files with 233 additions and 0 deletions
+22
View File
@@ -1419,6 +1419,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