[Freeciv-Dev] (PR#39508) [Patch] Fix hash callback function registration.

2007-08-07 Thread Marko Lindqvist

URL: http://bugs.freeciv.org/Ticket/Display.html?id=39508 

 hash_new_full() forgot to pass callback functions it gets as
parameters to lower levels for registration. Fix attached. Includes
also some documentation about these callbacks.


 - ML



___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


Re: [Freeciv-Dev] (PR#39508) [Patch] Fix hash callback function registration.

2007-08-07 Thread Marko Lindqvist

URL: http://bugs.freeciv.org/Ticket/Display.html?id=39508 

 Fix attached. Includes

 Here


 - ML

diff -Nurd -X.diff_ignore freeciv/utility/hash.c freeciv/utility/hash.c
--- freeciv/utility/hash.c	2007-08-04 18:36:14.0 +0300
+++ freeciv/utility/hash.c	2007-08-08 02:12:40.0 +0300
@@ -40,6 +40,15 @@
qsort-type comparison function (but the hash table does not make
use of the ordering information if the return value is non-zero).
 
+   Some constructors also accept following functions to be registered:
+
+ free_key_func: This is called when hash no longer needs key construct.
+   Note that one key construct gets freed even when it is replaced with
+   another that is considered identical by fcmp().
+
+ free_data_func: This is called when hash no longer needs data construct. 
+
+
Implementation uses closed hashing with simple collision resolution.
Deleted elements are marked as DELETED rather than UNUSED so that
lookups on previously added entries work properly.
@@ -344,7 +353,7 @@
 			 hash_free_fn_t free_key_func,
 			 hash_free_fn_t free_data_func)
 {
-  return hash_new_nentries_full(fval, fcmp, NULL, NULL, 0);
+  return hash_new_nentries_full(fval, fcmp, free_key_func, free_data_func, 0);
 }
 
 /**
___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev