Functions | |
EAPI int | evas_hash_size (Evas_Hash *hash) |
Retrieves the number of buckets available in the given hash table. | |
EAPI void | evas_hash_free (Evas_Hash *hash) |
Free an entire hash table. | |
EAPI void | evas_hash_foreach (Evas_Hash *hash, Evas_Bool(*func)(Evas_Hash *hash, const char *key, void *data, void *fdata), const void *fdata) |
Call a function on every member stored in the hash table. | |
EAPI int | evas_hash_alloc_error (void) |
Return memory allocation failure flag after an function requiring allocation. |
EAPI int evas_hash_alloc_error | ( | void | ) |
Return memory allocation failure flag after an function requiring allocation.
Example:
Evas_Hash *hash = NULL; extern void *my_data; hash = evas_hash_add(hash, "My Data", my_data); if (evas_hash_alloc_error()) { fprintf(stderr, "ERROR: Memory is low. Hash allocation failed.\n"); exit(-1); } if (evas_hash_find(hash, "My Data") == my_data) { printf("My Data inserted and successfully found.\n"); }
EAPI void evas_hash_foreach | ( | Evas_Hash * | hash, | |
Evas_Bool(*)(Evas_Hash *hash, const char *key, void *data, void *fdata) | func, | |||
const void * | fdata | |||
) |
Call a function on every member stored in the hash table.
hash | The hash table whose members will be walked | |
func | The function to call on each parameter | |
fdata | The data pointer to pass to the function being called |
hash
and calls the function func
on each member. The function should NOT modify the hash table contents if it returns 1. IF the hash table contents are modified by this function or the function wishes to stop processing it must return 0, otherwise return 1 to keep processing.Example:
extern Evas_Hash *hash; Evas_Bool hash_fn(Evas_Hash *hash, const char *key, void *data, void *fdata) { printf("Func data: %s, Hash entry: %s / %p\n", fdata, key, data); return 1; } int main(int argc, char **argv) { char *hash_fn_data; hash_fn_data = strdup("Hello World"); evas_hash_foreach(hash, hash_fn, hash_fn_data); free(hash_fn_data); }
EAPI void evas_hash_free | ( | Evas_Hash * | hash | ) |
Free an entire hash table.
hash | The hash table to be freed |
hash
. Any entries in the table that the program has no more pointers for elsewhere may now be lost, so this should only be called if the program has lready freed any allocated data in the hash table or has the pointers for data in teh table stored elswehere as well.Example:
extern Evas_Hash *hash; evas_hash_free(hash); hash = NULL;
EAPI int evas_hash_size | ( | Evas_Hash * | hash | ) |
Retrieves the number of buckets available in the given hash table.
hash | The given hash table. |
256
if hash
is not NULL
. 0
otherwise.