void deallocate_string (char * str) { int h; block_t *b, **prev; h = StrHash(str); prev = base_table + h; while ((b = *prev)) { if (STRING(b) == str) { *prev = NEXT(b); break; } prev = &(NEXT(b)); } DEBUG_CHECK1(!b,"stralloc.c: deallocate_string called on non-shared string: %s.\n", str); FREE(b); }
void free_string (const char * str) { block_t **prev, *b; int h; b = BLOCK(str); DEBUG_CHECK1(b != findblock(str),"stralloc.c: free_string called on non-shared string: %s.\n", str); /* * if a string has been ref'd USHRT_MAX times then we assume that its used * often enough to justify never freeing it. */ if (!REFS(b)) return; REFS(b)--; SUB_STRING(SIZE(b)); NDBG(b); if (REFS(b) > 0) return; h = StrHash(str); prev = base_table + h; while ((b = *prev)) { if (STRING(b) == str) { *prev = NEXT(b); break; } prev = &(NEXT(b)); } DEBUG_CHECK1(!b, "free_string: not found in string table! (\"%s\")\n", str); SUB_NEW_STRING(SIZE(b), sizeof(block_t)); FREE(b); CHECK_STRING_STATS; }
_tsulong varHash(void* str){ return StrHash((const TSStr*) str, HASH_TABLE_BITS); }