c++ - GLib HashTable passing the functions as the parameters -


i learning glib ghashtable source code. can see source code link here.

https://github.com/gnome/glib/blob/master/glib/ghash.c

https://github.com/gnome/glib/blob/master/glib/ghash.h

ghashtable *g_hash_table_new (ghashfunc  hash_func,                                 gequalfunc key_equal_func) 

g_hash_table_new function create basic hash table here. question parameters. first 2 parameters "ghashfunc hash_func, gequalfunc key_equal_func" passing function.

in ghash.h, there no hash_func , key_equal_func, symbols. replaced real hash functions. how 2 functions become parameters here?

i know there hash functions in ghash.h files, like:

guint g_int_hash (gconstpointer v)  guint g_str_hash (gconstpointer v) 

those functions passing "g_hash_table_new " during running time replace "hash_func" , "key_equal_func ". not know kind of technique that? how passing function parameter function , replace during running time.

thanks

you pass param point, define hash compute function. function process callback function. hash table pass param equel function.


Comments