예제 #1
0
int main(int argc, char* argv[]){

	Hashtable* table = HTCreate(10, hashfct, freefct, cmpfct);
	
	int* ptr = NULL;
	int i = 0;
	
	for(i = 0; i < 5; i++){
		ptr = malloc(sizeof(int));
		*ptr = i;
		
		HTAdd(table, ptr, ptr);
	}
	
	for(i = 0; i < 5; i++){
		ptr = malloc(sizeof(int));
		*ptr = i;
		
		int* v = HTGet(table, ptr);
		printf("%d\n",*ptr);
		free(ptr);
		free(v);
	}
		
	
	HTDestroy(table);

	return 0;
}
예제 #2
0
/*
 *	DictionaryDestroy
 *
 *	Author:	Christian Schafmeister (1991)
 *
 *	Destroy the DICTIONARY.
 */
void	
DictionaryDestroy( DICTIONARY *dPDict )
{

    zDictionarySortCleanup(*dPDict);

		/* First FREE all of the keys */

    HTWalk( (*dPDict)->htEntries, NULL, zDictionaryDestroyKey );

		/* Destroy the HASH_TABLE */
    HTDestroy( &((*dPDict)->htEntries) );

    (*dPDict)->PKlass = NULL;
    FREE((*dPDict));
    *dPDict = NULL;

}