ucx/map.h

changeset 124
80609f9675f1
parent 0
1f419bd32da1
child 152
62921b370c60
--- a/ucx/map.h	Tue Feb 16 17:39:33 2016 +0100
+++ b/ucx/map.h	Mon May 23 12:28:32 2016 +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.
  * 
- * <b>Note:</b> the contents are <b>not</b> freed, use an UcxMempool for that
- * purpose.
+ * <b>Note:</b> the contents are <b>not</b> 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.
+ * 
+ * <b>Note:</b> the contents are <b>not</b> 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.
  * 
  * <b>Note:</b> The destination map does not need to be empty. However, if it

mercurial