From: erickson Date: Tue, 31 Jan 2006 21:10:56 +0000 (+0000) Subject: added a default freeItem function for freeing list items X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=301d64618dfc1eb31247450888cc2f02a7ecba89;p=working%2FOpenSRF.git added a default freeItem function for freeing list items git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@635 9efc2488-bf62-4759-914b-345cdb29e865 --- diff --git a/src/libstack/osrf_list.c b/src/libstack/osrf_list.c index 7277720..cc591db 100644 --- a/src/libstack/osrf_list.c +++ b/src/libstack/osrf_list.c @@ -168,3 +168,11 @@ void osrfListIteratorReset( osrfListIterator* itr ) { } +void osrfListVanillaFree( void* item ) { + free(item); +} + +void osrfListSetDefaultFree( osrfList* list ) { + if(!list) return; + list->freeItem = osrfListVanillaFree; +} diff --git a/src/libstack/osrf_list.h b/src/libstack/osrf_list.h index cea3a94..dc1dc15 100644 --- a/src/libstack/osrf_list.h +++ b/src/libstack/osrf_list.h @@ -126,5 +126,17 @@ void __osrfListSetSize( osrfList* list ); */ unsigned long osrfListGetCount( osrfList* list ); +/** + * May be used as a default memory freeing call + * Just calls free() on list items + */ +void osrfListVanillaFree( void* item ); + +/** + * Tells the list to just call 'free()' on each item when + * an item or the whole list is destroyed + */ +void osrfListSetDefaultFree( osrfList* list ); + #endif