#include <stdio.h>
#include <string.h>
struct _Phone_Entry {
const char *name;
const char *number;
};
typedef struct _Phone_Entry Phone_Entry;
static Phone_Entry _start_entries[] = {
{ "Wolfgang Amadeus Mozart", "+01 23 456-78910" },
{ "Ludwig van Beethoven", "+12 34 567-89101" },
{ "Richard Georg Strauss", "+23 45 678-91012" },
{ "Heitor Villa-Lobos", "+34 56 789-10123" },
{ NULL, NULL }
};
static void
_phone_entry_free_cb(void *data)
{
free(data);
}
static void
_phone_book_stringshared_free_cb(void *data)
{
Phone_Entry *e = data;
free(e);
}
void *data,
{
Phone_Entry *e = data;
const char *name = e->name;
const char *number = e->number;
printf("%s: %s\n", name, number);
}
static void
example_hash_stringshared(void)
{
int i;
for (i = 0; _start_entries[i].name != NULL; i++)
{
Phone_Entry *e = malloc(sizeof(Phone_Entry));
}
printf("List of phones:\n");
printf("\n");
}
static unsigned int
_phone_book_string_key_length(const char *key)
{
if (!key)
return 0;
return (int)strlen(key) + 1;
}
static int
_phone_book_string_key_cmp(
const char *key1,
int key1_length
EINA_UNUSED,
{
return strcmp(key1, key2);
}
static void
example_hash_big(void)
{
int i;
const char *phone;
_phone_entry_free_cb,
10);
for (i = 0; _start_entries[i].name != NULL; i++)
{
strdup(_start_entries[i].number));
}
if (phone)
{
printf("Printing entry.\n");
printf("Name: Heitor Villa-Lobos\n");
printf("Number: %s\n\n", phone);
}
}
int
main(int argc, const char *argv[])
{
(void)argc;
(void)argv;
example_hash_stringshared();
example_hash_big();
}
#define EINA_KEY_CMP(Function)
Definition: eina_hash.h:325
EINA_API Eina_Hash * eina_hash_stringshared_new(Eina_Free_Cb data_free_cb)
Creates a new hash table optimized for stringshared values.
Definition: eina_hash.c:848
EINA_API int eina_hash_superfast(const char *key, int len)
Paul Hsieh (http://www.azillionmonkeys.com/qed/hash.html) hash function used by WebCore (http://webki...
Definition: eina_hash.c:1330
EINA_API Eina_Bool eina_hash_add(Eina_Hash *hash, const void *key, const void *data)
Adds an entry to the given hash table.
Definition: eina_hash.c:931
EINA_API void * eina_hash_find(const Eina_Hash *hash, const void *key)
Retrieves a specific entry in the given hash table.
Definition: eina_hash.c:1069
EINA_API void eina_hash_free(Eina_Hash *hash)
Frees the given hash table's resources.
Definition: eina_hash.c:868
EINA_API Eina_Bool eina_hash_direct_add(Eina_Hash *hash, const void *key, const void *data)
Adds an entry to the given hash table without duplicating the string.
Definition: eina_hash.c:948
EINA_API Eina_Hash * eina_hash_new(Eina_Key_Length key_length_cb, Eina_Key_Cmp key_cmp_cb, Eina_Key_Hash key_hash_cb, Eina_Free_Cb data_free_cb, int buckets_power_size)
Creates a new hash table.
Definition: eina_hash.c:742
EINA_API void eina_hash_foreach(const Eina_Hash *hash, Eina_Hash_Foreach func, const void *fdata)
Calls a function on every member stored in the hash table.
Definition: eina_hash.c:1223
struct _Eina_Hash Eina_Hash
Type for a generic hash table.
Definition: eina_hash.h:285
#define EINA_KEY_LENGTH(Function)
Definition: eina_hash.h:314
#define EINA_KEY_HASH(Function)
Definition: eina_hash.h:336
EINA_API int eina_shutdown(void)
Shuts down the Eina library.
Definition: eina_main.c:379
EINA_API int eina_init(void)
Initializes the Eina library.
Definition: eina_main.c:291
EINA_API Eina_Stringshare * eina_stringshare_add(const char *str)
Retrieves an instance of a string for use in a program.
Definition: eina_stringshare.c:606
EINA_API void eina_stringshare_del(Eina_Stringshare *str)
Notes that the given string has lost an instance.
Definition: eina_stringshare.c:533
#define EINA_TRUE
boolean value TRUE (numerical value 1)
Definition: eina_types.h:539
unsigned char Eina_Bool
Type to mimic a boolean.
Definition: eina_types.h:527
#define EINA_UNUSED
Used to indicate that a function parameter is purposely unused.
Definition: eina_types.h:339