void *fr_cursor_replace(fr_cursor_t *cursor, void *r) CC_HINT(nonnull);
-void fr_cursor_list_free(fr_cursor_t *cursor) CC_HINT(nonnull);
+void fr_cursor_free_list(fr_cursor_t *cursor) CC_HINT(nonnull);
/** Initialise a cursor with runtime talloc type safety checks and a custom iterator
*
void *_fr_cursor_init(fr_cursor_t *cursor, void * const *head, size_t offset,
fr_cursor_iter_t iter, void const *ctx, char const *type);
-/** talloc_free the current item, and all subsequent items
+/** talloc_free the current item
*
* @param[in] cursor to free items from.
*/
-static inline void fr_cursor_free(fr_cursor_t *cursor)
+static inline void fr_cursor_free_item(fr_cursor_t *cursor)
{
- void *v;
if (!cursor) return;
- while ((v = fr_cursor_remove(cursor))) talloc_free(v);
+
+ talloc_free(fr_cursor_remove(cursor));
}
#endif
*
* @param[in] cursor to free items in.
*/
-void fr_cursor_list_free(fr_cursor_t *cursor)
+void fr_cursor_free_list(fr_cursor_t *cursor)
{
void *v;
- if (!*cursor->head) return; /* noop */
+ if (!*(cursor->head)) return; /* noop */
do {
v = fr_cursor_remove(cursor);
fr_cursor_append(&cursor, item3);
fr_cursor_next(&cursor);
- fr_cursor_list_free(&cursor);
+ fr_cursor_free_list(&cursor);
TEST_CHECK(fr_cursor_current(&cursor) == NULL);
TEST_CHECK(!fr_cursor_list_prev_peek(&cursor));
if (!n_vb) {
xlat_error:
fr_cursor_head(&from);
- fr_cursor_free(&from);
+ fr_cursor_free_list(&from);
fr_cursor_head(&values);
- fr_cursor_free(&values);
+ fr_cursor_free_list(&values);
goto error;
}
if (!n_vb) {
attr_error:
fr_cursor_head(&values);
- fr_cursor_free(&values);
+ fr_cursor_free_list(&values);
goto error;
}
if (!n_vb) {
data_error:
fr_cursor_head(&values);
- fr_cursor_free(&values);
+ fr_cursor_free_list(&values);
goto error;
}
/*
vp = map_list_mod_to_vp(ctx, mod->lhs, vb);
if (!vp) {
fr_cursor_head(&cursor);
- fr_cursor_free(&cursor);
+ fr_cursor_free_list(&cursor);
return NULL;
}
fr_cursor_insert(&cursor, vp);
node->fmt);
if (xlat_eval_one_letter(ctx, out, request, node->fmt[0]) == XLAT_ACTION_FAIL) {
fail:
- fr_cursor_free(out); /* Only frees what we've added during this call */
+ fr_cursor_free_list(out); /* Only frees what we've added during this call */
xa = XLAT_ACTION_FAIL;
goto finish;
}
*/
if (fr_value_box_cast(ctx, &string, FR_TYPE_STRING, NULL, head) < 0) {
RPERROR("Casting one letter expansion to string failed");
- fr_cursor_free(&cursor);
+ fr_cursor_free_list(&cursor);
return NULL;
}
memcpy(&str, &string.vb_strvalue, sizeof(str));
- fr_cursor_free(&cursor);
+ fr_cursor_free_list(&cursor);
break;
case XLAT_ATTRIBUTE:
if (!str) {
attr_error:
RPERROR("Printing box to string failed");
- fr_cursor_free(&cursor);
+ fr_cursor_free_list(&cursor);
return NULL;
}
str = talloc_strdup_append_buffer(str, more);
talloc_free(more);
}
- fr_cursor_free(&cursor);
+ fr_cursor_free_list(&cursor);
break;
case XLAT_VIRTUAL:
if ((end - p) < 8) {
fr_strerror_printf("Malformed diameter VPs. Needed at least 8 bytes, got %zu bytes", end - p);
error:
- fr_cursor_list_free(cursor);
+ fr_cursor_free_list(cursor);
return -1;
}