EAPI Eina_Accessor * eina_inarray_accessor_new(const Eina_Inarray *array) { Eina_Accessor_Inarray *ac; EINA_MAGIC_CHECK_INARRAY(array, NULL); eina_error_set(0); ac = calloc(1, sizeof(Eina_Accessor_Inarray)); if (!ac) { eina_error_set(EINA_ERROR_OUT_OF_MEMORY); return NULL; } EINA_MAGIC_SET(ac, EINA_MAGIC_INARRAY_ACCESSOR); EINA_MAGIC_SET(&ac->accessor, EINA_MAGIC_ACCESSOR); ac->array = array; ac->accessor.version = EINA_ACCESSOR_VERSION; ac->accessor.get_at = FUNC_ACCESSOR_GET_AT(_eina_inarray_accessor_get_at); ac->accessor.get_container = FUNC_ACCESSOR_GET_CONTAINER (_eina_inarray_accessor_get_container); ac->accessor.free = FUNC_ACCESSOR_FREE(_eina_inarray_accessor_free); return &ac->accessor; }
/** * @brief Returns a new accessor associated to a list. * * @param list The list. * @return A new accessor. * * This function returns a newly allocated accessor associated to * @p list. If @p list is @c NULL or the count member of @p list is * less or equal than 0, this function returns NULL. If the memory can * not be allocated, NULL is returned and #EINA_ERROR_OUT_OF_MEMORY is * set. Otherwise, a valid accessor is returned. */ EAPI Eina_Accessor * eina_inlist_accessor_new(const Eina_Inlist *list) { Eina_Accessor_Inlist *ac; eina_error_set(0); ac = calloc(1, sizeof (Eina_Accessor_Inlist)); if (!ac) { eina_error_set(EINA_ERROR_OUT_OF_MEMORY); return NULL; } ac->head = list; ac->current = list; ac->index = 0; ac->accessor.version = EINA_ACCESSOR_VERSION; ac->accessor.get_at = FUNC_ACCESSOR_GET_AT(eina_inlist_accessor_get_at); ac->accessor.get_container = FUNC_ACCESSOR_GET_CONTAINER( eina_inlist_accessor_get_container); ac->accessor.free = FUNC_ACCESSOR_FREE(eina_inlist_accessor_free); EINA_MAGIC_SET(&ac->accessor, EINA_MAGIC_ACCESSOR); return &ac->accessor; }