# HG changeset patch # User Mike Becker # Date 1444913965 -7200 # Node ID 4f02199d8aae84680076f88ac10c7d8adcfdf923 # Parent 262c7be94eba10b34e92b07e8ea2c1b32933300e moved ucx_destructor type to ucx.h and added destructor argument to ucx_map_free_content diff -r 262c7be94eba -r 4f02199d8aae ucx/map.c --- a/ucx/map.c Thu Oct 15 14:21:38 2015 +0200 +++ b/ucx/map.c Thu Oct 15 14:59:25 2015 +0200 @@ -82,11 +82,11 @@ alfree(map->allocator, map); } -void ucx_map_free_content(UcxMap *map) { +void ucx_map_free_content(UcxMap *map, ucx_destructor destr) { UcxMapIterator iter = ucx_map_iterator(map); void *val; UCX_MAP_FOREACH(key, val, iter) { - free(val); + destr(val); } } diff -r 262c7be94eba -r 4f02199d8aae ucx/map.h --- a/ucx/map.h Thu Oct 15 14:21:38 2015 +0200 +++ b/ucx/map.h Thu Oct 15 14:59:25 2015 +0200 @@ -158,17 +158,19 @@ * Frees the contents of a hash map. * * This is a convenience function that iterates over the map and passes all - * values to the standard library free() function. + * values to the specified destructor function (e.g. stdlib free()). * - * You must ensure, that it is valid to pass each value in the map to free(). + * You must ensure, that it is valid to pass each value in the map to the same + * destructor function. * * You should free or clear the map afterwards, as the contents will be invalid. * * @param map for which the contents shall be freed + * @param destr pointer to the destructor function * @see ucx_map_free() * @see ucx_map_clear() */ -void ucx_map_free_content(UcxMap *map); +void ucx_map_free_content(UcxMap *map, ucx_destructor destr); /** * Clears a hash map. diff -r 262c7be94eba -r 4f02199d8aae ucx/mempool.h --- a/ucx/mempool.h Thu Oct 15 14:21:38 2015 +0200 +++ b/ucx/mempool.h Thu Oct 15 14:59:25 2015 +0200 @@ -47,13 +47,6 @@ #endif /** - * A function pointer to a destructor function. - * @see ucx_mempool_setdestr() - * @see ucx_mempool_regdestr() - */ -typedef void(*ucx_destructor)(void*); - -/** * UCX mempool structure. */ typedef struct { diff -r 262c7be94eba -r 4f02199d8aae ucx/ucx.h --- a/ucx/ucx.h Thu Oct 15 14:21:38 2015 +0200 +++ b/ucx/ucx.h Thu Oct 15 14:59:25 2015 +0200 @@ -70,6 +70,14 @@ /** Pointless in C. */ #define UCX_EXTERN #endif + + +/** + * A function pointer to a destructor function. + * @see ucx_mempool_setdestr() + * @see ucx_mempool_regdestr() + */ +typedef void(*ucx_destructor)(void*); /** * Function pointer to a compare function.