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 ();
|
||||
|
||||
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
|
||||
|
||||
@deftypefun {size_t} cfulist_num_entries (cfulist_t *@var{list})
|
||||
|
@ -84,10 +84,16 @@ cfulist_new(void) {
|
||||
cfulist_t *
|
||||
cfulist_new_with_free_fn(cfulist_free_fn_t free_fn) {
|
||||
cfulist_t *list = cfulist_new();
|
||||
list->free_fn = free_fn;
|
||||
cfulist_set_free_function (list, free_fn);
|
||||
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
|
||||
cfulist_num_entries(cfulist_t *list) {
|
||||
return list->num_entries;
|
||||
|
@ -65,9 +65,7 @@ typedef void (*cfulist_free_fn_t)(void *data);
|
||||
/* Returns a new list. */
|
||||
cfulist_t * cfulist_new(void);
|
||||
|
||||
/* Same as cfulist_new(), but set a function to be called on each
|
||||
* element when the list is destroyed.
|
||||
*/
|
||||
/* Same as cfulist_new() except automatically calls cfulist_set_free_fn(). */
|
||||
cfulist_t * cfulist_new_with_free_fn(cfulist_free_fn_t free_fn);
|
||||
|
||||
/* Returns the number of entries in the list. */
|
||||
|
Reference in New Issue
Block a user