Added cfulist_set_free_fn()
In analogy with cfuhash_set_free_fn()
This commit is contained in:
parent
1294791f0c
commit
4f4439828f
@ -490,7 +490,12 @@ cfulist_map(). The return value is used to build a new list.
|
|||||||
|
|
||||||
@deftypefun {cfulist_t *} cfulist_new ();
|
@deftypefun {cfulist_t *} cfulist_new ();
|
||||||
|
|
||||||
Returns a new list.
|
Creates a new list.
|
||||||
|
@end deftypefun
|
||||||
|
|
||||||
|
@deftypefun {cfulist_t *} cfulist_new_with_free_fn (cfulist_free_fn_t @var{ff})
|
||||||
|
|
||||||
|
Same as cfulist_new() except automatically calls cfulist_set_free_fn().
|
||||||
@end deftypefun
|
@end deftypefun
|
||||||
|
|
||||||
@deftypefun {size_t} cfulist_num_entries (cfulist_t *@var{list})
|
@deftypefun {size_t} cfulist_num_entries (cfulist_t *@var{list})
|
||||||
|
@ -84,10 +84,16 @@ cfulist_new(void) {
|
|||||||
cfulist_t *
|
cfulist_t *
|
||||||
cfulist_new_with_free_fn(cfulist_free_fn_t free_fn) {
|
cfulist_new_with_free_fn(cfulist_free_fn_t free_fn) {
|
||||||
cfulist_t *list = cfulist_new();
|
cfulist_t *list = cfulist_new();
|
||||||
list->free_fn = free_fn;
|
cfulist_set_free_function (list, free_fn);
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
cfulist_set_free_function(cfulist_t *list, cfulist_free_fn_t ff) {
|
||||||
|
if (ff) list->free_fn = ff;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
size_t
|
size_t
|
||||||
cfulist_num_entries(cfulist_t *list) {
|
cfulist_num_entries(cfulist_t *list) {
|
||||||
return list->num_entries;
|
return list->num_entries;
|
||||||
|
@ -65,9 +65,7 @@ typedef void (*cfulist_free_fn_t)(void *data);
|
|||||||
/* Returns a new list. */
|
/* Returns a new list. */
|
||||||
cfulist_t * cfulist_new(void);
|
cfulist_t * cfulist_new(void);
|
||||||
|
|
||||||
/* Same as cfulist_new(), but set a function to be called on each
|
/* Same as cfulist_new() except automatically calls cfulist_set_free_fn(). */
|
||||||
* element when the list is destroyed.
|
|
||||||
*/
|
|
||||||
cfulist_t * cfulist_new_with_free_fn(cfulist_free_fn_t free_fn);
|
cfulist_t * cfulist_new_with_free_fn(cfulist_free_fn_t free_fn);
|
||||||
|
|
||||||
/* Returns the number of entries in the list. */
|
/* Returns the number of entries in the list. */
|
||||||
|
Reference in New Issue
Block a user