From ec42bde527375660ccc182f141bfb420282c3ed8 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Wed, 18 Jul 2012 22:34:37 +0900 Subject: [PATCH] Make hash tables more const correct. And clean up the resulting mess :/ --- include/QF/hash.h | 8 ++++---- libs/audio/renderer/snd_sfx.c | 2 +- libs/console/menu.c | 2 +- libs/gamecode/pr_builtins.c | 6 +++--- libs/gamecode/pr_debug.c | 2 +- libs/gamecode/pr_load.c | 4 ++-- libs/gamecode/pr_opcode.c | 4 ++-- libs/gamecode/pr_resource.c | 2 +- libs/gamecode/pr_strings.c | 2 +- libs/gib/bi_gib.c | 2 +- libs/gib/gib_builtin.c | 2 +- libs/gib/gib_classes.c | 2 +- libs/gib/gib_function.c | 2 +- libs/gib/gib_object.c | 6 +++--- libs/gib/gib_regex.c | 2 +- libs/gib/gib_thread.c | 2 +- libs/gib/gib_vars.c | 4 ++-- libs/models/iqm/model_iqm.c | 4 ++-- libs/models/skin.c | 2 +- libs/ruamoko/rua_cmd.c | 2 +- libs/ruamoko/rua_hash.c | 12 ++++++------ libs/ruamoko/rua_obj.c | 8 ++++---- libs/ruamoko/rua_plist.c | 4 ++-- libs/util/cmd.c | 6 +++--- libs/util/cvar.c | 4 ++-- libs/util/hash.c | 18 +++++++++--------- libs/util/info.c | 2 +- libs/util/pakfile.c | 2 +- libs/util/plugin.c | 4 ++-- libs/util/qfplist.c | 2 +- libs/util/quakefs.c | 4 ++-- libs/util/wadfile.c | 4 ++-- libs/video/renderer/glsl/glsl_draw.c | 2 +- libs/video/renderer/r_progs.c | 2 +- libs/video/targets/old_keys.c | 2 +- qtv/source/client.c | 2 +- qtv/source/connection.c | 4 ++-- qtv/source/server.c | 2 +- qw/source/sv_user.c | 6 +++--- tools/qfbsp/source/map.c | 2 +- tools/qfcc/source/class.c | 8 ++++---- tools/qfcc/source/function.c | 4 ++-- tools/qfcc/source/grab.c | 2 +- tools/qfcc/source/linker.c | 2 +- tools/qfcc/source/method.c | 10 +++++----- tools/qfcc/source/opcodes.c | 6 +++--- tools/qfcc/source/qc-lex.l | 2 +- tools/qfcc/source/qfprogs.c | 4 ++-- tools/qfcc/source/qp-lex.l | 2 +- tools/qfcc/source/strpool.c | 4 ++-- tools/qfcc/source/switch.c | 4 ++-- tools/qfcc/source/symtab.c | 2 +- tools/qfcc/source/value.c | 4 ++-- 53 files changed, 104 insertions(+), 104 deletions(-) diff --git a/include/QF/hash.h b/include/QF/hash.h index 9a540932a..5cff9d115 100644 --- a/include/QF/hash.h +++ b/include/QF/hash.h @@ -58,7 +58,7 @@ typedef struct hashtab_s hashtab_t; multiple inserions of the same key are fine; later insertions override previous ones until the later one is removed (Hash_Del). */ -hashtab_t *Hash_NewTable (int tsize, const char *(*gk)(void*,void*), +hashtab_t *Hash_NewTable (int tsize, const char *(*gk)(const void*,void*), void (*f)(void*,void*), void *ud); /** change the hash and compare functions used by the Hash_*Element functions. @@ -74,8 +74,8 @@ hashtab_t *Hash_NewTable (int tsize, const char *(*gk)(void*,void*), \param gh takes the same parameters as gk in Hash_NewTable \param cmp is element 1, element 2, userdata */ -void Hash_SetHashCompare (hashtab_t *tab, uintptr_t (*gh)(void*,void*), - int (*cmp)(void*,void*,void*)); +void Hash_SetHashCompare (hashtab_t *tab, uintptr_t (*gh)(const void*,void*), + int (*cmp)(const void*,const void*,void*)); /** delete a hash table. @@ -114,7 +114,7 @@ void *Hash_Find (hashtab_t *tab, const char *key); \param ele element with info identifying the element being searched for \return pointer to the element if found, otherwise 0. */ -void *Hash_FindElement (hashtab_t *tab, void *ele); +void *Hash_FindElement (hashtab_t *tab, const void *ele); /** find a list of elements within a hash table. \param tab the table to search diff --git a/libs/audio/renderer/snd_sfx.c b/libs/audio/renderer/snd_sfx.c index 35d9e7998..25d023de8 100644 --- a/libs/audio/renderer/snd_sfx.c +++ b/libs/audio/renderer/snd_sfx.c @@ -56,7 +56,7 @@ static hashtab_t *snd_sfx_hash; static cvar_t *precache; static const char * -snd_sfx_getkey (void *sfx, void *unused) +snd_sfx_getkey (const void *sfx, void *unused) { return ((sfx_t *) sfx)->name; } diff --git a/libs/console/menu.c b/libs/console/menu.c index a8f3dc044..26572376d 100644 --- a/libs/console/menu.c +++ b/libs/console/menu.c @@ -139,7 +139,7 @@ error: } static const char * -menu_get_key (void *m, void *unused) +menu_get_key (const void *m, void *unused) { return ((menu_item_t *) m)->text; } diff --git a/libs/gamecode/pr_builtins.c b/libs/gamecode/pr_builtins.c index 26cbf4e4b..a3ab8c9d9 100644 --- a/libs/gamecode/pr_builtins.c +++ b/libs/gamecode/pr_builtins.c @@ -52,7 +52,7 @@ #include "compat.h" static const char * -builtin_get_key (void *_bi, void *unused) +builtin_get_key (const void *_bi, void *unused) { builtin_t *bi = (builtin_t *)_bi; @@ -60,7 +60,7 @@ builtin_get_key (void *_bi, void *unused) } static uintptr_t -builtin_get_hash (void *_bi, void *unused) +builtin_get_hash (const void *_bi, void *unused) { builtin_t *bi = (builtin_t *)_bi; @@ -68,7 +68,7 @@ builtin_get_hash (void *_bi, void *unused) } static int -builtin_compare (void *_bia, void *_bib, void *unused) +builtin_compare (const void *_bia, const void *_bib, void *unused) { builtin_t *bia = (builtin_t *)_bia; builtin_t *bib = (builtin_t *)_bib; diff --git a/libs/gamecode/pr_debug.c b/libs/gamecode/pr_debug.c index eb51ab081..4ac781746 100644 --- a/libs/gamecode/pr_debug.c +++ b/libs/gamecode/pr_debug.c @@ -77,7 +77,7 @@ static char **source_paths; static const char * -file_get_key (void *_f, void *unused) +file_get_key (const void *_f, void *unused) { return ((file_t*)_f)->name; } diff --git a/libs/gamecode/pr_load.c b/libs/gamecode/pr_load.c index cb8f89032..b32cf71c3 100644 --- a/libs/gamecode/pr_load.c +++ b/libs/gamecode/pr_load.c @@ -59,7 +59,7 @@ cvar_t *pr_deadbeef_locals; cvar_t *pr_faultchecks; static const char * -function_get_key (void *f, void *_pr) +function_get_key (const void *f, void *_pr) { progs_t *pr = (progs_t*)_pr; dfunction_t *func = (dfunction_t*)f; @@ -67,7 +67,7 @@ function_get_key (void *f, void *_pr) } static const char * -var_get_key (void *d, void *_pr) +var_get_key (const void *d, void *_pr) { progs_t *pr = (progs_t*)_pr; ddef_t *def = (ddef_t*)d; diff --git a/libs/gamecode/pr_opcode.c b/libs/gamecode/pr_opcode.c index ea1b3eb1d..fa9a31035 100644 --- a/libs/gamecode/pr_opcode.c +++ b/libs/gamecode/pr_opcode.c @@ -1046,13 +1046,13 @@ VISIBLE opcode_t pr_opcodes[] = { static uintptr_t -opcode_get_hash (void *op, void *unused) +opcode_get_hash (const void *op, void *unused) { return ((opcode_t *)op)->opcode; } static int -opcode_compare (void *_opa, void *_opb, void *unused) +opcode_compare (const void *_opa, const void *_opb, void *unused) { opcode_t *opa = (opcode_t *)_opa; opcode_t *opb = (opcode_t *)_opb; diff --git a/libs/gamecode/pr_resource.c b/libs/gamecode/pr_resource.c index 8ae962a77..14cd4a38b 100644 --- a/libs/gamecode/pr_resource.c +++ b/libs/gamecode/pr_resource.c @@ -45,7 +45,7 @@ struct pr_resource_s { }; static const char * -resource_get_key (void *r, void *unused) +resource_get_key (const void *r, void *unused) { return ((pr_resource_t *)r)->name; } diff --git a/libs/gamecode/pr_strings.c b/libs/gamecode/pr_strings.c index 8b2260705..f6983469a 100644 --- a/libs/gamecode/pr_strings.c +++ b/libs/gamecode/pr_strings.c @@ -161,7 +161,7 @@ string_index (progs_t *pr, strref_t *sr) } static const char * -strref_get_key (void *_sr, void *notused) +strref_get_key (const void *_sr, void *notused) { strref_t *sr = (strref_t*)_sr; diff --git a/libs/gib/bi_gib.c b/libs/gib/bi_gib.c index 5edf6b8ed..b1482c030 100644 --- a/libs/gib/bi_gib.c +++ b/libs/gib/bi_gib.c @@ -59,7 +59,7 @@ typedef struct bi_gib_resources_s { static hashtab_t *bi_gib_builtins; static const char * -bi_gib_builtin_get_key (void *c, void *unused) +bi_gib_builtin_get_key (const void *c, void *unused) { return ((bi_gib_builtin_t *)c)->builtin->name; } diff --git a/libs/gib/gib_builtin.c b/libs/gib/gib_builtin.c index c545c4ee8..308e77285 100644 --- a/libs/gib/gib_builtin.c +++ b/libs/gib/gib_builtin.c @@ -72,7 +72,7 @@ hashtab_t *gib_builtins; Hashtable callbacks */ static const char * -GIB_Builtin_Get_Key (void *ele, void *ptr) +GIB_Builtin_Get_Key (const void *ele, void *ptr) { return ((gib_builtin_t *) ele)->name; } diff --git a/libs/gib/gib_classes.c b/libs/gib/gib_classes.c index 2d8bee1ff..749e7ff07 100644 --- a/libs/gib/gib_classes.c +++ b/libs/gib/gib_classes.c @@ -369,7 +369,7 @@ typedef struct ObjectHash_s { } ObjectHash_t; static const char * -ObjRef_Get_Key (void *ele, void *ptr) +ObjRef_Get_Key (const void *ele, void *ptr) { return ((ObjRef_t *) ele)->key; } diff --git a/libs/gib/gib_function.c b/libs/gib/gib_function.c index 4b94c36be..72c1d1ea5 100644 --- a/libs/gib/gib_function.c +++ b/libs/gib/gib_function.c @@ -53,7 +53,7 @@ hashtab_t *gib_functions = 0; Hashtable callbacks */ static const char * -GIB_Function_Get_Key (void *ele, void *ptr) +GIB_Function_Get_Key (const void *ele, void *ptr) { return ((gib_function_t *) ele)->name; } diff --git a/libs/gib/gib_object.c b/libs/gib/gib_object.c index 4a5552aeb..a4954762b 100644 --- a/libs/gib/gib_object.c +++ b/libs/gib/gib_object.c @@ -53,7 +53,7 @@ hashtab_t *gib_classes; Hashtable callbacks */ static const char * -GIB_Class_Get_Key (void *ele, void *ptr) +GIB_Class_Get_Key (const void *ele, void *ptr) { return ((gib_class_t *) ele)->name; } @@ -69,7 +69,7 @@ GIB_Class_Free (void *ele, void *ptr) } static const char * -GIB_Method_Get_Key (void *ele, void *ptr) +GIB_Method_Get_Key (const void *ele, void *ptr) { return ((gib_method_t *) ele)->name; } @@ -81,7 +81,7 @@ GIB_Method_Free (void *ele, void *ptr) } static const char * -GIB_Signal_Get_Key (void *ele, void *ptr) +GIB_Signal_Get_Key (const void *ele, void *ptr) { return ((gib_signal_t *) ele)->name; } diff --git a/libs/gib/gib_regex.c b/libs/gib/gib_regex.c index 5517420a8..e808532d6 100644 --- a/libs/gib/gib_regex.c +++ b/libs/gib/gib_regex.c @@ -47,7 +47,7 @@ hashtab_t *gib_regexs; static char errstr[1024]; static const char * -GIB_Regex_Get_Key (void *ele, void *ptr) +GIB_Regex_Get_Key (const void *ele, void *ptr) { return ((gib_regex_t *) ele)->regex; } diff --git a/libs/gib/gib_thread.c b/libs/gib/gib_thread.c index 92fb63fd8..9c317d9fe 100644 --- a/libs/gib/gib_thread.c +++ b/libs/gib/gib_thread.c @@ -105,7 +105,7 @@ GIB_Thread_Init (void) } static const char * -GIB_Event_Get_Key (void *ele, void *ptr) +GIB_Event_Get_Key (const void *ele, void *ptr) { return ((gib_event_t *) ele)->name; } diff --git a/libs/gib/gib_vars.c b/libs/gib/gib_vars.c index a1559a0a0..d8a555673 100644 --- a/libs/gib/gib_vars.c +++ b/libs/gib/gib_vars.c @@ -57,7 +57,7 @@ GIB_Var_New (const char *key) } static const char * -GIB_Var_Get_Key (void *ele, void *ptr) +GIB_Var_Get_Key (const void *ele, void *ptr) { return ((gib_var_t *) ele)->key; } @@ -270,7 +270,7 @@ GIB_Var_Assign (gib_var_t * var, unsigned int index, dstring_t ** values, } static const char * -GIB_Domain_Get_Key (void *ele, void *ptr) +GIB_Domain_Get_Key (const void *ele, void *ptr) { return ((gib_domain_t *) ele)->name; } diff --git a/libs/models/iqm/model_iqm.c b/libs/models/iqm/model_iqm.c index 08e208d3e..cbf56bc4e 100644 --- a/libs/models/iqm/model_iqm.c +++ b/libs/models/iqm/model_iqm.c @@ -558,14 +558,14 @@ swap_bones (byte *bi, byte *bw, int b1, int b2) } static uintptr_t -blend_get_hash (void *e, void *unused) +blend_get_hash (const void *e, void *unused) { iqmblend_t *b = (iqmblend_t *) e; return CRC_Block ((byte *) b, sizeof (iqmblend_t)); } static int -blend_compare (void *e1, void *e2, void *unused) +blend_compare (const void *e1, const void *e2, void *unused) { iqmblend_t *b1 = (iqmblend_t *) e1; iqmblend_t *b2 = (iqmblend_t *) e2; diff --git a/libs/models/skin.c b/libs/models/skin.c index 61869c3e0..a96317d8d 100644 --- a/libs/models/skin.c +++ b/libs/models/skin.c @@ -224,7 +224,7 @@ Skin_SetSkin (skin_t *skin, int cmap, const char *skinname) } static const char * -skin_getkey (void *sb, void *unused) +skin_getkey (const void *sb, void *unused) { return ((skinbank_t *) sb)->name; } diff --git a/libs/ruamoko/rua_cmd.c b/libs/ruamoko/rua_cmd.c index 7225a5890..a18e2805e 100644 --- a/libs/ruamoko/rua_cmd.c +++ b/libs/ruamoko/rua_cmd.c @@ -60,7 +60,7 @@ typedef struct { static hashtab_t *bi_cmds; static const char * -bi_cmd_get_key (void *c, void *unused) +bi_cmd_get_key (const void *c, void *unused) { return ((bi_cmd_t *)c)->name; } diff --git a/libs/ruamoko/rua_hash.c b/libs/ruamoko/rua_hash.c index f4374efb4..cc6d2b8c6 100644 --- a/libs/ruamoko/rua_hash.c +++ b/libs/ruamoko/rua_hash.c @@ -92,7 +92,7 @@ table_index (hash_resources_t *res, bi_hashtab_t *table) } static const char * -bi_get_key (void *key, void *_ht) +bi_get_key (const void *key, void *_ht) { bi_hashtab_t *ht = (bi_hashtab_t *)_ht; PR_RESET_PARAMS (ht->pr); @@ -103,7 +103,7 @@ bi_get_key (void *key, void *_ht) } static uintptr_t -bi_get_hash (void *key, void *_ht) +bi_get_hash (const void *key, void *_ht) { bi_hashtab_t *ht = (bi_hashtab_t *)_ht; PR_RESET_PARAMS (ht->pr); @@ -114,7 +114,7 @@ bi_get_hash (void *key, void *_ht) } static int -bi_compare (void *key1, void *key2, void *_ht) +bi_compare (const void *key1, const void *key2, void *_ht) { bi_hashtab_t *ht = (bi_hashtab_t *)_ht; PR_RESET_PARAMS (ht->pr); @@ -140,7 +140,7 @@ bi_Hash_NewTable (progs_t *pr) { hash_resources_t *res = PR_Resources_Find (pr, "Hash"); int tsize = P_INT (pr, 0); - const char *(*gk)(void*,void*); + const char *(*gk)(const void*,void*); void (*f)(void*,void*); bi_hashtab_t *ht; @@ -177,8 +177,8 @@ static void bi_Hash_SetHashCompare (progs_t *pr) { bi_hashtab_t *ht = get_table (pr, __FUNCTION__, P_INT (pr, 0)); - uintptr_t (*gh)(void*,void*); - int (*cmp)(void*,void*,void*); + uintptr_t (*gh)(const void*,void*); + int (*cmp)(const void*,const void*,void*); ht->gh = P_FUNCTION (pr, 1); ht->cmp = P_FUNCTION (pr, 2); diff --git a/libs/ruamoko/rua_obj.c b/libs/ruamoko/rua_obj.c index 25c84f0bf..1fb6e30bf 100644 --- a/libs/ruamoko/rua_obj.c +++ b/libs/ruamoko/rua_obj.c @@ -288,26 +288,26 @@ obj_postorder_traverse (progs_t *pr, class_tree *tree, int level, } static const char * -selector_get_key (void *s, void *_pr) +selector_get_key (const void *s, void *_pr) { progs_t *pr = (progs_t *) _pr; return PR_GetString (pr, pr->selector_names[(intptr_t) s]); } static const char * -class_get_key (void *c, void *pr) +class_get_key (const void *c, void *pr) { return PR_GetString ((progs_t *)pr, ((pr_class_t *)c)->name); } static uintptr_t -load_methods_get_hash (void *m, void *pr) +load_methods_get_hash (const void *m, void *pr) { return (uintptr_t) m; } static int -load_methods_compare (void *m1, void *m2, void *pr) +load_methods_compare (const void *m1, const void *m2, void *pr) { return m1 == m2; } diff --git a/libs/ruamoko/rua_plist.c b/libs/ruamoko/rua_plist.c index d873de441..40a8b072f 100644 --- a/libs/ruamoko/rua_plist.c +++ b/libs/ruamoko/rua_plist.c @@ -411,14 +411,14 @@ bi_PL_Free (progs_t *pr) } static uintptr_t -plist_get_hash (void *key, void *unused) +plist_get_hash (const void *key, void *unused) { bi_plist_t *plist = (bi_plist_t *) key; return (uintptr_t) plist->plitem; } static int -plist_compare (void *k1, void *k2, void *unused) +plist_compare (const void *k1, const void *k2, void *unused) { bi_plist_t *pl1 = (bi_plist_t *) k1; bi_plist_t *pl2 = (bi_plist_t *) k2; diff --git a/libs/util/cmd.c b/libs/util/cmd.c index 82923dcf6..f4cdc79d0 100644 --- a/libs/util/cmd.c +++ b/libs/util/cmd.c @@ -294,7 +294,7 @@ cmd_alias_free (void *_a, void *unused) } static const char * -cmd_alias_get_key (void *_a, void *unused) +cmd_alias_get_key (const void *_a, void *unused) { cmdalias_t *a = (cmdalias_t *) _a; @@ -302,7 +302,7 @@ cmd_alias_get_key (void *_a, void *unused) } static const char * -cmd_get_key (void *c, void *unused) +cmd_get_key (const void *c, void *unused) { cmd_function_t *cmd = (cmd_function_t *) c; @@ -319,7 +319,7 @@ cmd_provider_free (void *_a, void *unused) } static const char * -cmd_provider_get_key (void *_a, void *unused) +cmd_provider_get_key (const void *_a, void *unused) { cmd_provider_t *p = (cmd_provider_t *) _a; diff --git a/libs/util/cvar.c b/libs/util/cvar.c index ff61e6990..32e3af26a 100644 --- a/libs/util/cvar.c +++ b/libs/util/cvar.c @@ -556,7 +556,7 @@ cvar_free (void *c, void *unused) } static const char * -cvar_get_key (void *c, void *unused) +cvar_get_key (const void *c, void *unused) { cvar_t *cvar = (cvar_t*)c; return cvar->name; @@ -571,7 +571,7 @@ calias_free (void *c, void *unused) } static const char * -calias_get_key (void *c, void *unused) +calias_get_key (const void *c, void *unused) { cvar_alias_t *calias = (cvar_alias_t *) c; return calias->name; diff --git a/libs/util/hash.c b/libs/util/hash.c index 21f647c7f..0f95ef7fa 100644 --- a/libs/util/hash.c +++ b/libs/util/hash.c @@ -56,9 +56,9 @@ struct hashtab_s { unsigned int size_bits; size_t num_ele; void *user_data; - int (*compare)(void*,void*,void*); - uintptr_t (*get_hash)(void*,void*); - const char *(*get_key)(void*,void*); + int (*compare)(const void*,const void*,void*); + uintptr_t (*get_hash)(const void*,void*); + const char *(*get_key)(const void*,void*); void (*free_ele)(void*,void*); hashlink_t *tab[1]; // variable size }; @@ -146,13 +146,13 @@ Hash_Buffer (const void *_buf, int len) } static uintptr_t -get_hash (void *ele, void *data) +get_hash (const void *ele, void *data) { return (uintptr_t)ele; } static int -compare (void *a, void *b, void *data) +compare (const void *a, const void *b, void *data) { return a == b; } @@ -182,7 +182,7 @@ get_index (uintptr_t hash, size_t size, size_t bits) } VISIBLE hashtab_t * -Hash_NewTable (int tsize, const char *(*gk)(void*,void*), +Hash_NewTable (int tsize, const char *(*gk)(const void*,void*), void (*f)(void*,void*), void *ud) { hashtab_t *tab = calloc (1, field_offset (hashtab_t, tab[tsize])); @@ -204,8 +204,8 @@ Hash_NewTable (int tsize, const char *(*gk)(void*,void*), } VISIBLE void -Hash_SetHashCompare (hashtab_t *tab, uintptr_t (*gh)(void*,void*), - int (*cmp)(void*,void*,void*)) +Hash_SetHashCompare (hashtab_t *tab, uintptr_t (*gh)(const void*,void*), + int (*cmp)(const void*,const void*,void*)) { tab->get_hash = gh; tab->compare = cmp; @@ -291,7 +291,7 @@ Hash_Find (hashtab_t *tab, const char *key) } VISIBLE void * -Hash_FindElement (hashtab_t *tab, void *ele) +Hash_FindElement (hashtab_t *tab, const void *ele) { unsigned long h = tab->get_hash (ele, tab->user_data); size_t ind = get_index (h, tab->tab_size, tab->size_bits); diff --git a/libs/util/info.c b/libs/util/info.c index 93862be18..e9e8e9727 100644 --- a/libs/util/info.c +++ b/libs/util/info.c @@ -206,7 +206,7 @@ Info_Print (info_t *info) } static const char * -info_get_key (void *k, void *unused) +info_get_key (const void *k, void *unused) { return ((info_key_t *)k)->key; } diff --git a/libs/util/pakfile.c b/libs/util/pakfile.c index c4cb3435a..5ddbbb9a2 100644 --- a/libs/util/pakfile.c +++ b/libs/util/pakfile.c @@ -49,7 +49,7 @@ #include "QF/sys.h" static const char * -pack_get_key (void *p, void *unused) +pack_get_key (const void *p, void *unused) { return ((dpackfile_t *) p)->name; } diff --git a/libs/util/plugin.c b/libs/util/plugin.c index a2ef09977..31fa725fd 100644 --- a/libs/util/plugin.c +++ b/libs/util/plugin.c @@ -77,13 +77,13 @@ hashtab_t *registered_plugins, *loaded_plugins; static const char *pi_error = ""; static const char * -plugin_get_key (void *pl, void *unused) +plugin_get_key (const void *pl, void *unused) { return ((plugin_list_t *) pl)->name; } static const char * -loaded_plugin_get_key (void *lp, void *unusued) +loaded_plugin_get_key (const void *lp, void *unusued) { return ((loaded_plugin_t *) lp)->name; } diff --git a/libs/util/qfplist.c b/libs/util/qfplist.c index 479bcb675..8723cb2c3 100644 --- a/libs/util/qfplist.c +++ b/libs/util/qfplist.c @@ -119,7 +119,7 @@ static char *PL_ParseUnquotedString (pldata_t *); static char *PL_ParseData (pldata_t *, int *); static const char * -dict_get_key (void *i, void *unused) +dict_get_key (const void *i, void *unused) { dictkey_t *item = (dictkey_t *) i; return item->key; diff --git a/libs/util/quakefs.c b/libs/util/quakefs.c index c6ea64709..9d73c2bb1 100644 --- a/libs/util/quakefs.c +++ b/libs/util/quakefs.c @@ -212,7 +212,7 @@ static int num_gamedir_callbacks; static int max_gamedir_callbacks; static const char * -qfs_var_get_key (void *_v, void *unused) +qfs_var_get_key (const void *_v, void *unused) { return ((qfs_var_t *)_v)->var; } @@ -402,7 +402,7 @@ qfs_compare (const void *a, const void *b) } static const char * -qfs_dir_get_key (void *_k, void *unused) +qfs_dir_get_key (const void *_k, void *unused) { return _k; } diff --git a/libs/util/wadfile.c b/libs/util/wadfile.c index 8b5b7002c..d5bf7c7fd 100644 --- a/libs/util/wadfile.c +++ b/libs/util/wadfile.c @@ -56,7 +56,7 @@ // case insensitive hash and compare static uintptr_t -wad_get_hash (void *l, void *unused) +wad_get_hash (const void *l, void *unused) { char name[17]; int i; @@ -68,7 +68,7 @@ wad_get_hash (void *l, void *unused) } static int -wad_compare (void *la, void *lb, void *unused) +wad_compare (const void *la, const void *lb, void *unused) { return strncasecmp (((lumpinfo_t *) la)->name, ((lumpinfo_t *) lb)->name, 16) == 0; diff --git a/libs/video/renderer/glsl/glsl_draw.c b/libs/video/renderer/glsl/glsl_draw.c index b0aebb41d..675e3007a 100644 --- a/libs/video/renderer/glsl/glsl_draw.c +++ b/libs/video/renderer/glsl/glsl_draw.c @@ -153,7 +153,7 @@ new_cachepic (const char *name, qpic_t *pic) } static const char * -cachepic_getkey (void *_cp, void *unused) +cachepic_getkey (const void *_cp, void *unused) { return ((cachepic_t *) _cp)->name; } diff --git a/libs/video/renderer/r_progs.c b/libs/video/renderer/r_progs.c index 7c3ddb8f6..66ae9072f 100644 --- a/libs/video/renderer/r_progs.c +++ b/libs/video/renderer/r_progs.c @@ -304,7 +304,7 @@ bi_Draw_Crosshair (progs_t *pr) } static const char * -bi_draw_get_key (void *p, void *unused) +bi_draw_get_key (const void *p, void *unused) { return ((qpic_res_t *) p)->name; } diff --git a/libs/video/targets/old_keys.c b/libs/video/targets/old_keys.c index 9d872726e..6ec5dfd35 100644 --- a/libs/video/targets/old_keys.c +++ b/libs/video/targets/old_keys.c @@ -223,7 +223,7 @@ old_keyname_t old_keynames[] = { hashtab_t *old_key_table; static const char * -ok_get_key (void *_ok, void *unused) +ok_get_key (const void *_ok, void *unused) { old_keyname_t *ok = (old_keyname_t *)_ok; return ok->old_name; diff --git a/qtv/source/client.c b/qtv/source/client.c index 62dc696ca..d53849f7f 100644 --- a/qtv/source/client.c +++ b/qtv/source/client.c @@ -1193,7 +1193,7 @@ Client_NewConnection (void) } static const char * -ucmds_getkey (void *_a, void *unused) +ucmds_getkey (const void *_a, void *unused) { ucmd_t *a = (ucmd_t*)_a; return a->name; diff --git a/qtv/source/connection.c b/qtv/source/connection.c index 924b5f769..0ff5d4464 100644 --- a/qtv/source/connection.c +++ b/qtv/source/connection.c @@ -57,7 +57,7 @@ connection_free (void *_c, void *unused) } static uintptr_t -connection_get_hash (void *_c, void *unused) +connection_get_hash (const void *_c, void *unused) { connection_t *c = (connection_t *) _c; unsigned long hash; @@ -68,7 +68,7 @@ connection_get_hash (void *_c, void *unused) } static int -connection_compare (void *_c1, void *_c2, void *unused) +connection_compare (const void *_c1, const void *_c2, void *unused) { connection_t *c1 = (connection_t *) _c1; connection_t *c2 = (connection_t *) _c2; diff --git a/qtv/source/server.c b/qtv/source/server.c index d76f5d55e..6375177a2 100644 --- a/qtv/source/server.c +++ b/qtv/source/server.c @@ -64,7 +64,7 @@ static hashtab_t *server_hash; static server_t *servers; static const char * -server_get_key (void *sv, void *unused) +server_get_key (const void *sv, void *unused) { return ((server_t *) sv)->name; } diff --git a/qw/source/sv_user.c b/qw/source/sv_user.c index 438254379..608b44480 100644 --- a/qw/source/sv_user.c +++ b/qw/source/sv_user.c @@ -1339,7 +1339,7 @@ call_qc_hook (void *qc_hook) } static const char * -ucmds_getkey (void *_a, void *unused) +ucmds_getkey (const void *_a, void *unused) { ucmd_t *a = (ucmd_t*)_a; return a->name; @@ -1366,14 +1366,14 @@ ucmds_free (void *_c, void *unused) */ static uintptr_t -ucmd_get_hash (void *_a, void *data) +ucmd_get_hash (const void *_a, void *data) { ucmd_t *a = (ucmd_t*)_a; return Hash_String (a->name); } static int -ucmd_compare (void *a, void *b, void *data) +ucmd_compare (const void *a, const void *b, void *data) { return a == b; } diff --git a/tools/qfbsp/source/map.c b/tools/qfbsp/source/map.c index dcf5e82e1..f2038e44d 100644 --- a/tools/qfbsp/source/map.c +++ b/tools/qfbsp/source/map.c @@ -78,7 +78,7 @@ map_error (const char *fmt, ...) } static const char * -miptex_getkey (void *key, void *unused) +miptex_getkey (const void *key, void *unused) { intptr_t index = (intptr_t) key; return miptexnames[index - 1]; diff --git a/tools/qfcc/source/class.c b/tools/qfcc/source/class.c index 3c548551a..252f6d4c7 100644 --- a/tools/qfcc/source/class.c +++ b/tools/qfcc/source/class.c @@ -175,13 +175,13 @@ static struct_def_t object_ivars[] = { }; static const char * -class_get_key (void *class, void *unused) +class_get_key (const void *class, void *unused) { return ((class_t *) class)->name; } static const char * -protocol_get_key (void *protocol, void *unused) +protocol_get_key (const void *protocol, void *unused) { return ((protocol_t *) protocol)->name; } @@ -869,14 +869,14 @@ class_message_response (class_t *class, int class_msg, expr_t *sel) } static uintptr_t -category_get_hash (void *_c, void *unused) +category_get_hash (const void *_c, void *unused) { category_t *c = (category_t *) _c; return Hash_String (c->name) ^ Hash_String (c->class->name); } static int -category_compare (void *_c1, void *_c2, void *unused) +category_compare (const void *_c1, const void *_c2, void *unused) { category_t *c1 = (category_t *) _c1; category_t *c2 = (category_t *) _c2; diff --git a/tools/qfcc/source/function.c b/tools/qfcc/source/function.c index 03547aa05..eb7f4b6cf 100644 --- a/tools/qfcc/source/function.c +++ b/tools/qfcc/source/function.c @@ -68,14 +68,14 @@ static hashtab_t *overloaded_functions; static hashtab_t *function_map; static const char * -ol_func_get_key (void *_f, void *unused) +ol_func_get_key (const void *_f, void *unused) { overloaded_function_t *f = (overloaded_function_t *) _f; return f->full_name; } static const char * -func_map_get_key (void *_f, void *unused) +func_map_get_key (const void *_f, void *unused) { overloaded_function_t *f = (overloaded_function_t *) _f; return f->name; diff --git a/tools/qfcc/source/grab.c b/tools/qfcc/source/grab.c index 33ce1be1d..071223705 100644 --- a/tools/qfcc/source/grab.c +++ b/tools/qfcc/source/grab.c @@ -73,7 +73,7 @@ static frame_t grab_list[] = { }; static const char * -frame_get_key (void *f, void *unused) +frame_get_key (const void *f, void *unused) { return ((frame_t*)f)->name; } diff --git a/tools/qfcc/source/linker.c b/tools/qfcc/source/linker.c index 33aef3a34..1fe3aa870 100644 --- a/tools/qfcc/source/linker.c +++ b/tools/qfcc/source/linker.c @@ -206,7 +206,7 @@ get_defref (qfo_def_t *def, qfo_mspace_t *space) } static const char * -defs_get_key (void *_r, void *unused) +defs_get_key (const void *_r, void *unused) { defref_t *r = (defref_t *)_r; qfo_def_t *d = REF (r); diff --git a/tools/qfcc/source/method.c b/tools/qfcc/source/method.c index ea806cad3..734788bc9 100644 --- a/tools/qfcc/source/method.c +++ b/tools/qfcc/source/method.c @@ -64,7 +64,7 @@ static hashtab_t *known_methods; static const char * -method_get_key (void *meth, void *unused) +method_get_key (const void *meth, void *unused) { return ((method_t *) meth)->name; } @@ -298,7 +298,7 @@ static hashtab_t *sel_index_hash; static int sel_index; static uintptr_t -sel_get_hash (void *_sel, void *unused) +sel_get_hash (const void *_sel, void *unused) { selector_t *sel = (selector_t *) _sel; uintptr_t hash; @@ -308,7 +308,7 @@ sel_get_hash (void *_sel, void *unused) } static int -sel_compare (void *_s1, void *_s2, void *unused) +sel_compare (const void *_s1, const void *_s2, void *unused) { selector_t *s1 = (selector_t *) _s1; selector_t *s2 = (selector_t *) _s2; @@ -319,14 +319,14 @@ sel_compare (void *_s1, void *_s2, void *unused) } static uintptr_t -sel_index_get_hash (void *_sel, void *unused) +sel_index_get_hash (const void *_sel, void *unused) { selector_t *sel = (selector_t *) _sel; return sel->index; } static int -sel_index_compare (void *_s1, void *_s2, void *unused) +sel_index_compare (const void *_s1, const void *_s2, void *unused) { selector_t *s1 = (selector_t *) _s1; selector_t *s2 = (selector_t *) _s2; diff --git a/tools/qfcc/source/opcodes.c b/tools/qfcc/source/opcodes.c index 93e318a1d..3eb9ac44e 100644 --- a/tools/qfcc/source/opcodes.c +++ b/tools/qfcc/source/opcodes.c @@ -53,7 +53,7 @@ hashtab_t *opcode_void_table; #define ROTL(x,n) ((((unsigned)(x))<<(n))|((unsigned)(x))>>(32-n)) static uintptr_t -get_hash (void *_op, void *_tab) +get_hash (const void *_op, void *_tab) { opcode_t *op = (opcode_t *) _op; uintptr_t hash; @@ -64,7 +64,7 @@ get_hash (void *_op, void *_tab) } static int -compare (void *_opa, void *_opb, void *unused) +compare (const void *_opa, const void *_opb, void *unused) { opcode_t *opa = (opcode_t *) _opa; opcode_t *opb = (opcode_t *) _opb; @@ -77,7 +77,7 @@ compare (void *_opa, void *_opb, void *unused) } static const char * -get_key (void *op, void *unused) +get_key (const void *op, void *unused) { return ((opcode_t *) op)->name; } diff --git a/tools/qfcc/source/qc-lex.l b/tools/qfcc/source/qc-lex.l index 64b1142ca..b5c47ed55 100644 --- a/tools/qfcc/source/qc-lex.l +++ b/tools/qfcc/source/qc-lex.l @@ -326,7 +326,7 @@ static keyword_t keywords[] = { }; static const char * -keyword_get_key (void *kw, void *unused) +keyword_get_key (const void *kw, void *unused) { return ((keyword_t*)kw)->name; } diff --git a/tools/qfcc/source/qfprogs.c b/tools/qfcc/source/qfprogs.c index d2741af72..cce030610 100644 --- a/tools/qfcc/source/qfprogs.c +++ b/tools/qfcc/source/qfprogs.c @@ -204,13 +204,13 @@ free_progs_mem (progs_t *pr, void *mem) } static uintptr_t -func_hash (void *func, void *unused) +func_hash (const void *func, void *unused) { return ((dfunction_t *) func)->first_statement; } static int -func_compare (void *f1, void *f2, void *unused) +func_compare (const void *f1, const void *f2, void *unused) { return ((dfunction_t *) f1)->first_statement == ((dfunction_t *) f2)->first_statement; diff --git a/tools/qfcc/source/qp-lex.l b/tools/qfcc/source/qp-lex.l index 8a9f77037..4dda1d1d7 100644 --- a/tools/qfcc/source/qp-lex.l +++ b/tools/qfcc/source/qp-lex.l @@ -230,7 +230,7 @@ static keyword_t keywords[] = { }; static const char * -keyword_get_key (void *kw, void *unused) +keyword_get_key (const void *kw, void *unused) { return ((keyword_t *) kw)->name; } diff --git a/tools/qfcc/source/strpool.c b/tools/qfcc/source/strpool.c index e06456cbc..c7659de07 100644 --- a/tools/qfcc/source/strpool.c +++ b/tools/qfcc/source/strpool.c @@ -50,7 +50,7 @@ static hashtab_t *saved_strings; static const char * -strpool_get_key (void *_str, void *_strpool) +strpool_get_key (const void *_str, void *_strpool) { long str = (long) _str; strpool_t *strpool = (strpool_t *) _strpool; @@ -121,7 +121,7 @@ strpool_addstr (strpool_t *strpool, const char *str) } static const char * -ss_get_key (void *s, void *unused) +ss_get_key (const void *s, void *unused) { return (const char *)s; } diff --git a/tools/qfcc/source/switch.c b/tools/qfcc/source/switch.c index 1ba458924..1108f6916 100644 --- a/tools/qfcc/source/switch.c +++ b/tools/qfcc/source/switch.c @@ -72,7 +72,7 @@ get_value (expr_t *e) } static uintptr_t -get_hash (void *_cl, void *unused) +get_hash (const void *_cl, void *unused) { case_label_t *cl = (case_label_t *) _cl; ex_value_t *val; @@ -84,7 +84,7 @@ get_hash (void *_cl, void *unused) } static int -compare (void *_cla, void *_clb, void *unused) +compare (const void *_cla, const void *_clb, void *unused) { case_label_t *cla = (case_label_t *) _cla; case_label_t *clb = (case_label_t *) _clb; diff --git a/tools/qfcc/source/symtab.c b/tools/qfcc/source/symtab.c index b7fdb9fd4..37b1788e8 100644 --- a/tools/qfcc/source/symtab.c +++ b/tools/qfcc/source/symtab.c @@ -68,7 +68,7 @@ new_symbol_type (const char *name, type_t *type) } static const char * -sym_getkey (void *k, void *unused) +sym_getkey (const void *k, void *unused) { return ((symbol_t *) k)->name; } diff --git a/tools/qfcc/source/value.c b/tools/qfcc/source/value.c index 1f4df30fa..1e421943a 100644 --- a/tools/qfcc/source/value.c +++ b/tools/qfcc/source/value.c @@ -82,7 +82,7 @@ static hashtab_t *quaternion_imm_defs; static hashtab_t *integer_imm_defs; static uintptr_t -imm_get_hash (void *_imm, void *_tab) +imm_get_hash (const void *_imm, void *_tab) { immediate_t *imm = (immediate_t *) _imm; hashtab_t **tab = (hashtab_t **) _tab; @@ -113,7 +113,7 @@ imm_get_hash (void *_imm, void *_tab) } static int -imm_compare (void *_imm1, void *_imm2, void *_tab) +imm_compare (const void *_imm1, const void *_imm2, void *_tab) { immediate_t *imm1 = (immediate_t *) _imm1; immediate_t *imm2 = (immediate_t *) _imm2;