Evas_Hash_General_Group (3) - Linux Manuals

Evas_Hash_General_Group: Miscellaneous functions that operate on hash objects.

NAME

Hash General Functions - Miscellaneous functions that operate on hash objects.

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

This function returns the state of the memory allocation flag. This flag is set if memory allocations fail during evas_hash_add() calls. If they do, 1 will be returned, otherwise 0 will be returned. The flag will remain in its current state until the next call that requires allocation is called, and is then reset.

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.);
     exit(-1);
   }
 if (evas_hash_find(hash, 'My Data') == my_data)
   {
     printf('My Data inserted and successfully found.);
   }


 

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

This function goes through every entry in the hash table 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, 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.

Todo

Complete polishing documentation for evas_hash.c. The functions' docs may be grouped, but they need some simplification.

Parameters:

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 if hash is not NULL. 0 otherwise.

Referenced by evas_hash_foreach(), and evas_hash_free().

Author

Generated automatically by Doxygen for Evas from the source code.