Hash General Functions
Miscellaneous functions that operate on hash objects. More...Functions | |
EAPI int | evas_hash_size (const 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 (const Evas_Hash *hash, Evas_Bool(*func)(const 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. |
Detailed Description
Miscellaneous functions that operate on hash objects.
Function Documentation
EAPI int evas_hash_alloc_error | ( | void | ) |
Return memory allocation failure flag after an function requiring allocation.
- Returns:
- The state of the allocation flag
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 | ( | const Evas_Hash * | hash, | |
Evas_Bool(*)(const 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.
- Parameters:
-
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); }
References evas_hash_size().
EAPI void evas_hash_free | ( | Evas_Hash * | hash | ) |
Free an entire hash table.
@param hash The hash table to be freed
This function frees up all the memory allocated to storing the specified hash tale pointed to by 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;
References evas_hash_size().
Referenced by evas_free().
EAPI int evas_hash_size | ( | const Evas_Hash * | hash | ) |
Retrieves the number of buckets available in the given hash table.
- Parameters:
-
hash The given hash table.
- Returns:
256
ifhash
is notNULL
.0
otherwise.
Referenced by evas_hash_foreach(), and evas_hash_free().