return CMP_MATCH;
}
-#define USE_CONTAINER(x) (((x) & (OBJ_MULTIPLE | OBJ_NODATA)) == OBJ_MULTIPLE)
-
/*!
* Browse the container using different stategies accoding the flags.
* \return Is a pointer to an object or to a list of object if OBJ_MULTIPLE is
if (INTERNAL_OBJ(c) == NULL) /* safety check on the argument */
return NULL;
- if (USE_CONTAINER(flags)) {
+ /*
+ * This logic is used so we can support OBJ_MULTIPLE with OBJ_NODATA
+ * turned off. This if statement checks for the special condition
+ * where multiple items may need to be returned.
+ */
+ if ((flags & (OBJ_MULTIPLE | OBJ_NODATA)) == OBJ_MULTIPLE) {
/* we need to return an ao2_iterator with the results,
* as there could be more than one. the iterator will
* hold the only reference to a container that has all the
}
}
- /* if we are in OBJ_MULTIPLE mode, link the object into the
- * container that will hold the results
+ /* If we are in OBJ_MULTIPLE mode and OBJ_NODATE is off,
+ * link the object into the container that will hold the results.
*/
- if (ret && USE_CONTAINER(flags)) {
+ if (ret && (multi_container != NULL)) {
__ao2_link(multi_container, ret);
ret = NULL;
}
ast_free(cur); /* free the link record */
}
- if ((match & CMP_STOP) || USE_CONTAINER(flags)) {
+ if ((match & CMP_STOP) || !(flags & OBJ_MULTIPLE)) {
/* We found our only (or last) match, so force an exit from
the outside loop. */
i = last;
}
}
ao2_unlock(c);
- if (USE_CONTAINER(flags)) {
+
+ /* if multi_container was created, we are returning multiple objects */
+ if (multi_container != NULL) {
*multi_iterator = ao2_iterator_init(multi_container,
AO2_ITERATOR_DONTLOCK | AO2_ITERATOR_UNLINK | AO2_ITERATOR_MALLOCD);
ao2_ref(multi_container, -1);