Commit 34c80337 34c80337c72928c94ece819fbff8ba42f8580dd3 by Alain Magloire

* mailbox/list.c (list_destroy) : Call to list->destroy_item() when

        the data is free().
        (list_set_destroy_item): New function.
1 parent 787d810d
...@@ -62,6 +62,8 @@ list_destroy (list_t *plist) ...@@ -62,6 +62,8 @@ list_destroy (list_t *plist)
62 { 62 {
63 previous = current; 63 previous = current;
64 current = current->next; 64 current = current->next;
65 if (list->destroy_item)
66 list->destroy_item (previous->item);
65 free (previous); 67 free (previous);
66 } 68 }
67 monitor_unlock (list->monitor); 69 monitor_unlock (list->monitor);
...@@ -293,3 +295,11 @@ list_do (list_t list, list_action_t * action, void *cbdata) ...@@ -293,3 +295,11 @@ list_do (list_t list, list_action_t * action, void *cbdata)
293 monitor_unlock (list->monitor); 295 monitor_unlock (list->monitor);
294 return status; 296 return status;
295 } 297 }
298
299 int
300 list_set_destroy_item (list_t list, void (*destroy_item)(void *item))
301 {
302 if (list == NULL)
303 return EINVAL;
304 list->destroy_item = destroy_item;
305 }
......