MCPcopy Create free account
hub / github.com/OpenXcom/OpenXcom / hash_init

Function hash_init

src/lodepng.cpp:1360–1376  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1358} Hash;
1359
1360static unsigned hash_init(Hash* hash, unsigned windowsize)
1361{
1362 unsigned i;
1363 hash->head = (int*)lodepng_malloc(sizeof(int) * HASH_NUM_VALUES);
1364 hash->val = (int*)lodepng_malloc(sizeof(int) * windowsize);
1365 hash->chain = (unsigned short*)lodepng_malloc(sizeof(unsigned short) * windowsize);
1366 hash->zeros = (unsigned short*)lodepng_malloc(sizeof(unsigned short) * windowsize);
1367
1368 if(!hash->head || !hash->val || !hash->chain || !hash->zeros) return 83; /*alloc fail*/
1369
1370 /*initialize hash table*/
1371 for(i = 0; i < HASH_NUM_VALUES; i++) hash->head[i] = -1;
1372 for(i = 0; i < windowsize; i++) hash->val[i] = -1;
1373 for(i = 0; i < windowsize; i++) hash->chain[i] = i; /*same value as index indicates uninitialized*/
1374
1375 return 0;
1376}
1377
1378static void hash_cleanup(Hash* hash)
1379{

Callers 1

lodepng_deflatevFunction · 0.85

Calls 1

lodepng_mallocFunction · 0.85

Tested by

no test coverage detected