src/stdlib/hashtab.c
/*======================
 * remove_hashtab -- Remove element from table
 * return old value if found
 *====================*/
- Remove element from table
return old value if found
- Remove element from table return old value if found
HVALUE
remove_hashtab (HASHTAB tab, CNSTRING key)
{
	HVALUE val=0;
	INT hval=0;
	HASHENT preve=0, thise=0;
	ASSERT(tab);
	ASSERT(tab->magic == hashtab_magic);
	hval = hash(tab, key);
	thise = tab->entries[hval];
	while (thise && nestr(key, thise->ekey)) {
		ASSERT(thise->magic == hashent_magic);
		preve = thise;
		thise = thise->enext;
	}
	if (!thise) return 0;
	if (preve)
		preve->enext = thise->enext;
	else
		tab->entries[hval] = thise->enext;
	val = thise->val;
	strfree((STRING *)&thise->ekey);
	thise->val = 0;
	stdfree(thise);
	--tab->count;
	return val;
}
HVALUE remove_hashtab ( HASHTAB tab , CNSTRING key ) { HVALUE val = 0 ; INT hval = 0 ; HASHENT preve = 0 , thise = 0 ; ASSERT ( tab ) ; ASSERT ( tab -> magic == hashtab_magic ) ; hval = hash ( tab , key ) ; thise = tab -> entries [ hval ] ; while ( thise && nestr ( key , thise -> ekey ) ) { ASSERT ( thise -> magic == hashent_magic ) ; preve = thise ; thise = thise -> enext ; } if ( ! thise ) return 0 ; if ( preve ) preve -> enext = thise -> enext ; else tab -> entries [ hval ] = thise -> enext ; val = thise -> val ; strfree ( ( STRING * ) & thise -> ekey ) ; thise -> val = 0 ; stdfree ( thise ) ; -- tab -> count ; return val ; }
remove_hashtab -- Remove element from table
 return old value if found
remove_hashtab -- Remove element from table return old value if found