Beispiel #1
0
int hashtable_search( hashtable *ht, char *key )
{
	int i,j,k;

strlwr( key );
k = hashtable_getkey( key );
i = 0;
while(i < ht->size )	{
	j = (k+(i++)) & ht->and_mask;
	if ( ht->key[j] == NULL )
		return -1;
	if (!stricmp(ht->key[j], key ))
		return ht->value[j];
	}
return -1;
}
Beispiel #2
0
Datei: hash.c Projekt: btb/d2x
void hashtable_insert( hashtable *ht, const char *key, int value )
{
	int i,j,k;

	k = hashtable_getkey( key );
	i = 0;

	while(i < ht->size)	{
		j = (k+(i++)) & ht->and_mask;
		if ( ht->key[j] == NULL )	{
			ht->nitems++;
			ht->key[j] = key;
			ht->value[j] = value;
			return;
		} else if (!stricmp( key, ht->key[j] ))	{
			return;
		}
	}
	Error( "Out of hash slots\n" );
}