*/
void tmpl_cursor_clear(tmpl_cursor_ctx_t *cc)
{
- TALLOC_FREE(cc->pool); /* just in case we somehow leaked memory */
-
if (!fr_dlist_num_elements(&cc->nested)) return;/* Help simplify dealing with unused cursor ctxs */
fr_dlist_remove(&cc->nested, &cc->leaf); /* Noop if leaf isn't inserted */
fr_dlist_talloc_free(&cc->nested);
+
+ TALLOC_FREE(cc->pool);
}
/** Copy pairs matching a #tmpl_t in the current #request_t
*/
static inline CC_HINT(nonnull(1)) void *fr_dlist_pop_head(fr_dlist_head_t *list_head)
{
- return fr_dlist_remove(list_head, fr_dlist_head(list_head));
+ void *item = fr_dlist_head(list_head);
+
+ (void)fr_dlist_remove(list_head, item);
+
+ return item; /* fr_dlist_remove returns the previous item */
}
/** Remove the tail item in a list
*/
static inline CC_HINT(nonnull(1)) void *fr_dlist_pop_tail(fr_dlist_head_t *list_head)
{
- return fr_dlist_remove(list_head, fr_dlist_tail(list_head));
+ void *item = fr_dlist_tail(list_head);
+
+ (void)fr_dlist_remove(list_head, item);
+
+ return item; /* fr_dlist_remove returns the previous item */
}
/** Check all items in the list are valid