#include "hash.h" #include #include #include int main() { hash_t* h = hash_new(10); char* str1_key = malloc(100); strcpy(str1_key, "key 1"); char* str1_value = malloc(100); strcpy(str1_value, "valor 1"); char* str2_key = malloc(100); strcpy(str2_key, "key 2"); char* str2_value = malloc(100); strcpy(str2_value, "valor 2"); char* str3_key = malloc(100); strcpy(str3_key, "key 3"); char* str3_value = malloc(100); strcpy(str3_value, "valor 3"); char* str4_key = malloc(100); strcpy(str4_key, "key 4"); char* str4_value = malloc(100); strcpy(str4_value, "valor 4"); hash_add (h, str1_key, str1_value); hash_add (h, str2_key, str2_value); hash_add (h, str3_key, str3_value); hash_add (h, str4_key, str4_value); hash_set_cmpfunc (h, (void*)strcmp); char *key = malloc(100); strcpy(key, "key 1"); printf ("%s\n", (char*)hash_get (h, key)); printf ("%s\n", (char*)hash_get (h, str1_key)); printf ("%s\n", (char*)hash_get (h, str2_key)); printf ("%s\n", (char*)hash_get (h, str3_key)); free(key); hash_free(h, free, free); return 0; }