Use lists for the many hash tables used in the C-CON compiler instead of dozens of lines of calls to hash_init() and hash_free().

git-svn-id: https://svn.eduke32.com/eduke32@5573 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2016-01-21 19:35:09 +00:00
parent 86a4660f08
commit 621f5db188

View file

@ -1250,28 +1250,26 @@ static hashtable_t h_tsprite = { ACTOR_END>>1, NULL };
static hashtable_t h_tiledata = { TILEDATA_END>>1, NULL }; static hashtable_t h_tiledata = { TILEDATA_END>>1, NULL };
static hashtable_t h_paldata = { PALDATA_END>>1, NULL }; static hashtable_t h_paldata = { PALDATA_END>>1, NULL };
static hashtable_t * const tables[] = {
&h_gamevars, &h_arrays, &h_labels, &h_keywords, &h_sector, &h_wall, &h_userdef,
&h_projectile, &h_player, &h_input, &h_actor, &h_tsprite, &h_tiledata, &h_paldata
};
static hashtable_t * const tables_free [] ={
&h_labels, &h_keywords, &h_sector, &h_wall, &h_userdef,
&h_projectile, &h_player, &h_input, &h_actor, &h_tsprite, &h_tiledata, &h_paldata
};
void C_InitHashes() void C_InitHashes()
{ {
int32_t i; uint32_t i;
for (i=0; i < ARRAY_SIZE(tables)-1; i++)
hash_init(tables[i]);
hash_init(&h_gamevars);
hash_init(&h_arrays);
hash_init(&h_labels);
inithashnames(); inithashnames();
initsoundhashnames(); initsoundhashnames();
hash_init(&h_keywords);
hash_init(&h_sector);
hash_init(&h_wall);
hash_init(&h_userdef);
hash_init(&h_projectile);
hash_init(&h_player);
hash_init(&h_input);
hash_init(&h_actor);
hash_init(&h_tsprite);
hash_init(&h_tiledata);
hash_init(&h_paldata);
for (i=0; i<NUMKEYWORDS; i++) hash_add(&h_keywords,keyw[i],i,0); for (i=0; i<NUMKEYWORDS; i++) hash_add(&h_keywords,keyw[i],i,0);
for (i=0; i<NUMALTKEYWORDS; i++) hash_add(&h_keywords, altkeyw[i].token, altkeyw[i].val, 0); for (i=0; i<NUMALTKEYWORDS; i++) hash_add(&h_keywords, altkeyw[i].token, altkeyw[i].val, 0);
for (i=0; SectorLabels[i].lId >= 0; i++) hash_add(&h_sector,SectorLabels[i].name,i,0); for (i=0; SectorLabels[i].lId >= 0; i++) hash_add(&h_sector,SectorLabels[i].name,i,0);
@ -6310,21 +6308,12 @@ void C_Compile(const char *filenam)
initprintf("Script compiled in %dms, %ld bytes%s\n", getticks() - startcompiletime, initprintf("Script compiled in %dms, %ld bytes%s\n", getticks() - startcompiletime,
(unsigned long)(g_scriptPtr-script), C_ScriptVersionString(g_scriptVersion)); (unsigned long)(g_scriptPtr-script), C_ScriptVersionString(g_scriptVersion));
hash_free(&h_labels); for (i=0; (unsigned)i < ARRAY_SIZE(tables_free)-1; i++)
hash_free(&h_keywords); hash_free(tables_free[i]);
freehashnames(); freehashnames();
freesoundhashnames(); freesoundhashnames();
hash_free(&h_sector);
hash_free(&h_wall);
hash_free(&h_userdef);
hash_free(&h_projectile);
hash_free(&h_player);
hash_free(&h_input);
hash_free(&h_actor);
hash_free(&h_tsprite);
if (g_scriptDebug) if (g_scriptDebug)
{ {
initprintf("%d/%d labels, %d/%d variables, %d/%d arrays\n", g_numLabels, initprintf("%d/%d labels, %d/%d variables, %d/%d arrays\n", g_numLabels,