Skip to content

Commit

Permalink
Add list 'o boxes free function
Browse files Browse the repository at this point in the history
  • Loading branch information
arr2036 committed Jan 25, 2018
1 parent ff08ae6 commit 4a279b5
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/include/value.h
Expand Up @@ -494,14 +494,19 @@ int fr_value_box_from_str(TALLOC_CTX *ctx, fr_value_box_t *dst,
char const *src, ssize_t src_len, char quote, bool tainted);

/*
* Printing
* Lists
*/
char *fr_value_box_asprint(TALLOC_CTX *ctx, fr_value_box_t const *data, char quote);

int fr_value_box_list_concat(TALLOC_CTX *ctx,
fr_value_box_t *out, fr_value_box_t *list,
fr_type_t type, bool free_input);

void fr_value_box_list_free(fr_value_box_t **head);

/*
* Printing
*/
char *fr_value_box_asprint(TALLOC_CTX *ctx, fr_value_box_t const *data, char quote);

size_t fr_value_box_snprint(char *out, size_t outlen, fr_value_box_t const *data, char quote);

char *fr_value_box_list_asprint(TALLOC_CTX *ctx, fr_value_box_t const *head, char const *delim, char quote);
Expand Down
16 changes: 16 additions & 0 deletions src/lib/util/value.c
Expand Up @@ -3765,6 +3765,22 @@ int fr_value_box_list_concat(TALLOC_CTX *ctx,
return 0;
}

/** Free all boxes in a list
*
* @param[in] head of the list to free.
*/
void fr_value_box_list_free(fr_value_box_t **head)
{
fr_value_box_t *v = *head, *next;

while (v) {
next = v->next;
talloc_free(v);
v = next;
}
*head = NULL;
}

/** Print the value of an attribute to a string
*
* @note return value should be checked with is_truncated.
Expand Down

0 comments on commit 4a279b5

Please sign in to comment.