forked from enlightenment/efl
* eina: fix structure content to be more futur proof and reduce
risk of ABI breakage. SVN revision: 51390
This commit is contained in:
parent
3c305771c3
commit
e6f9cee051
|
@ -51,6 +51,9 @@ typedef Eina_Bool (*Eina_Accessor_Lock_Callback)(Eina_Accessor *it);
|
|||
|
||||
struct _Eina_Accessor
|
||||
{
|
||||
#define EINA_ACCESSOR_VERSION 1
|
||||
int version;
|
||||
|
||||
Eina_Accessor_Get_At_Callback get_at EINA_ARG_NONNULL(1, 3) EINA_WARN_UNUSED_RESULT;
|
||||
Eina_Accessor_Get_Container_Callback get_container EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
|
||||
Eina_Accessor_Free_Callback free EINA_ARG_NONNULL(1);
|
||||
|
|
|
@ -65,6 +65,9 @@ typedef void **Eina_Array_Iterator;
|
|||
*/
|
||||
struct _Eina_Array
|
||||
{
|
||||
#define EINA_ARRAY_VERSION 1
|
||||
int version; /**< Should match EINA_ARRAY_VERSION used when compiled your apps, provided for ABI compatibility */
|
||||
|
||||
void **data; /**< Pointer to a vector of pointer to payload */
|
||||
unsigned int total; /**< Total number of slots in the vector */
|
||||
unsigned int count; /**< Number of active slots in the vector */
|
||||
|
@ -76,6 +79,7 @@ EAPI Eina_Array * eina_array_new(unsigned int step) EINA_WARN_UNUS
|
|||
EAPI Eina_Array * eina_array_threadsafe_new(unsigned int step) EINA_WARN_UNUSED_RESULT EINA_MALLOC EINA_WARN_UNUSED_RESULT;
|
||||
EAPI void eina_array_free(Eina_Array *array) EINA_ARG_NONNULL(1);
|
||||
EAPI void eina_array_step_set(Eina_Array *array,
|
||||
unsigned int sizeof_eina_array,
|
||||
unsigned int step) EINA_ARG_NONNULL(1);
|
||||
EAPI void eina_array_clean(Eina_Array *array) EINA_ARG_NONNULL(1);
|
||||
EAPI void eina_array_flush(Eina_Array *array) EINA_ARG_NONNULL(1);
|
||||
|
|
|
@ -49,6 +49,9 @@ typedef Eina_Bool (*Eina_Iterator_Lock_Callback)(Eina_Iterator *it);
|
|||
|
||||
struct _Eina_Iterator
|
||||
{
|
||||
#define EINA_ITERATOR_VERSION 1
|
||||
int version;
|
||||
|
||||
Eina_Iterator_Next_Callback next EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
|
||||
Eina_Iterator_Get_Container_Callback get_container EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
|
||||
Eina_Iterator_Free_Callback free EINA_ARG_NONNULL(1);
|
||||
|
|
|
@ -415,6 +415,7 @@ eina_array_new(unsigned int step)
|
|||
|
||||
EINA_MAGIC_SET(array, EINA_MAGIC_ARRAY);
|
||||
|
||||
array->version = EINA_ARRAY_VERSION;
|
||||
array->data = NULL;
|
||||
array->total = 0;
|
||||
array->count = 0;
|
||||
|
@ -448,6 +449,7 @@ eina_array_free(Eina_Array *array)
|
|||
* @brief Set the step of an array.
|
||||
*
|
||||
* @param array The array.
|
||||
* @param sizeof_array Should be the value returned by sizeof (Eina_Array).
|
||||
* @param step The count of pointers to add when increasing the array size.
|
||||
*
|
||||
* This function sets the step of @p array to @p step. For performance
|
||||
|
@ -456,9 +458,23 @@ eina_array_free(Eina_Array *array)
|
|||
* the array is not initialized.
|
||||
*/
|
||||
EAPI void
|
||||
eina_array_step_set(Eina_Array *array, unsigned int step)
|
||||
eina_array_step_set(Eina_Array *array,
|
||||
unsigned int sizeof_eina_array,
|
||||
unsigned int step)
|
||||
{
|
||||
EINA_SAFETY_ON_NULL_RETURN(array);
|
||||
|
||||
if (sizeof (Eina_Array) != sizeof_eina_array)
|
||||
{
|
||||
ERR("Unknow Eina_Array size ! Got %i, expected %i !\n",
|
||||
sizeof_eina_array,
|
||||
(int) sizeof (Eina_Array));
|
||||
/* Force memory to zero to provide a small layer of security */
|
||||
memset(array, 0, sizeof_eina_array);
|
||||
return ;
|
||||
}
|
||||
|
||||
array->version = EINA_ARRAY_VERSION;
|
||||
array->data = NULL;
|
||||
array->total = 0;
|
||||
array->count = 0;
|
||||
|
@ -654,6 +670,7 @@ eina_array_iterator_new(const Eina_Array *array)
|
|||
|
||||
it->array = array;
|
||||
|
||||
it->iterator.version = EINA_ITERATOR_VERSION;
|
||||
it->iterator.next = FUNC_ITERATOR_NEXT(eina_array_iterator_next);
|
||||
it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(
|
||||
eina_array_iterator_get_container);
|
||||
|
@ -695,6 +712,7 @@ eina_array_accessor_new(const Eina_Array *array)
|
|||
|
||||
it->array = array;
|
||||
|
||||
it->accessor.version = EINA_ACCESSOR_VERSION;
|
||||
it->accessor.get_at = FUNC_ACCESSOR_GET_AT(eina_array_accessor_get_at);
|
||||
it->accessor.get_container = FUNC_ACCESSOR_GET_CONTAINER(
|
||||
eina_array_accessor_get_container);
|
||||
|
|
|
@ -431,7 +431,7 @@ eina_file_ls(const char *dir)
|
|||
if (length < 1)
|
||||
return NULL;
|
||||
|
||||
it = malloc(sizeof (Eina_File_Iterator) + length);
|
||||
it = calloc(1, sizeof (Eina_File_Iterator) + length);
|
||||
if (!it)
|
||||
return NULL;
|
||||
|
||||
|
@ -450,6 +450,7 @@ eina_file_ls(const char *dir)
|
|||
else
|
||||
it->length = length - 1;
|
||||
|
||||
it->iterator.version = EINA_ITERATOR_VERSION;
|
||||
it->iterator.next = FUNC_ITERATOR_NEXT(_eina_file_ls_iterator_next);
|
||||
it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(
|
||||
_eina_file_ls_iterator_container);
|
||||
|
@ -498,7 +499,7 @@ eina_file_direct_ls(const char *dir)
|
|||
if (length + NAME_MAX + 2 >= PATH_MAX)
|
||||
return NULL;
|
||||
|
||||
it = malloc(sizeof(Eina_File_Direct_Iterator) + length);
|
||||
it = calloc(1, sizeof(Eina_File_Direct_Iterator) + length);
|
||||
if (!it)
|
||||
return NULL;
|
||||
|
||||
|
@ -523,6 +524,7 @@ eina_file_direct_ls(const char *dir)
|
|||
it->info.name_start = length + 1;
|
||||
}
|
||||
|
||||
it->iterator.version = EINA_ITERATOR_VERSION;
|
||||
it->iterator.next = FUNC_ITERATOR_NEXT(_eina_file_direct_ls_iterator_next);
|
||||
it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(
|
||||
_eina_file_direct_ls_iterator_container);
|
||||
|
|
|
@ -1632,6 +1632,7 @@ eina_hash_iterator_data_new(const Eina_Hash *hash)
|
|||
it->hash = hash;
|
||||
it->get_content = FUNC_ITERATOR_GET_CONTENT(_eina_hash_iterator_data_get_content);
|
||||
|
||||
it->iterator.version = EINA_ITERATOR_VERSION;
|
||||
it->iterator.next = FUNC_ITERATOR_NEXT(_eina_hash_iterator_next);
|
||||
it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(
|
||||
_eina_hash_iterator_get_container);
|
||||
|
@ -1682,6 +1683,7 @@ eina_hash_iterator_key_new(const Eina_Hash *hash)
|
|||
it->get_content = FUNC_ITERATOR_GET_CONTENT(
|
||||
_eina_hash_iterator_key_get_content);
|
||||
|
||||
it->iterator.version = EINA_ITERATOR_VERSION;
|
||||
it->iterator.next = FUNC_ITERATOR_NEXT(_eina_hash_iterator_next);
|
||||
it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(
|
||||
_eina_hash_iterator_get_container);
|
||||
|
@ -1723,7 +1725,6 @@ eina_hash_iterator_tuple_new(const Eina_Hash *hash)
|
|||
EINA_SAFETY_ON_NULL_RETURN_VAL(hash, NULL);
|
||||
EINA_MAGIC_CHECK_HASH(hash);
|
||||
|
||||
|
||||
eina_error_set(0);
|
||||
it = calloc(1, sizeof (Eina_Iterator_Hash));
|
||||
if (!it)
|
||||
|
@ -1736,6 +1737,7 @@ eina_hash_iterator_tuple_new(const Eina_Hash *hash)
|
|||
it->get_content = FUNC_ITERATOR_GET_CONTENT(
|
||||
_eina_hash_iterator_tuple_get_content);
|
||||
|
||||
it->iterator.version = EINA_ITERATOR_VERSION;
|
||||
it->iterator.next = FUNC_ITERATOR_NEXT(_eina_hash_iterator_next);
|
||||
it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(
|
||||
_eina_hash_iterator_get_container);
|
||||
|
|
|
@ -637,6 +637,7 @@ eina_inlist_iterator_new(const Eina_Inlist *list)
|
|||
it->head = list;
|
||||
it->current = list;
|
||||
|
||||
it->iterator.version = EINA_ITERATOR_VERSION;
|
||||
it->iterator.next = FUNC_ITERATOR_NEXT(eina_inlist_iterator_next);
|
||||
it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(
|
||||
eina_inlist_iterator_get_container);
|
||||
|
@ -676,6 +677,7 @@ eina_inlist_accessor_new(const Eina_Inlist *list)
|
|||
it->current = list;
|
||||
it->index = 0;
|
||||
|
||||
it->accessor.version = EINA_ACCESSOR_VERSION;
|
||||
it->accessor.get_at = FUNC_ACCESSOR_GET_AT(eina_inlist_accessor_get_at);
|
||||
it->accessor.get_container = FUNC_ACCESSOR_GET_CONTAINER(
|
||||
eina_inlist_accessor_get_container);
|
||||
|
|
|
@ -2078,6 +2078,7 @@ eina_list_iterator_new(const Eina_List *list)
|
|||
it->head = list;
|
||||
it->current = list;
|
||||
|
||||
it->iterator.version = EINA_ITERATOR_VERSION;
|
||||
it->iterator.next = FUNC_ITERATOR_NEXT(eina_list_iterator_next);
|
||||
it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(
|
||||
eina_list_iterator_get_container);
|
||||
|
@ -2127,6 +2128,7 @@ eina_list_iterator_reversed_new(const Eina_List *list)
|
|||
it->head = eina_list_last(list);
|
||||
it->current = it->head;
|
||||
|
||||
it->iterator.version = EINA_ITERATOR_VERSION;
|
||||
it->iterator.next = FUNC_ITERATOR_NEXT(eina_list_iterator_prev);
|
||||
it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(
|
||||
eina_list_iterator_get_container);
|
||||
|
@ -2167,6 +2169,7 @@ eina_list_accessor_new(const Eina_List *list)
|
|||
it->current = list;
|
||||
it->index = 0;
|
||||
|
||||
it->accessor.version = EINA_ACCESSOR_VERSION;
|
||||
it->accessor.get_at = FUNC_ACCESSOR_GET_AT(eina_list_accessor_get_at);
|
||||
it->accessor.get_container = FUNC_ACCESSOR_GET_CONTAINER(
|
||||
eina_list_accessor_get_container);
|
||||
|
|
|
@ -1608,6 +1608,7 @@ eina_matrixsparse_iterator_new(const Eina_Matrixsparse *m)
|
|||
it->ref.row = m->rows;
|
||||
it->ref.col = m->rows ? m->rows->cols : NULL;
|
||||
|
||||
it->iterator.version = EINA_ITERATOR_VERSION;
|
||||
it->iterator.next = FUNC_ITERATOR_NEXT(_eina_matrixsparse_iterator_next);
|
||||
it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(
|
||||
_eina_matrixsparse_iterator_get_container);
|
||||
|
@ -1670,6 +1671,7 @@ eina_matrixsparse_iterator_complete_new(const Eina_Matrixsparse *m)
|
|||
it->dummy.col.parent = &it->dummy.row;
|
||||
EINA_MAGIC_SET(&it->dummy.col, EINA_MAGIC_MATRIXSPARSE_CELL);
|
||||
|
||||
it->iterator.version = EINA_ITERATOR_VERSION;
|
||||
it->iterator.next = FUNC_ITERATOR_NEXT(
|
||||
_eina_matrixsparse_iterator_complete_next);
|
||||
it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(
|
||||
|
|
|
@ -204,6 +204,7 @@ _eina_rbtree_iterator_build(const Eina_Rbtree *root, unsigned char mask)
|
|||
|
||||
it->mask = mask;
|
||||
|
||||
it->iterator.version = EINA_ITERATOR_VERSION;
|
||||
it->iterator.next = FUNC_ITERATOR_NEXT(_eina_rbtree_iterator_next);
|
||||
it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(
|
||||
_eina_rbtree_iterator_get_content);
|
||||
|
|
|
@ -1190,6 +1190,7 @@ EAPI Eina_Iterator *eina_tiler_iterator_new(const Eina_Tiler *t)
|
|||
Eina_Iterator_Tiler *it;
|
||||
|
||||
EINA_MAGIC_CHECK_TILER(t, NULL);
|
||||
|
||||
it = calloc(1, sizeof (Eina_Iterator_Tiler));
|
||||
if (!it)
|
||||
return NULL;
|
||||
|
@ -1209,6 +1210,8 @@ EAPI Eina_Iterator *eina_tiler_iterator_new(const Eina_Tiler *t)
|
|||
}
|
||||
|
||||
it->curr = it->tiler->splitter.rects.head;
|
||||
|
||||
it->iterator.version = EINA_ITERATOR_VERSION;
|
||||
it->iterator.next = FUNC_ITERATOR_NEXT(_iterator_next);
|
||||
it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(
|
||||
_iterator_get_container);
|
||||
|
@ -1282,6 +1285,7 @@ eina_tile_grid_slicer_iterator_new(int x,
|
|||
|
||||
EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_ITERATOR);
|
||||
|
||||
it->iterator.version = EINA_ITERATOR_VERSION;
|
||||
it->iterator.next = FUNC_ITERATOR_NEXT(eina_tile_grid_slicer_iterator_next);
|
||||
it->iterator.free = FUNC_ITERATOR_FREE(eina_tile_grid_slicer_iterator_free);
|
||||
|
||||
|
|
|
@ -78,7 +78,7 @@ START_TEST(eina_array_static)
|
|||
|
||||
eina_init();
|
||||
|
||||
eina_array_step_set(&sea, 10);
|
||||
eina_array_step_set(&sea, sizeof(sea), 10);
|
||||
|
||||
for (i = 0; i < 200; ++i)
|
||||
{
|
||||
|
|
|
@ -155,15 +155,20 @@ evas_new(void)
|
|||
e->hinting = EVAS_FONT_HINTING_BYTECODE;
|
||||
e->name_hash = eina_hash_string_superfast_new(NULL);
|
||||
|
||||
eina_array_step_set(&e->delete_objects, 256);
|
||||
eina_array_step_set(&e->active_objects, 256);
|
||||
eina_array_step_set(&e->restack_objects, 256);
|
||||
eina_array_step_set(&e->render_objects, 256);
|
||||
eina_array_step_set(&e->pending_objects, 256);
|
||||
eina_array_step_set(&e->obscuring_objects, 256);
|
||||
eina_array_step_set(&e->temporary_objects, 256);
|
||||
eina_array_step_set(&e->calculate_objects, 256);
|
||||
eina_array_step_set(&e->clip_changes, 256);
|
||||
#define EVAS_ARRAY_SET(E, Array) \
|
||||
eina_array_step_set(&E->Array, sizeof (E->Array), 256);
|
||||
|
||||
EVAS_ARRAY_SET(e, delete_objects);
|
||||
EVAS_ARRAY_SET(e, active_objects);
|
||||
EVAS_ARRAY_SET(e, restack_objects);
|
||||
EVAS_ARRAY_SET(e, render_objects);
|
||||
EVAS_ARRAY_SET(e, pending_objects);
|
||||
EVAS_ARRAY_SET(e, obscuring_objects);
|
||||
EVAS_ARRAY_SET(e, temporary_objects);
|
||||
EVAS_ARRAY_SET(e, calculate_objects);
|
||||
EVAS_ARRAY_SET(e, clip_changes);
|
||||
|
||||
#undef EVAS_ARRAY_SET
|
||||
|
||||
return e;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue