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);
*/
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 */
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);
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);
EINA_MAGIC_SET(array, EINA_MAGIC_ARRAY);
+ array->version = EINA_ARRAY_VERSION;
array->data = NULL;
array->total = 0;
array->count = 0;
* @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
* 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;
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);
EINA_SAFETY_ON_NULL_RETURN_VAL(array, NULL);
EINA_MAGIC_CHECK_ARRAY(array);
- eina_error_set(0);
+ eina_error_set(0);
it = calloc(1, sizeof (Eina_Accessor_Array));
if (!it)
{
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);
if (length < 1)
return NULL;
- it = malloc(sizeof (Eina_File_Iterator) + length);
+ it = calloc(1, sizeof (Eina_File_Iterator) + length);
if (!it)
return NULL;
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);
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;
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);
EINA_SAFETY_ON_NULL_RETURN_VAL(hash, NULL);
EINA_MAGIC_CHECK_HASH(hash);
- eina_error_set(0);
+ eina_error_set(0);
it = calloc(1, sizeof (Eina_Iterator_Hash));
if (!it)
{
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);
EINA_SAFETY_ON_NULL_RETURN_VAL(hash, NULL);
EINA_MAGIC_CHECK_HASH(hash);
- eina_error_set(0);
+ eina_error_set(0);
it = calloc(1, sizeof (Eina_Iterator_Hash));
if (!it)
{
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);
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)
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);
{
Eina_Iterator_Inlist *it;
- eina_error_set(0);
+ eina_error_set(0);
it = calloc(1, sizeof (Eina_Iterator_Inlist));
if (!it)
{
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);
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);
{
Eina_Iterator_List *it;
- eina_error_set(0);
+ eina_error_set(0);
it = calloc(1, sizeof (Eina_Iterator_List));
if (!it)
{
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);
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);
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);
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);
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(
Eina_Iterator_Rbtree_List *first;
Eina_Iterator_Rbtree *it;
- eina_error_set(0);
+ eina_error_set(0);
it = calloc(1, sizeof (Eina_Iterator_Rbtree));
if (!it)
{
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);
Eina_Iterator_Tiler *it;
EINA_MAGIC_CHECK_TILER(t, NULL);
+
it = calloc(1, sizeof (Eina_Iterator_Tiler));
if (!it)
return NULL;
}
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);
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);
eina_init();
- eina_array_step_set(&sea, 10);
+ eina_array_step_set(&sea, sizeof(sea), 10);
for (i = 0; i < 200; ++i)
{