diff -r 59656cd16411 -r b9a6af0ae41a src/ucx/map.h --- a/src/ucx/map.h Mon Apr 06 16:36:25 2015 +0200 +++ b/src/ucx/map.h Fri Oct 16 19:23:49 2015 +0200 @@ -1,7 +1,7 @@ /* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * - * Copyright 2013 Olaf Wintermann. All rights reserved. + * Copyright 2015 Olaf Wintermann. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -146,14 +146,45 @@ /** * Frees a hash map. * - * Note: the contents are not freed, use an UcxMempool for that - * purpose. + * Note: the contents are not freed, use ucx_map_free_content() + * before calling this function to achieve that. * * @param map the map to be freed + * @see ucx_map_free_content() */ void ucx_map_free(UcxMap *map); /** + * Frees the contents of a hash map. + * + * This is a convenience function that iterates over the map and passes all + * 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 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, ucx_destructor destr); + +/** + * Clears a hash map. + * + * Note: the contents are not freed, use ucx_map_free_content() + * before calling this function to achieve that. + * + * @param map the map to be cleared + * @see ucx_map_free_content() + */ +void ucx_map_clear(UcxMap *map); + + +/** * Copies contents from a map to another map using a copy function. * * Note: The destination map does not need to be empty. However, if it