These functions provide some helper for a pseudo Copy On Write mechanism. More...
| Macros | |
| #define | EINA_COW_WRITE_BEGIN(Cow, Read, Write_Type, Write) | 
| Definition for the macro to setup a writeable pointer from a const one.  More... | |
| #define | EINA_COW_WRITE_END(Cow, Read, Write) | 
| Definition for the macro to close the writeable pointer.  More... | |
| Typedefs | |
| typedef struct _Eina_Cow | Eina_Cow | 
| Type for Eina_Cow pool. | |
| typedef void | Eina_Cow_Data | 
| Type of the returned pointer to simplify some reading. | |
| Functions | |
| Eina_Cow * | eina_cow_add (const char *name, unsigned int struct_size, unsigned int step, const void *default_value, Eina_Bool gc) | 
| Instantiates a new Eina_Cow pool.  More... | |
| void | eina_cow_del (Eina_Cow *cow) | 
| Destroys an Eina_Cow pool and all the allocated memory.  More... | |
| const Eina_Cow_Data * | eina_cow_alloc (Eina_Cow *cow) | 
| Returns an initialized pointer from the pool.  More... | |
| void | eina_cow_free (Eina_Cow *cow, const Eina_Cow_Data **data) | 
| Frees a pointer from the pool.  More... | |
| void * | eina_cow_write (Eina_Cow *cow, const Eina_Cow_Data *const *src) | 
| Gets a writeable pointer from a const pointer.  More... | |
| void | eina_cow_done (Eina_Cow *cow, const Eina_Cow_Data *const *dst, const void *data, Eina_Bool needed_gc) | 
| Sets back a pointer into read only.  More... | |
| void | eina_cow_memcpy (Eina_Cow *cow, const Eina_Cow_Data *const *dst, const Eina_Cow_Data *src) | 
| Makes the destination contain the same thing as the source pointer.  More... | |
| Eina_Bool | eina_cow_gc (Eina_Cow *cow) | 
| Tries to find entries that have the same content and update them.  More... | |
These functions provide some helper for a pseudo Copy On Write mechanism.
Eina_Cow will return const memory pointer to some default value that you will be able to change only by requesting a writable pointer. Later on a garbage collector can come online and try to merge back some of those pointer.
| #define EINA_COW_WRITE_BEGIN | ( | Cow, | |
| Read, | |||
| Write_Type, | |||
| Write | |||
| ) | 
Definition for the macro to setup a writeable pointer from a const one.
| Cow | The Eina_Cow where the const pointer come from. | 
| Read | The const pointer to get a writable handler from. | 
| Write_Type | The type of the pointer you want to write to. | 
| Write | The name of the variable where to put the writeable pointer to. | 
Be careful this macro opens a C scope that is expected to be closed by EINA_COW_WRITE_END().
Referenced by evas_map_coords_get(), evas_map_util_clockwise_get(), evas_object_del(), and evas_render_updates_free().
| #define EINA_COW_WRITE_END | ( | Cow, | |
| Read, | |||
| Write | |||
| ) | 
Definition for the macro to close the writeable pointer.
| Cow | The Eina_Cow where the const pointer come from. | 
| Read | The const pointer to get a writable handler from. | 
| Write | The name of the variable where to put the writeable pointer to. | 
Be careful this macro close the scope opened by EINA_COW_WRITE_BEGIN().
Referenced by evas_map_coords_get(), evas_map_util_clockwise_get(), evas_object_del(), and evas_render_updates_free().
| Eina_Cow* eina_cow_add | ( | const char * | name, | 
| unsigned int | struct_size, | ||
| unsigned int | step, | ||
| const void * | default_value, | ||
| Eina_Bool | gc | ||
| ) | 
Instantiates a new Eina_Cow pool.
| name | The name of this pool, used for debug. | 
| struct_size | The size of the object from this pool. | 
| step | How many objects to allocate when the pool gets empty. | 
| default_value | The default value returned by this pool. | 
| gc | Is it possible to run garbage collection on this pool. | 
NULL on error. Referenced by edje_init(), and efl_object_init().
| void eina_cow_del | ( | Eina_Cow * | cow | ) | 
Destroys an Eina_Cow pool and all the allocated memory.
| cow | The pool to destroy | 
References eina_hash_free(), and eina_mempool_del().
| const Eina_Cow_Data* eina_cow_alloc | ( | Eina_Cow * | cow | ) | 
Returns an initialized pointer from the pool.
| cow | The pool to take things from. | 
| void eina_cow_free | ( | Eina_Cow * | cow, | 
| const Eina_Cow_Data ** | data | ||
| ) | 
Frees a pointer from the pool.
| cow | The pool to gave back memory to. | 
| data | The data to give back. | 
References EINA_MAGIC_NONE, EINA_MAGIC_SET, and eina_mempool_free().
Referenced by efl_reuse(), and eina_cow_memcpy().
| void* eina_cow_write | ( | Eina_Cow * | cow, | 
| const Eina_Cow_Data *const * | src | ||
| ) | 
Gets a writeable pointer from a const pointer.
| cow | The pool the pointer come from. | 
| src | The pointer you want to write to. | 
NOTE: this function is not thread safe, be careful.
References EINA_FALSE, EINA_MAGIC_SET, eina_mempool_malloc(), EINA_TRUE, and ERR.
| void eina_cow_done | ( | Eina_Cow * | cow, | 
| const Eina_Cow_Data *const * | dst, | ||
| const void * | data, | ||
| Eina_Bool | needed_gc | ||
| ) | 
Sets back a pointer into read only.
| cow | The pool the pointer come from. | 
| dst | The read only version of the pointer. | 
| data | The pointer to which data was written to. | 
| needed_gc | Does this pool need to be garbage collected? | 
NOTE: this function is not thread safe, be careful.
References EINA_FALSE, and ERR.
| void eina_cow_memcpy | ( | Eina_Cow * | cow, | 
| const Eina_Cow_Data *const * | dst, | ||
| const Eina_Cow_Data * | src | ||
| ) | 
Makes the destination contain the same thing as the source pointer.
| cow | The pool the pointers come from. | 
| dst | The destination to update. | 
| src | The source of information to copy. | 
References eina_cow_free().
Tries to find entries that have the same content and update them.
| cow | The cow to try to compact. | 
There is no guaranty in the time it will require, but should remain low. It does run a hash function on all possible common structures trying to find the one that match and merge them into one pointer.
References EINA_FALSE, eina_hash_iterator_data_new(), eina_hash_population(), eina_iterator_free(), eina_iterator_next(), and EINA_TRUE.