Eina.h   Eina.h 
/* EINA - EFL data type library /* EINA - EFL data type library
* Copyright (C) 2008-2010 Enlightenment Developers: * Copyright (C) 2008-2011 Enlightenment Developers:
* Albin "Lutin" Tonnerre <albin.tonnerre@gmail.com> * Albin "Lutin" Tonnerre <albin.tonnerre@gmail.com>
* Alexandre "diaxen" Becoulet <diaxen@free.fr> * Alexandre "diaxen" Becoulet <diaxen@free.fr>
* Andre Dieb <andre.dieb@gmail.com> * Andre Dieb <andre.dieb@gmail.com>
* Arnaud de Turckheim "quarium" <quarium@gmail.com> * Arnaud de Turckheim "quarium" <quarium@gmail.com>
* Carsten Haitzler <raster@rasterman.com> * Carsten Haitzler <raster@rasterman.com>
* Cedric Bail <cedric.bail@free.fr> * Cedric Bail <cedric.bail@free.fr>
* Corey "atmos" Donohoe <atmos@atmos.org> * Corey "atmos" Donohoe <atmos@atmos.org>
* Fabiano Fidêncio <fidencio@profusion.mobi> * Fabiano Fidêncio <fidencio@profusion.mobi>
* Gustavo Chaves <glima@profusion.mobi> * Gustavo Chaves <glima@profusion.mobi>
* Gustavo Sverzut Barbieri <barbieri@gmail.com> * Gustavo Sverzut Barbieri <barbieri@gmail.com>
skipping to change at line 39 skipping to change at line 39
* *
* You should have received a copy of the GNU Lesser General Public * You should have received a copy of the GNU Lesser General Public
* License along with this library; * License along with this library;
* if not, see <http://www.gnu.org/licenses/>. * if not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef EINA_H_ #ifndef EINA_H_
#define EINA_H_ #define EINA_H_
/** /**
* @file
* @brief Eina Utility library
*
* These routines are used for Eina.
*/
/**
* @mainpage Eina * @mainpage Eina
* *
* @author Albin "Lutin" Tonnerre <albin.tonnerre@@gmail.com> * @version 1.1
* @author Alexandre "diaxen" Becoulet <diaxen@@free.fr> * @date 2008-2011
* @author Andre Dieb <andre.dieb@@gmail.com>
* @author Arnaud de Turckheim "quarium" <quarium@@gmail.com>
* @author Carsten Haitzler <raster@@rasterman.com>
* @author Cedric Bail <cedric.bail@@free.fr>
* @author Corey "atmos" Donohoe <atmos@@atmos.org>
* @author Fabiano Fidêncio <fidencio@@profusion.mobi>
* @author Gustavo Chaves <glima@@profusion.mobi>
* @author Gustavo Sverzut Barbieri <barbieri@@profusion.mobi>
* @author Jorge Luis "turran" Zapata <jorgeluis.zapata@@gmail.com>
* @author Peter "pfritz" Wehrfritz <peter.wehrfritz@@web.de>
* @author Raphael Kubo da Costa <kubo@@profusion.mobi>
* @author Tilman Sauerbeck <tilman@@code-monkey.de>
* @author Vincent "caro" Torri <vtorri at univ-evry dot fr>
* @author Tom Hacohen <tom@@stosb.com>
* @date 2008-2010
* *
* @section eina_intro_sec Introduction * @section eina_intro_sec Introduction
* *
* The Eina library is a library that implements an API for data types * The Eina library is a library that implements an API for data types
* in an efficient way. It also provides some useful tools like * in an efficient way. It also provides some useful tools like
* openin shared libraries, errors management, type conversion, * opening shared libraries, errors management, type conversion,
* time accounting and memory pool. * time accounting and memory pool.
* *
* This library is cross-platform and can be compiled and used on * This library is cross-platform and can be compiled and used on
* Linux, BSD, Opensolaris and Windows (XP and CE). * Linux, BSD, Opensolaris and Windows (XP and CE).
* *
* The data types that are available are (see @ref Eina_Data_Types_Group): * The data types that are available are (see @ref Eina_Data_Types_Group):
* @li @ref Eina_Array_Group standard array of @c void* data. * @li @ref Eina_Array_Group standard array of @c void* data.
* @li @ref Eina_Hash_Group standard hash of @c void* data. * @li @ref Eina_Hash_Group standard hash of @c void* data.
* @li @ref Eina_Inline_List_Group list with nodes inlined into user type. * @li @ref Eina_Inline_List_Group list with nodes inlined into user type.
* @li @ref Eina_CList_Group compact inlined list.
* @li @ref Eina_List_Group standard list of @c void* data. * @li @ref Eina_List_Group standard list of @c void* data.
* @li @ref Eina_Iterator_Group Iterator functions.
* @li @ref Eina_Matrixsparse_Group sparse matrix of @c void* data. * @li @ref Eina_Matrixsparse_Group sparse matrix of @c void* data.
* @li @ref Eina_Rbtree_Group red-black tree with nodes inlined into user t ype. * @li @ref Eina_Rbtree_Group red-black tree with nodes inlined into user t ype.
* @li @ref Eina_String_Buffer_Group mutable string to prepend, insert or a ppend strings to a buffer. * @li @ref Eina_String_Buffer_Group mutable string to prepend, insert or a ppend strings to a buffer.
* @li @ref Eina_Stringshare_Group saves memory by sharing read-only string references. * @li @ref Eina_Stringshare_Group saves memory by sharing read-only string references.
* @li @ref Eina_Tiler_Group split, merge and navigates into 2D tiled regio ns. * @li @ref Eina_Tiler_Group split, merge and navigates into 2D tiled regio ns.
* @li @ref Eina_Trash_Group container of unused but allocated data. * @li @ref Eina_Trash_Group container of unused but allocated data.
* *
* The tools that are available are (see @ref Eina_Tools_Group): * The tools that are available are (see @ref Eina_Tools_Group):
* @li @ref Eina_Benchmark_Group helper to write benchmarks. * @li @ref Eina_Benchmark_Group helper to write benchmarks.
* @li @ref Eina_Convert_Group faster conversion from strings to integers, double, etc. * @li @ref Eina_Convert_Group faster conversion from strings to integers, double, etc.
skipping to change at line 96 skipping to change at line 90
* @li @ref Eina_File_Group simple file list and path split. * @li @ref Eina_File_Group simple file list and path split.
* @li @ref Eina_Lalloc_Group simple lazy allocator. * @li @ref Eina_Lalloc_Group simple lazy allocator.
* @li @ref Eina_Log_Group full-featured logging system. * @li @ref Eina_Log_Group full-featured logging system.
* @li @ref Eina_Magic_Group provides runtime type checking. * @li @ref Eina_Magic_Group provides runtime type checking.
* @li @ref Eina_Memory_Pool_Group abstraction for various memory allocator s. * @li @ref Eina_Memory_Pool_Group abstraction for various memory allocator s.
* @li @ref Eina_Module_Group lists, loads and share modules using Eina_Mod ule standard. * @li @ref Eina_Module_Group lists, loads and share modules using Eina_Mod ule standard.
* @li @ref Eina_Rectangle_Group rectangle structure and standard manipulat ion methods. * @li @ref Eina_Rectangle_Group rectangle structure and standard manipulat ion methods.
* @li @ref Eina_Safety_Checks_Group extra checks that will report unexpect ed conditions and can be disabled at compile time. * @li @ref Eina_Safety_Checks_Group extra checks that will report unexpect ed conditions and can be disabled at compile time.
* @li @ref Eina_String_Group a set of functions that manages C strings. * @li @ref Eina_String_Group a set of functions that manages C strings.
* *
* @defgroup Eina_Data_Types_Group Data types. * Please see the @ref authors page for contact details.
*
* @defgroup Eina_Data_Types_Group Data types
* *
* Eina provide easy to use and optimized data types and structures. * Eina provide easy to use and optimized data types and structures.
* *
* *
* @defgroup Eina_Containers_Group Containers * @defgroup Eina_Containers_Group Containers
* *
* Containers are data types that hold data and allow iteration over * Containers are data types that hold data and allow iteration over
* their elements with an @ref Eina_Iterator_Group, or eventually an * their elements with an @ref Eina_Iterator_Group, or eventually an
* @ref Eina_Accessor_Group. * @ref Eina_Accessor_Group.
* *
* *
* @defgroup Eina_Tools_Group Tools * @defgroup Eina_Tools_Group Tools
* *
* Eina tools aims to help application development, providing ways to * Eina tools aims to help application development, providing ways to
* make it safer, log errors, manage memory more efficiently and more. * make it safer, log errors, manage memory more efficiently and more.
*
*/ */
#include <dirent.h> /**
*
* @page authors Authors
*
* @author Albin "Lutin" Tonnerre <albin.tonnerre@@gmail.com>
* @author Alexandre "diaxen" Becoulet <diaxen@@free.fr>
* @author Andre Dieb <andre.dieb@@gmail.com>
* @author Arnaud de Turckheim "quarium" <quarium@@gmail.com>
* @author Carsten Haitzler <raster@@rasterman.com>
* @author Cedric Bail <cedric.bail@@free.fr>
* @author Corey "atmos" Donohoe <atmos@@atmos.org>
* @author Fabiano Fidêncio <fidencio@@profusion.mobi>
* @author Gustavo Chaves <glima@@profusion.mobi>
* @author Gustavo Sverzut Barbieri <barbieri@@profusion.mobi>
* @author Jorge Luis "turran" Zapata <jorgeluis.zapata@@gmail.com>
* @author Peter "pfritz" Wehrfritz <peter.wehrfritz@@web.de>
* @author Raphael Kubo da Costa <kubo@@profusion.mobi>
* @author Tilman Sauerbeck <tilman@@code-monkey.de>
* @author Vincent "caro" Torri <vtorri at univ-evry dot fr>
* @author Tom Hacohen <tom@@stosb.com>
*
* Please contact <enlightenment-devel@lists.sourceforge.net> to get in
* contact with the developers and maintainers.
*
*/
#ifdef _WIN32 #ifdef _WIN32
# include <Evil.h> # include <Evil.h>
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
#include "eina_config.h" #include "eina_config.h"
#include "eina_types.h" #include "eina_types.h"
#include "eina_main.h" #include "eina_main.h"
#include "eina_fp.h" #include "eina_fp.h"
#include "eina_rectangle.h" #include "eina_rectangle.h"
#include "eina_clist.h"
#include "eina_inlist.h" #include "eina_inlist.h"
#include "eina_file.h" #include "eina_file.h"
#include "eina_list.h" #include "eina_list.h"
#include "eina_hash.h" #include "eina_hash.h"
#include "eina_trash.h" #include "eina_trash.h"
#include "eina_lalloc.h" #include "eina_lalloc.h"
#include "eina_module.h" #include "eina_module.h"
#include "eina_mempool.h" #include "eina_mempool.h"
#include "eina_error.h" #include "eina_error.h"
#include "eina_log.h" #include "eina_log.h"
skipping to change at line 157 skipping to change at line 179
#include "eina_iterator.h" #include "eina_iterator.h"
#include "eina_benchmark.h" #include "eina_benchmark.h"
#include "eina_convert.h" #include "eina_convert.h"
#include "eina_cpu.h" #include "eina_cpu.h"
#include "eina_sched.h" #include "eina_sched.h"
#include "eina_tiler.h" #include "eina_tiler.h"
#include "eina_hamster.h" #include "eina_hamster.h"
#include "eina_matrixsparse.h" #include "eina_matrixsparse.h"
#include "eina_str.h" #include "eina_str.h"
#include "eina_strbuf.h" #include "eina_strbuf.h"
#include "eina_binbuf.h"
#include "eina_ustrbuf.h" #include "eina_ustrbuf.h"
#include "eina_unicode.h" #include "eina_unicode.h"
#include "eina_quadtree.h" #include "eina_quadtree.h"
#include "eina_simple_xml_parser.h"
#include "eina_lock.h"
#include "eina_prefix.h"
#include "eina_refcount.h"
#include "eina_mmap.h"
#include "eina_xattr.h"
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif /* EINA_H */ #endif /* EINA_H */
 End of changes. 12 change blocks. 
21 lines changed or deleted 50 lines changed or added


 eina_accessor.h   eina_accessor.h 
skipping to change at line 28 skipping to change at line 28
#ifndef EINA_ACCESSOR_H__ #ifndef EINA_ACCESSOR_H__
#define EINA_ACCESSOR_H__ #define EINA_ACCESSOR_H__
#include "eina_config.h" #include "eina_config.h"
#include "eina_types.h" #include "eina_types.h"
#include "eina_magic.h" #include "eina_magic.h"
/** /**
* @page eina_accessor_example_01_page Eina_Accessor usage
* @dontinclude eina_accessor_01.c
*
* We start by including necessary headers, declaring variables and
* initializing eina:
* @skip #include
* @until eina_init
*
* Next we populate our array and list:
* @until }
*
* Now that we have two containers populated we can actually start the exam
ple
* and create an accessor:
* @until accessor_new
*
* Once having the accessor we can use it to access certain elements in the
* container:
* @until }
* @note Unlike iterators accessors allow us non-linear access, which allow
s us
* to print only the odd elements in the container.
*
* As with every other resource we allocate we need to free the accessor(an
d the
* array):
* @until array_free
*
* Now we create another accessor, this time for the list:
* @until accessor_new
*
* And now the interesting bit, we use the same code we used above to print
* parts of the array to print parts of the list:
* @until }
*
* And to free the list we use a gimmick, instead of freeing @a list, we as
k the
* accessor for it's container and free that:
* @until list_free
*
* Finally we shut eina down and leave:
* @until }
*
* The full source code can be found on the examples folder
* on the @ref eina_accessor_01_c "eina_accessor_01.c" file.
*/
/**
* @page eina_accessor_01_c Eina_Accessor usage example
*
* @include eina_accessor_01.c
* @example eina_accessor_01.c
*/
/**
* @addtogroup Eina_Accessor_Group Accessor Functions
*
* @brief These functions manage accessor on containers.
*
* These functions allow to access elements of a container in a
* generic way, without knowing which container is used (a bit like
* iterators in the C++ STL). Accessors allows random access (that is, any
* element in the container). For sequential access, see
* @ref Eina_Iterator_Group.
*
* An accessor is created from container data types, so no creation
* function is available here. An accessor is deleted with
* eina_accessor_free(). To get the data of an element at a given
* position, use eina_accessor_data_get(). To call a function on
* chosen elements of a container, use eina_accessor_over().
*
* See an example @ref eina_accessor_example_01_page "here".
*/
/**
* @addtogroup Eina_Content_Access_Group Content Access * @addtogroup Eina_Content_Access_Group Content Access
* *
* @{ * @{
*/ */
/** /**
* @defgroup Eina_Accessor_Group Accessor Functions * @defgroup Eina_Accessor_Group Accessor Functions
* *
* @{ * @{
*/ */
skipping to change at line 71 skipping to change at line 142
* Type for a callback that frees the container. * Type for a callback that frees the container.
*/ */
typedef void (*Eina_Accessor_Free_Callback)(Eina_Accessor *it); typedef void (*Eina_Accessor_Free_Callback)(Eina_Accessor *it);
/** /**
* @typedef Eina_Accessor_Lock_Callback * @typedef Eina_Accessor_Lock_Callback
* Type for a callback that lock the container. * Type for a callback that lock the container.
*/ */
typedef Eina_Bool (*Eina_Accessor_Lock_Callback)(Eina_Accessor *it); typedef Eina_Bool (*Eina_Accessor_Lock_Callback)(Eina_Accessor *it);
/**
* @struct _Eina_Accessor
* Type to provide random access to data structures.
*/
struct _Eina_Accessor struct _Eina_Accessor
{ {
#define EINA_ACCESSOR_VERSION 1 #define EINA_ACCESSOR_VERSION 1
int version; /**< Version of the Access or API. */ int version; /**< Version of the Access or API. */
Eina_Accessor_Get_At_Callback get_at EINA_ARG_NONNULL(1, 3 ) EINA_WARN_UNUSED_RESULT; /**< Callback called when a data element is requ ested. */ Eina_Accessor_Get_At_Callback get_at EINA_ARG_NONNULL(1, 3 ) EINA_WARN_UNUSED_RESULT; /**< Callback called when a data element is requ ested. */
Eina_Accessor_Get_Container_Callback get_container EINA_ARG_NONNULL(1) E INA_WARN_UNUSED_RESULT; /**< Callback called when the container is requeste d. */ Eina_Accessor_Get_Container_Callback get_container EINA_ARG_NONNULL(1) E INA_WARN_UNUSED_RESULT; /**< Callback called when the container is requeste d. */
Eina_Accessor_Free_Callback free EINA_ARG_NONNULL(1); /**< Callback called when the container is freed. */ Eina_Accessor_Free_Callback free EINA_ARG_NONNULL(1); /**< Callback called when the container is freed. */
Eina_Accessor_Lock_Callback lock EINA_WARN_UNUSED_RESU LT; /**< Callback called when the container is locked. */ Eina_Accessor_Lock_Callback lock EINA_WARN_UNUSED_RESU LT; /**< Callback called when the container is locked. */
skipping to change at line 111 skipping to change at line 186
* Helper macro to cast @p Function to a Eina_Accessor_Free_Callback. * Helper macro to cast @p Function to a Eina_Accessor_Free_Callback.
*/ */
#define FUNC_ACCESSOR_FREE(Function) ((Eina_Accessor_Free_Callback )Function) #define FUNC_ACCESSOR_FREE(Function) ((Eina_Accessor_Free_Callback )Function)
/** /**
* @def FUNC_ACCESSOR_LOCK(Function) * @def FUNC_ACCESSOR_LOCK(Function)
* Helper macro to cast @p Function to a Eina_Iterator_Lock_Callback. * Helper macro to cast @p Function to a Eina_Iterator_Lock_Callback.
*/ */
#define FUNC_ACCESSOR_LOCK(Function) ((Eina_Accessor_Lock_Callback )Function) #define FUNC_ACCESSOR_LOCK(Function) ((Eina_Accessor_Lock_Callback )Function)
/**
* @brief Free an accessor.
*
* @param accessor The accessor to free.
*
* This function frees @p accessor if it is not @c NULL;
*/
EAPI void eina_accessor_free(Eina_Accessor *accessor) EINA_ARG_NONNULL (1); EAPI void eina_accessor_free(Eina_Accessor *accessor) EINA_ARG_NONNULL (1);
/**
* @brief Retrieve the data of an accessor at a given position.
*
* @param accessor The accessor.
* @param position The position of the element.
* @param data The pointer that stores the data to retrieve.
* @return #EINA_TRUE on success, #EINA_FALSE otherwise.
*
* This function retrieves the data of the element pointed by
* @p accessor at the porition @p position, and stores it in
* @p data. If @p accessor is @c NULL or if an error occurred,
* #EINA_FALSE is returned, otherwise EINA_TRUE is returned.
*/
EAPI Eina_Bool eina_accessor_data_get(Eina_Accessor *accessor, EAPI Eina_Bool eina_accessor_data_get(Eina_Accessor *accessor,
unsigned int position, unsigned int position,
void **data) EINA_ARG_NONNULL (1); void **data) EINA_ARG_NONNULL (1);
/**
* @brief Return the container of an accessor.
*
* @param accessor The accessor.
* @return The container which created the accessor.
*
* This function returns the container which created @p accessor. If
* @p accessor is @c NULL, this function returns @c NULL.
*/
EAPI void *eina_accessor_container_get(Eina_Accessor *accessor) EINA_ARG_NO NNULL(1) EINA_PURE; EAPI void *eina_accessor_container_get(Eina_Accessor *accessor) EINA_ARG_NO NNULL(1) EINA_PURE;
/**
* @brief Iterate over the container and execute a callback on chosen eleme
nts.
*
* @param accessor The accessor.
* @param cb The callback called on the chosen elements.
* @param start The position of the first element.
* @param end The position of the last element.
* @param fdata The data passed to the callback.
*
* This function iterates over the elements pointed by @p accessor,
* starting from the element at position @p start and ending to the
* element at position @p end. For Each element, the callback
* @p cb is called with the data @p fdata. If @p accessor is @c NULL
* or if @p start is greter or equal than @p end, the function returns
* immediately.
*/
EAPI void eina_accessor_over(Eina_Accessor *accessor, EAPI void eina_accessor_over(Eina_Accessor *accessor,
Eina_Each_Cb cb, Eina_Each_Cb cb,
unsigned int start, unsigned int start,
unsigned int end, unsigned int end,
const void *fdata) EINA_ARG_NONNULL(1, 2); const void *fdata) EINA_ARG_NONNULL(1, 2);
/**
* @brief Lock the container of the accessor.
*
* @param accessor The accessor.
* @return #EINA_TRUE on success, #EINA_FALSE otherwise.
*
* If the container of the @p accessor permits it, it will be locked. When
a
* container is locked calling eina_accessor_over() on it will return
* immediately. If @p accessor is @c NULL or if a problem occurred, #EINA_F
ALSE
* is returned, otherwise #EINA_TRUE is returned. If the container isn't
* lockable, it will return EINA_TRUE.
*
* @warning None of the existing eina data structures are lockable.
*/
EAPI Eina_Bool eina_accessor_lock(Eina_Accessor *accessor) EINA_ARG_NONNULL (1); EAPI Eina_Bool eina_accessor_lock(Eina_Accessor *accessor) EINA_ARG_NONNULL (1);
/**
* @brief Unlock the container of the accessor.
*
* @param accessor The accessor.
* @return #EINA_TRUE on success, #EINA_FALSE otherwise.
*
* If the container of the @p accessor permits it and was previously
* locked, it will be unlocked. If @p accessor is @c NULL or if a
* problem occurred, #EINA_FALSE is returned, otherwise #EINA_TRUE
* is returned. If the container is not lockable, it will return
* EINA_TRUE.
*
* @warning None of the existing eina data structures are lockable.
*/
EAPI Eina_Bool eina_accessor_unlock(Eina_Accessor *accessor) EINA_ARG_NONNU LL(1); EAPI Eina_Bool eina_accessor_unlock(Eina_Accessor *accessor) EINA_ARG_NONNU LL(1);
/** /**
* @def EINA_ACCESSOR_FOREACH * @def EINA_ACCESSOR_FOREACH
* @brief Macro to iterate over all elements easily. * @brief Macro to iterate over all elements easily.
* *
* @param accessor The accessor to use. * @param accessor The accessor to use.
* @param counter A counter used by eina_accessor_data_get() when * @param counter A counter used by eina_accessor_data_get() when
* iterating over the container. * iterating over the container.
* @param data Where to store * data, must be a pointer support getting * @param data Where to store * data, must be a pointer support getting
 End of changes. 8 change blocks. 
0 lines changed or deleted 160 lines changed or added


 eina_array.h   eina_array.h 
skipping to change at line 33 skipping to change at line 33
#include "eina_config.h" #include "eina_config.h"
#include "eina_types.h" #include "eina_types.h"
#include "eina_error.h" #include "eina_error.h"
#include "eina_iterator.h" #include "eina_iterator.h"
#include "eina_accessor.h" #include "eina_accessor.h"
#include "eina_magic.h" #include "eina_magic.h"
/** /**
* @page array_01_example_page Basic array usage
* @dontinclude eina_array_01.c
*
* For this example we add stdlib.h, stdio.h and string.h for some
* convenience functions. The first thing to do to be able to use an
* @ref Eina_Array is to include Eina.h:
* @skip #include
* @until Eina.h
*
* Here we have a callback that prints the element given to it:
* @until }
*
* Now we create our entry point and declare some variables, nothing especi
al:
* @until unsigned
*
* Before we can start using any array function we need to initialize eina:
* @until eina_init
*
* So now to actually creating our array. The only interesting thing here i
s the
* argument given to the eina_array_new() function, this argument sets how
fast
* the array grows.
* @until array_new
*
* If you know before hand how big the array will need to be you should set
the
* step to that. In our case we can set it to the number of string we have
and
* since we didn't do that in the eina_array_new() we can do it now:
* @until array_step_set
*
* Now let us populate our array with some strings:
* @until push
* @note Notice we use strdup, so we will have to free that memory later on
.
*
* Now lets check the size of the array:
* @until printf
*
* And now we call a function on every member of our array to print it:
* @until foreach
*
* One of the strenghts of @ref Eina_Array over @ref Eina_List is that it h
as
* very fast random access to elements, so this is very efficient:
* @until printf
*
* And now we free up the memory allocated with the strdup()s:
* @until free
*
* And the array memory itself:
* @until array_free
*
* And finally shutdown eina and exit:
* @until }
*
* The full source code can be found on the examples folder
* on the @ref eina_array_01_c "eina_array_01.c" file.
*/
/**
* @page eina_array_01_c Basic array usage example
*
* @include eina_array_01.c
* @example eina_array_01.c
*/
/**
* @page array_02_example_page Removing array elements
* @dontinclude eina_array_02.c
*
* Just the usual includes:
* @skip #include
* @until Eina.h
*
* This the callback we are going to use to decide which strings stay on th
e
* array and which will be removed, we use something simple, but this can b
e as
* complex as you like:
* @until }
*
* This is the same code we used before to populate the list with the sligh
t
* difference of not using strdup:
* @until array_push
*
* So we have added all our elements to the array, but it turns out that is
not
* the elements we wanted, so let's empty the array and add the correct str
ings:
* @until array_push
*
* It seems we made a little mistake in one of our strings so we need to re
place
* it, here is how:
* @until data_set
*
* Now that there is a populated array we can remove elements from it easil
y:
* @until array_remove
*
* And check that the elements were actually removed:
* @until printf
*
* Since this time we didn't use strdup we don't need to free each string:
* @until }
*
* The full source code can be found on the examples folder
* on the @ref eina_array_02_c "eina_array_02.c" file.
*/
/**
* @page eina_array_02_c Basic array usage example
*
* @include eina_array_02.c
* @example eina_array_02.c
*/
/**
* @addtogroup Eina_Array_Group Array
*
* @brief These functions provide array management.
*
* The Array data type in Eina is designed to have very fast access to
* its data (compared to the Eina @ref Eina_List_Group). On the other hand,
* data can be added or removed only at the end of the array. To insert
* data at any place, the Eina @ref Eina_List_Group is the correct containe
r
* to use.
*
* To use the array data type, eina_init() must be called before any
* other array functions. When no more eina array functions are used,
* eina_shutdown() must be called to free all the resources.
*
* An array must be created with eina_array_new(). It allocates all
* the necessary data for an array. When not needed anymore, an array
* is freed with eina_array_free(). This function does not free any
* allocated memory used to store the data of each element. For that,
* just iterate over the array to free them. A convenient way to do
* that is by using #EINA_ARRAY_ITER_NEXT. An example of code is given
* in the description of this macro.
*
* @warning Functions do not check if the used array is valid or not. It's
up to
* the user to be sure of that. It is designed like that for performance
* reasons.
*
* The usual features of an array are classic ones: to append an
* element, use eina_array_push() and to remove the last element, use
* eina_array_pop(). To retrieve the element at a given position, use
* eina_array_data_get(). The number of elements can be retrieved with
* eina_array_count_get().
*
* Eina_Array is different from a conventional C array in a number of ways,
most
* importantly they grow and shrink dynamically, this means that if you add
an
* element to a full array it grows and that when you remove an element fro
m an
* array it @b may shrink.
*
* When the array needs to grow it allocates memory not just for the elemen
t
* currently being added since that would mean allocating memory(which is
* computationally expensive) often, instead it grows to be able to hold @p
step
* more elements. Similarly if you remove elements in such a way that that
the
* array is left holding its capacity - @p step elements it will shrink.
*
* The following image illustrates how an Eina_Array grows:
*
* @image html eina_array-growth.png
* @image latex eina_array-growth.eps width=\textwidth
*
* Eina_Array only stores pointers but it can store data of any type in the
form
* of void pointers.
*
* See here some examples:
* @li @ref array_01_example_page
* @li @ref array_02_example_page
*/
/**
* @addtogroup Eina_Data_Types_Group Data Types * @addtogroup Eina_Data_Types_Group Data Types
* *
* @{ * @{
*/ */
/** /**
* @addtogroup Eina_Containers_Group Containers * @addtogroup Eina_Containers_Group Containers
* *
* @{ * @{
*/ */
skipping to change at line 78 skipping to change at line 243
#define EINA_ARRAY_VERSION 1 #define EINA_ARRAY_VERSION 1
int version; /**< Should match EINA_ARRAY_VERSION used when com piled your apps, provided for ABI compatibility */ int version; /**< Should match EINA_ARRAY_VERSION used when com piled your apps, provided for ABI compatibility */
void **data; /**< Pointer to a vector of pointer to payload */ void **data; /**< Pointer to a vector of pointer to payload */
unsigned int total; /**< Total number of slots in the vector */ unsigned int total; /**< Total number of slots in the vector */
unsigned int count; /**< Number of active slots in the vector */ unsigned int count; /**< Number of active slots in the vector */
unsigned int step; /**< How much must we grow the vector when it is full */ unsigned int step; /**< How much must we grow the vector when it is full */
EINA_MAGIC EINA_MAGIC
}; };
/**
* @brief Create a new array.
*
* @param step The count of pointers to add when increasing the array size.
* @return @c NULL on failure, non @c NULL otherwise.
*
* This function creates a new array. When adding an element, the array
* allocates @p step elements. When that buffer is full, then adding
* another element will increase the buffer by @p step elements again.
*
* This function return a valid array on success, or @c NULL if memory
* allocation fails. In that case, the error is set to
* #EINA_ERROR_OUT_OF_MEMORY.
*/
EAPI Eina_Array *eina_array_new(unsigned int step) EINA_WARN_UNUSED_RESULT EINA_MALLOC EINA_WARN_UNUSED_RESULT; EAPI Eina_Array *eina_array_new(unsigned int step) EINA_WARN_UNUSED_RESULT EINA_MALLOC EINA_WARN_UNUSED_RESULT;
/**
* @brief Free an array.
*
* @param array The array to free.
*
* This function frees @p array. It calls first eina_array_flush() then
* free the memory of the pointer. It does not free the memory
* allocated for the elements of @p array. To free them, use
* #EINA_ARRAY_ITER_NEXT. For performance reasons, there is no check
* of @p array.
*/
EAPI void eina_array_free(Eina_Array *array) EINA_ARG_NONNULL(1); EAPI void eina_array_free(Eina_Array *array) EINA_ARG_NONNULL(1);
/**
* @brief Set the step of an array.
*
* @param array The array.
* @param sizeof_eina_array Should be the value returned by sizeof(Eina_Arr
ay).
* @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
* reasons, there is no check of @p array. If it is @c NULL or
* invalid, the program may crash.
*
* @warning This function can @b only be called on uninitialized arrays.
*/
EAPI void eina_array_step_set(Eina_Array *array, EAPI void eina_array_step_set(Eina_Array *array,
unsigned int sizeof_eina_array, unsigned int sizeof_eina_array,
unsigned int step) EINA_ARG_NONNULL(1) ; unsigned int step) EINA_ARG_NONNULL(1) ;
/**
* @brief Clean an array.
*
* @param array The array to clean.
*
* This function sets the count member of @p array to 0, however it doesn't
free
* any space. This is particularly useful if you need to empty the array an
d
* add lots of elements quickly. For performance reasons, there is no check
of
* @p array. If it is @c NULL or invalid, the program may crash.
*/
static inline void eina_array_clean(Eina_Array *array) EINA_ARG_NONNULL(1); static inline void eina_array_clean(Eina_Array *array) EINA_ARG_NONNULL(1);
/**
* @brief Flush an array.
*
* @param array The array to flush.
*
* This function sets the count and total members of @p array to 0,
* frees and set to NULL its data member. For performance reasons,
* there is no check of @p array. If it is @c NULL or invalid, the
* program may crash.
*/
EAPI void eina_array_flush(Eina_Array *array) EINA_ARG_NONNULL(1); EAPI void eina_array_flush(Eina_Array *array) EINA_ARG_NONNULL(1);
/**
* @brief Rebuild an array by specifying the data to keep.
*
* @param array The array.
* @param keep The functions which selects the data to keep.
* @param gdata The data to pass to the function keep.
* @return #EINA_TRUE on success, #EINA_FALSE oterwise.
*
* This function rebuilds @p array be specifying the elements to keep with
the
* function @p keep. No empty/invalid fields are left in the array. @p gdat
a is
* an additional data to pass to @p keep. For performance reasons, there is
no
* check of @p array. If it is @c NULL or invalid, the program may crash.
*
* If it wasn't able to remove items due to an allocation failure, it will
* return #EINA_FALSE and the error is set to #EINA_ERROR_OUT_OF_MEMORY.
*/
EAPI Eina_Bool eina_array_remove(Eina_Array * array, EAPI Eina_Bool eina_array_remove(Eina_Array * array,
Eina_Bool (*keep)(void *data, void *gdata) , Eina_Bool (*keep)(void *data, void *gdata) ,
void *gdata) EINA_ARG_NONNULL(1, 2); void *gdata) EINA_ARG_NONNULL(1, 2);
static inline Eina_Bool eina_array_push(Eina_Array *array, static inline Eina_Bool eina_array_push(Eina_Array *array,
const void *data) EINA_ARG_NONNULL( 1, 2); const void *data) EINA_ARG_NONNULL( 1, 2);
static inline void *eina_array_pop(Eina_Array *array) EINA_ARG_NONNULL( 1); static inline void *eina_array_pop(Eina_Array *array) EINA_ARG_NONNULL( 1);
static inline void *eina_array_data_get(const Eina_Array *array, static inline void *eina_array_data_get(const Eina_Array *array,
unsigned int idx) EINA_ARG _NONNULL(1); unsigned int idx) EINA_ARG _NONNULL(1);
/**
* @brief Set the data at a given position in an array.
*
* @param array The array.
* @param idx The potition of the data to set.
* @param data The data to set.
*
* This function sets the data at the position @p idx in @p
* array to @p data, this effectively replaces the previously held data, yo
u
* must therefore get a pointer to it first if you need to free it. For
* performance reasons, there is no check of @p array or @p idx. If it is @
c
* NULL or invalid, the program may crash.
*/
static inline void eina_array_data_set(const Eina_Array *array, static inline void eina_array_data_set(const Eina_Array *array,
unsigned int idx, unsigned int idx,
const void *data) EINA_AR G_NONNULL(1); const void *data) EINA_AR G_NONNULL(1);
static inline unsigned int eina_array_count_get(const Eina_Array *array) EI NA_ARG_NONNULL(1); static inline unsigned int eina_array_count_get(const Eina_Array *array) EI NA_ARG_NONNULL(1);
/**
* @brief Returned a new iterator associated to an array.
*
* @param array The array.
* @return A new iterator.
*
* This function returns a newly allocated iterator associated to
* @p array. If @p array is @c NULL or the count member of @p array 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 iterator is returned.
*/
EAPI Eina_Iterator *eina_array_iterator_new(const Eina_Array *array) EINA_MALLOC EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT; EAPI Eina_Iterator *eina_array_iterator_new(const Eina_Array *array) EINA_MALLOC EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
/**
* @brief Returned a new accessor associated to an array.
*
* @param array The array.
* @return A new accessor.
*
* This function returns a newly allocated accessor associated to
* @p array. If @p array is @c NULL or the count member of @p array 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_array_accessor_new(const Eina_Array *array) EINA_MALLOC EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT; EAPI Eina_Accessor *eina_array_accessor_new(const Eina_Array *array) EINA_MALLOC EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
/**
* @brief Provide a safe way to iterate over an array
*
* @param array The array to iterate over.
* @param cb The callback to call for each item.
* @param fdata The user data to pass to the callback.
* @return EINA_TRUE if it successfully iterate all items of the array.
*
* This function provide a safe way to iterate over an array. @p cb should
* return EINA_TRUE as long as you want the function to continue iterating,
* by returning EINA_FALSE it will stop and return EINA_FALSE as a result.
*/
static inline Eina_Bool eina_array_foreach(Eina_Array *array, static inline Eina_Bool eina_array_foreach(Eina_Array *array,
Eina_Each_Cb cb, Eina_Each_Cb cb,
void *data); void *data);
/** /**
* @def EINA_ARRAY_ITER_NEXT * @def EINA_ARRAY_ITER_NEXT
* @brief Macro to iterate over an array easily. * @brief Macro to iterate over an array easily.
* *
* @param array The array to iterate over. * @param array The array to iterate over.
* @param index The integer number that is increased while itareting. * @param index The integer number that is increased while itareting.
* @param item The data * @param item The data
 End of changes. 11 change blocks. 
0 lines changed or deleted 326 lines changed or added


 eina_benchmark.h   eina_benchmark.h 
skipping to change at line 25 skipping to change at line 25
* License along with this library; * License along with this library;
* if not, see <http://www.gnu.org/licenses/>. * if not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef EINA_BENCHMARK_H_ #ifndef EINA_BENCHMARK_H_
#define EINA_BENCHMARK_H_ #define EINA_BENCHMARK_H_
#include "eina_array.h" #include "eina_array.h"
/** /**
* @page tutorial_benchmark_page Benchmark Tutorial
*
* The Benchmark module allows you to write easily benchmarks
* framework in a project for timing critical part and detect slow
* parts of code. In addition it automatically creates data files of
* these benchmark, as well as a gnuplot file which can display the
* comparison curves of the benchmarks.
*
* @section tutorial_benchmark_basic_usage Basic Usage
*
* To create a basic benchmark, you have to follow these steps:
*
* @li Create a new bechmark
* @li Write the functions that wraps the the functions you want to
* bechmark.
* @li Register these wrappers functions.
* @li Run the benchmark.
* @li Free the memory.
*
* Here is a basic example of bechmark which creates two functions
* that will be run. These functions just print a message.
*
* @code
* #include <stdlib.h>
* #include <stdio.h>
*
* #include <Eina.h>
*
* static
* void work1(int request)
* {
* printf ("work1 in progress... Request: %d\n", request);
* }
*
* static
* void work2(int request)
* {
* printf ("work2 in progress... Request: %d\n", request);
* }
*
* int main()
* {
* Eina_Benchmark *test;
* Eina_Array *ea;
*
* if (!eina_init())
* return EXIT_FAILURE;
*
* test = eina_benchmark_new("test", "run");
* if (!test)
* goto shutdown_eina;
*
* eina_benchmark_register(test, "work-1", EINA_BENCHMARK(work1), 200, 30
0, 10);
* eina_benchmark_register(test, "work-2", EINA_BENCHMARK(work2), 100, 15
0, 5);
*
* ea = eina_benchmark_run(test);
*
* eina_benchmark_free(test);
* eina_shutdown();
*
* return EXIT_SUCCESS;
*
* shutdown_eina:
* eina_shutdown();
*
* return EXIT_FAILURE;
* }
* @endcode
*
* As "test", "run" are passed to eina_benchmark_new() and as the tests
* "work-1" and "work-2" are registered, the data files
* bench_test_run.work-1.data and bench_test_run.work-2.data will be
* created after the eina_benchmark_run() call. They contain four
* columns. The file bench_test_run.work-1.data contains for example:
*
* @code
* # specimen experiment time starting time ending time
* 200 23632 2852446 2876078
* 210 6924 2883046 2889970
* 220 6467 2895962 2902429
* 230 6508 2908271 2914779
* 240 6278 2920610 2926888
* 250 6342 2932830 2939172
* 260 6252 2944954 2951206
* 270 6463 2956978 2963441
* 280 6347 2969548 2975895
* 290 6457 2981702 2988159
* @endcode
*
* The first column (specimen) is the integer passed to the work1()
* function when the test is run. The second column (experiment time)
* is the time, in nanosecond, that work1() takes. The third and
* fourth columnd are self-explicit.
*
* You can see that the integer passed work1() starts from 200 and
* finishes at 290, with a step of 10. These values are computed withe
* last 3 values passed to eina_benchmark_register(). See the document
* of that function for the detailed behavior.
*
* The gnuplot file will be named bench_test_run.gnuplot. Just run:
*
* @code
* gnuplot bench_test_run.gnuplot
* @endcode
*
* to create the graphic of the comparison curves. The image file is
* named output_test_run.png.
*
* @section tutorial_benchmark_advanced_usage More Advanced Usage
*
* In this section, several test will be created and run. The idea is
* exactly the same than in the previous section, but with some basic
* automatic way to run all the benchmarks. The following code
* benchmarks some Eina converts functions, and some Eina containers
* types:
*
* @code
* #include <stdlib.h>
* #include <stdio.h>
* #include <time.h>
*
* #include <Eina.h>
*
* static void bench_convert(Eina_Benchmark *bench);
* static void bench_container(Eina_Benchmark *bench);
*
* typedef struct _Benchmark_Case Benchmark_Case;
*
* struct _Benchmark_Case
* {
* const char *bench_case;
* void (*build)(Eina_Benchmark *bench);
* };
*
* static const Benchmark_Case benchmarks[] = {
* { "Bench 1", bench_convert },
* { "Bench 2", bench_container },
* { NULL, NULL }
* };
*
* static
* void convert1(int request)
* {
* char tmp[128];
* int i;
*
* srand(time(NULL));
*
* for (i = 0; i < request; ++i)
* eina_convert_itoa(rand(), tmp);
* }
*
* static
* void convert2(int request)
* {
* char tmp[128];
* int i;
*
* srand(time(NULL));
*
* for (i = 0; i < request; ++i)
* eina_convert_xtoa(rand(), tmp);
* }
*
* static void
* bench_convert(Eina_Benchmark *bench)
* {
* eina_benchmark_register(bench, "convert-1", EINA_BENCHMARK(convert1),
200, 400, 10);
* eina_benchmark_register(bench, "convert-2", EINA_BENCHMARK(convert2),
200, 400, 10);
* }
*
* static
* void array(int request)
* {
* Eina_Array *array;
* Eina_Array_Iterator it;
* int *data;
* int i;
*
* srand(time(NULL));
*
* array = eina_array_new(64);
*
* for (i = 0; i < request; ++i)
* {
* data = (int *)malloc(sizeof(int));
* if (!data) continue;
* *data = rand();
* eina_array_push(array, data);
* }
*
* EINA_ARRAY_ITER_NEXT(array, i, data, it)
* free(data);
*
* eina_array_free(array);
* }
*
* static
* void list(int request)
* {
* Eina_List *l = NULL;
* int *data;
* int i;
*
* srand(time(NULL));
*
* for (i = 0; i < request; ++i)
* {
* data = (int *)malloc(sizeof(int));
* if (!data) continue;
* *data = rand();
* l = eina_list_prepend(l, data);
* }
*
* while (l)
* {
* free(eina_list_data_get(l));
* l = eina_list_remove_list(l, l);
* }
* }
*
* static void
* bench_container(Eina_Benchmark *bench)
* {
* eina_benchmark_register(bench, "array", EINA_BENCHMARK(array), 200, 30
0, 10);
* eina_benchmark_register(bench, "list", EINA_BENCHMARK(list), 200, 300,
10);
* }
*
* int main()
* {
* Eina_Benchmark *test;
* Eina_Array *ea;
* unsigned int i;
*
* if (!eina_init())
* return EXIT_FAILURE;
*
* for (i = 0; benchmarks[i].bench_case != NULL; ++i)
* {
* test = eina_benchmark_new(benchmarks[i].bench_case, "Benchmark exa
mple");
* if (!test)
* continue;
*
* benchmarks[i].build(test);
*
* ea = eina_benchmark_run(test);
*
* eina_benchmark_free(test);
* }
*
* eina_shutdown();
*
* return EXIT_SUCCESS;
* }
* @endcode
*
* gnuplot can be used to see how are performed the convert functions
* together, as well as how are performed the containers. So it is now
* easy to see that the hexadecimal convert function is faster than
* the decimal one, and that arrays are faster than lists.
*
* You can improve all that by executing automatically gnuplot in your
* program, or integrate the Eina benchmark framework in an autotooled
* project. See that
* <a href="http://trac.enlightenment.org/e/wiki/AutotoolsIntegration#Bench
mark">page</a>
* for more informations.
*
*/
/**
* @addtogroup Eina_Benchmark_Group Benchmark
*
* These functions allow you to add benchmark framework in a project
* for timing critical part and detect slow parts of code. It is used
* in Eina to compare the time used by eina, glib, evas and ecore data
* types.
*
* To use the benchmark module, Eina must be initialized with
* eina_init() and later shut down with eina_shutdown(). A benchmark
* is created with eina_benchmark_new() and freed with
* eina_benchmark_free().
*
* eina_benchmark_register() adds a test to a benchmark. That test can
* be run a certain amount of times. Adding more than one test to be
* executed allows the comparison between several parts of a program,
* or different implementations.
*
* eina_benchmark_run() runs all the tests registered with
* eina_benchmark_register(). The amount of time of each test is
* written in a gnuplot file.
*
* For more information, you can look at the @ref tutorial_benchmark_page.
*/
/**
* @addtogroup Eina_Tools_Group Tools * @addtogroup Eina_Tools_Group Tools
* *
* @{ * @{
*/ */
/** /**
* @defgroup Eina_Benchmark_Group Benchmark * @defgroup Eina_Benchmark_Group Benchmark
* *
* @{ * @{
*/ */
skipping to change at line 58 skipping to change at line 353
/** /**
* @def EINA_BENCHMARK * @def EINA_BENCHMARK
* @brief cast to an #Eina_Benchmark_Specimens. * @brief cast to an #Eina_Benchmark_Specimens.
* *
* @param function The function to cast. * @param function The function to cast.
* *
* This macro casts @p function to Eina_Benchmark_Specimens. * This macro casts @p function to Eina_Benchmark_Specimens.
*/ */
#define EINA_BENCHMARK(function) ((Eina_Benchmark_Specimens)function) #define EINA_BENCHMARK(function) ((Eina_Benchmark_Specimens)function)
/**
* @brief Create a new array.
*
* @param name The name of the benchmark.
* @param run The name of the run.
* @return @c NULL on failure, non @c NULL otherwise.
*
* This function creates a new benchmark. @p name and @p run are used
* to name the gnuplot file that eina_benchmark_run() will create.
*
* This function return a valid benchmark on success, or @c NULL if
* memory allocation fails. In that case, the error is set to
* #EINA_ERROR_OUT_OF_MEMORY.
*
* When the new module is not needed anymore, use
* eina_benchmark_free() to free the allocated memory.
*/
EAPI Eina_Benchmark *eina_benchmark_new(const char *name, EAPI Eina_Benchmark *eina_benchmark_new(const char *name,
const char *run); const char *run);
/**
* @brief Free a benchmark object.
*
* @param bench The benchmark to free.
*
* This function removes all the benchmark tests that have been
* registered and frees @p bench. If @p bench is @c NULL, this
* function returns immediately.
*/
EAPI void eina_benchmark_free(Eina_Benchmark *bench); EAPI void eina_benchmark_free(Eina_Benchmark *bench);
/**
* @brief Add a test to a benchmark.
*
* @param bench The benchmark.
* @param name The name of the test.
* @param bench_cb The test function to be called.
* @param count_start The start data to be passed to @p bench_cb.
* @param count_end The end data to be passed to @p bench_cb.
* @param count_step The step data to be passed to @p bench_cb.
* @return #EINA_FALSE on failure, #EINA_TRUE otherwise.
*
* This function adds the test named @p name to @p benchmark. @p
* bench_cb is the function called when the test is executed. That
* test can be executed a certain amount of time. @p start, @p end and
* @p step define a loop with a step increment. The integer that is
* increasing by @p step from @p start to @p end is passed to @p
* bench_cb when eina_benchmark_run() is called.
*
* If @p bench is @c NULL, this function returns imediatly. If the
* allocation of the memory of the test to add fails, the error is set
* to #EINA_ERROR_OUT_OF_MEMORY. This function returns #EINA_FALSE
* on failure, #EINA_TRUE otherwise.
*/
EAPI Eina_Bool eina_benchmark_register(Eina_Benchmark *bench , EAPI Eina_Bool eina_benchmark_register(Eina_Benchmark *bench ,
const char *name, const char *name,
Eina_Benchmark_Specimens bench _cb, Eina_Benchmark_Specimens bench _cb,
int count _start, int count _start,
int count _end, int count _end,
int count _set); int count _set);
/**
* @brief Run the benchmark tests that have been registered.
*
* @param bench The benchmark.
* @return The list of names of the test files.
*
* This function runs all the tests that as been registered with
* eina_benchmark_register() and save the result in a gnuplot
* file. The name of the file has the following format:
*
* @code
* bench_[name]_[run]%s.gnuplot
* @endcode
*
* where [name] and [run] are the values passed to
* eina_benchmark_new().
*
* Each registered test is executed and timed. The time is written to
* the gnuplot file. The number of times each test is executed is
* controlled by the parameters passed to eina_benchmark_register().
*
* If @p bench is @c NULL, this functions returns @c NULL
* immediately. Otherwise, it returns the list of the names of each
* test.
*/
EAPI Eina_Array *eina_benchmark_run(Eina_Benchmark *bench); EAPI Eina_Array *eina_benchmark_run(Eina_Benchmark *bench);
/** /**
* @} * @}
*/ */
/** /**
* @} * @}
*/ */
 End of changes. 5 change blocks. 
0 lines changed or deleted 380 lines changed or added


 eina_binshare.h   eina_binshare.h 
skipping to change at line 57 skipping to change at line 57
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWA RE. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWA RE.
*/ */
#ifndef EINA_BINSHARE_H_ #ifndef EINA_BINSHARE_H_
#define EINA_BINSHARE_H_ #define EINA_BINSHARE_H_
#include "eina_types.h" #include "eina_types.h"
/** /**
* @page tutorial_binshare_page Binary Share Tutorial
*
* Should call eina_binshare_init() before usage and eina_binshare_shutdown
() after.
* to be written...
*
*/
/**
* @addtogroup Eina_Binshare_Group Binary Share
*
* These functions allow you to store one copy of an object, and use it
* throughout your program.
*
* This is a method to reduce the number of duplicated objects kept in
* memory.
*
* For more information, you can look at the @ref tutorial_binshare_page.
*/
/**
* @addtogroup Eina_Data_Types_Group Data Types * @addtogroup Eina_Data_Types_Group Data Types
* *
* @{ * @{
*/ */
/** /**
* @defgroup Eina_Binshare_Group Binary Share * @defgroup Eina_Binshare_Group Binary Share
* *
* @{ * @{
*/ */
/**
* @brief Retrieve an instance of an object for use in a program.
*
* @param obj The binary object to retrieve an instance of.
* @param olen The byte size
* @return A pointer to an instance of the object on success.
* @c NULL on failure.
*
* This function retrieves an instance of @p obj. If @p obj is
* @c NULL, then @c NULL is returned. If @p obj is already stored, it
* is just returned and its reference counter is increased. Otherwise
* it is added to the objects to be searched and a duplicated object
* of @p obj is returned.
*
* This function does not check object size, but uses the
* exact given size. This can be used to share part of a larger
* object or subobject.
*
* @see eina_binshare_add()
*/
EAPI const void *eina_binshare_add_length(const void *obj, EAPI const void *eina_binshare_add_length(const void *obj,
unsigned int olen) EINA_PURE EINA _WARN_UNUSED_RESULT; unsigned int olen) EINA_PURE EINA _WARN_UNUSED_RESULT;
/**
* Increment references of the given shared object.
*
* @param obj The shared object.
* @return A pointer to an instance of the object on success.
* @c NULL on failure.
*
* This is similar to eina_share_common_add(), but it's faster since it wil
l
* avoid lookups if possible, but on the down side it requires the paramete
r
* to be shared before, in other words, it must be the return of a previous
* eina_binshare_add().
*
* There is no unref since this is the work of eina_binshare_del().
*/
EAPI const void *eina_binshare_ref(const void *obj); EAPI const void *eina_binshare_ref(const void *obj);
/**
* @brief Note that the given object has lost an instance.
*
* @param obj object The given object.
*
* This function decreases the reference counter associated to @p obj
* if it exists. If that counter reaches 0, the memory associated to
* @p obj is freed. If @p obj is NULL, the function returns
* immediately.
*
* Note that if the given pointer is not shared or NULL, bad things
* will happen, likely a segmentation fault.
*/
EAPI void eina_binshare_del(const void *obj); EAPI void eina_binshare_del(const void *obj);
/**
* @brief Note that the given object @b must be shared.
*
* @param obj the shared object to know the length. It is safe to
* give NULL, in that case -1 is returned.
* @return The length of the shared object.
*
* This function is a cheap way to known the length of a shared
* object. Note that if the given pointer is not shared, bad
* things will happen, likely a segmentation fault. If in doubt, try
* strlen().
*/
EAPI int eina_binshare_length(const void *obj) EINA_WARN_UNUSED_RES ULT; EAPI int eina_binshare_length(const void *obj) EINA_WARN_UNUSED_RES ULT;
/**
* @brief Dump the contents of the share_common.
*
* This function dumps all objects in the share_common to stdout with a
* DDD: prefix per line and a memory usage summary.
*/
EAPI void eina_binshare_dump(void); EAPI void eina_binshare_dump(void);
/** /**
* @brief Retrieve an instance of a blob for use in a program. * @brief Retrieve an instance of a blob for use in a program.
* *
* @param ptr The binary blob to retrieve an instance of. * @param ptr The binary blob to retrieve an instance of.
* @return A pointer to an instance of the string on success. * @return A pointer to an instance of the string on success.
* @c NULL on failure. * @c NULL on failure.
* *
* This macro retrieves an instance of @p obj. If @p obj is * This macro retrieves an instance of @p obj. If @p obj is
 End of changes. 6 change blocks. 
0 lines changed or deleted 92 lines changed or added


 eina_config.h   eina_config.h 
skipping to change at line 46 skipping to change at line 46
#ifdef EINA_HAVE_INTTYPES_H #ifdef EINA_HAVE_INTTYPES_H
# undef EINA_HAVE_INTTYPES_H # undef EINA_HAVE_INTTYPES_H
#endif #endif
#define EINA_HAVE_INTTYPES_H #define EINA_HAVE_INTTYPES_H
#ifdef EINA_HAVE_STDINT_H #ifdef EINA_HAVE_STDINT_H
# undef EINA_HAVE_STDINT_H # undef EINA_HAVE_STDINT_H
#endif #endif
#define EINA_HAVE_STDINT_H #define EINA_HAVE_STDINT_H
#ifdef EINA_HAVE_THREADS
# undef EINA_HAVE_THREADS
#endif
#define EINA_HAVE_THREADS
#ifdef EINA_HAVE_DEBUG_THREADS
# undef EINA_HAVE_DEBUG_THREADS
#endif
#ifdef EINA_SIZEOF_WCHAR_T #ifdef EINA_SIZEOF_WCHAR_T
# undef EINA_SIZEOF_WCHAR_T # undef EINA_SIZEOF_WCHAR_T
#endif #endif
#define EINA_SIZEOF_WCHAR_T 4 #define EINA_SIZEOF_WCHAR_T 4
#ifdef EINA_HAVE_ON_OFF_THREADS
# undef EINA_HAVE_ON_OFF_THREADS
#endif
#endif /* EINA_CONFIG_H_ */ #endif /* EINA_CONFIG_H_ */
 End of changes. 2 change blocks. 
0 lines changed or deleted 13 lines changed or added


 eina_convert.h   eina_convert.h 
skipping to change at line 28 skipping to change at line 28
#ifndef EINA_CONVERT_H_ #ifndef EINA_CONVERT_H_
#define EINA_CONVERT_H_ #define EINA_CONVERT_H_
#include "eina_types.h" #include "eina_types.h"
#include "eina_error.h" #include "eina_error.h"
#include "eina_fp.h" #include "eina_fp.h"
/** /**
* @addtogroup Eina_Convert_Group Convert
*
* These functions allow you to convert integer or real numbers to
* string or conversely.
*
* To use these functions, you have to call eina_init()
* first, and eina_shutdown() when eina is not used anymore.
*
* @section Eina_Convert_From_Integer_To_Sring Conversion from integer to s
tring
*
* To convert an integer to a string in the decimal base,
* eina_convert_itoa() should be used. If the hexadecimal base is
* wanted, eina_convert_xtoa() should be used. They all need a bufffer
* sufficiently large to store all the cyphers.
*
* Here is an example of use:
*
* @code
* #include <stdlib.h>
* #include <stdio.h>
*
* #include <Eina.h>
*
* int main(void)
* {
* char tmp[128];
*
* if (!eina_init())
* {
* printf ("Error during the initialization of eina.\n");
* return EXIT_FAILURE;
* }
*
* eina_convert_itoa(45, tmp);
* printf("value: %s\n", tmp);
* eina_convert_xtoa(0xA1, tmp);
* printf("value: %s\n", tmp);
*
* eina_shutdown();
*
* return EXIT_SUCCESS;
* }
* @endcode
*
* Compile this code with the following command:
*
* @code
* gcc -Wall -o test_eina_convert test_eina.c `pkg-config --cflags --libs e
ina`
* @endcode
*
* @note
* The alphabetical cyphers are in lower case.
*
* @section Eina_Convert_Double Conversion double / string
*
* To convert a double to a string, eina_convert_dtoa() should be
* used. Like with the integer functions, a buffer must be used. The
* resulting string ghas the following format (which is the result
* obtained with snprintf() and the @%a modifier):
*
* @code
* [-]0xh.hhhhhp[+-]e
* @endcode
*
* To convert a string to a double, eina_convert_atod() should be
* used. The format of the string must be as above. Then, the double
* has the following mantiss and exponent:
*
* @code
* mantiss : [-]hhhhhh
* exponent : 2^([+-]e - 4 * n)
* @endcode
*
* with n being number of cypers after the point in the string
* format. To obtain the double number from the mantiss and exponent,
* use ldexp().
*
* Here is an example of use:
*
* @code
* #include <stdlib.h>
* #include <stdio.h>
* #include <math.h>
*
* #include <Eina.h>
*
* int main(void)
* {
* char tmp[128];
* long long int m = 0;
* long int e = 0;
* double r;
*
* if (!eina_init())
* {
* printf ("Error during the initialization of eina.\n");
* return EXIT_FAILURE;
* }
*
* printf("initial value : 40.56\n");
* eina_convert_dtoa(40.56, tmp);
* printf("result dtoa : %s\n", tmp);
* eina_convert_atod(tmp, 128, &m, &e);
* r = ldexp((double)m, e);
* printf("result atod : %f\n", r);
*
* eina_shutdown();
*
* return EXIT_SUCCESS;
* }
* @endcode
*
* Compile this code with the following command:
*
* @code
* gcc -Wall -o test_eina_convert test_eina.c `pkg-config --cflags --libs e
ina` -lm
* @endcode
*/
/**
* @addtogroup Eina_Tools_Group Tools * @addtogroup Eina_Tools_Group Tools
* *
* @{ * @{
*/ */
/** /**
* @defgroup Eina_Convert_Group Convert * @defgroup Eina_Convert_Group Convert
* *
* @{ * @{
*/ */
/** /**
* @var EINA_ERROR_CONVERT_P_NOT_FOUND * @var EINA_ERROR_CONVERT_P_NOT_FOUND
* Error identifier corresponding to string not containing 'p'. * Error identifier corresponding to string not containing 'p'.
*/ */
EAPI extern Eina_Error EINA_ERROR_CONVERT_P_NOT_FOUND; EAPI extern Eina_Error EINA_ERROR_CONVERT_P_NOT_FOUND;
/** /**
* @var EINA_ERROR_CONVERT_0X_NOT_FOUND * @var EINA_ERROR_CONVERT_0X_NOT_FOUND
* Error identifier corresponding to string not containing '0x'. * Error identifier corresponding to string not containing '0x'.
*/ */
EAPI extern Eina_Error EINA_ERROR_CONVERT_0X_NOT_FOUND; EAPI extern Eina_Error EINA_ERROR_CONVERT_0X_NOT_FOUND;
/** /**
* @var EINA_ERROR_CONVERT_OUTRUN_STRING_LENGTH * @var EINA_ERROR_CONVERT_OUTRUN_STRING_LENGTH
* Error identifier corresponding to length of the string being too small. * Error identifier corresponding to length of the string being too small.
*/ */
EAPI extern Eina_Error EINA_ERROR_CONVERT_OUTRUN_STRING_LENGTH; EAPI extern Eina_Error EINA_ERROR_CONVERT_OUTRUN_STRING_LENGTH;
/**
* @brief Convert an integer number to a string in decimal base.
*
* @param n The integer to convert.
* @param s The buffer to store the converted integer.
* @return The length of the string, including the nul terminated
* character.
*
* This function converts @p n to a nul terminated string. The
* converted string is in decimal base. As no check is done, @p s must
* be a buffer that is sufficiently large to store the integer.
*
* The returned value is the length of the string, including the nul
* terminated character.
*/
EAPI int eina_convert_itoa(int n, char *s) EINA_ARG_NONNULL(2); EAPI int eina_convert_itoa(int n, char *s) EINA_ARG_NONNULL(2);
/**
* @brief Convert an integer number to a string in hexadecimal base.
*
* @param n The integer to convert.
* @param s The buffer to store the converted integer.
* @return The length of the string, including the nul terminated
* character.
*
* This function converts @p n to a nul terminated string. The
* converted string is in hexadecimal base and the alphabetical
* cyphers are in lower case. As no check is done, @p s must be a
* buffer that is sufficiently large to store the integer.
*
* The returned value is the length of the string, including the nul
* terminated character.
*/
EAPI int eina_convert_xtoa(unsigned int n, char *s) EINA_ARG_NONNULL( 2); EAPI int eina_convert_xtoa(unsigned int n, char *s) EINA_ARG_NONNULL( 2);
/**
* @brief Convert a double to a string.
*
* @param d The double to convert.
* @param des The destination buffer to store the converted double.
* @return #EINA_TRUE on success, #EINA_FALSE otherwise.
*
* This function converts the double @p d to a string. The string is
* stored in the buffer pointed by @p des and must be sufficiently
* large to contain the converted double. The returned string is nul
* terminated and has the following format:
*
* @code
* [-]0xh.hhhhhp[+-]e
* @endcode
*
* where the h are the hexadecimal cyphers of the mantiss and e the
* exponent (a decimal number).
*
* The returned value is the length of the string, including the nul
* character.
*/
EAPI int eina_convert_dtoa(double d, char *des) EINA_ARG_NONNULL(2); EAPI int eina_convert_dtoa(double d, char *des) EINA_ARG_NONNULL(2);
/**
* @brief Convert a string to a double.
*
* @param src The string to convert.
* @param length The length of the string.
* @param m The mantisse.
* @param e The exponent.
* @return #EINA_TRUE on success, #EINA_FALSE otherwise.
*
* This function converts the string @p s of length @p length that
* represent a double in hexadecimal base to a double. It is used to
* replace the use of snprintf() with the \%a modifier, which is
* missing on some platform (like Windows (tm) or OpenBSD).
*
* The string must have the following format:
*
* @code
* [-]0xh.hhhhhp[+-]e
* @endcode
*
* where the h are the hexadecimal cyphers of the mantiss and e the
* exponent (a decimal number). If n is the number of cypers after the
* point, the returned mantiss and exponents are:
*
* @code
* mantiss : [-]hhhhhh
* exponent : 2^([+-]e - 4 * n)
* @endcode
*
* The mantiss and exponent are stored in the buffers pointed
* respectively by @p m and @p e.
*
* If the string is invalid, the error is set to:
*
* @li #EINA_ERROR_CONVERT_0X_NOT_FOUND if no 0x is found,
* @li #EINA_ERROR_CONVERT_P_NOT_FOUND if no p is found,
* @li #EINA_ERROR_CONVERT_OUTRUN_STRING_LENGTH if @p length is not
* correct.
*
* In those cases, #EINA_FALSE is returned, otherwise #EINA_TRUE is
* returned.
*/
EAPI Eina_Bool eina_convert_atod(const char *src, EAPI Eina_Bool eina_convert_atod(const char *src,
int length, int length,
long long *m, long long *m,
long *e) EINA_ARG_NONNULL(1, 3, 4); long *e) EINA_ARG_NONNULL(1, 3, 4);
/**
* @brief Convert a 32.32 fixed point number to a string.
*
* @param fp The fixed point number to convert.
* @param des The destination buffer to store the converted fixed point num
ber.
* @return #EINA_TRUE on success, #EINA_FALSE otherwise.
*
* This function converts the 32.32 fixed point number @p fp to a
* string. The string is stored in the buffer pointed by @p des and
* must be sufficiently large to contain the converted fixed point
* number. The returned string is terminated and has the following
* format:
*
* @code
* [-]0xh.hhhhhp[+-]e
* @endcode
*
* where the h are the hexadecimal cyphers of the mantiss and e the
* exponent (a decimal number).
*
* The returned value is the length of the string, including the nul
* character.
*
* @note The code is the same than eina_convert_dtoa() except that it
* implements the frexp() function for fixed point numbers and does
* some optimisations.
*/
EAPI int eina_convert_fptoa(Eina_F32p32 fp, EAPI int eina_convert_fptoa(Eina_F32p32 fp,
char *des) EINA_ARG_NONNULL(2); char *des) EINA_ARG_NONNULL(2);
/**
* @brief Convert a string to a 32.32 fixed point number.
*
* @param src The string to convert.
* @param length The length of the string.
* @param fp The fixed point number.
* @return #EINA_TRUE on success, #EINA_FALSE otherwise.
*
* This function converts the string @p src of length @p length that
* represent a double in hexadecimal base to a 32.32 fixed point
* number stored in @p fp. The function always tries to convert the
* string with eina_convert_atod().
*
* The string must have the following format:
*
* @code
* [-]0xh.hhhhhp[+-]e
* @endcode
*
* where the h are the hexadecimal cyphers of the mantiss and e the
* exponent (a decimal number). If n is the number of cypers after the
* point, the returned mantiss and exponents are:
*
* @code
* mantiss : [-]hhhhhh
* exponent : 2^([+-]e - 4 * n)
* @endcode
*
* The mantiss and exponent are stored in the buffers pointed
* respectively by @p m and @p e.
*
* If the string is invalid, the error is set to:
*
* @li #EINA_ERROR_CONVERT_0X_NOT_FOUND if no 0x is found,
* @li #EINA_ERROR_CONVERT_P_NOT_FOUND if no p is found,
* @li #EINA_ERROR_CONVERT_OUTRUN_STRING_LENGTH if @p length is not
* correct.
*
* In those cases, or if @p fp is @c NULL, #EINA_FALSE is returned,
* otherwise @p fp is computed and #EINA_TRUE is returned.
*
* @note The code uses eina_convert_atod() and do the correct bit
* shift to compute the fixed point number.
*/
EAPI Eina_Bool eina_convert_atofp(const char *src, EAPI Eina_Bool eina_convert_atofp(const char *src,
int length, int length,
Eina_F32p32 *fp) EINA_ARG_NONNULL(1, 3); Eina_F32p32 *fp) EINA_ARG_NONNULL(1, 3);
/** /**
* @} * @}
*/ */
/** /**
* @} * @}
 End of changes. 8 change blocks. 
0 lines changed or deleted 295 lines changed or added


 eina_counter.h   eina_counter.h 
skipping to change at line 25 skipping to change at line 25
* License along with this library; * License along with this library;
* if not, see <http://www.gnu.org/licenses/>. * if not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef EINA_COUNTER_H_ #ifndef EINA_COUNTER_H_
#define EINA_COUNTER_H_ #define EINA_COUNTER_H_
#include "eina_types.h" #include "eina_types.h"
/** /**
* @addtogroup Eina_Counter_Group Counter
*
* @brief These functions allow you to get the time spent in a part of a co
de.
*
* Before using the counter system, Eina must be initialized with
* eina_init() and later shut down with eina_shutdown(). The create a
* counter, use eina_counter_new(). To free it, use
* eina_counter_free().
*
* To time a part of a code, call eina_counter_start() just before it,
* and eina_counter_stop() just after it. Each time you start to time
* a code, a clock is added to a list. You can give a number of that
* clock with the second argument of eina_counter_stop(). To send all
* the registered clocks to a stream (like stdout, ofr a file), use
* eina_counter_dump().
*
* Here is a straightforward example:
*
* @code
* #include <stdlib.h>
* #include <stdio.h>
*
* #include <eina_counter.h>
*
* void test_malloc(void)
* {
* int i;
*
* for (i = 0; i < 100000; ++i)
* {
* void *buf;
*
* buf = malloc(100);
* free(buf);
* }
* }
*
* int main(void)
* {
* Eina_Counter *counter;
*
* if (!eina_init())
* {
* printf("Error during the initialization of eina\n");
* return EXIT_FAILURE;
* }
*
* counter = eina_counter_new("malloc");
*
* eina_counter_start(counter);
* test_malloc();
* eina_counter_stop(counter, 1);
*
* char* result = eina_counter_dump(counter);
* printf("%s", result);
* free(result);
*
* eina_counter_free(counter);
* eina_shutdown();
*
* return EXIT_SUCCESS;
* }
* @endcode
*
* Compile this code with the following commant:
*
* @verbatim
* gcc -Wall -o test_eina_counter test_eina.c `pkg-config --cflags --libs e
ina`
* @endverbatim
*
* The result should be something like that:
*
* @verbatim
* \# specimen experiment time starting time ending time
* 1 9794125 783816 10577941
* @endverbatim
*
* Note that the displayed time is in nanosecond.
*/
/**
* @addtogroup Eina_Tools_Group Tools * @addtogroup Eina_Tools_Group Tools
* *
* @{ * @{
*/ */
/** /**
* @defgroup Eina_Counter_Group Counter * @defgroup Eina_Counter_Group Counter
* *
* @{ * @{
*/ */
/** /**
* @typedef Eina_Counter * @typedef Eina_Counter
* Counter type. * Counter type.
*/ */
typedef struct _Eina_Counter Eina_Counter; typedef struct _Eina_Counter Eina_Counter;
/**
* @brief Return a counter.
*
* @param name The name of the counter.
* @return A newly allocated counter.
*
* This function returns a new counter. It is characterized by @p
* name. If @p name is @c NULL, the function returns @c NULL
* immediately. If memory allocation fails, @c NULL is returned and the
* error is set to #EINA_ERROR_OUT_OF_MEMORY.
*
* Whe the new counter is not needed anymore, use eina_counter_free() to
* free the allocated memory.
*/
EAPI Eina_Counter *eina_counter_new(const char *name) EINA_WARN_UNUSED_RESU LT EINA_ARG_NONNULL(1); EAPI Eina_Counter *eina_counter_new(const char *name) EINA_WARN_UNUSED_RESU LT EINA_ARG_NONNULL(1);
/**
* @brief Delete a counter.
*
* @param counter The counter to delete.
*
* This function remove the clock of @p counter from the used clocks
* (see eina_counter_start()) and frees the memory allocated for
* @p counter. If @p counter is @c NULL, the function returns
* immediately.
*/
EAPI void eina_counter_free(Eina_Counter *counter) EINA_ARG_NONNUL L(1); EAPI void eina_counter_free(Eina_Counter *counter) EINA_ARG_NONNUL L(1);
/**
* @brief Start the time count.
*
* @param counter The counter.
*
* This function specifies that the part of the code beginning just
* after its call is being to be timed, using @p counter. If
* @p counter is @c NULL, this function returns immediately.
*
* This function adds the clock associated to @p counter in a list. If
* the memory needed by that clock can not be allocated, the function
* returns and the error is set to #EINA_ERROR_OUT_OF_MEMORY.
*
* To stop the timing, eina_counter_stop() must be called with the
* same counter.
*/
EAPI void eina_counter_start(Eina_Counter *counter) EINA_ARG_NONNU LL(1); EAPI void eina_counter_start(Eina_Counter *counter) EINA_ARG_NONNU LL(1);
/**
* @brief Stop the time count.
*
* @param counter The counter.
* @param specimen The number of the test.
*
* This function stop the timing that has been started with
* eina_counter_start(). @p counter must be the same than the one used
* with eina_counter_start(). @p specimen is the number of the
* test. If @p counter or its associated clock are @c NULL, or if the
* time can't be retrieved the function exits.
*/
EAPI void eina_counter_stop(Eina_Counter *counter, EAPI void eina_counter_stop(Eina_Counter *counter,
int specimen) EINA_ARG_NONNU LL(1); int specimen) EINA_ARG_NONNU LL(1);
/**
* @brief Dump the result of all clocks of a counter to a stream.
*
* @return A string with a summary of the test.
* @param counter The counter.
*
* This function returns an malloc'd string containing the dump of
* all the valid clocks of @p counter.
* If @p counter @c NULL, the functions exits
* immediately. Otherwise, the output is formattted like that:
*
* @verbatim
* \# specimen experiment time starting time ending time
* 1 208 120000 120208
* @endverbatim
*
* The unit of time is the nanosecond.
*/
EAPI char *eina_counter_dump(Eina_Counter *counter) EINA_ARG_NONNUL L(1); EAPI char *eina_counter_dump(Eina_Counter *counter) EINA_ARG_NONNUL L(1);
/** /**
* @} * @}
*/ */
/** /**
* @} * @}
*/ */
 End of changes. 6 change blocks. 
0 lines changed or deleted 157 lines changed or added


 eina_error.h   eina_error.h 
skipping to change at line 27 skipping to change at line 27
*/ */
#ifndef EINA_ERROR_H_ #ifndef EINA_ERROR_H_
#define EINA_ERROR_H_ #define EINA_ERROR_H_
#include <stdarg.h> #include <stdarg.h>
#include "eina_types.h" #include "eina_types.h"
/** /**
* @page tutorial_error_page Error Tutorial
*
* @section tutorial_error_registering_msg Registering messages
*
* The error module can provide a system that mimics the errno system
* of the C standard library. It consists in 2 parts:
*
* @li a way of registering new messages with
* eina_error_msg_register() and eina_error_msg_get(),
* @li a way of setting / getting last error message with
* eina_error_set() / eina_error_get().
*
* So one has to fisrt register all the error messages that a program
* or a lib should manage. Then, when an error can occur, use
* eina_error_set(), and when errors are managed, use
* eina_error_get(). If eina_error_set() is used to set an error, do
* not forget to call before eina_error_set(), to remove previous set
* errors.
*
* Here is an example of use:
*
* @include eina_error_01.c
*
* Of course, instead of printf(), eina_log_print() can be used to
* have beautiful error messages.
*/
/**
* @addtogroup Eina_Error_Group Error
*
* @brief These functions provide error management for projects.
*
* The Eina error module provides a way to manage errors in a simple but
* powerful way in libraries and modules. It is also used in Eina itself.
* Similar to libC's @c errno and strerror() facilities, this is extensible
and
* recommended for other libraries and applications.
*
* A simple example of how to use this can be seen @ref tutorial_error_page
* "here".
*/
/**
* @addtogroup Eina_Tools_Group Tools * @addtogroup Eina_Tools_Group Tools
* *
* @{ * @{
*/ */
/** /**
* @defgroup Eina_Error_Group Error * @defgroup Eina_Error_Group Error
* *
* @{ * @{
*/ */
skipping to change at line 48 skipping to change at line 90
/** /**
* @typedef Eina_Error * @typedef Eina_Error
* Error type. * Error type.
*/ */
typedef int Eina_Error; typedef int Eina_Error;
/** /**
* @var EINA_ERROR_OUT_OF_MEMORY * @var EINA_ERROR_OUT_OF_MEMORY
* Error identifier corresponding to a lack of memory. * Error identifier corresponding to a lack of memory.
*/ */
EAPI extern Eina_Error EINA_ERROR_OUT_OF_MEMORY; EAPI extern Eina_Error EINA_ERROR_OUT_OF_MEMORY;
/**
* @brief Register a new error type.
*
* @param msg The description of the error. It will be duplicated using
* eina_stringshare_add().
* @return The unique number identifier for this error.
*
* This function stores in a list the error message described by
* @p msg. The returned value is a unique identifier greater or equal
* than 1. The description can be retrieve later by passing to
* eina_error_msg_get() the returned value.
*
* @see eina_error_msg_static_register()
*/
EAPI Eina_Error eina_error_msg_register(const char *msg) EINA_ARG_NONNULL( 1) EINA_WARN_UNUSED_RESULT; EAPI Eina_Error eina_error_msg_register(const char *msg) EINA_ARG_NONNULL( 1) EINA_WARN_UNUSED_RESULT;
/**
* @brief Register a new error type, statically allocated message.
*
* @param msg The description of the error. This string will not be
* duplicated and thus the given pointer should live during
* usage of eina_error.
* @return The unique number identifier for this error.
*
* This function stores in a list the error message described by
* @p msg. The returned value is a unique identifier greater or equal
* than 1. The description can be retrieve later by passing to
* eina_error_msg_get() the returned value.
*
* @see eina_error_msg_register()
*/
EAPI Eina_Error eina_error_msg_static_register(const char *msg) EINA_ARG_N ONNULL(1) EINA_WARN_UNUSED_RESULT; EAPI Eina_Error eina_error_msg_static_register(const char *msg) EINA_ARG_N ONNULL(1) EINA_WARN_UNUSED_RESULT;
/**
* @brief Change the message of an already registered message
*
* @param error The Eina_Error to change the message of
* @param msg The description of the error. This string will be
* duplicated only if the error was registered with @ref eina_error_msg_reg
ister
* otherwise it must remain intact for the duration.
* @return EINA_TRUE if successful, EINA_FALSE on error
*
* This function modifies the message associated with @p error and changes
* it to @p msg. If the error was previously registered by @ref eina_error
_msg_static_register
* then the string will not be duplicated, otherwise the previous message
* will be unrefed and @p msg copied.
*
* @see eina_error_msg_register()
*/
EAPI Eina_Bool eina_error_msg_modify(Eina_Error error, EAPI Eina_Bool eina_error_msg_modify(Eina_Error error,
const char *msg) EINA_ARG_NONNULL(2) ; const char *msg) EINA_ARG_NONNULL(2) ;
/**
* @brief Return the last set error.
*
* @return The last error.
*
* This function returns the last error set by eina_error_set(). The
* description of the message is returned by eina_error_msg_get().
*/
EAPI Eina_Error eina_error_get(void); EAPI Eina_Error eina_error_get(void);
/**
* @brief Set the last error.
*
* @param err The error identifier.
*
* This function sets the last error identifier. The last error can be
* retrieved with eina_error_get().
*
* @note This is also used to clear previous errors, in that case @p err sh
ould
* be @c 0.
*/
EAPI void eina_error_set(Eina_Error err); EAPI void eina_error_set(Eina_Error err);
/**
* @brief Return the description of the given an error number.
*
* @param error The error number.
* @return The description of the error.
*
* This function returns the description of an error that has been
* registered with eina_error_msg_register(). If an incorrect error is
* given, then @c NULL is returned.
*/
EAPI const char *eina_error_msg_get(Eina_Error error) EINA_PURE; EAPI const char *eina_error_msg_get(Eina_Error error) EINA_PURE;
/** /**
* @brief Find the #Eina_Error corresponding to a message string
* @param msg The error message string to match (NOT #NULL)
* @return The #Eina_Error matching @p msg, or 0 on failure
* This function attempts to match @p msg with its corresponding #Eina_Erro
r value.
* If no such value is found, 0 is returned.
*/
EAPI Eina_Error eina_error_find(const char *msg) EINA_ARG_NONNULL(1) EINA_
PURE;
/**
* @} * @}
*/ */
/** /**
* @} * @}
*/ */
#endif /* EINA_ERROR_H_ */ #endif /* EINA_ERROR_H_ */
 End of changes. 9 change blocks. 
0 lines changed or deleted 137 lines changed or added


 eina_file.h   eina_file.h 
/* EINA - EFL data type library /* EINA - EFL data type library
* Copyright (C) 2007-2008 Jorge Luis Zapata Muga * Copyright (C) 2007-2008 Jorge Luis Zapata Muga
* 2011 Cedric Bail
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either * License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version. * version 2.1 of the License, or (at your option) any later version.
* *
* This library is distributed in the hope that it will be useful, * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details. * Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public * You should have received a copy of the GNU Lesser General Public
* License along with this library; * License along with this library;
* if not, see <http://www.gnu.org/licenses/>. * if not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef EINA_FILE_H_ #ifndef EINA_FILE_H_
#define EINA_FILE_H_ #define EINA_FILE_H_
#include <limits.h> #include <limits.h>
#include <time.h>
#include "eina_types.h" #include "eina_types.h"
#include "eina_array.h" #include "eina_array.h"
#include "eina_iterator.h" #include "eina_iterator.h"
/** /**
* @page eina_file_example_01_page
* @dontinclude eina_file_01.c
*
* For brevity includes, variable declarations and initialization was omitt
ed
* from this page, however the full source code can be seen @ref
* eina_file_example_01 "here".
*
* Here we have a simple callback to print the name of a file and the path
that
* contains it:
* @skip static
* @until }
*
* We can use this callback in the following call:
* @skipline eina_file_dir_list
*
* The above was a way to print the files in a directory, but it is not the
only
* one:
* @until iterator_free
*
* And now two ways to get more information than just file names:
* @until iterator_free
* @until iterator_free
*
* The above ways of getting files on a list may produce the same output, b
ut
* they have an important difference, eina_file_direct_ls() will @b not cal
l
* stat, this means that on some systems it might not have file type
* information. On the other hand it might be faster than eina_file_stat_ls
().
*/
/**
* @page eina_file_example_01
* @include eina_file_01.c
* @example eina_file_01.c
*/
/**
* @addtogroup Eina_Tools_Group Tools * @addtogroup Eina_Tools_Group Tools
* *
* @{ * @{
*/ */
/** /**
* @defgroup Eina_File_Group File * @addtogroup Eina_File_Group File
*
* @brief Functions to handle files and directories.
*
* This functions make it easier to do a number o file and directory operat
ions
* such as getting the list of files in a directory, spliting paths and fin
ding
* out file size and type.
*
* @warning All functions in this group are @b blocking which means they ma
ke
* take a long time to return, use them carefully.
*
* See an example @ref eina_file_example_01_page "here".
* *
* @{ * @{
*/ */
/** /**
* @typedef Eina_File_Direct_Info * @typedef Eina_File_Direct_Info
* A typedef to #_Eina_File_Direct_Info. * A typedef to #_Eina_File_Direct_Info.
*/ */
typedef struct _Eina_File_Direct_Info Eina_File_Direct_Info; typedef struct _Eina_File_Direct_Info Eina_File_Direct_Info;
/** /**
* @typedef Eina_File_Dir_List_Cb * @typedef Eina_File_Dir_List_Cb
* Type for a callback to be called when iterating over the files of a * Type for a callback to be called when iterating over the files of a
* directory. * directory.
* @param The file name EXCLUDING the path
* @param path The path passed to eina_file_dir_list()
* @param data The data passed to eina_file_dir_list()
*/ */
typedef void (*Eina_File_Dir_List_Cb)(const char *name, const char *path, v oid *data); typedef void (*Eina_File_Dir_List_Cb)(const char *name, const char *path, v oid *data);
/** /**
* @typedef Eina_File_Type * @typedef Eina_File_Type
* file type in Eina_File_Direct_Info. * file type in Eina_File_Direct_Info.
*/ */
typedef enum { typedef enum {
EINA_FILE_UNKNOWN, /**< Unknown file type. */ EINA_FILE_UNKNOWN, /**< Unknown file type. */
EINA_FILE_FIFO, /**< Named pipe (FIFO) type (unused on Windows). */ EINA_FILE_FIFO, /**< Named pipe (FIFO) type (unused on Windows). */
EINA_FILE_CHR, /**< Character device type (unused on Windows). */ EINA_FILE_CHR, /**< Character device type (unused on Windows). */
EINA_FILE_DIR, /**< Directory type. */ EINA_FILE_DIR, /**< Directory type. */
EINA_FILE_BLK, /**< Block device type (unused on Windows). */ EINA_FILE_BLK, /**< Block device type (unused on Windows). */
EINA_FILE_REG, /**< Regular file type. */ EINA_FILE_REG, /**< Regular file type. */
EINA_FILE_LNK, /**< Symbolic link type. */ EINA_FILE_LNK, /**< Symbolic link type. */
EINA_FILE_SOCK, /**< UNIX domain socket type (unused on Windows). */ EINA_FILE_SOCK, /**< UNIX domain socket type (unused on Windows). */
EINA_FILE_WHT /**< Whiteout file type (unused on Windows). */ EINA_FILE_WHT /**< Whiteout file type (unused on Windows). */
} Eina_File_Type; } Eina_File_Type;
typedef struct _Eina_File Eina_File;
typedef enum {
EINA_FILE_RANDOM, /**< Advise random memory access to the mapped memo
ry. */
EINA_FILE_SEQUENTIAL, /**< Advise sequential memory access to the mapped
memory. */
EINA_FILE_WILLNEED, /**< Advise need for all the mapped memory. */
EINA_FILE_POPULATE /**< Request all the mapped memory. */
} Eina_File_Populate;
/* Why do this? Well PATH_MAX may vary from when eina itself is compiled /* Why do this? Well PATH_MAX may vary from when eina itself is compiled
* to when the app using eina is compiled. exposing the path buffer below * to when the app using eina is compiled. exposing the path buffer below
* cant safely and portably vary based on how/when you compile. it should * can't safely and portably vary based on how/when you compile. it should
* always be the same for both eina inside AND for apps outside that use ei na * always be the same for both eina inside AND for apps outside that use ei na
* so define this to 8192 - most PATH_MAX values are like 4096 or 1024 (wit h * so define this to 8192 - most PATH_MAX values are like 4096 or 1024 (wit h
* windows i think being 260), so 8192 should cover almost all cases. there * windows i think being 260), so 8192 should cover almost all cases. there
* is a possibility that PATH_MAX could be more than 8192. if anyone spots * is a possibility that PATH_MAX could be more than 8192. if anyone spots
* a path_max that is bigger - let us know, but, for now we will assume * a path_max that is bigger - let us know, but, for now we will assume
* it never happens */ * it never happens */
#define EINA_PATH_MAX 8192 #define EINA_PATH_MAX 8192
/** /**
* @struct _Eina_File_Direct_Info * @struct _Eina_File_Direct_Info
* A structure to store informations of a path. * A structure to store informations of a path.
skipping to change at line 105 skipping to change at line 157
/** /**
* @def EINA_FILE_DIR_LIST_CB * @def EINA_FILE_DIR_LIST_CB
* @brief cast to an #Eina_File_Dir_List_Cb. * @brief cast to an #Eina_File_Dir_List_Cb.
* *
* @param function The function to cast. * @param function The function to cast.
* *
* This macro casts @p function to Eina_File_Dir_List_Cb. * This macro casts @p function to Eina_File_Dir_List_Cb.
*/ */
#define EINA_FILE_DIR_LIST_CB(function) ((Eina_File_Dir_List_Cb)function) #define EINA_FILE_DIR_LIST_CB(function) ((Eina_File_Dir_List_Cb)function)
/**
* @brief List all files on the directory calling the function for every fi
le found.
*
* @param dir The directory name.
* @param recursive Iterate recursively in the directory.
* @param cb The callback to be called.
* @param data The data to pass to the callback.
* @return #EINA_TRUE on success, #EINA_FALSE otherwise.
*
* This function calls @p cb for each file that is in @p dir. To have @p cb
* called on files that are in subdirectories of @p dir @p recursive should
be
* EINA_TRUE. In other words if @p recursive is EINA_FALSE, only direct chi
ldren
* of @p dir will be operated on, if @p recursive is EINA_TRUE the entire t
ree
* of files that is below @p dir will be operated on.
*
* If @p cb or @p dir are @c NULL, or if @p dir is a string of size 0,
* or if @p dir can not be opened, this function returns #EINA_FALSE
* immediately. otherwise, it returns #EINA_TRUE.
*/
EAPI Eina_Bool eina_file_dir_list(const char *dir, EAPI Eina_Bool eina_file_dir_list(const char *dir,
Eina_Bool recursive, Eina_Bool recursive,
Eina_File_Dir_List_Cb cb, Eina_File_Dir_List_Cb cb,
void *data) EINA_ARG_NONN ULL(1, 3); void *data) EINA_ARG_NONN ULL(1, 3);
/**
* @brief Split a path according to the delimiter of the filesystem.
*
* @param path The path to split.
* @return An array of the parts of the path to split.
*
* This function splits @p path according to the delimiter of the used
* filesystem. If @p path is @c NULL or if the array can not be
* created, @c NULL is returned, otherwise, an array with each part of @p p
ath
* is returned.
*/
EAPI Eina_Array *eina_file_split(char *path) EINA_WARN_UNUSED_RESULT EIN A_ARG_NONNULL(1) EINA_MALLOC; EAPI Eina_Array *eina_file_split(char *path) EINA_WARN_UNUSED_RESULT EIN A_ARG_NONNULL(1) EINA_MALLOC;
/**
* @brief Get an iterator to list the content of a directory.
*
* @param dir The name of the directory to list
* @return Return an Eina_Iterator that will walk over the files and direct
ories
* in @p dir. On failure it will return NULL.
*
* Returns an iterator for shared strings, the name of each file in @p dir
will
* only be fetched when advancing the iterator, which means there is very l
ittle
* cost associated with creating the list and stopping halfway through it.
*
* @warning The iterator will hand the user a stringshared value with the f
ull
* path. The user must free the string using eina_stringshare_del() on it.
*
* @note The container for the iterator is of type DIR*.
* @note The iterator will walk over '.' and '..' without returning them.
*
* @see eina_file_direct_ls()
*/
EAPI Eina_Iterator *eina_file_ls(const char *dir) EINA_WARN_UNUSED_RESULT E INA_ARG_NONNULL(1) EINA_MALLOC; EAPI Eina_Iterator *eina_file_ls(const char *dir) EINA_WARN_UNUSED_RESULT E INA_ARG_NONNULL(1) EINA_MALLOC;
/**
* @brief Get an iterator to list the content of a directory, with direct
* information.
*
* @param dir The name of the directory to list
*
* @return Return an Eina_Iterator that will walk over the files and
* directory in the pointed directory. On failure it will
* return NULL.
*
* Returns an iterator for Eina_File_Direct_Info, the name of each file in
@p
* dir will only be fetched when advancing the iterator, which means there
is
* cost associated with creating the list and stopping halfway through it.
*
* @warning The Eina_File_Direct_Info returned by the iterator <b>must not<
/b>
* be modified in any way.
* @warning When the iterator is advanced or deleted the Eina_File_Direct_I
nfo
* returned is no longer valid.
*
* @note The container for the iterator is of type DIR*.
* @note The iterator will walk over '.' and '..' without returning them.
* @note The difference between this function ahd eina_file_direct_ls() is
that
* it guarantees the file type information will be correct incurring
a
* possible performance penalty.
*
* @see eina_file_direct_ls()
*/
EAPI Eina_Iterator *eina_file_stat_ls(const char *dir) EINA_WARN_UNUSED_RES ULT EINA_ARG_NONNULL(1) EINA_MALLOC; EAPI Eina_Iterator *eina_file_stat_ls(const char *dir) EINA_WARN_UNUSED_RES ULT EINA_ARG_NONNULL(1) EINA_MALLOC;
/**
* @brief Get an iterator to list the content of a directory, with direct
* information.
*
* @param dir The name of the directory to list
*
* @return Return an Eina_Iterator that will walk over the files and
* directory in the pointed directory. On failure it will
* return NULL.
*
* Returns an iterator for Eina_File_Direct_Info, the name of each file in
@p
* dir will only be fetched when advancing the iterator, which means there
is
* cost associated with creating the list and stopping halfway through it.
*
* @warning If readdir_r doesn't contain file type information file type wi
ll
* be DT_UNKNOW.
* @warning The Eina_File_Direct_Info returned by the iterator <b>must not<
/b>
* be modified in any way.
* @warning When the iterator is advanced or deleted the Eina_File_Direct_I
nfo
* returned is no longer valid.
*
* @note The container for the iterator is of type DIR*.
* @note The iterator will walk over '.' and '..' without returning them.
* @note The difference between this function ahd eina_file_stat_ls() is th
at
* it may not get the file type information however it is likely to b
e
* faster.
*
* @see eina_file_ls()
*/
EAPI Eina_Iterator *eina_file_direct_ls(const char *dir) EINA_WARN_UNUSED_R ESULT EINA_ARG_NONNULL(1) EINA_MALLOC; EAPI Eina_Iterator *eina_file_direct_ls(const char *dir) EINA_WARN_UNUSED_R ESULT EINA_ARG_NONNULL(1) EINA_MALLOC;
/** /**
* @brief Sanitize file path.
*
* @param path The path to sanitize
*
* @return an allocated string with the sanitized path.
*
* This function take care of adding the current working directory if it's
a
* relative path and also remove all '..' and '//' reference in the origina
l
* path.
*
* @since 1.1
*/
EAPI char *eina_file_path_sanitize(const char *path);
/**
* @brief Get a read-only handler to a file.
*
* @param name Filename to open
* @param shared Requested a shm
*
* Opens a file in read-only mode. @p name should be an absolute path. An
* Eina_File handle can be shared among multiple instances if @p shared is
* EINA_TRUE.
*
* @since 1.1
*/
EAPI Eina_File *eina_file_open(const char *name, Eina_Bool shared) EINA_WAR
N_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_MALLOC;
/**
* @brief Unref file handler.
*
* @param file File handler to unref.
*
* Decremente file's refcount and if it reaches zero close it.
*
* @since 1.1
*/
EAPI void eina_file_close(Eina_File *file);
/**
* @brief Get file size at open time.
*
* @param file The file handler to request the size from.
* @return The length of the file.
*
* @since 1.1
*/
EAPI size_t eina_file_size_get(Eina_File *file);
/**
* @brief Get the last modification time of an open file.
*
* @param file The file handler to request the modification time from.
* @return The last modification time.
*
* @since 1.1
*/
EAPI time_t eina_file_mtime_get(Eina_File *file);
/**
* @brief Get the filename of an open file.
*
* @param file The file handler to request the name from.
* @return Stringshared filename of the file.
*
* @since 1.1
*/
EAPI const char *eina_file_filename_get(Eina_File *file);
/**
* @brief Map all the file to a buffer.
*
* @param file The file handler to map in memory
* @param rule The rule to apply to the mapped memory
* @return A pointer to a buffer that map all the file content. @c NULL if
it fail.
*
* @since 1.1
*/
EAPI void *eina_file_map_all(Eina_File *file, Eina_File_Populate rule);
/**
* @brief Map a part of the file.
*
* @param file The file handler to map in memory
* @param rule The rule to apply to the mapped memory
* @param offset The offset inside the file
* @param length The length of the memory to map
* @return A valid pointer to the system memory with @p length valid byte i
n it. And @c NULL if not inside the file or anything else goes wrong.
*
* This does handle refcounting so it will share map that target the same m
emory area.
*
* @since 1.1
*/
EAPI void *eina_file_map_new(Eina_File *file, Eina_File_Populate rule,
unsigned long int offset, unsigned long int le
ngth);
/**
* @brief Unref and unmap memory if possible.
*
* @param file The file handler to unmap memory from.
* @param map Memory map to unref and unmap.
*
* @since 1.1
*/
EAPI void eina_file_map_free(Eina_File *file, void *map);
/**
* @} * @}
*/ */
/** /**
* @} * @}
*/ */
#endif /* EINA_FILE_H_ */ #endif /* EINA_FILE_H_ */
 End of changes. 14 change blocks. 
6 lines changed or deleted 314 lines changed or added


 eina_hamster.h   eina_hamster.h 
skipping to change at line 23 skipping to change at line 23
* *
* You should have received a copy of the GNU Lesser General Public * You should have received a copy of the GNU Lesser General Public
* License along with this library; * License along with this library;
* if not, see <http://www.gnu.org/licenses/>. * if not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef EINA_HAMSTER_H_ #ifndef EINA_HAMSTER_H_
#define EINA_HAMSTER_H_ #define EINA_HAMSTER_H_
/** /**
* @addtogroup Eina_Core_Group Core * @addtogroup Eina_Hamster_Group Hamster
*
* @brief These functions provide hamster calls.
* *
* @{ * @{
*/ */
/** /**
* @defgroup Eina_Hamster_Group Hamster * @addtogroup Eina_Core_Group Core
* *
* @{ * @{
*/ */
/**
* @defgroup Eina_Hamster_Group Hamster
*/
/**
* @brief Get the hamster count.
*
* @return The number of available hamsters.
*
* This function returns how many hamsters you have.
*/
EAPI int eina_hamster_count(void); EAPI int eina_hamster_count(void);
/** /**
* @} * @}
*/ */
/** /**
* @} * @}
*/ */
 End of changes. 3 change blocks. 
2 lines changed or deleted 15 lines changed or added


 eina_hash.h   eina_hash.h 
skipping to change at line 27 skipping to change at line 27
* if not, see <http://www.gnu.org/licenses/>. * if not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef EINA_HASH_H_ #ifndef EINA_HASH_H_
#define EINA_HASH_H_ #define EINA_HASH_H_
#include "eina_types.h" #include "eina_types.h"
#include "eina_iterator.h" #include "eina_iterator.h"
/** /**
* @page hash_01_example_page Eina_Hash in action
* @dontinclude eina_hash_01.c
*
* We are going to store some tuples into our table, that will map each @a
name
* to a @a number. The cost to access a given number from the name should b
e
* very small, even with many entries in our table. This is the initial dat
a:
* @skip _Phone_Entry
* @until // _start_entries
*
* Before starting to play with the hash, let's write a callback that will
be
* used to free the elements from it. Since we are just storing strduped
* strings, we just need to free them:
*
* @skip static
* @until }
*
* We also need a callback to iterate over the elements of the list later,
so
* we are defining it now:
*
* @skip Eina_Bool
* @until }
*
* Now let's create our @ref Eina_Hash using @ref
* eina_hash_string_superfast_new :
*
* @skip eina_init
* @until phone_book
*
* Now we add the keys and data to the hash using @ref eina_hash_add . This
* means that the key is copied inside the table, together with the pointer
to
* the data (phone numbers).
*
* @skip for
* @until }
*
* Some basic manipulations with the hash, like finding a value given a key
,
* deleting an entry, modifying an entry are exemplified in the following l
ines.
* Notice that the @ref eina_hash_modify function returns the old value sto
red
* in that entry, and it needs to be freed, while the @ref eina_hash_del
* function already calls our free callback:
*
* @skip Look for
* @until free(
*
* The @ref eina_hash_set function can be used to set a key-value entry to
the
* table if it doesn't exist, or to modify an existent entry. It returns th
e old
* entry if it was already set, and NULL otherwise. But since it will
* return NULL on error too, we need to check if an error has occurred:
*
* @skip Modify
* @until printf("\n");
*
* There are different ways of iterate over the entries of a hash. Here we
show
* two of them: using @ref eina_hash_foreach and @ref Eina_Iterator .
*
* @skip List of phones
* @until eina_iterator_free(it);
*
* It's also possible to change the key for a specific entry, without havin
g to
* remove the entry from the table and adding it again:
*
* @skipline eina_hash_move
*
* We can remove all the elements from the table without free the table its
elf:
*
* @skip Empty the phone book
* @until eina_hash_population
*
* Or free the the entire table with its content:
*
* @skipline eina_hash_free
*
*
* The full code for this example can be seen here: @ref eina_hash_01_c
*/
/**
* @page eina_hash_01_c Hash table in action
*
* @include eina_hash_01.c
* @example eina_hash_01.c
*/
/**
* @page hash_02_example_page Different types of tables
*
* This example shows two more types of hash tables that can be created usi
ng
* @ref Eina_Hash . For more types, consult the reference documentation of
@ref
* eina_hash_new.
* @include eina_hash_02.c
* @example eina_hash_02.c
*/
/**
* @example eina_hash_03.c
* Same example as @ref hash_01_example_page but using a "string small" has
h
* table instead of "string superfast".
*/
/**
* @example eina_hash_04.c
* Same example as @ref hash_01_example_page but using a "string djb2" hash
* table instead of "string superfast".
*/
/**
* @example eina_hash_05.c
* Same example as @ref hash_01_example_page but using a "int32" hash
* table instead of "string superfast".
*/
/**
* @example eina_hash_06.c
* Same example as @ref hash_01_example_page but using a "int64" hash
* table instead of "string superfast".
*/
/**
* @example eina_hash_07.c
* Same example as @ref hash_01_example_page but using a "pointer" hash
* table instead of "string superfast".
*/
/**
* @example eina_hash_08.c
* This example shows the the usage of eina_hash_add(), eina_hash_add_by_ha
sh(),
* eina_hash_direct_add_by_hash(), eina_hash_del(), eina_hash_del_by_key_ha
sh(),
* eina_hash_del_by_key(), eina_hash_del_by_data(), eina_hash_find_by_hash(
) and
* eina_hash_modify_by_hash().
*/
/**
* @addtogroup Eina_Hash_Group Hash Table
*
* @brief Hash table management. Useful for mapping keys to values.
*
* The hash table is useful for when one wants to implement a table that ma
ps
* keys (usually strings) to data, and have relatively fast access time. Th
e
* performance is proportional to the load factor of the table (number of
* elements / number of buckets). See @ref hashtable_algo for implementatio
n
* details.
*
* Different implementations exists depending on what kind of key will be u
sed
* to access the data: strings, integers, pointers, stringshared or your ow
n.
*
* Eina hash tables can copy the keys when using eina_hash_add() or not whe
n
* using eina_hash_direct_add().
*
* @section hashtable_algo Algorithm
*
* The Eina_Hash is implemented using an array of N "buckets", where each
* bucket is a pointer to a structure that is the head of a <a
* href="http://en.wikipedia.org/wiki/Red-black_tree">red-black tree</a>. T
he
* array can then be indexed by the [hash_of_element mod N]. The
* hash_of_element is calculated using the hashing function, passed as
* parameter to the @ref eina_hash_new function. N is the number of buckets
* (array positions), and is calculated based on the buckets_power_size
* (argument of @ref eina_hash_new too). The following picture ilustrates t
he
* basic idea:
*
* @htmlonly
* <img src="01_hash-table.png" width="500" />
* @endhtmlonly
* @image latex 01_hash-table.eps
*
* Adding an element to the hash table is made of:
* @li calculating the hash for that key (using the specified hash function
);
* @li calculate the array position [hash mod N];
* @li add the element to the rbtree on that position.
*
* The two first steps have constant time, proportional to the hash functio
n
* being used. Adding the key to the rbtree will be proportional on the num
ber
* of keys on that bucket.
*
* The average cost of lookup depends on the number of keys per
* bucket (load factor) of the table, if the distribution of keys is
* sufficiently uniform.
*
* @section hashtable_perf Performance
*
* As said before, the performance depends on the load factor. So trying to
keep
* the load factor as small as possible will improve the hash table perform
ance. But
* increasing the buckets_power_size will also increase the memory consumpt
ion.
* The default hash table creation functions already have a good number of
* buckets, enough for most cases. Particularly for strings, if just a few
keys
* (less than 30) will be added to the hash table, @ref
* eina_hash_string_small_new should be used, since it will reduce the memo
ry
* consumption for the buckets, and you still won't have many collisions.
* However, @ref eina_hash_string_small_new still uses the same hash calcul
ation
* function that @ref eina_hash_string_superfast_new, which is more complex
than
* @ref eina_hash_string_djb2_new. The latter has a faster hash computation
* function, but that will imply on a not so good distribution. But if just
a
* few keys are being added, this is not a problem, it will still have not
many
* collisions and be faster to calculate the hash than in a hash created wi
th
* @ref eina_hash_string_small_new and @ref eina_hash_string_superfast_new.
*
* A simple comparison between them would be:
*
* @li @c djb2 - faster hash function - 256 buckets (higher memory consumpt
ion)
* @li @c string_small - slower hash function but less collisions - 32 buck
ets
* (lower memory consumption)
* @li @c string_superfast - slower hash function but less collisions - 256
buckets
* (higher memory consumption)
*
* Basically for a very small number of keys (10 or less), @c djb2 should b
e
* used, or @c string_small if you have a restriction on memory usage. And
for a
* higher number of keys, @c string_superfast should be always preferred.
*
* If just stringshared keys are being added, use @ref
* eina_hash_stringshared_new. If a lot of keys will be added to the hash t
able
* (e.g. more than 1000), then it's better to increase the buckets_power_si
ze.
* See @ref eina_hash_new for more details.
*
* When adding a new key to a hash table, use @ref eina_hash_add or @ref
* eina_hash_direct_add (the latter if this key is already stored elsewhere
). If
* the key may be already inside the hash table, instead of checking with
* @ref eina_hash_find and then doing @ref eina_hash_add, one can use just
@ref
* eina_hash_set (this will change the data pointed by this key if it was
* already present in the table).
*
* @section hashtable_tutorial Tutorial
*
* These examples show many Eina_Hash functions in action:
* <ul>
* <li> @ref hash_01_example_page
* <li> @ref hash_02_example_page
* <li> Different types of hash in use:
* <ul>
* <li> @ref eina_hash_03.c "string small"
* <li> @ref eina_hash_04.c "string djb2"
* <li> @ref eina_hash_05.c "int32"
* <li> @ref eina_hash_06.c "int64"
* <li> @ref eina_hash_07.c "pointer"
* </ul>
* <li> @ref eina_hash_08.c "Different add and delete functions"
* </ul>
*/
/**
* @addtogroup Eina_Data_Types_Group Data Types * @addtogroup Eina_Data_Types_Group Data Types
* *
* @{ * @{
*/ */
/** /**
* @addtogroup Eina_Containers_Group Containers * @addtogroup Eina_Containers_Group Containers
* *
* @{ * @{
*/ */
skipping to change at line 67 skipping to change at line 306
}; };
typedef unsigned int (*Eina_Key_Length)(const void *key); typedef unsigned int (*Eina_Key_Length)(const void *key);
#define EINA_KEY_LENGTH(Function) ((Eina_Key_Length)Function) #define EINA_KEY_LENGTH(Function) ((Eina_Key_Length)Function)
typedef int (*Eina_Key_Cmp)(const void *key1, int key1_length, con st void *key2, int key2_length); typedef int (*Eina_Key_Cmp)(const void *key1, int key1_length, con st void *key2, int key2_length);
#define EINA_KEY_CMP(Function) ((Eina_Key_Cmp)Function) #define EINA_KEY_CMP(Function) ((Eina_Key_Cmp)Function)
typedef int (*Eina_Key_Hash)(const void *key, int key_length); typedef int (*Eina_Key_Hash)(const void *key, int key_length);
#define EINA_KEY_HASH(Function) ((Eina_Key_Hash)Function) #define EINA_KEY_HASH(Function) ((Eina_Key_Hash)Function)
typedef Eina_Bool (*Eina_Hash_Foreach)(const Eina_Hash *hash, const void *key, void *data, void *fdata); typedef Eina_Bool (*Eina_Hash_Foreach)(const Eina_Hash *hash, const void *key, void *data, void *fdata);
/**
* @brief Create a new hash table.
*
* @param key_length_cb The function called when getting the size of the ke
y.
* @param key_cmp_cb The function called when comparing the keys.
* @param key_hash_cb The function called when getting the values.
* @param data_free_cb The function called on each value when the hash tabl
e is
* freed, or when an item is deleted from it. @c NULL can be passed as
* callback.
* @param buckets_power_size The size of the buckets.
* @return The new hash table.
*
* This function creates a new hash table using user-defined callbacks
* to manage the hash table. On failure, @c NULL is returned and
* #EINA_ERROR_OUT_OF_MEMORY is set. If @p key_cmp_cb or @p key_hash_cb
* are @c NULL, @c NULL is returned. If @p buckets_power_size is
* smaller or equal than 2, or if it is greater or equal than 17,
* @c NULL is returned.
*
* The number of buckets created will be 2 ^ @p buckets_power_size. This me
ans
* that if @p buckets_power_size is 5, there will be created 32 buckets. fo
r a
* @p buckets_power_size of 8, there will be 256 buckets.
*
* Pre-defined functions are available to create a hash table. See
* eina_hash_string_djb2_new(), eina_hash_string_superfast_new(),
* eina_hash_string_small_new(), eina_hash_int32_new(),
* eina_hash_int64_new(), eina_hash_pointer_new() and
* eina_hash_stringshared_new().
*/
EAPI Eina_Hash *eina_hash_new(Eina_Key_Length key_length_cb, EAPI Eina_Hash *eina_hash_new(Eina_Key_Length key_length_cb,
Eina_Key_Cmp key_cmp_cb, Eina_Key_Cmp key_cmp_cb,
Eina_Key_Hash key_hash_cb, Eina_Key_Hash key_hash_cb,
Eina_Free_Cb data_free_cb, Eina_Free_Cb data_free_cb,
int buckets_power_size) EINA_MALL OC EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(2, 3); int buckets_power_size) EINA_MALL OC EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(2, 3);
/**
* @brief Redefine the callback that clean the data of a hash
*
* @param hash The given hash table
* @param data_free_cb The function called on each value when the hash
* table is freed, or when an item is deleted from it. @c NULL can be passe
d as
* callback.
* @since 1.1
* See @ref eina_hash_new.
*/
EAPI void eina_hash_free_cb_set(Eina_Hash *hash, Eina_Free_Cb data_free_cb)
EINA_ARG_NONNULL(1);
/**
* @brief Create a new hash table using the djb2 algorithm.
*
* @param data_free_cb The function called on each value when the hash tabl
e
* is freed, or when an item is deleted from it. @c NULL can be passed as
* callback.
* @return The new hash table.
*
* This function creates a new hash table using the djb2 algorithm for
* table management and strcmp() to compare the keys. Values can then
* be looked up with pointers other than the original key pointer that
* was used to add values. On failure, this function returns @c NULL.
*/
EAPI Eina_Hash *eina_hash_string_djb2_new(Eina_Free_Cb data_free_cb); EAPI Eina_Hash *eina_hash_string_djb2_new(Eina_Free_Cb data_free_cb);
/**
* @brief Create a new hash table for use with strings.
*
* @param data_free_cb The function called on each value when the hash tabl
e
* is freed, or when an item is deleted from it. @c NULL can be passed as
* callback.
* @return The new hash table.
*
* This function creates a new hash table using the superfast algorithm
* for table management and strcmp() to compare the keys. Values can
* then be looked up with pointers other than the original key pointer
* that was used to add values. On failure, this function returns
* @c NULL.
*/
EAPI Eina_Hash *eina_hash_string_superfast_new(Eina_Free_Cb data_free_cb); EAPI Eina_Hash *eina_hash_string_superfast_new(Eina_Free_Cb data_free_cb);
/**
* @brief Create a new hash table for use with strings with small bucket si
ze.
*
* @param data_free_cb The function called on each value when the hash tab
le
* is freed, or when an item is deleted from it. @c NULL can be passed as
* callback.
* @return The new hash table.
*
* This function creates a new hash table using the superfast algorithm
* for table management and strcmp() to compare the keys, but with a
* smaller bucket size (compared to eina_hash_string_superfast_new())
* which will minimize the memory used by the returned hash
* table. Values can then be looked up with pointers other than the
* original key pointer that was used to add values. On failure, this
* function returns @c NULL.
*/
EAPI Eina_Hash *eina_hash_string_small_new(Eina_Free_Cb data_free_cb); EAPI Eina_Hash *eina_hash_string_small_new(Eina_Free_Cb data_free_cb);
/**
* @brief Create a new hash table for use with 32bit integers.
*
* @param data_free_cb The function called on each value when the hash tab
le
* is freed, or when an item is deleted from it. @c NULL can be passed as
* callback.
* @return The new hash table.
*
* This function creates a new hash table where keys are 32bit integers.
* When adding or looking up in the hash table, pointers to 32bit integers
* must be passed. They can be addresses on the stack if you let the
* eina_hash copy the key. Values can then
* be looked up with pointers other than the original key pointer that was
* used to add values. This method is not suitable to match string keys as
* it would only match the first character.
* On failure, this function returns @c NULL.
*/
EAPI Eina_Hash *eina_hash_int32_new(Eina_Free_Cb data_free_cb); EAPI Eina_Hash *eina_hash_int32_new(Eina_Free_Cb data_free_cb);
/**
* @brief Create a new hash table for use with 64bit integers.
*
* @param data_free_cb The function called on each value when the hash tab
le
* is freed, or when an item is deleted from it. @c NULL can be passed as
* callback.
* @return The new hash table.
*
* This function creates a new hash table where keys are 64bit integers.
* When adding or looking up in the hash table, pointers to 64bit integers
* must be passed. They can be addresses on the stack. Values can then
* be looked up with pointers other than the original key pointer that was
* used to add values. This method is not suitable to match string keys as
* it would only match the first character.
* On failure, this function returns @c NULL.
*/
EAPI Eina_Hash *eina_hash_int64_new(Eina_Free_Cb data_free_cb); EAPI Eina_Hash *eina_hash_int64_new(Eina_Free_Cb data_free_cb);
/**
* @brief Create a new hash table for use with pointers.
*
* @param data_free_cb The function called on each value when the hash tab
le
* is freed, or when an item is deleted from it. @c NULL can be passed as
* callback.
* @return The new hash table.
*
* This function creates a new hash table using the int64/int32 algorithm f
or
* table management and dereferenced pointers to compare the
* keys. Values can then be looked up with pointers other than the
* original key pointer that was used to add values. This method may
* appear to be able to match string keys, actually it only matches
* the first character. On failure, this function returns @c NULL.
*/
EAPI Eina_Hash *eina_hash_pointer_new(Eina_Free_Cb data_free_cb); EAPI Eina_Hash *eina_hash_pointer_new(Eina_Free_Cb data_free_cb);
/**
* @brief Create a new hash table optimized for stringshared values.
*
* @param data_free_cb The function called on each value when the hash tab
le
* is freed, or when an item is deleted from it. @c NULL can be passed as
* callback.
* @return The new hash table.
*
* This function creates a new hash table optimized for stringshared
* values. Values CAN NOT be looked up with pointers not
* equal to the original key pointer that was used to add a value. On failu
re,
* this function returns @c NULL.
*
* Excerpt of code that will NOT work with this type of hash:
*
* @code
* extern Eina_Hash *hash;
* extern const char *value;
* const char *a = eina_stringshare_add("key");
*
* eina_hash_add(hash, a, value);
* eina_hash_find(hash, "key")
* @endcode
*/
EAPI Eina_Hash *eina_hash_stringshared_new(Eina_Free_Cb data_free_cb); EAPI Eina_Hash *eina_hash_stringshared_new(Eina_Free_Cb data_free_cb);
/**
* @brief Add an entry to the given hash table.
*
* @param hash The given hash table. Cannot be @c NULL.
* @param key A unique key. Cannot be @c NULL.
* @param data Data to associate with the string given by @p key. Cannot be
@c
* NULL.
* @return #EINA_FALSE if an error occurred, #EINA_TRUE otherwise.
*
* This function adds @p key to @p hash. @p key is
* expected to be unique within the hash table. Key uniqueness varies
* depending on the type of @p hash: a stringshared @ref Eina_Hash
* need to have unique pointers (which implies unique strings).
* All other string hash types require the strings
* themselves to be unique. Pointer, int32 and int64 hashes need to have th
ese
* values as unique. Failure to use sufficient uniqueness will
* result in unexpected results when inserting data pointers accessed
* with eina_hash_find(), and removed with eina_hash_del(). Key
* strings are case sensitive. If an error occurs, eina_error_get()
* should be used to determine if an allocation error occurred during
* this function. This function returns #EINA_FALSE if an error
* occurred, #EINA_TRUE otherwise.
*/
EAPI Eina_Bool eina_hash_add(Eina_Hash *hash, EAPI Eina_Bool eina_hash_add(Eina_Hash *hash,
const void *key, const void *key,
const void *data) EINA_ARG_NONNULL(1, 2, 3); const void *data) EINA_ARG_NONNULL(1, 2, 3);
/**
* @brief Add an entry to the given hash table without duplicating the stri
ng
* key.
*
* @param hash The given hash table. Cannot be @c NULL.
* @param key A unique key. Cannot be @c NULL.
* @param data Data to associate with the string given by @p key. Cannot be
@c
* NULL
* @return #EINA_FALSE if an error occurred, #EINA_TRUE otherwise.
*
* This function adds @p key to @p hash. @p key is
* expected to be unique within the hash table. Key uniqueness varies
* depending on the type of @p hash: a stringshared @ref Eina_Hash
* need have unique pointers (which implies unique strings).
* All other string hash types require the strings
* themselves to be unique. Pointer, int32 and int64 hashes need to have th
ese
* values as unique. Failure to use sufficient uniqueness will
* result in unexpected results when inserting data pointers accessed
* with eina_hash_find(), and removed with eina_hash_del(). This
* function does not make a copy of @p key, so it must be a string
* constant or stored elsewhere ( in the object being added). Key
* strings are case sensitive. If an error occurs, eina_error_get()
* should be used to determine if an allocation error occurred during
* this function. This function returns #EINA_FALSE if an error
* occurred, #EINA_TRUE otherwise.
*/
EAPI Eina_Bool eina_hash_direct_add(Eina_Hash *hash, EAPI Eina_Bool eina_hash_direct_add(Eina_Hash *hash,
const void *key, const void *key,
const void *data) EINA_ARG_NONNULL(1, 2 , 3); const void *data) EINA_ARG_NONNULL(1, 2 , 3);
/**
* @brief Remove the entry identified by a key or a data from the given
* hash table.
*
* @param hash The given hash table.
* @param key The key.
* @param data The data pointer to remove if the key is @c NULL.
* @return #EINA_FALSE if an error occurred, #EINA_TRUE otherwise.
*
* This function removes the entry identified by @p key or @p data
* from @p hash. If a free function was given to the
* callback on creation, it will be called for the data being
* deleted. If @p hash is @c NULL, the functions returns immediately
* #EINA_FALSE. If @p key is @c NULL, then @p data is used to find the a
* match to remove, otherwise @p key is used and @p data is not
* required and can be @c NULL. This function returns #EINA_FALSE if
* an error occurred, #EINA_TRUE otherwise.
*
* @note if you know you already have the key, use
* eina_hash_del_by_key() or eina_hash_del_by_key_hash(). If you
* know you don't have the key, use eina_hash_del_by_data()
* directly.
*/
EAPI Eina_Bool eina_hash_del(Eina_Hash *hash, EAPI Eina_Bool eina_hash_del(Eina_Hash *hash,
const void *key, const void *key,
const void *data) EINA_ARG_NONNULL(1); const void *data) EINA_ARG_NONNULL(1);
/**
* @brief Retrieve a specific entry in the given hash table.
*
* @param hash The given hash table.
* @param key The key of the entry to find.
* @return The data pointer for the stored entry on success, @c NULL
* otherwise.
*
* This function retrieves the entry associated to @p key in
* @p hash. If @p hash is @c NULL, this function returns immediately
* @c NULL. This function returns the data pointer on success, @c NULL
* otherwise.
*/
EAPI void *eina_hash_find(const Eina_Hash *hash, EAPI void *eina_hash_find(const Eina_Hash *hash,
const void *key) EINA_ARG_NONNULL(2); const void *key) EINA_ARG_NONNULL(1, 2);
/**
* @brief Modify the entry pointer at the specified key and return the old
* entry.
* @param hash The given hash table.
* @param key The key of the entry to modify.
* @param data The data to replace the old entry.
* @return The data pointer for the old stored entry on success, or
* @c NULL otherwise.
*
* This function modifies the data of @p key with @p data in @p
* hash. If no entry is found, nothing is added to @p hash. On success
* this function returns the old entry, otherwise it returns @c NULL.
*/
EAPI void *eina_hash_modify(Eina_Hash *hash, EAPI void *eina_hash_modify(Eina_Hash *hash,
const void *key, const void *key,
const void *data) EINA_ARG_NONNULL(1, 2, 3); const void *data) EINA_ARG_NONNULL(1, 2, 3);
/**
* @brief Modify the entry pointer at the specified key and return the
* old entry or add the entry if not found.
*
* @param hash The given hash table.
* @param key The key of the entry to modify.
* @param data The data to replace the old entry
* @return The data pointer for the old stored entry, or @c NULL
* otherwise.
*
* This function modifies the data of @p key with @p data in @p
* hash. If no entry is found, @p data is added to @p hash with the
* key @p key. On success this function returns the old entry,
* otherwise it returns @c NULL. To check for errors, use
* eina_error_get().
*/
EAPI void *eina_hash_set(Eina_Hash *hash, EAPI void *eina_hash_set(Eina_Hash *hash,
const void *key, const void *key,
const void *data) EINA_ARG_NONNULL(1, 2, 3); const void *data) EINA_ARG_NONNULL(1, 2);
/**
* @brief Change the key associated with a data without triggering the
* free callback.
*
* @param hash The given hash table.
* @param old_key The current key associated with the data
* @param new_key The new key to associate data with
* @return EINA_FALSE in any case but success, EINA_TRUE on success.
*
* This function allows for the move of data from one key to another,
* but does not call the Eina_Free_Cb associated with the hash table
* when destroying the old key.
*/
EAPI Eina_Bool eina_hash_move(Eina_Hash *hash, EAPI Eina_Bool eina_hash_move(Eina_Hash *hash,
const void *old_key, const void *old_key,
const void *new_key) EINA_ARG_NONNULL(1, 2, 3 ); const void *new_key) EINA_ARG_NONNULL(1, 2, 3 );
/**
* Free the given hash table resources.
*
* @param hash The hash table to be freed.
*
* This function frees up all the memory allocated to storing @p hash,
* and call the free callback if it has been passed to the hash table
* at creation time. If no free callback has been passed, 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
* already freed any allocated data in the hash table or has the
* pointers for data in the table stored elsewhere as well. If @p hash
* is @c NULL, the function returns immediately.
*
* Example:
* @code
* extern Eina_Hash *hash;
*
* eina_hash_free(hash);
* hash = NULL;
* @endcode
*/
EAPI void eina_hash_free(Eina_Hash *hash) EINA_ARG_NONNULL(1); EAPI void eina_hash_free(Eina_Hash *hash) EINA_ARG_NONNULL(1);
/**
* Free the given hash table buckets resources.
*
* @param hash The hash table whose buckets have to be freed.
*
* This function frees up all the memory allocated to storing the
* buckets of @p hash, and calls the free callback on all hash table
* buckets if it has been passed to the hash table at creation time,
* then frees the buckets. If no free callback has been passed, no
* buckets value will be freed. If @p hash is @c NULL, the function
* returns immediately.
*/
EAPI void eina_hash_free_buckets(Eina_Hash *hash) EINA_ARG_NONNULL(1); EAPI void eina_hash_free_buckets(Eina_Hash *hash) EINA_ARG_NONNULL(1);
/**
* @brief Returns the number of entries in the given hash table.
*
* @param hash The given hash table.
* @return The number of entries in the hash table.
*
* This function returns the number of entries in @p hash, or 0 on
* error. If @p hash is @c NULL, 0 is returned.
*/
EAPI int eina_hash_population(const Eina_Hash *hash) EINA_ARG_NONNULL (1); EAPI int eina_hash_population(const Eina_Hash *hash) EINA_ARG_NONNULL (1);
/**
* @brief Add an entry to the given hash table.
*
* @param hash The given hash table. Cannot be @c NULL.
* @param key A unique key. Cannot be @c NULL.
* @param key_length The length of the key.
* @param key_hash The hash that will always match key.
* @param data The data to associate with the string given by the key. Cann
ot be
* @c NULL.
* @return #EINA_FALSE if an error occurred, #EINA_TRUE otherwise.
*
* This function adds @p key to @p hash. @p hash, @p key and @p data
* cannot be @c NULL, in that case #EINA_FALSE is returned. @p key is
* expected to be a unique within the hash table. Otherwise,
* one cannot be sure which inserted data pointer will be accessed
* with @ref eina_hash_find, and removed with @ref eina_hash_del. Do
* not forget to count '\\0' for string when setting the value of
* @p key_length. @p key_hash is expected to always match
* @p key. Otherwise, one cannot be sure to find it again with @ref
* eina_hash_find_by_hash. Key strings are case sensitive. If an error
* occurs, eina_error_get() should be used to determine if an
* allocation error occurred during this function. This function
* returns #EINA_FALSE if an error occurred, #EINA_TRUE otherwise.
*
* @see eina_hash_add()
*/
EAPI Eina_Bool eina_hash_add_by_hash(Eina_Hash *hash, EAPI Eina_Bool eina_hash_add_by_hash(Eina_Hash *hash,
const void *key, const void *key,
int key_length, int key_length,
int key_hash, int key_hash,
const void *data) EINA_ARG_NONNULL(1, 2, 5); const void *data) EINA_ARG_NONNULL(1, 2, 5);
/**
* @brief Add an entry to the given hash table and do not duplicate the str
ing
* key.
*
* @param hash The given hash table. Cannot be @c NULL.
* @param key A unique key. Cannot be @c NULL.
* @param key_length Should be the length of @p key (don't forget to count
* '\\0' for string).
* @param key_hash The hash that will always match key.
* @param data Data to associate with the string given by @p key. Cannot be
@c
* NULL.
* @return #EINA_FALSE if an error occurred, #EINA_TRUE otherwise.
*
* This function adds @p key to @p hash. @p hash, @p key and @p data
* can be @c NULL, in that case #EINA_FALSE is returned. @p key is
* expected to be unique within the hash table. Otherwise,
* one cannot be sure which inserted data pointer will be accessed
* with @ref eina_hash_find, and removed with @ref eina_hash_del. This
* function does not make a copy of @p key so it must be a string
* constant or stored elsewhere (in the object being added). Do
* not forget to count '\\0' for string when setting the value of
* @p key_length. @p key_hash is expected to always match
* @p key. Otherwise, one cannot be sure to find it again with @ref
* eina_hash_find_by_hash. Key strings are case sensitive. If an error
* occurs, eina_error_get() should be used to determine if an
* allocation error occurred during this function. This function
* returns #EINA_FALSE if an error occurred, #EINA_TRUE otherwise.
*
* @see eina_hash_direct_add()
*/
EAPI Eina_Bool eina_hash_direct_add_by_hash(Eina_Hash *hash, EAPI Eina_Bool eina_hash_direct_add_by_hash(Eina_Hash *hash,
const void *key, const void *key,
int key_length, int key_length,
int key_hash, int key_hash,
const void *data) EINA_ARG_NONN ULL(1, 2, 5); const void *data) EINA_ARG_NONN ULL(1, 2, 5);
/**
* @brief Remove the entry identified by a key and a key hash from the give
n
* hash table.
*
* @param hash The given hash table. Cannot be @c NULL.
* @param key The key. Cannot be @c NULL.
* @param key_length The length of the key.
* @param key_hash The hash that always match the key.
* @return #EINA_FALSE if an error occurred, #EINA_TRUE otherwise.
*
* This function removes the entry identified by @p key and
* @p key_hash from @p hash. If a free function was given to the
* callback on creation, it will be called for the data being
* deleted. Do not forget to count '\\0' for string when setting the
* value of @p key_length. If @p hash or @p key are @c NULL, the
* functions returns immediately #EINA_FALSE. This function returns
* #EINA_FALSE if an error occurred, #EINA_TRUE otherwise.
*
* @note if you don't have the key_hash, use eina_hash_del_by_key() instead
.
* @note if you don't have the key, use eina_hash_del_by_data() instead.
*/
EAPI Eina_Bool eina_hash_del_by_key_hash(Eina_Hash *hash, EAPI Eina_Bool eina_hash_del_by_key_hash(Eina_Hash *hash,
const void *key, const void *key,
int key_length, int key_length,
int key_hash) EINA_ARG_NON NULL(1, 2); int key_hash) EINA_ARG_NON NULL(1, 2);
/**
* @brief Remove the entry identified by a key from the given hash table.
*
* This version will calculate key length and hash by using functions
* provided to hash creation function.
*
* @param hash The given hash table. Cannot be @c NULL.
* @param key The key. Cannot be @c NULL.
* @return #EINA_FALSE if an error occurred, #EINA_TRUE otherwise.
*
* This function removes the entry identified by @p key from @p
* hash. The key length and hash will be calculated automatically by
* using functiond provided to has creation function. If a free
* function was given to the callback on creation, it will be called
* for the data being deleted. If @p hash or @p key are @c NULL, the
* functions returns immediately #EINA_FALSE. This function returns
* #EINA_FALSE if an error occurred, #EINA_TRUE otherwise.
*
* @note if you already have the key_hash, use eina_hash_del_by_key_hash()
* instead.
* @note if you don't have the key, use eina_hash_del_by_data() instead.
*/
EAPI Eina_Bool eina_hash_del_by_key(Eina_Hash *hash, EAPI Eina_Bool eina_hash_del_by_key(Eina_Hash *hash,
const void *key) EINA_ARG_NONNULL(1, 2) ; const void *key) EINA_ARG_NONNULL(1, 2) ;
/**
* @brief Remove the entry identified by a data from the given hash table.
*
* This version is slow since there is no quick access to nodes based on da
ta.
*
* @param hash The given hash table. Cannot be @c NULL.
* @param data The data value to search and remove. Cannot be @c NULL.
* @return #EINA_FALSE if an error occurred, #EINA_TRUE otherwise.
* thing goes fine.
*
* This function removes the entry identified by @p data from @p
* hash. If a free function was given to the callback on creation, it
* will be called for the data being deleted. If @p hash or @p data
* are @c NULL, the functions returns immediately #EINA_FALSE. This
* function returns #EINA_FALSE if an error occurred, #EINA_TRUE
* otherwise.
*
* @note if you already have the key, use eina_hash_del_by_key() or
* eina_hash_del_by_key_hash() instead.
*/
EAPI Eina_Bool eina_hash_del_by_data(Eina_Hash *hash, EAPI Eina_Bool eina_hash_del_by_data(Eina_Hash *hash,
const void *data) EINA_ARG_NONNULL(1, 2); const void *data) EINA_ARG_NONNULL(1, 2);
/**
* @brief Remove the entry identified by a key and a key hash or a
* data from the given hash table.
*
* If @p key is @c NULL, then @p data is used to find a match to
* remove.
*
* @param hash The given hash table. Cannot be @c NULL.
* @param key The key.
* @param key_length The length of the key.
* @param key_hash The hash that always match the key.
* @param data The data pointer to remove if the key is @c NULL.
* @return #EINA_FALSE if an error occurred, #EINA_TRUE otherwise.
*
* This function removes the entry identified by @p key and
* @p key_hash, or @p data, from @p hash. If a free function was given to
* the callback on creation, it will be called for the data being
* deleted. If @p hash is @c NULL, the functions returns immediately
* #EINA_FALSE. If @p key is @c NULL, then @p key_length and @p key_hash
* are ignored and @p data is used to find a match to remove,
* otherwise @p key and @p key_hash are used and @p data is not
* required and can be @c NULL. Do not forget to count '\\0' for
* string when setting the value of @p key_length. This function
* returns #EINA_FALSE if an error occurred, #EINA_TRUE otherwise.
*
* @note if you know you already have the key, use eina_hash_del_by_key_has
h(),
* if you know you don't have the key, use eina_hash_del_by_data()
* directly.
*/
EAPI Eina_Bool eina_hash_del_by_hash(Eina_Hash *hash, EAPI Eina_Bool eina_hash_del_by_hash(Eina_Hash *hash,
const void *key, const void *key,
int key_length, int key_length,
int key_hash, int key_hash,
const void *data) EINA_ARG_NONNULL(1); const void *data) EINA_ARG_NONNULL(1);
/**
* @brief Retrieve a specific entry in the given hash table.
*
* @param hash The given hash table. Cannot be @c NULL.
* @param key The key of the entry to find.
* @param key_length The length of the key.
* @param key_hash The hash that always match the key
* @return The data pointer for the stored entry on success, @c NULL
* otherwise.
*
* This function retrieves the entry associated to @p key of length
* @p key_length in @p hash. @p key_hash is the hash that always match
* @p key. It is ignored if @p key is @c NULL. Do not forget to count
* '\\0' for string when setting the value of @p key_length. If
* @p hash is @c NULL, this function returns immediately @c NULL. This
* function returns the data pointer on success, @c NULL otherwise.
*/
EAPI void *eina_hash_find_by_hash(const Eina_Hash *hash, EAPI void *eina_hash_find_by_hash(const Eina_Hash *hash,
const void *key, const void *key,
int key_length, int key_length,
int key_hash) EINA_ARG_NONNU LL(1, 2); int key_hash) EINA_ARG_NONNU LL(1, 2);
/**
* @brief Modify the entry pointer at the specified key and returns
* the old entry.
*
* @param hash The given hash table.
* @param key The key of the entry to modify.
* @param key_length Should be the length of @p key (don't forget to count
* '\\0' for string).
* @param key_hash The hash that always match the key. Ignored if @p key is
* @c NULL.
* @param data The data to replace the old entry, if it exists.
* @return The data pointer for the old stored entry, or @c NULL if not
* found. If an existing entry is not found, nothing is added to t
he
* hash.
*/
EAPI void *eina_hash_modify_by_hash(Eina_Hash *hash, EAPI void *eina_hash_modify_by_hash(Eina_Hash *hash,
const void *key, const void *key,
int key_length, int key_length,
int key_hash, int key_hash,
const void *data) EINA_ARG_NONNULL(1, 2 , 5); const void *data) EINA_ARG_NONNULL(1, 2 , 5);
/**
* @brief Returned a new iterator associated to hash keys.
*
* @param hash The hash.
* @return A new iterator.
*
* This function returns a newly allocated iterator associated to @p
* hash. If @p hash is not populated, this function still returns a
* valid iterator that will always return false on
* eina_iterator_next(), thus keeping API sane.
*
* If the memory can not be allocated, NULL is returned and
* #EINA_ERROR_OUT_OF_MEMORY is set. Otherwise, a valid iterator is
* returned.
*
* @warning if the hash structure changes then the iterator becomes
* invalid! That is, if you add or remove items this iterator
* behavior is undefined and your program may crash!
*/
EAPI Eina_Iterator *eina_hash_iterator_key_new(const Eina_Hash *hash) EINA_ MALLOC EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT; EAPI Eina_Iterator *eina_hash_iterator_key_new(const Eina_Hash *hash) EINA_ MALLOC EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
/**
* @brief Returned a new iterator associated to hash data.
*
* @param hash The hash.
* @return A new iterator.
*
* This function returns a newly allocated iterator associated to
* @p hash. If @p hash is not populated, this function still returns a
* valid iterator that will always return false on
* eina_iterator_next(), thus keeping API sane.
*
* If the memory can not be allocated, @c NULL is returned and
* #EINA_ERROR_OUT_OF_MEMORY is set. Otherwise, a valid iterator is
* returned.
*
* @warning if the hash structure changes then the iterator becomes
* invalid. That is, if you add or remove items this iterator behavior
* is undefined and your program may crash.
*/
EAPI Eina_Iterator *eina_hash_iterator_data_new(const Eina_Hash *hash) EINA _MALLOC EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT; EAPI Eina_Iterator *eina_hash_iterator_data_new(const Eina_Hash *hash) EINA _MALLOC EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
/**
* @brief Returned a new iterator associated to hash keys and data.
*
* @param hash The hash.
* @return A new iterator.
*
* This function returns a newly allocated iterator associated to @p
* hash. If @p hash is not populated, this function still returns a
* valid iterator that will always return false on
* eina_iterator_next(), thus keeping API sane.
*
* If the memory can not be allocated, NULL is returned and
* #EINA_ERROR_OUT_OF_MEMORY is set. Otherwise, a valid iterator is
* returned.
*
* @note iterator data will provide values as Eina_Hash_Tuple that should n
ot
* be modified!
*
* @warning if the hash structure changes then the iterator becomes
* invalid! That is, if you add or remove items this iterator
* behavior is undefined and your program may crash!
*/
EAPI Eina_Iterator *eina_hash_iterator_tuple_new(const Eina_Hash *hash) EIN A_MALLOC EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT; EAPI Eina_Iterator *eina_hash_iterator_tuple_new(const Eina_Hash *hash) EIN A_MALLOC EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
/**
* @brief Call a function on every member stored in the hash table
*
* @param hash The hash table whose members will be walked
* @param func The function to call on each parameter
* @param fdata The data pointer to pass to the function being called
*
* This function goes through every entry in the hash table @p hash and cal
ls
* the function @p func on each member. The function should @b not modify t
he
* hash table contents if it returns 1. @b If the hash table contents are
* modified by this function or the function wishes to stop processing it m
ust
* return 0, otherwise return 1 to keep processing.
*
* Example:
* @code
* extern Eina_Hash *hash;
*
* Eina_Bool hash_fn(const Eina_Hash *hash, const void *key,
* void *data, void *fdata)
* {
* printf("Func data: %s, Hash entry: %s / %p\n",
* fdata, (const char *)key, data);
* return 1;
* }
*
* int main(int argc, char **argv)
* {
* char *hash_fn_data;
*
* hash_fn_data = strdup("Hello World");
* eina_hash_foreach(hash, hash_fn, hash_fn_data);
* free(hash_fn_data);
* }
* @endcode
*/
EAPI void eina_hash_foreach(const Eina_Hash *hash, EAPI void eina_hash_foreach(const Eina_Hash *hash,
Eina_Hash_Foreach cb, Eina_Hash_Foreach cb,
const void *fdata) EINA_ARG_NON NULL(1, 2); const void *fdata) EINA_ARG_NON NULL(1, 2);
/* Paul Hsieh (http://www.azillionmonkeys.com/qed/hash.html) hash function used by WebCore (http://webkit.org/blog/8/hashtables-part-2/) */ /* Paul Hsieh (http://www.azillionmonkeys.com/qed/hash.html) hash function used by WebCore (http://webkit.org/blog/8/hashtables-part-2/) */
EAPI int eina_hash_superfast(const char *key, EAPI int eina_hash_superfast(const char *key,
int len) EINA_ARG_NONNULL(1); int len) EINA_ARG_NONNULL(1);
/* Hash function first reported by dan bernstein many years ago in comp.lan g.c */ /* Hash function first reported by dan bernstein many years ago in comp.lan g.c */
static inline int eina_hash_djb2(const char *key, static inline int eina_hash_djb2(const char *key,
int len) EINA_ARG_NONNULL(1); int len) EINA_ARG_NONNULL(1);
static inline int eina_hash_djb2_len(const char *key, static inline int eina_hash_djb2_len(const char *key,
int *plen) EINA_ARG_NONNULL(1, 2); int *plen) EINA_ARG_NONNULL(1, 2);
/* Hash function from http://www.concentric.net/~Ttwang/tech/inthash.htm */ /* Hash function from http://www.concentric.net/~Ttwang/tech/inthash.htm */
static inline int eina_hash_int32(const unsigned int *pkey, static inline int eina_hash_int32(const unsigned int *pkey,
int len) EINA_ARG_NONNULL (1); int len) EINA_ARG_NONNULL (1);
static inline int eina_hash_int64(const unsigned long int *pkey, static inline int eina_hash_int64(const unsigned long int *pkey,
int len) EINA_ARG_NO NNULL(1); int len) EINA_ARG_NO NNULL(1);
/* http://sites.google.com/site/murmurhash/ */
static inline int eina_hash_murmur3(const char *key,
int len) EINA_ARG_NONNULL(1);
#include "eina_inline_hash.x" #include "eina_inline_hash.x"
/** /**
* @} * @}
*/ */
/** /**
* @} * @}
*/ */
 End of changes. 32 change blocks. 
3 lines changed or deleted 957 lines changed or added


 eina_inline_array.x   eina_inline_array.x 
skipping to change at line 114 skipping to change at line 114
* This function returns the data at the position @p idx in @p * This function returns the data at the position @p idx in @p
* array. For performance reasons, there is no check of @p array or @p * array. For performance reasons, there is no check of @p array or @p
* idx. If it is @c NULL or invalid, the program may crash. * idx. If it is @c NULL or invalid, the program may crash.
*/ */
static inline void * static inline void *
eina_array_data_get(const Eina_Array *array, unsigned int idx) eina_array_data_get(const Eina_Array *array, unsigned int idx)
{ {
return array->data[idx]; return array->data[idx];
} }
/**
* @brief Set the data at a given position in an array.
*
* @param array The array.
* @param idx The potition of the data to set.
* @param data The data to set.
*
* This function sets the data at the position @p idx in @p
* array. For performance reasons, there is no check of @p array or @p
* idx. If it is @c NULL or invalid, the program may crash.
*/
static inline void static inline void
eina_array_data_set(const Eina_Array *array, unsigned int idx, const void * data) eina_array_data_set(const Eina_Array *array, unsigned int idx, const void * data)
{ {
array->data[idx] = (void*) data; array->data[idx] = (void*) data;
} }
/** /**
* @brief Return the number of elements in an array. * @brief Return the number of elements in an array.
* *
* @param array The array. * @param array The array.
skipping to change at line 147 skipping to change at line 136
* This function returns the number of elements in @p array. For * This function returns the number of elements in @p array. For
* performance reasons, there is no check of @p array. If it is * performance reasons, there is no check of @p array. If it is
* @c NULL or invalid, the program may crash. * @c NULL or invalid, the program may crash.
*/ */
static inline unsigned int static inline unsigned int
eina_array_count_get(const Eina_Array *array) eina_array_count_get(const Eina_Array *array)
{ {
return array->count; return array->count;
} }
/**
* @brief Provide a safe way to iterate over an array
*
* @param array The array to iterate over.
* @param cb The callback to call for each item.
* @param fdata The user data to pass to the callback.
* @return EINA_TRUE if it successfully iterate all items of the array.
*
* This function provide a safe way to iterate over an array. @p cb should
* return EINA_TRUE as long as you want the function to continue iterating,
* by returning EINA_FALSE it will stop and return EINA_FALSE as a result.
*/
static inline Eina_Bool static inline Eina_Bool
eina_array_foreach(Eina_Array *array, Eina_Each_Cb cb, void *fdata) eina_array_foreach(Eina_Array *array, Eina_Each_Cb cb, void *fdata)
{ {
void *data; void *data;
Eina_Array_Iterator iterator; Eina_Array_Iterator iterator;
unsigned int i; unsigned int i;
Eina_Bool ret = EINA_TRUE; Eina_Bool ret = EINA_TRUE;
EINA_ARRAY_ITER_NEXT(array, i, data, iterator) EINA_ARRAY_ITER_NEXT(array, i, data, iterator)
if (cb(array, data, fdata) != EINA_TRUE) if (cb(array, data, fdata) != EINA_TRUE)
{ {
ret = EINA_FALSE; ret = EINA_FALSE;
break; break;
} }
return ret; return ret;
} }
/**
* @brief Clean an array.
*
* @param array The array to clean.
*
* This function sets the count member of @p array to 0. For
* performance reasons, there is no check of @p array. If it is
* @c NULL or invalid, the program may crash.
*/
static inline void static inline void
eina_array_clean(Eina_Array *array) eina_array_clean(Eina_Array *array)
{ {
array->count = 0; array->count = 0;
} }
/** /**
* @} * @}
*/ */
 End of changes. 3 change blocks. 
32 lines changed or deleted 0 lines changed or added


 eina_inline_hash.x   eina_inline_hash.x 
skipping to change at line 59 skipping to change at line 59
hash_num = ((hash_num << 5) + hash_num) ^ *ptr; /* hash * 33 ^ c */ hash_num = ((hash_num << 5) + hash_num) ^ *ptr; /* hash * 33 ^ c */
*plen = len + 1; *plen = len + 1;
return (int)hash_num; return (int)hash_num;
} }
static inline int static inline int
eina_hash_int32(const unsigned int *pkey, int len) eina_hash_int32(const unsigned int *pkey, int len)
{ {
unsigned int key = *pkey; unsigned int key = *pkey;
(void) len; (void) len;
key = ~key + (key << 15); key = ~key + (key << 15);
key = key ^ (key >> 12); key ^= key >> 12;
key = key + (key << 2); key += key << 2;
key = key ^ (key >> 4); key ^= key >> 4;
key = key * 2057; key *= 2057;
key = key ^ (key >> 16); key ^= key >> 16;
return key; return key;
} }
static inline int static inline int
eina_hash_int64(const unsigned long int *pkey, int len) eina_hash_int64(const unsigned long int *pkey, int len)
{ {
unsigned long int key = *pkey; unsigned long int key = *pkey;
(void) len; (void) len;
key = (~key) + (key << 18); key = ~key + (key << 18);
key = key ^ (key >> 31); key ^= key >> 31;
key = key * 21; key *= 21;
key = key ^ (key >> 11); key ^= key >> 11;
key = key + (key << 6); key += key << 6;
key = key ^ (key >> 22); key ^= key >> 22;
return (int) key; return (int) key;
} }
static inline unsigned int _rotl32(unsigned int x, char r)
{
return (x << r) | (x >> (32 - r));
}
static inline unsigned int _fmix32(unsigned int h)
{
h ^= h >> 16;
h *= 0x85ebca6b;
h ^= h >> 13;
h *= 0xc2b2ae35;
h ^= h >> 16;
return h;
}
int
eina_hash_murmur3(const char *key, int len)
{
const unsigned char * data = (const unsigned char*)key;
const int nblocks = len / 4;
unsigned int h1 = 0, k1;
unsigned int c1 = 0xcc9e2d51;
unsigned int c2 = 0x1b873593;
const unsigned int * blocks = (const unsigned int *)(data + nblocks*4);
int i;
const unsigned char *tail;
for(i = -nblocks; i; i++)
{
k1 = blocks[i];
k1 *= c1;
k1 = _rotl32(k1, 15);
k1 *= c2;
h1 ^= k1;
h1 = _rotl32(h1, 13);
h1 = h1*5+0xe6546b64;
}
tail = (const unsigned char*)(data + nblocks*4);
k1 = 0;
switch(len & 3)
{
case 3:
k1 ^= tail[2] << 16;
case 2:
k1 ^= tail[1] << 8;
case 1:
k1 ^= tail[0];
k1 *= c1;
k1 = _rotl32(k1, 16);
k1 *= c2;
h1 ^= k1;
}
h1 ^= len;
return _fmix32(h1);
}
#endif #endif
 End of changes. 7 change blocks. 
18 lines changed or deleted 81 lines changed or added


 eina_inline_list.x   eina_inline_list.x 
skipping to change at line 22 skipping to change at line 22
* Lesser General Public License for more details. * Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public * You should have received a copy of the GNU Lesser General Public
* License along with this library; * License along with this library;
* if not, see <http://www.gnu.org/licenses/>. * if not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef EINA_LIST_INLINE_H_ #ifndef EINA_LIST_INLINE_H_
#define EINA_LIST_INLINE_H_ #define EINA_LIST_INLINE_H_
/**
* @addtogroup Eina_List_Group List
*
* @brief These functions provide list management.
*
* @{
*/
/**
* @brief Get the last list node in the list.
*
* @param list The list to get the last list node from.
* @return The last list node in the list.
*
* This function returns the last list node in the list @p list. If
* @p list is @c NULL or empty, @c NULL is returned.
*
* This is a order-1 operation (it takes the same short time
* regardless of the length of the list).
*/
static inline Eina_List * static inline Eina_List *
eina_list_last(const Eina_List *list) eina_list_last(const Eina_List *list)
{ {
if (!list) return NULL; if (!list) return NULL;
return list->accounting->last; return list->accounting->last;
} }
/**
* @brief Get the next list node after the specified list node.
*
* @param list The list node to get the next list node from
* @return The next list node on success, @c NULL otherwise.
*
* This function returns the next list node after the current one in
* @p list. It is equivalent to list->next. If @p list is @c NULL or
* if no next list node exists, it returns @c NULL.
*/
static inline Eina_List * static inline Eina_List *
eina_list_next(const Eina_List *list) eina_list_next(const Eina_List *list)
{ {
if (!list) return NULL; if (!list) return NULL;
return list->next; return list->next;
} }
/**
* @brief Get the previous list node before the specified list node.
*
* @param list The list node to get the previous list node from.
* @return The previous list node o success, @c NULL otherwise.
* if no previous list node exists
*
* This function returns the previous list node before the current one
* in @p list. It is equivalent to list->prev. If @p list is @c NULL or
* if no previous list node exists, it returns @c NULL.
*/
static inline Eina_List * static inline Eina_List *
eina_list_prev(const Eina_List *list) eina_list_prev(const Eina_List *list)
{ {
if (!list) return NULL; if (!list) return NULL;
return list->prev; return list->prev;
} }
/**
* @brief Get the list node data member.
*
* @param list The list node to get the data member of.
* @return The data member from the list node.
*
* This function returns the data member of the specified list node @p
* list. It is equivalent to list->data. If @p list is @c NULL, this
* function returns @c NULL.
*/
static inline void * static inline void *
eina_list_data_get(const Eina_List *list) eina_list_data_get(const Eina_List *list)
{ {
if (!list) return NULL; if (!list) return NULL;
return list->data; return list->data;
} }
/**
* @brief Set the list node data member.
*
* @param list The list node to get the data member of.
* @param data The data member to the list node.
* @return The previous data value.
*
* This function set the data member @p data of the specified list node
* @p list. It returns the previous data of the node. If @p list is
* @c NULL, this function returns @c NULL.
*/
static inline void * static inline void *
eina_list_data_set(Eina_List *list, const void *data) eina_list_data_set(Eina_List *list, const void *data)
{ {
void *tmp; void *tmp;
if (!list) return NULL; if (!list) return NULL;
tmp = list->data; tmp = list->data;
list->data = (void*) data; list->data = (void*) data;
return tmp; return tmp;
} }
/**
* @brief Get the count of the number of items in a list.
*
* @param list The list whose count to return.
* @return The number of members in the list.
*
* This function returns how many members @p list contains. If the
* list is @c NULL, 0 is returned.
*
* NB: This is an order-1 operation and takes the same time regardless
* of the length of the list.
*/
static inline unsigned int static inline unsigned int
eina_list_count(const Eina_List *list) eina_list_count(const Eina_List *list)
{ {
if (!list) return 0; if (!list) return 0;
return list->accounting->count; return list->accounting->count;
} }
/**
* @}
*/
#endif /* EINA_LIST_INLINE_H_ */ #endif /* EINA_LIST_INLINE_H_ */
 End of changes. 7 change blocks. 
78 lines changed or deleted 0 lines changed or added


 eina_inline_log.x   eina_inline_log.x 
skipping to change at line 52 skipping to change at line 52
* my_func_code(data); * my_func_code(data);
* } * }
* @endcode * @endcode
* *
* @return #EINA_TRUE if level is equal or smaller than the current global * @return #EINA_TRUE if level is equal or smaller than the current global
* logging level. * logging level.
*/ */
static inline Eina_Bool static inline Eina_Bool
eina_log_level_check(int level) eina_log_level_check(int level)
{ {
return eina_log_level_get() >= level; return eina_log_level_get() <= level;
} }
/** /**
* Checks whenever the given level should be printed out. * Checks whenever the given level should be printed out.
* *
* This is useful to enable certain blocks of code just when given * This is useful to enable certain blocks of code just when given
* level is to be used. * level is to be used.
* *
* @code * @code
* #include <Eina.h> * #include <Eina.h>
skipping to change at line 84 skipping to change at line 84
* *
* @return #EINA_TRUE if level is equal or smaller than the current * @return #EINA_TRUE if level is equal or smaller than the current
* domain logging level. * domain logging level.
*/ */
static inline Eina_Bool static inline Eina_Bool
eina_log_domain_level_check(int domain, int level) eina_log_domain_level_check(int domain, int level)
{ {
int dom_level = eina_log_domain_registered_level_get(domain); int dom_level = eina_log_domain_registered_level_get(domain);
if (EINA_UNLIKELY(dom_level == EINA_LOG_LEVEL_UNKNOWN)) if (EINA_UNLIKELY(dom_level == EINA_LOG_LEVEL_UNKNOWN))
return EINA_FALSE; return EINA_FALSE;
return dom_level >= level; return dom_level <= level;
} }
/** /**
* Function to format the level as a 3 character (+1 null byte) string. * Function to format the level as a 3 character (+1 null byte) string.
* *
* This function converts the given level to a known string name (CRI, * This function converts the given level to a known string name (CRI,
* ERR, WRN, INF or DBG) or a zero-padded 3-character string. In any * ERR, WRN, INF or DBG) or a zero-padded 3-character string. In any
* case the last byte will contain a trailing null byte. * case the last byte will contain a trailing null byte.
* *
* If extreme level values are used (greater than 999 and smaller than * If extreme level values are used (greater than 999 and smaller than
 End of changes. 2 change blocks. 
2 lines changed or deleted 2 lines changed or added


 eina_inline_mempool.x   eina_inline_mempool.x 
skipping to change at line 29 skipping to change at line 29
#ifndef EINA_INLINE_MEMPOOL_X_ #ifndef EINA_INLINE_MEMPOOL_X_
#define EINA_INLINE_MEMPOOL_X_ #define EINA_INLINE_MEMPOOL_X_
/** /**
* @addtogroup Eina_Memory_Pool_Group Memory Pool * @addtogroup Eina_Memory_Pool_Group Memory Pool
* *
* @{ * @{
*/ */
/* Memory Pool */ /* Memory Pool */
typedef struct _Eina_Mempool_Backend_ABI1 Eina_Mempool_Backend_ABI1;
typedef struct _Eina_Mempool_Backend_ABI2 Eina_Mempool_Backend_ABI2;
struct _Eina_Mempool_Backend struct _Eina_Mempool_Backend
{ {
const char *name; const char *name;
void *(*init)(const char *context, const char *options, va_list args); void *(*init)(const char *context, const char *options, va_list args);
void (*free)(void *data, void *element); void (*free)(void *data, void *element);
void *(*alloc)(void *data, unsigned int size); void *(*alloc)(void *data, unsigned int size);
void *(*realloc)(void *data, void *element, unsigned int size); void *(*realloc)(void *data, void *element, unsigned int size);
void (*garbage_collect)(void *data); void (*garbage_collect)(void *data);
void (*statistics)(void *data); void (*statistics)(void *data);
void (*shutdown)(void *data); void (*shutdown)(void *data);
void (*repack)(void *data, Eina_Mempool_Repack_Cb cb, void *cb_data);
};
struct _Eina_Mempool_Backend_ABI1
{
const char *name;
void *(*init)(const char *context, const char *options, va_list args);
void (*free)(void *data, void *element);
void *(*alloc)(void *data, unsigned int size);
void *(*realloc)(void *data, void *element, unsigned int size);
void (*garbage_collect)(void *data);
void (*statistics)(void *data);
void (*shutdown)(void *data);
};
struct _Eina_Mempool_Backend_ABI2
{
void (*repack)(void *data, Eina_Mempool_Repack_Cb cb, void *cb_data);
}; };
struct _Eina_Mempool struct _Eina_Mempool
{ {
Eina_Mempool_Backend backend; Eina_Mempool_Backend_ABI1 backend;
void *backend_data; void *backend_data;
Eina_Mempool_Backend_ABI2 *backend2;
}; };
/** /**
* @brief Re-allocate a amount memory by the given mempool. * @brief Re-allocate a amount memory by the given mempool.
* *
* @param mp The mempool. * @param mp The mempool.
* @param element The element to re-allocate. * @param element The element to re-allocate.
* @param size The size in bytes to re-allocate. * @param size The size in bytes to re-allocate.
* @return The newly re-allocated data. * @return The newly re-allocated data.
* *
 End of changes. 4 change blocks. 
1 lines changed or deleted 23 lines changed or added


 eina_inline_tiler.x   eina_inline_tiler.x 
skipping to change at line 45 skipping to change at line 45
int w1_rel, h1_rel; // width,height of the first col,row int w1_rel, h1_rel; // width,height of the first col,row
int w2_rel, h2_rel; // width,height of the last col,row int w2_rel, h2_rel; // width,height of the last col,row
struct Eina_Tile_Grid_Info info; // info about the current tile struct Eina_Tile_Grid_Info info; // info about the current tile
Eina_Bool first; Eina_Bool first;
}; };
/** /**
* @endcond * @endcond
*/ */
/**
* @brief Iterates over the tiles set by eina_tile_grid_slicer_setup().
*
* @param slc Pointer to an Eina_Tile_Grid_Slicer struct.
* @param rect Pointer to a struct Eina_Tile_Grid_Info *.
* @return @c EINA_TRUE if the current rect is valid.
* @c EINA_FALSE if there is no more rects to iterate over (and
* thus the current one isn't valid).
*
* This functions iterates over each Eina_Tile_Grid_Info *rect of the grid.
* eina_tile_grid_slicer_setup() must be called first, and *rect is only va
lid
* if this function returns EINA_TRUE. Its content shouldn't be modified.
*/
static inline Eina_Bool static inline Eina_Bool
eina_tile_grid_slicer_next(Eina_Tile_Grid_Slicer *slc, const Eina_Tile_Grid _Info **rect) eina_tile_grid_slicer_next(Eina_Tile_Grid_Slicer *slc, const Eina_Tile_Grid _Info **rect)
{ {
EINA_SAFETY_ON_NULL_RETURN_VAL(slc, 0); EINA_SAFETY_ON_NULL_RETURN_VAL(slc, 0);
if (slc->first) if (slc->first)
{ {
slc->first = 0; slc->first = 0;
*rect = &slc->info; *rect = &slc->info;
return EINA_TRUE; return EINA_TRUE;
skipping to change at line 105 skipping to change at line 92
if (slc->info.rect.w == slc->tile_w && slc->info.rect.h == slc->tile_h) if (slc->info.rect.w == slc->tile_w && slc->info.rect.h == slc->tile_h)
slc->info.full = EINA_TRUE; slc->info.full = EINA_TRUE;
else else
slc->info.full = EINA_FALSE; slc->info.full = EINA_FALSE;
*rect = &slc->info; *rect = &slc->info;
return EINA_TRUE; return EINA_TRUE;
} }
/**
* @brief Setup an Eina_Tile_Grid_Slicer struct.
*
* @param slc Pointer to an Eina_Tile_Grid_Slicer struct.
* @param x X axis coordinate.
* @param y Y axis coordinate.
* @param w width.
* @param h height.
* @param tile_w tile width.
* @param tile_h tile height.
* @return A pointer to the Eina_Iterator.
* @c NULL on failure.
*
* This function splits the rectangle given as argument into tiles of size
* tile_w X tile_h, and returns an iterator to them. The geometry of each
* tile can be accessed with eina_tile_grid_slicer_next, where rect
* will be a pointer to a struct Eina_Tile_Grid_Info.
*/
static inline Eina_Bool static inline Eina_Bool
eina_tile_grid_slicer_setup(Eina_Tile_Grid_Slicer *slc, int x, int y, int w , int h, int tile_w, int tile_h) eina_tile_grid_slicer_setup(Eina_Tile_Grid_Slicer *slc, int x, int y, int w , int h, int tile_w, int tile_h)
{ {
int tx1, tx2, ty1, ty2; int tx1, tx2, ty1, ty2;
EINA_SAFETY_ON_NULL_RETURN_VAL(slc, 0); EINA_SAFETY_ON_NULL_RETURN_VAL(slc, 0);
tx1 = x; tx1 = x;
ty1 = y; ty1 = y;
tx2 = x + w - 1; tx2 = x + w - 1;
 End of changes. 2 change blocks. 
32 lines changed or deleted 0 lines changed or added


 eina_inlist.h   eina_inlist.h 
skipping to change at line 28 skipping to change at line 28
#ifndef EINA_INLIST_H_ #ifndef EINA_INLIST_H_
#define EINA_INLIST_H_ #define EINA_INLIST_H_
#include "eina_types.h" #include "eina_types.h"
#include "eina_iterator.h" #include "eina_iterator.h"
#include "eina_accessor.h" #include "eina_accessor.h"
#include <stddef.h> #include <stddef.h>
/** /**
* @page inlist_01_example_page Eina_Inlist basic usage
* @dontinclude eina_inlist_01.c
*
* To see the full source for this example, click here: @ref
* eina_inlist_01_c
*
* As explained before, inline lists mean its nodes pointers are part of sa
me
* memory block/blob. This is done by using the macro @ref EINA_INLIST insi
de the
* data structure that will be used:
*
* @skip struct
* @until };
*
* The resulting node representing this struct can be exemplified by the
* following picture:
*
* @image html eina_inlist-node_eg1-my-struct.png
* @image rtf eina_inlist-node_eg1-my-struct.png
* @image latex eina_inlist-node_eg1-my-struct.eps
*
* Let's define a comparison function that will be used later during the
* sorting of the list:
*
* @skip int
* @until }
*
* The @ref Eina_Inlist can be used exactly the same way as @ref Eina_List
when
* appending, prepending and removing items. But since we already have the
node
* pointers inside the structure, they need to be retrieved with the macro
@ref
* EINA_INLIST_GET :
*
* @skip malloc
* @until append
*
* Notice that @ref eina_inlist_append always receives the head of the list
as
* first argument, and its return value should be used as the list pointer
* (head):
*
* @skip malloc
* @until append
*
* After appending 3 items, the list now should look similar to this:
*
* @image html eina_inlist-node_eg1-inlist.png
* @image rtf eina_inlist-node_eg1-inlist.png
* @image latex eina_inlist-node_eg1-inlist.eps width=\textwidth
*
* The macro @ref EINA_INLIST_FOREACH can be used to iterate over the list:
*
* @skip printf
* @until cur->a
*
* @ref eina_inlist_promote(), @ref eina_inlist_demote(), @ref
* eina_inlist_append_relative() and similar functions all work in the same
way
* as the @ref Eina_List :
*
* @skip eina_inlist_promote
* @until eina_inlist_demote
*
* Now let's use the @c sort_cb function declared above to sort our list:
*
* @skipline eina_inlist_sort
*
* Removing an element from the inlist is also similar to @ref Eina_List :
*
* @skip inlist_remove
* @until free
*
* Another way of walking through the inlist.
*
* @skip for
* @until }
*
* Notice that in the previous piece of code, since we only have the pointe
rs to
* the inlist nodes, we have to use the @ref EINA_INLIST_CONTAINER_GET macr
o
* that will return the pointer to the entire structure. Of course, in this
case
* it is the same as the list pointer, since the @ref EINA_INLIST macro was
used
* in the beginning of the structure.
*
* Now to finish this example, lets delete this list:
*
* @skip while
* @until }
*/
/**
* @page inlist_02_example_page Eina_Inlist advanced usage - lists and inli
sts
* @dontinclude eina_inlist_02.c
*
* This example describes the usage of @ref Eina_Inlist mixed with @ref
* Eina_List . We create and add elements to an inlist, and the even member
s
* are also added to a normal list. Later we remove the elements divisible
by 3
* from this normal list.
*
* The struct that is going to be used is the same used in @ref
* inlist_01_example_page , since we still need the @ref EINA_INLIST macro
to
* declare the inlist node info:
*
* @skip struct
* @until };
*
* The resulting node representing this struct can be exemplified by the
* following picture:
*
* @image html eina_inlist-node_eg2-my-struct.png
* @image rtf eina_inlist-node_eg2-my-struct.png
* @image latex eina_inlist-node_eg2-my-struct.eps
*
* Now we need some pointers and auxiliar variables that will help us itera
te on
* the lists:
*
* @skip struct
* @until l_next;
*
* Allocating 100 elements and putting them into an inlist, and the even
* elements also go to the normal list:
*
* @skip for
* @until }
*
* After this point, what we have are two distinct lists that share some
* elements. The first list (inlist) is defined by the pointers inside the
* elements data structure, while the second list (normal list) has its own
node
* data structure that is kept outside of the elements.
*
* The two lists, sharing some elements, can be represented by the followin
g
* picture:
*
* @htmlonly
* <img src="eina_inlist-node_eg2-list-inlist.png" style="max-width: 100%;"
/>
* @endhtmlonly
* @image rtf eina_inlist-node_eg2-list-inlist.png
* @image latex eina_inlist-node_eg2-list-inlist.eps width=\textwidth
*
* Accessing both lists is done normally, as if they didn't have any elemen
ts in
* common:
*
* @skip printf
* @until eina_list_count
*
* We can remove elements from the normal list, but we just don't free them
* because they are still stored in the inlist:
*
* @skip EINA_LIST_FOREACH_SAFE
* @until eina_list_count
*
* To finish this example, we want to free both lists, we can't just free a
ll
* elements on the second list (normal list) because they are still being u
sed
* in the inlist. So we first discard the normal list without freeing its
* elements, then we free all elements in the inlist (that contains all ele
ments
* allocated until now):
*
* @skip eina_list_free
* @until }
*
* Here is the full source code for this example: @ref eina_inlist_02_c
*/
/**
* @page inlist_03_example_page Eina_Inlist advanced usage - multi-inlists
* @dontinclude eina_inlist_03.c
*
* This example describes the usage of multiple inlists storing the same da
ta.
* It means that some data may appear in more than one inlist at the same t
ime.
* We will demonstrate this by creating an inlist with 100 numbers, and add
ing
* the odd numbers to the second inlist, then remove the numbers divisible
by 3
* from the second list.
*
* To accomplish this, it is necessary to have two inlist pointers in the s
truct
* that is going to be stored. We are using the default inlist member @ref
* EINA_INLIST, and adding another member @c even that is of type @ref
* Eina_Inlist too:
*
* @skip struct
* @until };
*
* The representation for this struct is:
*
* @image html eina_inlist-node_eg3-my-struct.png
* @image rtf eina_inlist-node_eg3-my-struct.png
* @image latex eina_inlist-node_eg3-my-struct.eps
*
* And we will define some convenience macros that are equivalent to @ref
* EINA_INLIST_GET and @ref EINA_INLIST_CONTAINER_GET :
*
* @skip define
* @until offsetof
*
* We need two pointers, one for each list, and a pointer that will be used
as
* an iterator:
*
* @skipline Eina_Inlist
*
* Now we allocate and add to the first list every number from 0 to 99. The
se
* nodes data also have the @ref Eina_Inlist node info for the second list
(@c
* even). We will use them to add just the even numbers to the second list,
the
* @c list_even. Also notice that we are using our macro @c EVEN_INLIST_GET
to
* get the pointer to the even list node info:
*
* @skip for
* @until }
*
* And the resulting lists will be as follow:
*
* @htmlonly
* <img src="eina_inlist-node_eg3-two-inlists.png" style="max-width: 100%;"
/>
* @endhtmlonly
* @image rtf eina_inlist-node_eg3-two-inlists.png
* @image latex eina_inlist-node_eg3-two-inlists.eps width=\textwidth
*
* For the first list, we can use the macro @ref EINA_INLIST_FOREACH to ite
rate
* over its elements:
*
* @skip FOREACH
* @until printf
*
* But for the second list, we have to do it manually. Of course we could c
reate
* a similar macro to @ref EINA_INLIST_FOREACH, but since this macro is mor
e
* complex than the other two and we are using it only once, it's better to
just
* do it manually:
*
* @skip for
* @until }
*
* Let's just check that the two lists have the expected number of elements
:
*
* @skip list count
* @until list_even count
*
* And removing the numbers divisible by 3 only from the second list:
*
* @skip itr
* @until list_even count
*
* Now that we don't need the two lists anymore, we can just free all the i
tems.
* Since all of the allocated data was put into the first list, and both li
sts
* are made of pointers to inside the data structures, we can free only the
* first list (that contains all the elements) and the second list will be
gone
* with it:
*
* @skip while
* @until free
*
* To see the full source code for this example, click here: @ref
* eina_inlist_03_c
*
*/
/**
* @page eina_inlist_01_c eina_inlist_01.c Eina_Inlist basic usage source
* @include eina_inlist_01.c
*/
/**
* @page eina_inlist_02_c eina_inlist_02.c Eina_Inlist advanced usage - lis
ts and inlists source
* @include eina_inlist_02.c
*/
/**
* @page eina_inlist_03_c eina_inlist_03.c Eina_Inlist advanced usage - mul
ti-inlists source
* @include eina_inlist_03.c
*/
/**
* @addtogroup Eina_Inline_List_Group Inline List
*
* @brief These functions provide inline list management.
*
* Inline lists mean its nodes pointers are part of same memory as
* data. This has the benefit of fragmenting memory less and avoiding
* @c node->data indirection, but has the drawback of higher cost for some
* common operations like count and sort.
*
* It is possible to have inlist nodes to be part of regular lists, created
with
* @ref eina_list_append() or @ref eina_list_prepend(). It's also possible
to
* have a structure with two inlist pointers, thus be part of two different
* inlists at the same time, but the current convenience macros provided wo
n't
* work for both of them. Consult @ref inlist_advanced for more info.
*
* Inline lists have their purposes, but if you don't know what those purpo
ses are, go with
* regular lists instead.
*
* Tip: When using inlists in more than one place (that is, passing them ar
ound
* functions or keeping a pointer to them in a structure) it's more correct
* to keep a pointer to the first container, and not a pointer to the first
* inlist item (mostly they are the same, but that's not always correct).
* This lets the compiler to do type checking and let the programmer know
* exactly what type this list is.
*
* A simple example demonstrating the basic usage of an inlist can be found
* here: @ref inlist_01_example_page
*
* @section inlist_algo Algorithm
*
* The basic structure can be represented by the following picture:
*
* @image html eina_inlist-node.png
* @image rtf eina_inlist-node.png
* @image latex eina_inlist-node.eps
*
* One data structure will also have the node information, with three point
ers:
* @a prev, @a next and @a last. The @a last pointer is just valid for the
first
* element (the list head), otherwise each insertion in the list would have
to
* be done updating every node with the correct pointer. This means that it
's
* always very important to keep a pointer to the first element of the list
,
* since it is the only one that has the correct information to allow a pro
per
* O(1) append to the list.
*
* @section inlist_perf Performance
*
* Due to the nature of the inlist, there's no accounting information, and
no
* easy access to the last element from each list node. This means that @re
f
* eina_inlist_count() is order-N, while @ref eina_list_count() is order-1
(constant
* time).
*
* For the same reasons, @ref eina_inlist_sort() is slower than @ref
* eina_list_sort() . If the list is intended to have faster access, be
* sorted/merged frequently, or needs to have other complex operations, con
sider
* using @ref Eina_List instead.
*
* @section inlist_advanced Advanced Usage
*
* The basic usage considers a struct that will have the user data, and als
o
* have an inlist node information (prev, next and last pointers) created w
ith
* @ref EINA_INLIST during the struct declaration. This allows one to use t
he
* convenience macros @ref EINA_INLIST_GET(), @ref EINA_INLIST_CONTAINER_GE
T(),
* @ref EINA_INLIST_FOREACH() and so. This happens because the @ref EINA_IN
LIST
* macro declares a struct member with the name @a __inlist, and all the ot
her
* macros assume that this struct member has this name.
*
* It may be the case that someone needs to have some inlist nodes added to
a
* @ref Eina_List too. If this happens, the inlist nodes can be added to th
e
* @ref Eina_List without any problems. This example demonstrates this case
:
* @ref inlist_02_example_page
*
* It's also possible to have some data that is part of two different inlis
ts.
* If this is the case, then it won't be possible to use the convenience ma
cros
* to both of the lists. It will be necessary to create a new set of macros
that
* will allow access to the second list node info. An example for this usag
e can
* be found here:
* @ref inlist_03_example_page
*
* List of examples:
* @li @ref inlist_01_example_page
* @li @ref inlist_02_example_page
* @li @ref inlist_03_example_page
*/
/**
* @addtogroup Eina_Data_Types_Group Data Types * @addtogroup Eina_Data_Types_Group Data Types
* *
* @{ * @{
*/ */
/** /**
* @addtogroup Eina_Containers_Group Containers * @addtogroup Eina_Containers_Group Containers
* *
* @{ * @{
*/ */
skipping to change at line 52 skipping to change at line 401
* @{ * @{
*/ */
/** /**
* @typedef Eina_Inlist * @typedef Eina_Inlist
* Inlined list type. * Inlined list type.
*/ */
typedef struct _Eina_Inlist Eina_Inlist; typedef struct _Eina_Inlist Eina_Inlist;
/** /**
* @typedef Eina_Inlist_Sorted_State
* @since 1.1.0
* State of sorted Eina_Inlist
*/
typedef struct _Eina_Inlist_Sorted_State Eina_Inlist_Sorted_State;
/**
* @struct _Eina_Inlist * @struct _Eina_Inlist
* Inlined list type. * Inlined list type.
*/ */
struct _Eina_Inlist struct _Eina_Inlist
{ {
Eina_Inlist *next; /**< next node */ Eina_Inlist *next; /**< next node */
Eina_Inlist *prev; /**< previous node */ Eina_Inlist *prev; /**< previous node */
Eina_Inlist *last; /**< last node */ Eina_Inlist *last; /**< last node */
}; };
/** Used for declaring an inlist member in a struct */ /** Used for declaring an inlist member in a struct */
#define EINA_INLIST Eina_Inlist __in_list #define EINA_INLIST Eina_Inlist __in_list
/** Utility macro to get the inlist object of a struct */ /** Utility macro to get the inlist object of a struct */
#define EINA_INLIST_GET(Inlist) (& ((Inlist)->__in_list)) #define EINA_INLIST_GET(Inlist) (& ((Inlist)->__in_list))
/** Utility macro to get the container object of an inlist */ /** Utility macro to get the container object of an inlist */
#define EINA_INLIST_CONTAINER_GET(ptr, \ #define EINA_INLIST_CONTAINER_GET(ptr, \
type) ((type *)((char *)ptr - \ type) ((type *)((char *)ptr - \
offsetof(type, __in_list) )) offsetof(type, __in_list) ))
/**
* Add a new node to end of a list.
*
* @note this code is meant to be fast: appends are O(1) and do not
* walk @a list.
*
* @note @a new_l is considered to be in no list. If it was in another
* list before, eina_inlist_remove() it before adding. No
* check of @a new_l prev and next pointers is done, so it's safe
* to have them uninitialized.
*
* @param list existing list head or NULL to create a new list.
* @param new_l new list node, must not be NULL.
*
* @return the new list head. Use it and not @a list anymore.
*/
EAPI Eina_Inlist *eina_inlist_append(Eina_Inlist *in_list, EAPI Eina_Inlist *eina_inlist_append(Eina_Inlist *in_list,
Eina_Inlist *in_item) EINA_ARG_NONNULL (2) EINA_WARN_UNUSED_RESULT; Eina_Inlist *in_item) EINA_ARG_NONNULL (2) EINA_WARN_UNUSED_RESULT;
/**
* Add a new node to beginning of list.
*
* @note this code is meant to be fast: appends are O(1) and do not
* walk @a list.
*
* @note @a new_l is considered to be in no list. If it was in another
* list before, eina_inlist_remove() it before adding. No
* check of @a new_l prev and next pointers is done, so it's safe
* to have them uninitialized.
*
* @param list existing list head or NULL to create a new list.
* @param new_l new list node, must not be NULL.
*
* @return the new list head. Use it and not @a list anymore.
*/
EAPI Eina_Inlist *eina_inlist_prepend(Eina_Inlist *in_list, EAPI Eina_Inlist *eina_inlist_prepend(Eina_Inlist *in_list,
Eina_Inlist *in_item) EINA_ARG_NONNUL L(2) EINA_WARN_UNUSED_RESULT; Eina_Inlist *in_item) EINA_ARG_NONNUL L(2) EINA_WARN_UNUSED_RESULT;
/**
* Add a new node after the given relative item in list.
*
* @note this code is meant to be fast: appends are O(1) and do not
* walk @a list.
*
* @note @a new_l is considered to be in no list. If it was in another
* list before, eina_inlist_remove() it before adding. No
* check of @a new_l prev and next pointers is done, so it's safe
* to have them uninitialized.
*
* @note @a relative is considered to be inside @a list, no checks are
* done to confirm that and giving nodes from different lists
* will lead to problems. Giving NULL @a relative is the same as
* eina_list_append().
*
* @param list existing list head or NULL to create a new list.
* @param new_l new list node, must not be NULL.
* @param relative reference node, @a new_l will be added after it.
*
* @return the new list head. Use it and not @a list anymore.
*/
EAPI Eina_Inlist *eina_inlist_append_relative(Eina_Inlist *in_list, EAPI Eina_Inlist *eina_inlist_append_relative(Eina_Inlist *in_list,
Eina_Inlist *in_item, Eina_Inlist *in_item,
Eina_Inlist *in_relative) EIN A_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT; Eina_Inlist *in_relative) EIN A_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
/**
* Add a new node before the given relative item in list.
*
* @note this code is meant to be fast: appends are O(1) and do not
* walk @a list.
*
* @note @a new_l is considered to be in no list. If it was in another
* list before, eina_inlist_remove() it before adding. No
* check of @a new_l prev and next pointers is done, so it's safe
* to have them uninitialized.
*
* @note @a relative is considered to be inside @a list, no checks are
* done to confirm that and giving nodes from different lists
* will lead to problems. Giving NULL @a relative is the same as
* eina_list_prepend().
*
* @param list existing list head or NULL to create a new list.
* @param new_l new list node, must not be NULL.
* @param relative reference node, @a new_l will be added before it.
*
* @return the new list head. Use it and not @a list anymore.
*/
EAPI Eina_Inlist *eina_inlist_prepend_relative(Eina_Inlist *in_list, EAPI Eina_Inlist *eina_inlist_prepend_relative(Eina_Inlist *in_list,
Eina_Inlist *in_item, Eina_Inlist *in_item,
Eina_Inlist *in_relative) EI NA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT; Eina_Inlist *in_relative) EI NA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
/**
* Remove node from list.
*
* @note this code is meant to be fast: appends are O(1) and do not
* walk @a list.
*
* @note @a item is considered to be inside @a list, no checks are
* done to confirm that and giving nodes from different lists
* will lead to problems, especially if @a item is the head since
* it will be different from @a list and the wrong new head will
* be returned.
*
* @param list existing list head, must not be NULL.
* @param item existing list node, must not be NULL.
*
* @return the new list head. Use it and not @a list anymore.
*/
EAPI Eina_Inlist *eina_inlist_remove(Eina_Inlist *in_list, EAPI Eina_Inlist *eina_inlist_remove(Eina_Inlist *in_list,
Eina_Inlist *in_item) EINA_ARG_NONNU LL(1, 2) EINA_WARN_UNUSED_RESULT; Eina_Inlist *in_item) EINA_ARG_NONNU LL(1, 2) EINA_WARN_UNUSED_RESULT;
/**
* Find given node in list, returns itself if found, NULL if not.
*
* @warning this is an expensive call and has O(n) cost, possibly
* walking the whole list.
*
* @param list existing list to search @a item in, must not be NULL.
* @param item what to search for, must not be NULL.
*
* @return @a item if found, NULL if not.
*/
EAPI Eina_Inlist *eina_inlist_find(Eina_Inlist *in_list, EAPI Eina_Inlist *eina_inlist_find(Eina_Inlist *in_list,
Eina_Inlist *in_item) EINA_ARG_NONNULL (2) EINA_WARN_UNUSED_RESULT; Eina_Inlist *in_item) EINA_ARG_NONNULL (2) EINA_WARN_UNUSED_RESULT;
/**
* Move existing node to beginning of list.
*
* @note this code is meant to be fast: appends are O(1) and do not
* walk @a list.
*
* @note @a item is considered to be inside @a list. No checks are
* done to confirm this, and giving nodes from different lists
* will lead to problems.
*
* @param list existing list head or NULL to create a new list.
* @param item list node to move to beginning (head), must not be NULL.
*
* @return the new list head. Use it and not @a list anymore.
*/
EAPI Eina_Inlist *eina_inlist_promote(Eina_Inlist *list, EAPI Eina_Inlist *eina_inlist_promote(Eina_Inlist *list,
Eina_Inlist *item) EINA_ARG_NONNULL (1, 2) EINA_WARN_UNUSED_RESULT; Eina_Inlist *item) EINA_ARG_NONNULL (1, 2) EINA_WARN_UNUSED_RESULT;
/**
* Move existing node to end of list.
*
* @note this code is meant to be fast: appends are O(1) and do not
* walk @a list.
*
* @note @a item is considered to be inside @a list. No checks are
* done to confirm this, and giving nodes from different lists
* will lead to problems.
*
* @param list existing list head or NULL to create a new list.
* @param item list node to move to end (tail), must not be NULL.
*
* @return the new list head. Use it and not @a list anymore.
*/
EAPI Eina_Inlist *eina_inlist_demote(Eina_Inlist *list, EAPI Eina_Inlist *eina_inlist_demote(Eina_Inlist *list,
Eina_Inlist *item) EINA_ARG_NONNULL( 1, 2) EINA_WARN_UNUSED_RESULT; Eina_Inlist *item) EINA_ARG_NONNULL( 1, 2) EINA_WARN_UNUSED_RESULT;
/**
* @brief Get the count of the number of items in a list.
*
* @param list The list whose count to return.
* @return The number of members in the list.
*
* This function returns how many members @p list contains. If the
* list is @c NULL, 0 is returned.
*
* @warning This is an order-N operation and so the time will depend
* on the number of elements on the list, so, it might become
* slow for big lists!
*/
EAPI unsigned int eina_inlist_count(const Eina_Inlist *list) EINA_WARN_UN USED_RESULT; EAPI unsigned int eina_inlist_count(const Eina_Inlist *list) EINA_WARN_UN USED_RESULT;
/**
* @brief Returns a new iterator associated to @a list.
*
* @param list The list.
* @return A new iterator.
*
* This function returns a newly allocated iterator 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 still returns a valid iterator that
* will always return false on eina_iterator_next(), thus keeping API
* sane.
*
* If the memory can not be allocated, NULL is returned and
* #EINA_ERROR_OUT_OF_MEMORY is set. Otherwise, a valid iterator is
* returned.
*
* @warning if the list structure changes then the iterator becomes
* invalid, and if you add or remove nodes iterator
* behavior is undefined, and your program may crash!
*/
EAPI Eina_Iterator *eina_inlist_iterator_new(const Eina_Inlist *in_list) EI NA_MALLOC EINA_WARN_UNUSED_RESULT; EAPI Eina_Iterator *eina_inlist_iterator_new(const Eina_Inlist *in_list) EI NA_MALLOC EINA_WARN_UNUSED_RESULT;
/**
* @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 *in_list) EI NA_MALLOC EINA_WARN_UNUSED_RESULT; EAPI Eina_Accessor *eina_inlist_accessor_new(const Eina_Inlist *in_list) EI NA_MALLOC EINA_WARN_UNUSED_RESULT;
/**
* @brief Insert a new node into a sorted list.
*
* @param list The given linked list, @b must be sorted.
* @param item list node to insert, must not be NULL.
* @param func The function called for the sort.
* @return A list pointer.
* @since 1.1.0
*
* This function inserts item into a linked list assuming it was
* sorted and the result will be sorted. If @p list is @c NULLL, item
* is returned. On success, a new list pointer that should be
* used in place of the one given to this function is
* returned. Otherwise, the old pointer is returned. See eina_error_get().
*
* @note O(log2(n)) comparisons (calls to @p func) average/worst case
* performance. As said in eina_list_search_sorted_near_list(),
* lists do not have O(1) access time, so walking to the correct node
* can be costly, consider worst case to be almost O(n) pointer
* dereference (list walk).
*/
EAPI Eina_Inlist *eina_inlist_sorted_insert(Eina_Inlist *list, Eina_Inlist
*item, Eina_Compare_Cb func) EINA_ARG_NONNULL(2, 3) EINA_WARN_UNUSED_RESULT
;
/**
* @brief Create state with valid data in it.
*
* @return A valid Eina_Inlist_Sorted_State.
* @since 1.1.0
*
* See eina_inlist_sorted_state_insert() for more information.
*/
EAPI Eina_Inlist_Sorted_State *eina_inlist_sorted_state_new(void);
/**
* @brief Force an Eina_Inlist_Sorted_State to match the content of a list.
*
* @param state The state to update
* @param list The list to match
* @return The number of item in the actually in the list
* @since 1.1.0
*
* See eina_inlist_sorted_state_insert() for more information. This functio
n is
* usefull if you didn't use eina_inlist_sorted_state_insert() at some poin
t, but
* still think you have a sorted list. It will only correctly work on a sor
ted list.
*/
EAPI int eina_inlist_sorted_state_init(Eina_Inlist_Sorted_State *state, Ein
a_Inlist *list);
/**
* @brief Free an Eina_Inlist_Sorted_State.
*
* @param state The state to destroy
* @since 1.1.0
*
* See eina_inlist_sorted_state_insert() for more information.
*/
EAPI void eina_inlist_sorted_state_free(Eina_Inlist_Sorted_State *state);
/**
* @brief Insert a new node into a sorted list.
*
* @param list The given linked list, @b must be sorted.
* @param item list node to insert, must not be NULL.
* @param func The function called for the sort.
* @param state The current array for initial dichotomic search
* @return A list pointer.
* @since 1.1.0
*
* This function inserts item into a linked list assuming @p state match
* the exact content order of the list. It use @p state to do a fast
* first step dichotomic search before starting to walk the inlist itself.
* This make this code much faster than eina_inlist_sorted_insert() as it
* doesn't need to walk the list at all. The result is of course a sorted
* list with an updated state.. If @p list is @c NULLL, item
* is returned. On success, a new list pointer that should be
* used in place of the one given to this function is
* returned. Otherwise, the old pointer is returned. See eina_error_get().
*
* @note O(log2(n)) comparisons (calls to @p func) average/worst case
* performance. As said in eina_list_search_sorted_near_list(),
* lists do not have O(1) access time, so walking to the correct node
* can be costly, but this version try to minimize that by making it a
* O(log2(n)) for number small number. After n == 256, it start to add a
* linear cost again. Consider worst case to be almost O(n) pointer
* dereference (list walk).
*/
EAPI Eina_Inlist *eina_inlist_sorted_state_insert(Eina_Inlist *list,
Eina_Inlist *item,
Eina_Compare_Cb func,
Eina_Inlist_Sorted_State *
state);
/**
* @brief Sort a list according to the ordering func will return.
*
* @param list The list handle to sort.
* @param func A function pointer that can handle comparing the list data
* nodes.
* @return the new head of list.
*
* This function sorts all the elements of @p list. @p func is used to
* compare two elements of @p list. If @p list or @p func are @c NULL,
* this function returns @c NULL.
*
* @note @b in-place: this will change the given list, so you should
* now point to the new list head that is returned by this function.
*
* @note worst case is O(n * log2(n)) comparisons (calls to func()),
* O(n) comparisons average case. That means that for 1,000,000 list
* elements, sort will usually do 1,000,000 comparisons, but may do up
* to 20,000,000.
*
* Example:
* @code
* typedef struct _Sort_Ex Sort_Ex;
* struct _Sort_Ex
* {
* INLIST;
* const char *text;
* };
*
* int
* sort_cb(const Inlist *l1, const Inlist *l2)
* {
* const Sort_Ex *x1;
* const Sort_Ex *x2;
*
* x1 = EINA_INLIST_CONTAINER_GET(l1, Sort_Ex);
* x2 = EINA_INLIST_CONTAINER_GET(l2, Sort_Ex);
*
* return(strcmp(x1->text, x2->text));
* }
* extern Eina_Inlist *list;
*
* list = eina_inlist_sort(list, sort_cb);
* @endcode
*/
EAPI Eina_Inlist *eina_inlist_sort(Eina_Inlist *head, Eina_Compare_Cb func)
;
/* This two macros are helpers for the _FOREACH ones, don't use them */ /* This two macros are helpers for the _FOREACH ones, don't use them */
#define _EINA_INLIST_OFFSET(ref) ((char *)&(ref)->__in_list - (char *)(ref)) #define _EINA_INLIST_OFFSET(ref) ((char *)&(ref)->__in_list - (char *)(ref))
#if !defined(__cplusplus)
#define _EINA_INLIST_CONTAINER(ref, ptr) (void *)((char *)(ptr) - \ #define _EINA_INLIST_CONTAINER(ref, ptr) (void *)((char *)(ptr) - \
_EINA_INLIST_OFFSET(ref)) _EINA_INLIST_OFFSET(ref))
#else
/*
* In C++ we can't assign a "type*" pointer to void* so we rely on GCC's ty
peof
* operator.
*/
#define _EINA_INLIST_CONTAINER(ref, ptr) (typeof(ref))((char *)(ptr) - \
_EINA_INLIST_OFFSET(ref))
#endif
#define EINA_INLIST_FOREACH(list, l) \ #define EINA_INLIST_FOREACH(list, l) \
for (l = NULL, l = (list ? _EINA_INLIST_CONTAINER(l, list) : NULL); l; \ for (l = NULL, l = (list ? _EINA_INLIST_CONTAINER(l, list) : NULL); l; \
l = (EINA_INLIST_GET(l)->next ? _EINA_INLIST_CONTAINER(l, EINA_INLIS T_GET(l)->next) : NULL)) l = (EINA_INLIST_GET(l)->next ? _EINA_INLIST_CONTAINER(l, EINA_INLIS T_GET(l)->next) : NULL))
#define EINA_INLIST_FOREACH_SAFE(list, list2, l) \
for (l = (list ? _EINA_INLIST_CONTAINER(l, list) : NULL), list2 = l ? ((
EINA_INLIST_GET(l) ? EINA_INLIST_GET(l)->next : NULL)) : NULL; \
l; \
l = _EINA_INLIST_CONTAINER(l, list2), list2 = list2 ? list2->next :
NULL)
#define EINA_INLIST_REVERSE_FOREACH(list, l) \ #define EINA_INLIST_REVERSE_FOREACH(list, l) \
for (l = NULL, l = (list ? _EINA_INLIST_CONTAINER(l, list->last) : NULL); \ for (l = NULL, l = (list ? _EINA_INLIST_CONTAINER(l, list->last) : NULL); \
l; l = (EINA_INLIST_GET(l)->prev ? _EINA_INLIST_CONTAINER(l, EINA_IN LIST_GET(l)->prev) : NULL)) l; l = (EINA_INLIST_GET(l)->prev ? _EINA_INLIST_CONTAINER(l, EINA_IN LIST_GET(l)->prev) : NULL))
/** /**
* @} * @}
*/ */
/** /**
* @} * @}
 End of changes. 17 change blocks. 
0 lines changed or deleted 777 lines changed or added


 eina_iterator.h   eina_iterator.h 
skipping to change at line 28 skipping to change at line 28
#ifndef EINA_ITERATOR_H__ #ifndef EINA_ITERATOR_H__
#define EINA_ITERATOR_H__ #define EINA_ITERATOR_H__
#include "eina_config.h" #include "eina_config.h"
#include "eina_types.h" #include "eina_types.h"
#include "eina_magic.h" #include "eina_magic.h"
/** /**
* @page eina_iterator_example Eina_Iterator usage
* @dontinclude eina_iterator_01.c
*
* As always when using eina we need to include it:
* @skip #include
* @until Eina.h
*
* Here we a declare an unimpressive @ref Eina_Each_Cb "function" that prin
ts
* some data:
* @until }
* @note Returning EINA_TRUE is important so we don't stop iterating over t
he
* container.
*
* And here a more interesting function, it uses an iterator to print the
* contents of a container. What's interesting about it is that it doesn't
care
* the type of container, it works for anything that can provide an iterato
r:
* @until }
*
* And on to our main function were we declare some variables and initializ
e
* eina, nothing too special:
* @until eina_init
*
* Next we populate both an array and a list with our strings, for more det
ails
* see @ref eina_list_01_example and @ref eina_array_01_example:
* @until }
*
* And now we create an array and because the first element of the containe
r
* doesn't interest us we skip it:
* @until iterator_next
*
* Having our iterator now pointing to interesting data we go ahead and pri
nt:
* @until print_eina_container
*
* As always once data with a structure we free it, but just because we can
we
* do it by asking the iterator for it's container, and then of course free
the
* iterator itself:
* @until eina_iterator_free
*
* But so far you're not impressed in @ref eina_array_01_example an array i
s
* also printed, so now we go to the cool stuff and use an iterator to do s
ame
* stuff to a list:
* @until eina_iterator_free
* @note The only significant diference to the block above is in the
* function used to create the iterator.
*
* And now we free the list and shut eina down:
* @until }
*/
/**
* @page eina_iterator_01_c Eina_Iterator usage
* @page eina_iterator_01_c Eina_Iterator usage
*
* @include eina_iterator_01.c
* @example eina_iterator_01.c
*/
/**
* @addtogroup Eina_Iterator_Group Iterator Functions
*
* @brief These functions manage iterators on containers.
*
* These functions allow to access elements of a container in a
* generic way, without knowing which container is used (a bit like
* iterators in the C++ STL). Iterators only allows sequential access
* (that is, from an element to the next one). For random access, see
* @ref Eina_Accessor_Group.
*
* An iterator is created from container data types, so no creation
* function is available here. An iterator is deleted with
* eina_iterator_free(). To get the data and iterate, use
* eina_iterator_next(). To call a function on all the elements of a
* container, use eina_iterator_foreach().
*
* Here an @ref eina_iterator_example "example"
*/
/**
* @addtogroup Eina_Content_Access_Group Content Access * @addtogroup Eina_Content_Access_Group Content Access
* *
* @{ * @{
*/ */
/** /**
* @defgroup Eina_Iterator_Group Iterator Functions * @defgroup Eina_Iterator_Group Iterator Functions
* *
* @{ * @{
*/ */
skipping to change at line 113 skipping to change at line 191
* Helper macro to cast @p Function to a Eina_Iterator_Free_Callback. * Helper macro to cast @p Function to a Eina_Iterator_Free_Callback.
*/ */
#define FUNC_ITERATOR_FREE(Function) ((Eina_Iterator_Free_Callback )Function) #define FUNC_ITERATOR_FREE(Function) ((Eina_Iterator_Free_Callback )Function)
/** /**
* @def FUNC_ITERATOR_LOCK(Function) * @def FUNC_ITERATOR_LOCK(Function)
* Helper macro to cast @p Function to a Eina_Iterator_Lock_Callback. * Helper macro to cast @p Function to a Eina_Iterator_Lock_Callback.
*/ */
#define FUNC_ITERATOR_LOCK(Function) ((Eina_Iterator_Lock_Callback )Function) #define FUNC_ITERATOR_LOCK(Function) ((Eina_Iterator_Lock_Callback )Function)
/**
* @brief Free an iterator.
*
* @param iterator The iterator to free.
*
* This function frees @p iterator if it is not @c NULL;
*/
EAPI void eina_iterator_free(Eina_Iterator *iterator) EINA_ARG_NONNULL (1); EAPI void eina_iterator_free(Eina_Iterator *iterator) EINA_ARG_NONNULL (1);
/**
* @brief Return the container of an iterator.
*
* @param iterator The iterator.
* @return The container which created the iterator.
*
* This function returns the container which created @p iterator. If
* @p iterator is @c NULL, this function returns @c NULL.
*/
EAPI void *eina_iterator_container_get(Eina_Iterator *iterator) EINA_AR G_NONNULL(1) EINA_PURE; EAPI void *eina_iterator_container_get(Eina_Iterator *iterator) EINA_AR G_NONNULL(1) EINA_PURE;
/**
* @brief Return the value of the current element and go to the next one.
*
* @param iterator The iterator.
* @param data The data of the element.
* @return #EINA_TRUE on success, #EINA_FALSE otherwise.
*
* This function returns the value of the current element pointed by
* @p iterator in @p data, then goes to the next element. If @p
* iterator is @c NULL or if a problem occurred, #EINA_FALSE is
* returned, otherwise #EINA_TRUE is returned.
*/
EAPI Eina_Bool eina_iterator_next(Eina_Iterator *iterator, EAPI Eina_Bool eina_iterator_next(Eina_Iterator *iterator,
void **data) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT; void **data) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
/**
* @brief Iterate over the container and execute a callback on each element
.
*
* @param iterator The iterator.
* @param callback The callback called on each iteration.
* @param fdata The data passed to the callback.
*
* This function iterates over the elements pointed by @p iterator,
* beginning from the current element. For Each element, the callback
* @p cb is called with the data @p fdata. If @p iterator is @c NULL,
* the function returns immediately. Also, if @p cb returns @c
* EINA_FALSE, the iteration stops at that point, if @p cb returns @c EINA_
TRUE
* the iteration continues.
*/
EAPI void eina_iterator_foreach(Eina_Iterator *iterator, EAPI void eina_iterator_foreach(Eina_Iterator *iterator,
Eina_Each_Cb callback, Eina_Each_Cb callback,
const void *fdata) EINA_ARG_NONNULL(1, 2 ); const void *fdata) EINA_ARG_NONNULL(1, 2 );
/**
* @brief Lock the container of the iterator.
*
* @param iterator The iterator.
* @return #EINA_TRUE on success, #EINA_FALSE otherwise.
*
* If the container of the @p iterator permits it, it will be locked. When
a
* container is locked calling eina_iterator_foreach() on it will return
* immediately. If @p iterator is @c NULL or if a problem occurred, #EINA_F
ALSE
* is returned, otherwise #EINA_TRUE is returned. If the container isn't
* lockable, it will return EINA_TRUE.
*
* @warning None of the existing eina data structures are lockable.
*/
EAPI Eina_Bool eina_iterator_lock(Eina_Iterator *iterator) EINA_ARG_NONNULL (1); EAPI Eina_Bool eina_iterator_lock(Eina_Iterator *iterator) EINA_ARG_NONNULL (1);
/**
* @brief Unlock the container of the iterator.
*
* @param iterator The iterator.
* @return #EINA_TRUE on success, #EINA_FALSE otherwise.
*
* If the container of the @p iterator permits it and was previously
* locked, it will be unlocked. If @p iterator is @c NULL or if a
* problem occurred, #EINA_FALSE is returned, otherwise #EINA_TRUE
* is returned. If the container is not lockable, it will return
* EINA_TRUE.
*
* @warning None of the existing eina data structures are lockable.
*/
EAPI Eina_Bool eina_iterator_unlock(Eina_Iterator *iterator) EINA_ARG_NONNU LL(1); EAPI Eina_Bool eina_iterator_unlock(Eina_Iterator *iterator) EINA_ARG_NONNU LL(1);
/** /**
* @def EINA_ITERATOR_FOREACH * @def EINA_ITERATOR_FOREACH
* @brief Macro to iterate over all elements easily. * @brief Macro to iterate over all elements easily.
* *
* @param itr The iterator to use. * @param itr The iterator to use.
* @param data Where to store * data, must be a pointer support getting * @param data Where to store * data, must be a pointer support getting
* its address since * eina_iterator_next() requires a pointer * its address since * eina_iterator_next() requires a pointer
* to pointer! * to pointer!
skipping to change at line 161 skipping to change at line 311
* EINA_ITERATOR_FOREACH(itr, data) * EINA_ITERATOR_FOREACH(itr, data)
* free(data); * free(data);
* eina_iterator_free(itr); * eina_iterator_free(itr);
* eina_list_free(list); * eina_list_free(list);
* @endcode * @endcode
* *
* @note this example is not optimal algorithm to release a list since * @note this example is not optimal algorithm to release a list since
* it will walk the list twice, but it serves as an example. For * it will walk the list twice, but it serves as an example. For
* optimized version use EINA_LIST_FREE() * optimized version use EINA_LIST_FREE()
* *
* @warning The order in which the elements will be traversed depends on th
e
* underlying container and @b shouldn't be relied upon.
*
* @warning unless explicitly stated in functions returning iterators, * @warning unless explicitly stated in functions returning iterators,
* do not modify the iterated object while you walk it, in this * do not modify the iterated object while you walk it, in this
* example using lists, do not remove list nodes or you might * example using lists, do not remove list nodes or you might
* crash! This is not a limitiation of iterators themselves, * crash! This is not a limitiation of iterators themselves,
* rather in the iterators implementations to keep them as simple * rather in the iterators implementations to keep them as simple
* and fast as possible. * and fast as possible.
*/ */
#define EINA_ITERATOR_FOREACH(itr, \ #define EINA_ITERATOR_FOREACH(itr, \
data) while (eina_iterator_next((itr), \ data) while (eina_iterator_next((itr), \
(void **)(voi d *)&(data))) (void **)(voi d *)&(data)))
 End of changes. 8 change blocks. 
0 lines changed or deleted 170 lines changed or added


 eina_list.h   eina_list.h 
skipping to change at line 32 skipping to change at line 32
#include <stdlib.h> #include <stdlib.h>
#include "eina_config.h" #include "eina_config.h"
#include "eina_types.h" #include "eina_types.h"
#include "eina_iterator.h" #include "eina_iterator.h"
#include "eina_accessor.h" #include "eina_accessor.h"
#include "eina_magic.h" #include "eina_magic.h"
/** /**
* @page list_01_example_page Adding elements to Eina_List
* @dontinclude eina_list_01.c
*
* Creating an @ref Eina_List and adding elements to it is very easy and ca
n be
* understood from an example:
* First thing is always to include Eina.h, for this example we also
* include stdio.h so we can use printf.
* @skip #include
* @until Eina.h
*
* Just some boilerplate code, declaring some variable and initializing ein
a.
* @until eina_init
* Here we add a sequence of elements to our list. By using append we add
* elements to the end of the list, so the list will look like this:@n
* @htmlonly
* <img src="eina_list_example_01_a.png" style="max-width: 100%;" />
* <a href="eina_list_example_01_a.png">Full-size</a>
* @endhtmlonly
* @image rtf eina_list_example_01_a.png
* @image latex eina_list_example_01_a.eps width=\textwidth
* @until roslin
* There are a couple of interesting things happening here, first is that w
e are
* passing a NULL pointer to the first @ref eina_list_append() call, when t
his
* is done a list is created. The other @b very important detail to notice
is
* that the return value is attributed to the @a list variable, this needs
to
* be done every time we use a a function that alters the contents of the l
ist.
*
* Now that we have a list we some elements in it we can look at it's conte
nts.
* @until printf
*
* There are many ways of accessing elements in the list, including by it's
* index:
* @until nth
* @note It should be noted that the index starts at 0.
*
* @ref eina_list_append() is not the only way to add elements to a a list.
A
* common requirement is to add an element in a specific position this can
be
* accomplished using @ref eina_list_append_relative() and
* @ref eina_list_append_relative_list():
* @until zarek
* First @a "cain" is added after the second element(remember that indexes
are
* 0 based) and then we add @a "zarek" after @a "cain".
*
* @ref Eina_List also has prepend analogs to append functions we have used
so
* far:
* @until lampkin
* With this additions our list now looks like this:@n
* @htmlonly
* <img src="eina_list_example_01_b.png" style="max-width: 100%;" />
* <a href="eina_list_example_01_b.png">Full-size</a>
* @endhtmlonly
* @image rtf eina_list_example_01_b.png
* @image latex eina_list_example_01_b.eps width=\textwidth
*
* Once done using the list it needs to be freed, and since we are done wit
h
* eina that also need to be shutdown:
* @until }
*
* The full source code can be found on the examples folder
* on the @ref eina_list_01_c "eina_list_01.c" file.
*/
/**
* @page eina_list_01_c Adding elements to Eina_List example
*
* @include eina_list_01.c
* @example eina_list_01.c
*/
/**
* @page list_02_example_page Sorting Eina_List elements
* @dontinclude eina_list_02.c
*
* If you don't know how to create lists see
* @ref list_01_example_page.
*
* @skip #include
* @until boomer
* This is the code we have already seen to create a list. Now if we need t
o
* search the list we can do it like this:
* @until return
*
* However if searching the list multiple times it probably is better to so
rt
* the list since the sorted_search functions are much faster:
* @until return
*
* Once the list is sorted it's not a good idea to use append/prepend funct
ions
* since that would add the element in the wrong place, instead elements sh
ould
* be added with @ref eina_list_sorted_insert():
* @until sorted_insert
*
* A noteworthy use case is adding an element to a list only if it doesn't
exist
* already, this can accomplished by searching for the element that is clos
est
* to what is being added, and if that doesn't match add:
* @until append
* @note @ref eina_list_search_sorted_near_list() will tell you not only th
e
* nearest node to what was searched for but how it compares to your term,
this
* way it is easy to know if you have to add before or after that node.
*
* It is sometimes useful to get a portion of the list as another list, her
e we
* take every element that comes after "boomer" and split it into "other_li
st":
* @until split_list
*
* It is also possible to add entire lists of elements using
* @ref eina_list_sorted_merge():
* @until sorted_merge
*
* And as always release memory and shutdown eina before ending:
* @until }
*
* The full source code can be found on the examples folder
* on the @ref eina_list_02_c "eina_list_02.c" file.
*/
/**
* @page eina_list_02_c Sorting Eina_List elements example
*
* @include eina_list_02.c
* @example eina_list_02.c
*/
/**
* @page list_03_example_page Reordering Eina_List elments
* @dontinclude eina_list_03.c
*
* If you don't know how to create lists see
* @ref list_01_example_page.
*
* We start out with code that should be familiar by now:
* @skip #include
* @until gemenon
*
* You can move elements around in a list using @ref eina_list_move() or us
ing
* @ref eina_list_promote_list() and @ref eina_list_demote_list() which mov
e a
* list node to the head and end of the list respectevely:
* @until demote
*
* Removing elements from a list can be done with ease:
* @until sagitarius
*
* To replace an element in the list it is not necessary to remove it and t
hen
* add with the new value, it is possible to just change the value of a nod
e:
* @until aquarius
*
* We will now take a peek to see if the list still has the right number of
* elements:
* @until printf
*
* Now that the list is in alphabetical order let's create a copy of it in
* reverse order and print every element to see if worked as expected:
* @until iterator_free
* @note Always remember to free your iterators when done using them.
*
* And as always release memory and shutdown eina before ending:
* @until }
*
* The full source code can be found on the examples folder
* on the @ref eina_list_03_c "eina_list_03.c" file.
*/
/**
* @page eina_list_03_c Reordering Eina_List elments example
*
* @include eina_list_03.c
* @example eina_list_03.c
*/
/**
* @page list_04_example_page Eina_List and memory allocation
* @dontinclude eina_list_04.c
*
* If you don't know how to create lists see
* @ref list_01_example_page. In this example we also use
* @ref eina_stringshare, however it should be possible to understand the c
ode
* regardless of previous knowledge about it.
*
* Here we have the usual list creation code with a twist, now we are using
as
* data for the list memory that has to be freed later on.
* @skip #include
* @until Sharon
*
* This time we are going to iterate over our list in a different way:
* @until printf
*
* And now we are going to iterate over the list backwards:
* @until printf
*
* And now we need to free up the memory allocated during creation of the l
ist:
* @until stringshare_del
* @note We don't need to use eina_list_free() since @ref EINA_LIST_FREE ta
kes
* care of that.
*
* And shut everything down:
* @until }
*
* The full source code can be found on the examples folder
* on the @ref eina_list_04_c "eina_list_04.c" file.
*/
/**
* @page eina_list_04_c Eina_List and memory allocation example
*
* @include eina_list_04.c
* @example eina_list_04.c
*/
/**
* @addtogroup Eina_List_Group List
*
* @brief These functions provide double linked list management.
*
* Eina_List is a doubly linked list. It can store data of any type in the
* form of void pointers. It has convenience functions to do all the common
* operations which means it should rarely if ever be necessary to directly
* access the struct's fields. Nevertheless it can be useful to understand
the
* inner workings of the data structure being used.
*
* @ref Eina_List nodes keep references to the previous node, the next node
, its
* data and to an accounting structure.
*
* @htmlonly
* <img src="eina_list.png" style="max-width: 100%;" />
* <a href="eina_list.png">Full-size</a>
* @endhtmlonly
* @image rtf eina_list.png
* @image latex eina_list.eps width=5cm
*
* @ref Eina_List_Accounting is used to improve the performance of some
* functions. It is private and <b>should not</b> be modified. It contains
a
* reference to the end of the list and the number of elements in the list.
*
* @note Every function that modifies the contents of the list returns a po
inter
* to the head of the list and it is essential that this be pointer be used
in
* any future references to the list.
*
* Most functions have two versions that have the same effect but operate o
n
* different arguments, the @a plain functions operate over data(eg.:
* @ref eina_list_append_relative, @ref eina_list_remove,
* @ref eina_list_data_find), the @a list versions of these functions opera
te
* on @ref Eina_List nodes.
*
* @warning You must @b always use the pointer to the first element of the
list
* as the list!
* @warning You must @b never use a pointer to an element in the middle of
the
* list as the list!
*
* Here are some examples of @ref Eina_List usage:
* @li @ref list_01_example_page
* @li @ref list_02_example_page
* @li @ref list_03_example_page
* @li @ref list_04_example_page
*/
/**
* @addtogroup Eina_Data_Types_Group Data Types * @addtogroup Eina_Data_Types_Group Data Types
* *
* @{ * @{
*/ */
/** /**
* @addtogroup Eina_Containers_Group Containers * @addtogroup Eina_Containers_Group Containers
* *
* @{ * @{
*/ */
skipping to change at line 89 skipping to change at line 343
* elements, for fast access. It is for private used and must not be * elements, for fast access. It is for private used and must not be
* touched. * touched.
*/ */
struct _Eina_List_Accounting struct _Eina_List_Accounting
{ {
Eina_List *last; /**< Pointer to the last element of the list - don't touch */ Eina_List *last; /**< Pointer to the last element of the list - don't touch */
unsigned int count; /**< Number of elements of the list - don't touch */ unsigned int count; /**< Number of elements of the list - don't touch */
EINA_MAGIC EINA_MAGIC
}; };
/**
* @brief Append the given data to the given linked list.
*
* @param list The given list.
* @param data The data to append.
* @return A list pointer.
*
* This function appends @p data to @p list. If @p list is @c NULL, a
* new list is returned. On success, a new list pointer that should be
* used in place of the one given to this function is
* returned. Otherwise, the old pointer is returned.
*
* The following example code demonstrates how to ensure that the
* given data has been successfully appended.
*
* @code
* Eina_List *list = NULL;
* extern void *my_data;
*
* list = eina_list_append(list, my_data);
* if (eina_error_get())
* {
* fprintf(stderr, "ERROR: Memory is low. List allocation failed.\n");
* exit(-1);
* }
* @endcode
*
* @warning @p list must be a pointer to the first element of the list(or N
ULL).
*/
EAPI Eina_List *eina_list_append(Eina_List *list, const void *da ta) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT; EAPI Eina_List *eina_list_append(Eina_List *list, const void *da ta) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
/**
* @brief Prepends the given data to the given linked list.
*
* @param list The given list.
* @param data The data to prepend.
* @return A list pointer.
*
* This function prepends @p data to @p list. If @p list is @c NULL, a
* new list is returned. On success, a new list pointer that should be
* used in place of the one given to this function is
* returned. Otherwise, the old pointer is returned.
*
* The following example code demonstrates how to ensure that the
* given data has been successfully prepended.
*
* Example:
* @code
* Eina_List *list = NULL;
* extern void *my_data;
*
* list = eina_list_prepend(list, my_data);
* if (eina_error_get())
* {
* fprintf(stderr, "ERROR: Memory is low. List allocation failed.\n");
* exit(-1);
* }
* @endcode
*
* @warning @p list must be a pointer to the first element of the list.
*/
EAPI Eina_List *eina_list_prepend(Eina_List *list, const void *d ata) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT; EAPI Eina_List *eina_list_prepend(Eina_List *list, const void *d ata) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
/**
* @brief Insert the given data into the given linked list after the specif
ied data.
*
* @param list The given linked list.
* @param data The data to insert.
* @param relative The data to insert after.
* @return A list pointer.
*
* This function inserts @p data to @p list after @p relative. If
* @p relative is not in the list, @p data is appended to the end of
* the list. If @p list is @c NULL, a new list is returned. If there
* are multiple instances of @p relative in the list, @p data is
* inserted after the first instance.On success, a new list pointer
* that should be used in place of the one given to this function is
* returned. Otherwise, the old pointer is returned.
*
* The following example code demonstrates how to ensure that the
* given data has been successfully inserted.
*
* @code
* Eina_List *list = NULL;
* extern void *my_data;
* extern void *relative_member;
*
* list = eina_list_append(list, relative_member);
* if (eina_error_get())
* {
* fprintf(stderr, "ERROR: Memory is low. List allocation failed.\n");
* exit(-1);
* }
* list = eina_list_append_relative(list, my_data, relative_member);
* if (eina_error_get())
* {
* fprintf(stderr, "ERROR: Memory is low. List allocation failed.\n");
* exit(-1);
* }
* @endcode
*
* @warning @p list must be a pointer to the first element of the list.
*/
EAPI Eina_List *eina_list_append_relative(Eina_List *list, const void *data, const void *relative) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RES ULT; EAPI Eina_List *eina_list_append_relative(Eina_List *list, const void *data, const void *relative) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RES ULT;
/**
* @brief Append a list node to a linked list after the specified member
*
* @param list The given linked list.
* @param data The data to insert.
* @param relative The list node to insert after.
* @return A list pointer.
*
* This function inserts @p data to @p list after the list node
* @p relative. If @p list or @p relative are @c NULL, @p data is just
* appended to @p list using eina_list_append(). If @p list is
* @c NULL, a new list is returned. If there are multiple instances
* of @p relative in the list, @p data is inserted after the first
* instance. On success, a new list pointer that should be used in
* place of the one given to this function is returned. Otherwise, the
* old pointer is returned.
*
* @warning @p list must be a pointer to the first element of the list.
*/
EAPI Eina_List *eina_list_append_relative_list(Eina_List *list, const void *data, Eina_List *relative) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED _RESULT; EAPI Eina_List *eina_list_append_relative_list(Eina_List *list, const void *data, Eina_List *relative) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED _RESULT;
/**
* @brief Prepend a data pointer to a linked list before the specified memb
er
*
* @param list The given linked list.
* @param data The data to insert.
* @param relative The data to insert before.
* @return A list pointer.
*
* This function inserts @p data to @p list before @p relative. If
* @p relative is not in the list, @p data is prepended to the list
* with eina_list_prepend(). If @p list is @c NULL, a new list is
* returned. If there are multiple instances of @p relative in the
* list, @p data is inserted before the first instance. On success, a
* new list pointer that should be used in place of the one given to
* this function is returned. Otherwise, the old pointer is returned.
*
* The following code example demonstrates how to ensure that the
* given data has been successfully inserted.
*
* @code
* Eina_List *list = NULL;
* extern void *my_data;
* extern void *relative_member;
*
* list = eina_list_append(list, relative_member);
* if (eina_error_get_error())
* {
* fprintf(stderr, "ERROR: Memory is low. List allocation failed.\n");
* exit(-1);
* }
* list = eina_list_prepend_relative(list, my_data, relative_member);
* if (eina_error_get())
* {
* fprintf(stderr, "ERROR: Memory is low. List allocation failed.\n");
* exit(-1);
* }
* @endcode
*
* @warning @p list must be a pointer to the first element of the list.
*/
EAPI Eina_List *eina_list_prepend_relative(Eina_List *list, cons t void *data, const void *relative) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RE SULT; EAPI Eina_List *eina_list_prepend_relative(Eina_List *list, cons t void *data, const void *relative) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RE SULT;
/**
* @brief Prepend a list node to a linked list before the specified member
*
* @param list The given linked list.
* @param data The data to insert.
* @param relative The list node to insert before.
* @return A list pointer.
*
* This function inserts @p data to @p list before the list node
* @p relative. If @p list or @p relative are @c NULL, @p data is just
* prepended to @p list using eina_list_prepend(). If @p list is
* @c NULL, a new list is returned. If there are multiple instances
* of @p relative in the list, @p data is inserted before the first
* instance. On success, a new list pointer that should be used in
* place of the one given to this function is returned. Otherwise, the
* old pointer is returned.
*
* @warning @p list must be a pointer to the first element of the list.
*/
EAPI Eina_List *eina_list_prepend_relative_list(Eina_List *list, const void *data, Eina_List *relative) EINA_ARG_NONNULL(2) EINA_WARN_UNUSE D_RESULT; EAPI Eina_List *eina_list_prepend_relative_list(Eina_List *list, const void *data, Eina_List *relative) EINA_ARG_NONNULL(2) EINA_WARN_UNUSE D_RESULT;
/**
* @brief Insert a new node into a sorted list.
*
* @param list The given linked list, @b must be sorted.
* @param func The function called for the sort.
* @param data The data to insert sorted.
* @return A list pointer.
*
* This function inserts values into a linked list assuming it was
* sorted and the result will be sorted. If @p list is @c NULLL, a new
* list is returned. On success, a new list pointer that should be
* used in place of the one given to this function is
* returned. Otherwise, the old pointer is returned. See eina_error_get().
*
* @note O(log2(n)) comparisons (calls to @p func) average/worst case
* performance as it uses eina_list_search_sorted_near_list() and thus
* is bounded to that. As said in eina_list_search_sorted_near_list(),
* lists do not have O(1) access time, so walking to the correct node
* can be costly, consider worst case to be almost O(n) pointer
* dereference (list walk).
*
* @warning @p list must be a pointer to the first element of the list.
*/
EAPI Eina_List *eina_list_sorted_insert(Eina_List *list, Eina_Co mpare_Cb func, const void *data) EINA_ARG_NONNULL(2, 3) EINA_WARN_UNUSED_RE SULT; EAPI Eina_List *eina_list_sorted_insert(Eina_List *list, Eina_Co mpare_Cb func, const void *data) EINA_ARG_NONNULL(2, 3) EINA_WARN_UNUSED_RE SULT;
/**
* @brief Remove the first instance of the specified data from the given li
st.
*
* @param list The given list.
* @param data The specified data.
* @return A list pointer.
*
* This function removes the first instance of @p data from
* @p list. If the specified data is not in the given list (tihis
* include the case where @p data is @c NULL), nothing is done. If
* @p list is @c NULL, @c NULL is returned, otherwise a new list
* pointer that should be used in place of the one passed to this
* function.
*
* @warning @p list must be a pointer to the first element of the list.
*/
EAPI Eina_List *eina_list_remove(Eina_List *list, const void *da ta) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT; EAPI Eina_List *eina_list_remove(Eina_List *list, const void *da ta) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
/**
* @brief Remove the specified data.
*
* @param list The given linked list.
* @param remove_list The list node which is to be removed.
* @return A list pointer.
*
* This function removes the list node @p remove_list from @p list and
* frees the list node structure @p remove_list. If @p list is
* @c NULL, this function returns @c NULL. If @p remove_list is
* @c NULL, it returns @p list, otherwise, a new list pointer that
* should be used in place of the one passed to this function.
*
* The following code gives an example (notice we use EINA_LIST_FOREACH
* instead of EINA_LIST_FOREACH_SAFE because we stop the loop after
* removing the current node).
*
* @code
* extern Eina_List *list;
* Eina_List *l;
* extern void *my_data;
* void *data
*
* EINA_LIST_FOREACH(list, l, data)
* {
* if (data == my_data)
* {
* list = eina_list_remove_list(list, l);
* break;
* }
* }
* @endcode
*
* @warning @p list must be a pointer to the first element of the list.
*/
EAPI Eina_List *eina_list_remove_list(Eina_List *list, Eina_List *remove_list) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT; EAPI Eina_List *eina_list_remove_list(Eina_List *list, Eina_List *remove_list) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
/**
* @brief Move the specified data to the head of the list.
*
* @param list The list handle to move the data.
* @param move_list The list node to move.
* @return A new list handle to replace the old one
*
* This function move @p move_list to the front of @p list. If list is
* @c NULL, @c NULL is returned. If @p move_list is @c NULL,
* @p list is returned. Otherwise, a new list pointer that should be
* used in place of the one passed to this function.
*
* Example:
* @code
* extern Eina_List *list;
* Eina_List *l;
* extern void *my_data;
* void *data;
*
* EINA_LIST_FOREACH(list, l, data)
* {
* if (data == my_data)
* {
* list = eina_list_promote_list(list, l);
* break;
* }
* }
* @endcode
*
* @warning @p list must be a pointer to the first element of the list.
*/
EAPI Eina_List *eina_list_promote_list(Eina_List *list, Eina_Lis t *move_list) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT; EAPI Eina_List *eina_list_promote_list(Eina_List *list, Eina_Lis t *move_list) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
/**
* @brief Move the specified data to the tail of the list.
*
* @param list The list handle to move the data.
* @param move_list The list node to move.
* @return A new list handle to replace the old one
*
* This function move @p move_list to the back of @p list. If list is
* @c NULL, @c NULL is returned. If @p move_list is @c NULL,
* @p list is returned. Otherwise, a new list pointer that should be
* used in place of the one passed to this function.
*
* Example:
* @code
* extern Eina_List *list;
* Eina_List *l;
* extern void *my_data;
* void *data;
*
* EINA_LIST_FOREACH(list, l, data)
* {
* if (data == my_data)
* {
* list = eina_list_demote_list(list, l);
* break;
* }
* }
* @endcode
*
* @warning @p list must be a pointer to the first element of the list.
*/
EAPI Eina_List *eina_list_demote_list(Eina_List *list, Eina_List *move_list); EAPI Eina_List *eina_list_demote_list(Eina_List *list, Eina_List *move_list);
/**
* @brief Find a member of a list and return the member.
*
* @param list The list to search for a data.
* @param data The data pointer to find in the list.
* @return The found member data pointer if found, @c NULL otherwise.
*
* This function searches in @p list from beginning to end for the
* first member whose data pointer is @p data. If it is found, @p data
* will be returned, otherwise NULL will be returned.
*
* Example:
* @code
* extern Eina_List *list;
* extern void *my_data;
*
* if (eina_list_data_find(list, my_data) == my_data)
* {
* printf("Found member %p\n", my_data);
* }
* @endcode
*
* @warning @p list must be a pointer to the first element of the list.
*/
EAPI void *eina_list_data_find(const Eina_List *list, const void *data) EINA_PURE EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT; EAPI void *eina_list_data_find(const Eina_List *list, const void *data) EINA_PURE EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
/**
* @brief Find a member of a list and return the list node containing that
member.
*
* @param list The list to search for data.
* @param data The data pointer to find in the list.
* @return The found members list node on success, @c NULL otherwise.
*
* This function searches in @p list from beginning to end for the
* first member whose data pointer is @p data. If it is found, the
* list node containing the specified member is returned, otherwise
* @c NULL is returned.
*
* @warning @p list must be a pointer to the first element of the list.
*/
EAPI Eina_List *eina_list_data_find_list(const Eina_List *list, const void *data) EINA_PURE EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT; EAPI Eina_List *eina_list_data_find_list(const Eina_List *list, const void *data) EINA_PURE EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
/**
* @brief Move a data pointer from one list to another
*
* @param to The list to move the data to
* @param from The list to move from
* @param data The data to move
* @return #EINA_TRUE on success, else #EINA_FALSE
*
* This function is a shortcut for doing the following:
* to = eina_list_append(to, data);
* from = eina_list_remove(from, data);
*
* @warning @p list must be a pointer to the first element of the list.
*/
EAPI Eina_Bool eina_list_move(Eina_List **to, Eina_List **from,
void *data);
/**
* @brief Move a list node from one list to another
*
* @param to The list to move the data to
* @param from The list to move from
* @param data The list node containing the data to move
* @return #EINA_TRUE on success, else #EINA_FALSE
*
* This function is a shortcut for doing the following:
* to = eina_list_append(to, data->data);
* from = eina_list_remove_list(from, data);
*
* @warning @p list must be a pointer to the first element of the list.
*/
EAPI Eina_Bool eina_list_move_list(Eina_List **to, Eina_List **
from, Eina_List *data);
/**
* @brief Free an entire list and all the nodes, ignoring the data containe
d.
* @param list The list to free
* @return A NULL pointer
*
* This function frees all the nodes of @p list. It does not free the
* data of the nodes. To free them, use #EINA_LIST_FREE.
*/
EAPI Eina_List *eina_list_free(Eina_List *list); EAPI Eina_List *eina_list_free(Eina_List *list);
/**
* @brief Get the nth member's data pointer in a list.
*
* @param list The list to get the specified member number from.
* @param n The number of the element (0 being the first).
* @return The data pointer stored in the specified element.
*
* This function returns the data pointer of element number @p n, in
* the @p list. The first element in the array is element number 0. If
* the element number @p n does not exist, @c NULL is
* returned. Otherwise, the data of the found element is returned.
*
* @note Worst case is O(n).
*
* @warning @p list must be a pointer to the first element of the list.
*/
EAPI void *eina_list_nth(const Eina_List *list, unsigned in t n) EINA_PURE EINA_WARN_UNUSED_RESULT; EAPI void *eina_list_nth(const Eina_List *list, unsigned in t n) EINA_PURE EINA_WARN_UNUSED_RESULT;
/**
* @brief Get the nth member's list node in a list.
*
* @param list The list to get the specfied member number from.
* @param n The number of the element (0 being the first).
* @return The list node stored in the numbered element.
*
* This function returns the list node of element number @p n, in
* @p list. The first element in the array is element number 0. If the
* element number @p n does not exist or @p list is @c NULL or @p n is
* greater than the count of elements in @p list minus 1, @c NULL is
* returned. Otherwise the list node stored in the numbered element is
* returned.
*
* @note Worst case is O(n).
*
* @warning @p list must be a pointer to the first element of the list.
*/
EAPI Eina_List *eina_list_nth_list(const Eina_List *list, unsign ed int n) EINA_PURE EINA_WARN_UNUSED_RESULT; EAPI Eina_List *eina_list_nth_list(const Eina_List *list, unsign ed int n) EINA_PURE EINA_WARN_UNUSED_RESULT;
/**
* @brief Reverse all the elements in the list.
*
* @param list The list to reverse.
* @return The list head after it has been reversed.
*
* This function reverses the order of all elements in @p list, so the
* last member is now first, and so on. If @p list is @c NULL, this
* functon returns @c NULL.
*
* @note @b in-place: this will change the given list, so you should
* now point to the new list head that is returned by this function.
*
* @warning @p list must be a pointer to the first element of the list.
*
* @see eina_list_reverse_clone()
* @see eina_list_iterator_reversed_new()
*/
EAPI Eina_List *eina_list_reverse(Eina_List *list) EINA_WARN_UNU SED_RESULT; EAPI Eina_List *eina_list_reverse(Eina_List *list) EINA_WARN_UNU SED_RESULT;
/**
* @brief Clone (copy) all the elements in the list in reverse order.
*
* @param list The list to reverse.
* @return The new list that has been reversed.
*
* This function reverses the order of all elements in @p list, so the
* last member is now first, and so on. If @p list is @c NULL, this
* functon returns @c NULL. This returns a copy of the given list.
*
* @note @b copy: this will copy the list and you should then
* eina_list_free() when it is not required anymore.
*
* @warning @p list must be a pointer to the first element of the list.
*
* @see eina_list_reverse()
* @see eina_list_clone()
*/
EAPI Eina_List *eina_list_reverse_clone(const Eina_List *list) E INA_WARN_UNUSED_RESULT; EAPI Eina_List *eina_list_reverse_clone(const Eina_List *list) E INA_WARN_UNUSED_RESULT;
/**
* @brief Clone (copy) all the elements in the list in exactly same order.
*
* @param list The list to clone.
* @return The new list that has been cloned.
*
* This function clone in order of all elements in @p list. If @p list
* is @c NULL, this functon returns @c NULL. This returns a copy of
* the given list.
*
* @note @b copy: this will copy the list and you should then
* eina_list_free() when it is not required anymore.
*
* @warning @p list must be a pointer to the first element of the list.
*
* @see eina_list_reverse_clone()
*/
EAPI Eina_List *eina_list_clone(const Eina_List *list) EINA_WARN _UNUSED_RESULT; EAPI Eina_List *eina_list_clone(const Eina_List *list) EINA_WARN _UNUSED_RESULT;
/**
* @brief Sort a list according to the ordering func will return.
*
* @param list The list handle to sort.
* @param size The length of the list to sort.
* @param func A function pointer that can handle comparing the list data
* nodes.
* @return the new head of list.
*
* This function sorts @p list. @p size if the number of the first
* element to sort. If @p size is 0 or greater than the number of
* elements in @p list, all the elements are sorted. @p func is used to
* compare two elements of @p list. If @p list or @p func are @c NULL,
* this function returns @c NULL.
*
* @note @b in-place: this will change the given list, so you should
* now point to the new list head that is returned by this function.
*
* @note worst case is O(n * log2(n)) comparisons (calls to func()),
* O(n) comparisons average case. That means that for 1,000,000 list
* elements, sort will usually do 1,000,000 comparisons, but may do up
* to 20,000,000.
*
* Example:
* @code
* int
* sort_cb(const void *d1, const void *d2)
* {
* const char *txt = d1;
* const char *txt2 = d2;
*
* if(!txt) return(1);
* if(!txt2) return(-1);
*
* return(strcmp(txt, txt2));
* }
* extern Eina_List *list;
*
* list = eina_list_sort(list, eina_list_count(list), sort_cb);
* @endcode
*
* @warning @p list must be a pointer to the first element of the list.
*/
EAPI Eina_List *eina_list_sort(Eina_List *list, unsigned int siz e, Eina_Compare_Cb func) EINA_ARG_NONNULL(3) EINA_WARN_UNUSED_RESULT; EAPI Eina_List *eina_list_sort(Eina_List *list, unsigned int siz e, Eina_Compare_Cb func) EINA_ARG_NONNULL(3) EINA_WARN_UNUSED_RESULT;
/**
* @brief Merge two list.
*
* @param left Head list to merge.
* @param right Tail list to merge.
* @return A new merged list.
*
* This function puts right at the end of left and return the head.
*
* Both left and right does not exist anymore after the merge.
*
* @note merge cost is O(n), being @b n the size of the smallest
* list. This is due the need to fix accounting of that segment,
* making count and last access O(1).
*
* @warning @p list must be a pointer to the first element of the list.
*/
EAPI Eina_List *eina_list_merge(Eina_List *left, Eina_List *righ t) EINA_WARN_UNUSED_RESULT; EAPI Eina_List *eina_list_merge(Eina_List *left, Eina_List *righ t) EINA_WARN_UNUSED_RESULT;
/**
* @brief Merge two sorted list according to the ordering func will return.
*
* @param left First list to merge.
* @param right Second list to merge.
* @param func A function pointer that can handle comparing the list data
* nodes.
* @return A new sorted list.
*
* This function compares the head of @p left and @p right, and choose the
* smallest one to be head of the returned list. It will continue this proc
ess
* for all entry of both list.
*
* Both left and right does not exist anymore after the merge.
* If @p func is NULL, it will return NULL.
*
* Example:
* @code
* int
* sort_cb(void *d1, void *d2)
* {
* const char *txt = NULL;
* const char *txt2 = NULL;
*
* if(!d1) return(1);
* if(!d2) return(-1);
*
* return(strcmp((const char*)d1, (const char*)d2));
* }
* extern Eina_List *sorted1;
* extern Eina_List *sorted2;
*
* list = eina_list_sorted_merge(sorted1, sorted2, sort_cb);
* @endcode
*
* @warning @p list must be a pointer to the first element of the list.
*/
EAPI Eina_List *eina_list_sorted_merge(Eina_List *left, Eina_Lis t *right, Eina_Compare_Cb func) EINA_ARG_NONNULL(3) EINA_WARN_UNUSED_RESULT ; EAPI Eina_List *eina_list_sorted_merge(Eina_List *left, Eina_Lis t *right, Eina_Compare_Cb func) EINA_ARG_NONNULL(3) EINA_WARN_UNUSED_RESULT ;
/**
* @brief Split a list into 2 lists.
*
* @param list List to split.
* @param relative The list will be split after @p relative.
* @param right The head of the new right list.
* @return The new left list
*
* This function splits @p list into two lists ( left and right ) after the
node @p relative. @p Relative
* will become the last node of the left list. If @p list or @p right are N
ULL list is returns.
* If @p relative is NULL right is set to @p list and NULL is returns.
* If @p relative is the last node of @p list list is returns and @p right
is set to NULL.
*
* list does not exist anymore after the split.
*
* @warning @p list must be a pointer to the first element of the list.
*/
EAPI Eina_List *eina_list_split_list(Eina_List *list, Eina_List *relative, Eina_List **right) EINA_WARN_UNUSED_RESULT; EAPI Eina_List *eina_list_split_list(Eina_List *list, Eina_List *relative, Eina_List **right) EINA_WARN_UNUSED_RESULT;
/**
* @brief Returns node nearest to data is in the sorted list.
*
* @param list The list to search for data, @b must be sorted.
* @param func A function pointer that can handle comparing the list data n
odes.
* @param data reference value to search.
* @param result_cmp if provided returns the result of
* func(node->data, data) node being the last (returned) node. If node
* was found (exact match), then it is 0. If returned node is smaller
* than requested data, it is less than 0 and if it's bigger it's
* greater than 0. It is the last value returned by func().
* @return the nearest node, NULL if not found.
*
* This function searches for a node containing @p data as it's data in @p
list,
* if such a node exists it will be returned and @p result_cmp will be @p 0
. If
* the data of no node in @p list is equal to @p data, the node with the ne
arest
* value to that will be returned and @p result_cmp will be the return valu
e of
* @p func with @p data and the returned node's data as arguments.
*
* This function is useful for inserting an element in the list only in cas
e it
* isn't already present in the list, the naive way of doing this would be:
* @code
* void *ptr = eina_list_data_find(list, "my data");
* if (!ptr)
* eina_list_sorted_insert(list, "my data");
* @endcode
*
* However this has the downside of walking through the list twice, once to
* check if the data is already present and another to insert the element i
n the
* corret position. This can be done more eficiently:
* @code
* int cmp_result;
* l = eina_list_search_sorted_near_list(list, cmp_func, "my data",
* &cmp_result);
* if (cmp_result > 0)
* list = eina_list_prepend_relative_list(list, "my data", l);
* else if (cmp_result < 0)
* list = eina_list_append_relative_list(list, "my data", l);
* @endcode
*
* If @a cmp_result is 0 the element is already in the list and we need not
* insert it, if @a cmp_result is greater than zero @a "my @a data" needs t
o
* come after @a l(the nearest node present), if less than zero before.
*
* @note O(log2(n)) average/worst case performance, for 1,000,000
* elements it will do a maximum of 20 comparisons. This is much
* faster than the 1,000,000 comparisons made naively walking the list
* from head to tail, so depending on the number of searches and
* insertions, it may be worth to eina_list_sort() the list and do the
* searches later. As lists do not have O(1) access time, walking to
* the correct node can be costly, consider worst case to be almost
* O(n) pointer dereference (list walk).
*
* @warning @p list must be a pointer to the first element of the list.
*
* @see eina_list_search_sorted_list()
* @see eina_list_sort()
* @see eina_list_sorted_merge()
*/
EAPI Eina_List *eina_list_search_sorted_near_list(const Eina_Lis t *list, Eina_Compare_Cb func, const void *data, int *result_cmp); EAPI Eina_List *eina_list_search_sorted_near_list(const Eina_Lis t *list, Eina_Compare_Cb func, const void *data, int *result_cmp);
/**
* @brief Returns node if data is in the sorted list.
*
* @param list The list to search for data, @b must be sorted.
* @param func A function pointer that can handle comparing the list data n
odes.
* @param data reference value to search.
* @return the node if func(node->data, data) == 0, NULL if not found.
*
* This can be used to check if some value is inside the list and get
* the container node in this case. It should be used when list is
* known to be sorted as it will do binary search for results.
*
* Example: imagine user gives a string, you check if it's in the list
* before duplicating its contents.
*
* @note O(log2(n)) average/worst case performance, for 1,000,000
* elements it will do a maximum of 20 comparisons. This is much
* faster than the 1,000,000 comparisons made by
* eina_list_search_unsorted_list(), so depending on the number of
* searches and insertions, it may be worth to eina_list_sort() the
* list and do the searches later. As said in
* eina_list_search_sorted_near_list(), lists do not have O(1) access
* time, so walking to the correct node can be costly, consider worst
* case to be almost O(n) pointer dereference (list walk).
*
* @warning @p list must be a pointer to the first element of the list.
*
* @see eina_list_search_sorted()
* @see eina_list_sort()
* @see eina_list_sorted_merge()
* @see eina_list_search_unsorted_list()
* @see eina_list_search_sorted_near_list()
*/
EAPI Eina_List *eina_list_search_sorted_list(const Eina_List *li st, Eina_Compare_Cb func, const void *data); EAPI Eina_List *eina_list_search_sorted_list(const Eina_List *li st, Eina_Compare_Cb func, const void *data);
/**
* @brief Returns node data if it is in the sorted list.
*
* @param list The list to search for data, @b must be sorted.
* @param func A function pointer that can handle comparing the list data n
odes.
* @param data reference value to search.
* @return the node value (@c node->data) if func(node->data, data) == 0,
* NULL if not found.
*
* This can be used to check if some value is inside the list and get
* the existing instance in this case. It should be used when list is
* known to be sorted as it will do binary search for results.
*
* Example: imagine user gives a string, you check if it's in the list
* before duplicating its contents.
*
* @note O(log2(n)) average/worst case performance, for 1,000,000
* elements it will do a maximum of 20 comparisons. This is much
* faster than the 1,000,000 comparisons made by
* eina_list_search_unsorted(), so depending on the number of
* searches and insertions, it may be worth to eina_list_sort() the
* list and do the searches later. As said in
* eina_list_search_sorted_near_list(), lists do not have O(1) access
* time, so walking to the correct node can be costly, consider worst
* case to be almost O(n) pointer dereference (list walk).
*
* @warning @p list must be a pointer to the first element of the list.
*
* @see eina_list_search_sorted_list()
* @see eina_list_sort()
* @see eina_list_sorted_merge()
* @see eina_list_search_unsorted_list()
*/
EAPI void *eina_list_search_sorted(const Eina_List *list, E ina_Compare_Cb func, const void *data); EAPI void *eina_list_search_sorted(const Eina_List *list, E ina_Compare_Cb func, const void *data);
/**
* @brief Returns node if data is in the unsorted list.
*
* @param list The list to search for data, may be unsorted.
* @param func A function pointer that can handle comparing the list data n
odes.
* @param data reference value to search.
* @return the node if func(node->data, data) == 0, NULL if not found.
*
* This can be used to check if some value is inside the list and get
* the container node in this case.
*
* Example: imagine user gives a string, you check if it's in the list
* before duplicating its contents.
*
* @note this is expensive and may walk the whole list, it's order-N,
* that is for 1,000,000 elements list it may walk and compare
* 1,000,000 nodes.
*
* @warning @p list must be a pointer to the first element of the list.
*
* @see eina_list_search_sorted_list()
* @see eina_list_search_unsorted()
*/
EAPI Eina_List *eina_list_search_unsorted_list(const Eina_List * list, Eina_Compare_Cb func, const void *data); EAPI Eina_List *eina_list_search_unsorted_list(const Eina_List * list, Eina_Compare_Cb func, const void *data);
/**
* @brief Returns node data if it is in the unsorted list.
*
* @param list The list to search for data, may be unsorted.
* @param func A function pointer that can handle comparing the list data n
odes.
* @param data reference value to search.
* @return the node value (@c node->data) if func(node->data, data) == 0,
* NULL if not found.
*
* This can be used to check if some value is inside the list and get
* the existing instance in this case.
*
* Example: imagine user gives a string, you check if it's in the list
* before duplicating its contents.
*
* @note this is expensive and may walk the whole list, it's order-N,
* that is for 1,000,000 elements list it may walk and compare
* 1,000,000 nodes.
*
* @warning @p list must be a pointer to the first element of the list.
*
* @see eina_list_search_sorted()
* @see eina_list_search_unsorted_list()
*/
EAPI void *eina_list_search_unsorted(const Eina_List *list, Eina_Compare_Cb func, const void *data); EAPI void *eina_list_search_unsorted(const Eina_List *list, Eina_Compare_Cb func, const void *data);
/**
* @brief Get the last list node in the list.
*
* @param list The list to get the last list node from.
* @return The last list node in the list.
*
* This function returns the last list node in the list @p list. If
* @p list is @c NULL or empty, @c NULL is returned.
*
* This is a order-1 operation (it takes the same short time
* regardless of the length of the list).
*
* @warning @p list must be a pointer to the first element of the list.
*/
static inline Eina_List *eina_list_last(const Eina_List *list) EINA_PURE EINA_WARN_UNUSED_RESULT; static inline Eina_List *eina_list_last(const Eina_List *list) EINA_PURE EINA_WARN_UNUSED_RESULT;
/**
* @brief Get the next list node after the specified list node.
*
* @param list The list node to get the next list node from
* @return The next list node on success, @c NULL otherwise.
*
* This function returns the next list node after the current one in
* @p list. It is equivalent to list->next. If @p list is @c NULL or
* if no next list node exists, it returns @c NULL.
*
* @warning @p list must be a pointer to the first element of the list.
*/
static inline Eina_List *eina_list_next(const Eina_List *list) EINA_PURE EINA_WARN_UNUSED_RESULT; static inline Eina_List *eina_list_next(const Eina_List *list) EINA_PURE EINA_WARN_UNUSED_RESULT;
/**
* @brief Get the previous list node before the specified list node.
*
* @param list The list node to get the previous list node from.
* @return The previous list node o success, @c NULL otherwise.
* if no previous list node exists
*
* This function returns the previous list node before the current one
* in @p list. It is equivalent to list->prev. If @p list is @c NULL or
* if no previous list node exists, it returns @c NULL.
*
* @warning @p list must be a pointer to the first element of the list.
*/
static inline Eina_List *eina_list_prev(const Eina_List *list) EINA_PURE EINA_WARN_UNUSED_RESULT; static inline Eina_List *eina_list_prev(const Eina_List *list) EINA_PURE EINA_WARN_UNUSED_RESULT;
/**
* @brief Get the list node data member.
*
* @param list The list node to get the data member of.
* @return The data member from the list node.
*
* This function returns the data member of the specified list node @p
* list. It is equivalent to list->data. If @p list is @c NULL, this
* function returns @c NULL.
*
* @warning @p list must be a pointer to the first element of the list.
*/
static inline void *eina_list_data_get(const Eina_List *list) EINA_P URE EINA_WARN_UNUSED_RESULT; static inline void *eina_list_data_get(const Eina_List *list) EINA_P URE EINA_WARN_UNUSED_RESULT;
/**
* @brief Set the list node data member.
*
* @param list The list node to get the data member of.
* @param data The data member to the list node.
* @return The previous data value.
*
* This function set the data member @p data of the specified list node
* @p list. It returns the previous data of the node. If @p list is
* @c NULL, this function returns @c NULL.
*
* @warning @p list must be a pointer to the first element of the list.
*/
static inline void *eina_list_data_set(Eina_List *list, const void *
data);
/**
* @brief Get the count of the number of items in a list.
*
* @param list The list whose count to return.
* @return The number of members in the list.
*
* This function returns how many members @p list contains. If the
* list is @c NULL, 0 is returned.
*
* NB: This is an order-1 operation and takes the same time regardless
* of the length of the list.
*
* @warning @p list must be a pointer to the first element of the list.
*/
static inline unsigned int eina_list_count(const Eina_List *list) EINA_PURE ; static inline unsigned int eina_list_count(const Eina_List *list) EINA_PURE ;
/**
* @brief Returned a new iterator associated to a list.
*
* @param list The list.
* @return A new iterator.
*
* This function returns a newly allocated iterator 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 still returns a valid iterator that
* will always return false on eina_iterator_next(), thus keeping API
* sane.
*
* If the memory can not be allocated, NULL is returned and
* #EINA_ERROR_OUT_OF_MEMORY is set. Otherwise, a valid iterator is
* returned.
*
* @warning @p list must be a pointer to the first element of the list.
*
* @warning if the list structure changes then the iterator becomes
* invalid! That is, if you add or remove nodes this iterator
* behavior is undefined and your program may crash!
*/
EAPI Eina_Iterator *eina_list_iterator_new(const Eina_List *list) EI NA_MALLOC EINA_WARN_UNUSED_RESULT; EAPI Eina_Iterator *eina_list_iterator_new(const Eina_List *list) EI NA_MALLOC EINA_WARN_UNUSED_RESULT;
/**
* @brief Returned a new reversed iterator associated to a list.
*
* @param list The list.
* @return A new iterator.
*
* This function returns a newly allocated iterator 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 still returns a valid iterator that
* will always return false on eina_iterator_next(), thus keeping API
* sane.
*
* Unlike eina_list_iterator_new(), this will walk the list backwards.
*
* If the memory can not be allocated, NULL is returned and
* #EINA_ERROR_OUT_OF_MEMORY is set. Otherwise, a valid iterator is
* returned.
*
* @warning @p list must be a pointer to the first element of the list.
*
* @warning if the list structure changes then the iterator becomes
* invalid! That is, if you add or remove nodes this iterator
* behavior is undefined and your program may crash!
*/
EAPI Eina_Iterator *eina_list_iterator_reversed_new(const Eina_List *list) EINA_MALLOC EINA_WARN_UNUSED_RESULT; EAPI Eina_Iterator *eina_list_iterator_reversed_new(const Eina_List *list) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
/**
* @brief Returned 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.
*
* @warning @p list must be a pointer to the first element of the list.
*/
EAPI Eina_Accessor *eina_list_accessor_new(const Eina_List *list) EI NA_MALLOC EINA_WARN_UNUSED_RESULT; EAPI Eina_Accessor *eina_list_accessor_new(const Eina_List *list) EI NA_MALLOC EINA_WARN_UNUSED_RESULT;
/** /**
* @def EINA_LIST_FOREACH * @def EINA_LIST_FOREACH
* @brief Macro to iterate over a list. * @brief Macro to iterate over a list.
* *
* @param list The list to iterate over. * @param list The list to iterate over.
* @param l A list that is used as an iterator and points to the current no de. * @param l A list that is used as an iterator and points to the current no de.
* @param data Current item's data. * @param data Current item's data.
* *
* This macro iterates over @p list from the first element to * This macro iterates over @p list from the first element to
* the last. @p data is the data related to the current element. * the last. @p data is the data related to the current element.
* @p l is an #Eina_List used as the list iterator. * @p l is an #Eina_List used as the list iterator.
* *
* The following diagram ilustrates this macro iterating over a list of fou
r
* elements("one", "two", "three" and "four"):
* @htmlonly
* <img src="eina-list-foreach.png" style="max-width: 100%;" />
* <a href="eina-list-foreach.png">Full-size</a>
* @endhtmlonly
* @image latex eina-list-foreach.eps width=\textwidth
*
* It can be used to free list data, as in the following example: * It can be used to free list data, as in the following example:
* *
* @code * @code
* Eina_List *list; * Eina_List *list;
* Eina_List *l; * Eina_List *l;
* char *data; * char *data;
* *
* // list is already filled, * // list is already filled,
* // its elements are just duplicated strings, * // its elements are just duplicated strings,
* // EINA_LIST_FOREACH will be used to free those strings * // EINA_LIST_FOREACH will be used to free those strings
* *
* EINA_LIST_FOREACH(list, l, data) * EINA_LIST_FOREACH(list, l, data)
* free(data); * free(data);
* eina_list_free(list); * eina_list_free(list);
* @endcode * @endcode
* *
* @note This is not the optimal way to release memory allocated to * @note This is not the optimal way to release memory allocated to
* a list, since it iterates over the list twice. * a list, since it iterates over the list twice.
* For an optimized algorithm, use EINA_LIST_FREE(). * For an optimized algorithm, use EINA_LIST_FREE().
* *
* @warning @p list must be a pointer to the first element of the list.
*
* @warning Be careful when deleting list nodes. * @warning Be careful when deleting list nodes.
* If you remove the current node and continue iterating, * If you remove the current node and continue iterating,
* the code will fail because the macro will not be able * the code will fail because the macro will not be able
* to get the next node. Notice that it's OK to remove any * to get the next node. Notice that it's OK to remove any
* node if you stop the loop after that. * node if you stop the loop after that.
* For destructive operations such as this, consider * For destructive operations such as this, consider
* using EINA_LIST_FOREACH_SAFE(). * using EINA_LIST_FOREACH_SAFE().
*/ */
#define EINA_LIST_FOREACH(list, l, data) \ #define EINA_LIST_FOREACH(list, l, data) \
for (l = list, \ for (l = list, \
skipping to change at line 219 skipping to change at line 1390
* *
* @param list The list to iterate over. * @param list The list to iterate over.
* @param l A list that is used as an iterator and points to the current no de. * @param l A list that is used as an iterator and points to the current no de.
* @param data Current item's data. * @param data Current item's data.
* *
* This macro works like EINA_LIST_FOREACH, but iterates from the * This macro works like EINA_LIST_FOREACH, but iterates from the
* last element of a list to the first. * last element of a list to the first.
* @p data is the data related to the current element, while @p l * @p data is the data related to the current element, while @p l
* is an #Eina_List that is used as the list iterator. * is an #Eina_List that is used as the list iterator.
* *
* The following diagram ilustrates this macro iterating over a list of fou
r
* elements("one", "two", "three" and "four"):
* @htmlonly
* <img src="eina-list-reverse-foreach.png" style="max-width: 100%;" />
* <a href="eina-list-reverse-foreach.png">Full-size</a>
* @endhtmlonly
* @image latex eina-list-reverse-foreach.eps width=\textwidth
*
* It can be used to free list data, as in the following example: * It can be used to free list data, as in the following example:
* *
* @code * @code
* Eina_List *list; * Eina_List *list;
* Eina_List *l; * Eina_List *l;
* char *data; * char *data;
* *
* // list is already filled, * // list is already filled,
* // its elements are just duplicated strings, * // its elements are just duplicated strings,
* // EINA_LIST_REVERSE_FOREACH will be used to free those strings * // EINA_LIST_REVERSE_FOREACH will be used to free those strings
* *
* EINA_LIST_REVERSE_FOREACH(list, l, data) * EINA_LIST_REVERSE_FOREACH(list, l, data)
* free(data); * free(data);
* eina_list_free(list); * eina_list_free(list);
* @endcode * @endcode
* *
* @note This is not the optimal way to release memory allocated to * @note This is not the optimal way to release memory allocated to
* a list, since it iterates over the list twice. * a list, since it iterates over the list twice.
* For an optimized algorithm, use EINA_LIST_FREE(). * For an optimized algorithm, use EINA_LIST_FREE().
* *
* @warning @p list must be a pointer to the first element of the list.
*
* @warning Be careful when deleting list nodes. * @warning Be careful when deleting list nodes.
* If you remove the current node and continue iterating, * If you remove the current node and continue iterating,
* the code will fail because the macro will not be able * the code will fail because the macro will not be able
* to get the next node. Notice that it's OK to remove any * to get the next node. Notice that it's OK to remove any
* node if you stop the loop after that. * node if you stop the loop after that.
* For destructive operations such as this, consider * For destructive operations such as this, consider
* using EINA_LIST_REVERSE_FOREACH_SAFE(). * using EINA_LIST_REVERSE_FOREACH_SAFE().
*/ */
#define EINA_LIST_REVERSE_FOREACH(list, l, data) \ #define EINA_LIST_REVERSE_FOREACH(list, l, data) \
for (l = eina_list_last(list), \ for (l = eina_list_last(list), \
skipping to change at line 270 skipping to change at line 1451
* @param l_next A list that is used as an iterator and points to the next node. * @param l_next A list that is used as an iterator and points to the next node.
* @param data Current item's data. * @param data Current item's data.
* *
* This macro iterates over @p list from the first element to * This macro iterates over @p list from the first element to
* the last. @p data is the data related to the current element. * the last. @p data is the data related to the current element.
* @p l is an #Eina_List used as the list iterator. * @p l is an #Eina_List used as the list iterator.
* *
* Since this macro stores a pointer to the next list node in @p l_next, * Since this macro stores a pointer to the next list node in @p l_next,
* deleting the current node and continuing looping is safe. * deleting the current node and continuing looping is safe.
* *
* The following diagram ilustrates this macro iterating over a list of fou
r
* elements("one", "two", "three" and "four"):
* @htmlonly
* <img src="eina-list-foreach-safe.png" style="max-width: 100%;" />
* <a href="eina-list-foreach-safe.png">Full-size</a>
* @endhtmlonly
* @image latex eina-list-foreach-safe.eps width=\textwidth
*
* This macro can be used to free list nodes, as in the following example: * This macro can be used to free list nodes, as in the following example:
* *
* @code * @code
* Eina_List *list; * Eina_List *list;
* Eina_List *l; * Eina_List *l;
* Eina_List *l_next; * Eina_List *l_next;
* char *data; * char *data;
* *
* // list is already filled, * // list is already filled,
* // its elements are just duplicated strings, * // its elements are just duplicated strings,
* // EINA_LIST_FOREACH_SAFE will be used to free elements that match "key" . * // EINA_LIST_FOREACH_SAFE will be used to free elements that match "key" .
* *
* EINA_LIST_FOREACH_SAFE(list, l, l_next, data) * EINA_LIST_FOREACH_SAFE(list, l, l_next, data)
* if (strcmp(data, "key") == 0) { * if (strcmp(data, "key") == 0) {
* free(data); * free(data);
* list = eina_list_remove_list(list, l); * list = eina_list_remove_list(list, l);
* } * }
* @endcode * @endcode
*
* @warning @p list must be a pointer to the first element of the list.
*/ */
#define EINA_LIST_FOREACH_SAFE(list, l, l_next, data) \ #define EINA_LIST_FOREACH_SAFE(list, l, l_next, data) \
for (l = list, \ for (l = list, \
l_next = eina_list_next(l), \ l_next = eina_list_next(l), \
data = eina_list_data_get(l); \ data = eina_list_data_get(l); \
l; \ l; \
l = l_next, \ l = l_next, \
l_next = eina_list_next(l), \ l_next = eina_list_next(l), \
data = eina_list_data_get(l)) data = eina_list_data_get(l))
skipping to change at line 316 skipping to change at line 1507
* @param data Current item's data. * @param data Current item's data.
* *
* This macro works like EINA_LIST_FOREACH_SAFE, but iterates from the * This macro works like EINA_LIST_FOREACH_SAFE, but iterates from the
* last element of a list to the first. * last element of a list to the first.
* @p data is the data related to the current element, while @p l * @p data is the data related to the current element, while @p l
* is an #Eina_List that is used as the list iterator. * is an #Eina_List that is used as the list iterator.
* *
* Since this macro stores a pointer to the previous list node in @p l_prev , * Since this macro stores a pointer to the previous list node in @p l_prev ,
* deleting the current node and continuing looping is safe. * deleting the current node and continuing looping is safe.
* *
* The following diagram ilustrates this macro iterating over a list of fou
r
* elements("one", "two", "three" and "four"):
* @htmlonly
* <img src="eina-list-reverse-foreach-safe.png" style="max-width: 100%;" /
>
* <a href="eina-list-reverse-foreach-safe.png">Full-size</a>
* @endhtmlonly
* @image latex eina-list-reverse-foreach-safe.eps width=\textwidth
*
* This macro can be used to free list nodes, as in the following example: * This macro can be used to free list nodes, as in the following example:
* *
* @code * @code
* Eina_List *list; * Eina_List *list;
* Eina_List *l; * Eina_List *l;
* Eina_List *l_prev; * Eina_List *l_prev;
* char *data; * char *data;
* *
* // list is already filled, * // list is already filled,
* // its elements are just duplicated strings, * // its elements are just duplicated strings,
* // EINA_LIST_REVERSE_FOREACH_SAFE will be used to free elements that mat ch "key". * // EINA_LIST_REVERSE_FOREACH_SAFE will be used to free elements that mat ch "key".
* *
* EINA_LIST_REVERSE_FOREACH_SAFE(list, l, l_prev, data) * EINA_LIST_REVERSE_FOREACH_SAFE(list, l, l_prev, data)
* if (strcmp(data, "key") == 0) { * if (strcmp(data, "key") == 0) {
* free(data); * free(data);
* list = eina_list_remove_list(list, l); * list = eina_list_remove_list(list, l);
* } * }
* @endcode * @endcode
*
* @warning @p list must be a pointer to the first element of the list.
*/ */
#define EINA_LIST_REVERSE_FOREACH_SAFE(list, l, l_prev, data) \ #define EINA_LIST_REVERSE_FOREACH_SAFE(list, l, l_prev, data) \
for (l = eina_list_last(list), \ for (l = eina_list_last(list), \
l_prev = eina_list_prev(l), \ l_prev = eina_list_prev(l), \
data = eina_list_data_get(l); \ data = eina_list_data_get(l); \
l; \ l; \
l = l_prev, \ l = l_prev, \
l_prev = eina_list_prev(l), \ l_prev = eina_list_prev(l), \
data = eina_list_data_get(l)) data = eina_list_data_get(l))
/** /**
* @def EINA_LIST_FREE * @def EINA_LIST_FREE
* @brief Macro to remove each list node while having access to each node's data. * @brief Macro to remove each list node while having access to each node's data.
* *
* @param list The list that will be cleared. * @param list The list that will be cleared.
* @param data Current node's data. * @param data Current node's data.
* *
* This macro will call #eina_list_remove_list for each list node, and stor e * This macro will call #eina_list_remove_list for each list node, and stor e
* the data contained in the current node in @p data. * the data contained in the current node in @p data.
* *
* The following diagram ilustrates this macro iterating over a list of fou
r
* elements("one", "two", "three" and "four"):
* @htmlonly
* <img src="eina-list-free.png" style="max-width: 100%;" />
* <a href="eina-list-free.png">Full-size</a>
* @endhtmlonly
* @image latex eina-list-free.eps width=\textwidth
*
* If you do not need to release node data, it is easier to call #eina_list _free(). * If you do not need to release node data, it is easier to call #eina_list _free().
* *
* @code * @code
* Eina_List *list; * Eina_List *list;
* char *data; * char *data;
* *
* // list is already filled, * // list is already filled,
* // its elements are just duplicated strings, * // its elements are just duplicated strings,
* *
* EINA_LIST_FREE(list, data) * EINA_LIST_FREE(list, data)
* free(data); * free(data);
* @endcode * @endcode
* *
* @warning @p list must be a pointer to the first element of the list.
*
* @see eina_list_free() * @see eina_list_free()
*/ */
#define EINA_LIST_FREE(list, data) \ #define EINA_LIST_FREE(list, data) \
for (data = eina_list_data_get(list); \ for (data = eina_list_data_get(list); \
list; \ list; \
list = eina_list_remove_list(list, list), \ list = eina_list_remove_list(list, list), \
data = eina_list_data_get(list)) data = eina_list_data_get(list))
#include "eina_inline_list.x" #include "eina_inline_list.x"
 End of changes. 47 change blocks. 
0 lines changed or deleted 1282 lines changed or added


 eina_log.h   eina_log.h 
skipping to change at line 41 skipping to change at line 41
#define EINA_COLOR_GREEN "\033[32;1m" #define EINA_COLOR_GREEN "\033[32;1m"
#define EINA_COLOR_YELLOW "\033[33;1m" #define EINA_COLOR_YELLOW "\033[33;1m"
#define EINA_COLOR_ORANGE "\033[0;33m" #define EINA_COLOR_ORANGE "\033[0;33m"
#define EINA_COLOR_WHITE "\033[37;1m" #define EINA_COLOR_WHITE "\033[37;1m"
#define EINA_COLOR_LIGHTCYAN "\033[36;1m" #define EINA_COLOR_LIGHTCYAN "\033[36;1m"
#define EINA_COLOR_CYAN "\033[36m" #define EINA_COLOR_CYAN "\033[36m"
#define EINA_COLOR_RESET "\033[0m" #define EINA_COLOR_RESET "\033[0m"
#define EINA_COLOR_HIGH "\033[1m" #define EINA_COLOR_HIGH "\033[1m"
/** /**
* @page tutorial_log_page Log Tutorial
*
* @section tutorial_log_introduction Introduction
*
* The Eina Log module provides logging facilities for libraries and
* applications. It provides colored logging, basic logging levels (error,
* warning, debug, info, critical) and loggers - called logging domains -
* which will be covered on next sections.
*
* @section tutorial_log_basic_usage Basic Usage
*
* Log messages can be displayed using the following macros:
*
* @li EINA_LOG_ERR(),
* @li EINA_LOG_INFO(),
* @li EINA_LOG_WARN(),
* @li EINA_LOG_DBG().
*
* Here is an example:
*
* @include eina_log_02.c
*
* If you compiled Eina without debug mode, execution will yield only one l
og
* message, which is "argument is negative".
*
* Here we introduce the concept of logging domains (or loggers), which mig
ht
* already be familiar to readers. It is basically a way to separate a set
of
* log messages into a context (e.g. a module) and provide a way of control
ling
* this set as a whole.
*
* For example, suppose you have 3 different modules on your application an
d you
* want to get logging only from one of them (e.g. create some sort of filt
er).
* For achieving that, all you need to do is create a logging domain for ea
ch
* module so that all logging inside a module can be considered as a whole.
*
* Logging domains are specified by a name, color applied to the name and t
he
* level. The first two (name and color) are set through code, that is, ins
ide
* your application/module/library.
*
* The level is used for controlling which messages should appear. It
* specifies the lowest level that should be displayed (e.g. a message
* with level 11 being logged on a domain with level set to 10 would be
* displayed, while a message with level 9 wouldn't).
*
* The domain level is set during runtime (in contrast with the name and
* color) through the environment variable EINA_LOG_LEVELS. This variable
* expects a list in the form domain_name1:level1,domain_name2:level2,... .
For
* example:
*
* @verbatim EINA_LOG_LEVELS=mymodule1:5,mymodule2:2,mymodule3:0 ./myapp@en
dverbatim
*
* This line would set mymodule1 level to 5, mymodule2 level to 2 and mymod
ule3
* level to 0.
*
* There's also a global logger to which EINA_LOG_(ERR, DBG, INFO, CRIT, WA
RN)
* macros do log on. It is a logger that is created internally by Eina Log
with
* an empty name and can be used for general logging (where logging domains
do
* not apply).
*
* Since this global logger doesn't have a name, you can't set its level th
rough
* EINA_LOG_LEVELS variable. Here we introduce a second environment variabl
e
* that is a bit more special: EINA_LOG_LEVEL.
*
* This variable specifies the level of the global logging domain and the l
evel
* of domains that haven't been set through EINA_LOG_LEVELS. Here's an exam
ple:
*
* @verbatim EINA_LOG_LEVEL=3 EINA_LOG_LEVELS=module1:10,module3:2 ./myapp@
endverbatim
*
* Supposing you have modules named "module1", "module2" and "module3", thi
s
* line would result in module1 with level 10, module2 with level 3 and mod
ule3
* with level 2. Note that module2's level wasn't specified, so it's level
is
* set to the global level. This way we can easily apply filters to multipl
e
* domains with only one parameter (EINA_LOG_LEVEL=num).
*
* The global level (EINA_LOG_LEVEL) can also be set through code, using
* eina_log_level_set() function.
*
* While developing your libraries or applications, you may notice that
* EINA_LOG_DOM_(ERR, DBG, INFO, CRIT, WARN) macros also print out
* messages from eina itself. Here we introduce another environment variabl
e
* that is a bit more special: EINA_LOG_LEVELS_GLOB.
*
* This variable allows you to disable the logging of any/all code in eina
itself.
* This is useful when developing your libraries or applications so that yo
u can
* see your own domain's messages easier without having to sift through a l
ot of
* internal eina debug messages. Here's an example:
*
* @verbatim EINA_LOG_LEVEL=3 EINA_LOG_LEVELS_GLOB=eina_*:0 ./myapp@endverb
atim
*
* This will disable eina_log output from all internal eina code thus allow
ing
* you to see your own domain messages easier.
*
* @section tutorial_log_advanced_display Advanced usage of print callbacks
*
* The log module allows the user to change the way
* eina_log_print() displays the messages. It suffices to pass to
* eina_log_print_cb_set() the function used to display the
* message. That function must be of type #Eina_Log_Print_Cb. As a
* custom data can be passed to that callback, powerful display
* messages can be displayed.
*
* It is suggested to not use __FILE__, __FUNCTION__ or __LINE__ when
* writing that callback, but when defining macros (like
* EINA_LOG_ERR() and other macros).
*
* Here is an example of custom callback, whose behavior can be
* changed at runtime:
*
* @include eina_log_03.c
* @example eina_log_02.c
* @example eina_log_03.c
*/
/**
* @addtogroup Eina_Log_Group Log
*
* @brief Full-featured logging system.
*
* Eina provides eina_log_print(), a standard function to manage all
* logging messages. This function may be called directly or using the
* helper macros such as EINA_LOG_DBG(), EINA_LOG_ERR() or those that
* take a specific domain as argument EINA_LOG_DOM_DBG(),
* EINA_LOG_DOM_ERR(). Internally, eina_log_print() will call the
* function defined with eina_log_print_cb_set(), that defaults to
* eina_log_print_cb_stderr(), but may be changed to do whatever you
* need, such as networking or syslog logging.
*
* The logging system is thread safe once initialized with
* eina_log_threads_enable(). The thread that calls this function
* first is considered "main thread" and other threads will have their
* thread id (pthread_self()) printed in the log message so it is easy
* to detect from where it is coming.
*
* Log domains is the Eina way to differentiate messages. There might
* be different domains to represent different modules, different
* feature-set, different categories and so on. Filtering can be
* applied to domain names by means of @c EINA_LOG_LEVELS environment
* variable or eina_log_domain_level_set().
*
* The different logging levels serve to customize the amount of
* debugging one want to take and may be used to automatically call
* abort() once some given level message is printed. This is
* controlled by environment variable @c EINA_LOG_ABORT and the level
* to be considered critical with @c EINA_LOG_ABORT_LEVEL. These can
* be changed with eina_log_abort_on_critical_set() and
* eina_log_abort_on_critical_level_set().
*
* The default maximum level to print is defined by environment
* variable @c EINA_LOG_LEVEL, but may be set per-domain with @c
* EINA_LOG_LEVELS. It will default to #EINA_LOG_ERR. This can be
* changed with eina_log_level_set().
*
* To use the log system Eina must be initialized with eina_init() and
* later shut down with eina_shutdown(). Here is a straightforward
* example:
*
* @include eina_log_01.c
*
* Compile this code with the following command:
*
* @verbatim gcc -Wall -o eina_log_01 eina_log_01.c `pkg-config --cflags --
libs eina`@endverbatim
*
* Now execute the program with:
*
* @verbatim EINA_LOG_LEVEL=2 ./eina_log_01@endverbatim
*
* You should see a message displayed in the terminal.
*
* For more information, you can look at the @ref tutorial_log_page.
*
* @example eina_log_01.c
*/
/**
* @addtogroup Eina_Tools_Group Tools * @addtogroup Eina_Tools_Group Tools
* *
* @{ * @{
*/ */
/** /**
* @defgroup Eina_Log_Group Log * @defgroup Eina_Log_Group Log
* *
* @{ * @{
*/ */
skipping to change at line 242 skipping to change at line 416
{ {
int level; /**< Max level to log */ int level; /**< Max level to log */
const char *domain_str; /**< Formatted string with color to print */ const char *domain_str; /**< Formatted string with color to print */
const char *name; /**< Domain name */ const char *name; /**< Domain name */
size_t namelen; /**< strlen(name) */ size_t namelen; /**< strlen(name) */
/* Private */ /* Private */
Eina_Bool deleted : 1; /**< Flags deletion of domain, a free slot */ Eina_Bool deleted : 1; /**< Flags deletion of domain, a free slot */
}; };
/**
* Enable logging module to handle threads.
*
* There is no disable option on purpose, if it is enabled, there is
* no way back until you call the last eina_shutdown().
*
* There is no function to retrieve if threads are enabled as one is
* not supposed to know this from outside.
*
* After this call is executed at least once, if Eina was compiled
* with threads support then logging will lock around debug messages
* and threads that are not the main thread will have its identifier
* printed.
*
* The main thread is considered the thread where the first
* eina_init() was called.
*/
EAPI void eina_log_threads_enable(void); EAPI void eina_log_threads_enable(void);
/** /**
* @enum _Eina_Log_Level * @enum _Eina_Log_Level
* List of available logging levels. * List of available logging levels.
*/ */
typedef enum _Eina_Log_Level typedef enum _Eina_Log_Level
{ {
EINA_LOG_LEVEL_CRITICAL, /**< Critical log level */ EINA_LOG_LEVEL_CRITICAL, /**< Critical log level */
EINA_LOG_LEVEL_ERR, /**< Error log level */ EINA_LOG_LEVEL_ERR, /**< Error log level */
skipping to change at line 271 skipping to change at line 462
* Type for print callbacks. * Type for print callbacks.
*/ */
typedef void (*Eina_Log_Print_Cb)(const Eina_Log_Domain *d, typedef void (*Eina_Log_Print_Cb)(const Eina_Log_Domain *d,
Eina_Log_Level level, Eina_Log_Level level,
const char *file, const char *fnc, int li ne, const char *file, const char *fnc, int li ne,
const char *fmt, void *data, va_list args ); const char *fmt, void *data, va_list args );
/* /*
* Customization * Customization
*/ */
/**
* Sets logging method to use.
*
* @param cb The callback to call when printing a log.
* @param data The data to pass to the callback.
*
* By default, eina_log_print_cb_stderr() is used.
*
* @note MT: safe to call from any thread.
*
* @note MT: given function @a cb will be called protected by mutex.
* This means you're safe from other calls but you should never
* call eina_log_print(), directly or indirectly.
*/
EAPI void eina_log_print_cb_set(Eina_Log_Print_Cb cb, void *data) EINA_ARG_ NONNULL(1); EAPI void eina_log_print_cb_set(Eina_Log_Print_Cb cb, void *data) EINA_ARG_ NONNULL(1);
/**
* @brief Set the default log level.
*
* @param level The log level.
*
* This function sets the log level @p level. It is used in
* eina_log_print().
*
* @note this is initially set to envvar EINA_LOG_LEVEL by eina_init().
*
* @see eina_log_level_get()
*/
EAPI void eina_log_level_set(int level); EAPI void eina_log_level_set(int level);
/**
* @brief Get the default log level.
*
* @return the log level that limits eina_log_print().
*
* @see eina_log_level_set()
*/
EAPI int eina_log_level_get(void) EINA_WARN_UNUSED_RESULT; EAPI int eina_log_level_get(void) EINA_WARN_UNUSED_RESULT;
static inline Eina_Bool static inline Eina_Bool eina_log_level_check(int level);
eina_log_level_check(int level);
/**
* Checks if current thread is the main thread.
*
* @return #EINA_TRUE if threads were enabled and the current thread
* is the one that called eina_log_threads_init(). If there is
* no thread support (compiled with --disable-pthreads) or
* they were not enabled, then #EINA_TRUE is also
* returned. The only case where #EINA_FALSE is returned is
* when threads were successfully enabled but the current
* thread is not the main (one that called
* eina_log_threads_init()).
*/
EAPI Eina_Bool eina_log_main_thread_check(void) EINA_CONST EINA_WA RN_UNUSED_RESULT; EAPI Eina_Bool eina_log_main_thread_check(void) EINA_CONST EINA_WA RN_UNUSED_RESULT;
/**
* @brief Set if color logging should be disabled.
*
* @param disabled if #EINA_TRUE, color logging should be disabled.
*
* @note this is initially set to envvar EINA_LOG_COLOR_DISABLE by eina_ini
t().
*
* @see eina_log_color_disable_get()
*/
EAPI void eina_log_color_disable_set(Eina_Bool disabled); EAPI void eina_log_color_disable_set(Eina_Bool disabled);
/**
* @brief Get if color logging should be disabled.
*
* @return if #EINA_TRUE, color logging should be disabled.
*
* @see eina_log_color_disable_set()
*/
EAPI Eina_Bool eina_log_color_disable_get(void) EINA_WARN_UNUSED_R ESULT; EAPI Eina_Bool eina_log_color_disable_get(void) EINA_WARN_UNUSED_R ESULT;
/**
* @brief Set if originating file name logging should be disabled.
*
* @param disabled if #EINA_TRUE, file name logging should be disabled.
*
* @note this is initially set to envvar EINA_LOG_FILE_DISABLE by eina_init
().
*
* @see eina_log_file_disable_get()
*/
EAPI void eina_log_file_disable_set(Eina_Bool disabled); EAPI void eina_log_file_disable_set(Eina_Bool disabled);
/**
* @brief Get if originating file name logging should be disabled.
*
* @return if #EINA_TRUE, file name logging should be disabled.
*
* @see eina_log_file_disable_set()
*/
EAPI Eina_Bool eina_log_file_disable_get(void) EINA_WARN_UNUSED_RE SULT; EAPI Eina_Bool eina_log_file_disable_get(void) EINA_WARN_UNUSED_RE SULT;
/**
* @brief Set if originating function name logging should be disabled.
*
* @param disabled if #EINA_TRUE, function name logging should be disabled.
*
* @note this is initially set to envvar EINA_LOG_FUNCTION_DISABLE by
* eina_init().
*
* @see eina_log_function_disable_get()
*/
EAPI void eina_log_function_disable_set(Eina_Bool disabled); EAPI void eina_log_function_disable_set(Eina_Bool disabled);
/**
* @brief Get if originating function name logging should be disabled.
*
* @return if #EINA_TRUE, function name logging should be disabled.
*
* @see eina_log_function_disable_set()
*/
EAPI Eina_Bool eina_log_function_disable_get(void) EINA_WARN_UNUSE D_RESULT; EAPI Eina_Bool eina_log_function_disable_get(void) EINA_WARN_UNUSE D_RESULT;
/**
* @brief Set if critical messages should abort the program.
*
* @param abort_on_critical if #EINA_TRUE, messages with level equal
* or smaller than eina_log_abort_on_critical_level_get() will
* abort the program.
*
* @note this is initially set to envvar EINA_LOG_ABORT by
* eina_init().
*
* @see eina_log_abort_on_critical_get()
* @see eina_log_abort_on_critical_level_set()
*/
EAPI void eina_log_abort_on_critical_set(Eina_Bool abort_on_c ritical); EAPI void eina_log_abort_on_critical_set(Eina_Bool abort_on_c ritical);
/**
* @brief Get if critical messages should abort the program.
*
* @return if #EINA_TRUE, any messages with level equal or smaller
* than eina_log_abort_on_critical_level_get() will abort the
* program.
*
* @see eina_log_abort_on_critical_set()
* @see eina_log_abort_on_critical_level_set()
*/
EAPI Eina_Bool eina_log_abort_on_critical_get(void) EINA_WARN_UNUS ED_RESULT; EAPI Eina_Bool eina_log_abort_on_critical_get(void) EINA_WARN_UNUS ED_RESULT;
/**
* @brief Set level that triggers abort if abort-on-critical is set.
*
* @param critical_level levels equal or smaller than the given value
* will trigger program abortion if
* eina_log_abort_on_critical_get() returns #EINA_TRUE.
*
* @note this is initially set to envvar EINA_LOG_ABORT_LEVEL by
* eina_init().
*
* @see eina_log_abort_on_critical_level_get()
* @see eina_log_abort_on_critical_get()
*/
EAPI void eina_log_abort_on_critical_level_set(int critical_l evel); EAPI void eina_log_abort_on_critical_level_set(int critical_l evel);
/**
* @brief Get level that triggers abort if abort-on-critical is set.
*
* @return critical level equal or smaller than value will trigger
* program abortion if eina_log_abort_on_critical_get() returns
* #EINA_TRUE.
*
* @see eina_log_abort_on_critical_level_set()
* @see eina_log_abort_on_critical_get()
*/
EAPI int eina_log_abort_on_critical_level_get(void) EINA_WAR N_UNUSED_RESULT; EAPI int eina_log_abort_on_critical_level_get(void) EINA_WAR N_UNUSED_RESULT;
/**
* Set the domain level given its name.
*
* This call has the same effect as setting
* EINA_LOG_LEVELS=&lt;@p domain_name&gt;:&lt;@p level&gt;
*
* @param domain_name domain name to change the level. It may be of a
* still not registered domain. If the domain is not registered
* yet, it will be saved as a pending set and applied upon
* registration.
* @param level level to use to limit eina_log_print() for given domain.
*/
EAPI void eina_log_domain_level_set(const char *domain_name, int level) EINA_ARG_NONNULL(1); EAPI void eina_log_domain_level_set(const char *domain_name, int level) EINA_ARG_NONNULL(1);
/**
* Get the domain level given its name.
*
* @param domain_name domain name to retrieve the level. It may be of
* a still not registered domain. If the domain is not
* registered yet, but there is a pending value, either from
* eina_log_domain_level_set(),EINA_LOG_LEVELS environment
* variable or from EINA_LOG_LEVELS_GLOB, these are
* returned. If nothing else was found, then the global/default
* level (eina_log_level_get()) is returned.
*
* @return level to use to limit eina_log_print() for given
* domain. On error (@p domain_name == NULL),
* EINA_LOG_LEVEL_UNKNOWN is returned.
*
* @see eina_log_domain_level_set()
* @see eina_log_domain_registered_level_get()
*/
EAPI int eina_log_domain_level_get(const char *domain_name) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); EAPI int eina_log_domain_level_get(const char *domain_name) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
/**
* Get the domain level given its identifier.
*
* @param domain identifier, so it must be previously registered with
* eina_log_domain_register(). It's a much faster version of
* eina_log_domain_level_get(), but relies on domain being
* present.
*
* @return level to use to limit eina_log_print() for given domain. On
* error EINA_LOG_LEVEL_UNKNOWN is returned.
*/
EAPI int eina_log_domain_registered_level_get(int domain) EI NA_WARN_UNUSED_RESULT; EAPI int eina_log_domain_registered_level_get(int domain) EI NA_WARN_UNUSED_RESULT;
static inline Eina_Bool eina_log_domain_level_check(int domain, int level); static inline Eina_Bool eina_log_domain_level_check(int domain, int level);
/* /*
* Logging domains * Logging domains
*/ */
/**
* @param name Domain name
* @param color Color of the domain name
*
* @return Domain index that will be used as the DOMAIN parameter on log
* macros. A negative return value means an log occurred.
*
* @note MT: safe to call from any thread.
*/
EAPI int eina_log_domain_register(const char *name, const char *color) EIN A_ARG_NONNULL(1); EAPI int eina_log_domain_register(const char *name, const char *color) EIN A_ARG_NONNULL(1);
/**
* Forget about a logging domain registered by eina_log_domain_register()
*
* @param domain domain identifier as reported by eina_log_domain_register(
),
* must be >= 0.
*
* @note MT: safe to call from any thread.
*/
EAPI void eina_log_domain_unregister(int domain); EAPI void eina_log_domain_unregister(int domain);
/* /*
* Logging functions. * Logging functions.
*/ */
/**
* Print out log message using given domain and level.
*
* @note Usually you'll not use this function directly but the helper
* macros EINA_LOG(), EINA_LOG_DOM_CRIT(), EINA_LOG_CRIT() and
* so on. See eina_log.h
*
* @param domain logging domain to use or @c EINA_LOG_DOMAIN_GLOBAL if
* you registered none. It is recommended that modules and
* applications have their own logging domain.
* @param level message level, those with level greater than user
* specified value (eina_log_level_set() or environment
* variables EINA_LOG_LEVEL, EINA_LOG_LEVELS) will be ignored.
* @param file filename that originated the call, must @b not be @c NULL.
* @param fnc function that originated the call, must @b not be @c NULL.
* @param line originating line in @a file.
* @param fmt printf-like format to use. Should not provide trailing
* '\n' as it is automatically included.
*
* @note MT: this function may be called from different threads if
* eina_log_threads_enable() was called before.
*/
EAPI void eina_log_print(int domain, EAPI void eina_log_print(int domain,
Eina_Log_Level level, Eina_Log_Level level,
const char *file, const char *file,
const char *function, const char *function,
int line, int line,
const char *fmt, const char *fmt,
...) EINA_ARG_NONNULL(3, 4, 6) EINA_PRINTF(6, 7) E INA_NOINSTRUMENT; ...) EINA_ARG_NONNULL(3, 4, 6) EINA_PRINTF(6, 7) E INA_NOINSTRUMENT;
/**
* Print out log message using given domain and level.
*
* @note Usually you'll not use this function directly but the helper
* macros EINA_LOG(), EINA_LOG_DOM_CRIT(), EINA_LOG_CRIT() and
* so on. See eina_log.h
*
* @param domain logging domain to use or @c EINA_LOG_DOMAIN_GLOBAL if
* you registered none. It is recommended that modules and
* applications have their own logging domain.
* @param level message level, those with level greater than user
* specified value (eina_log_level_set() or environment
* variables EINA_LOG_LEVEL, EINA_LOG_LEVELS) will be ignored.
* @param file filename that originated the call, must @b not be @c NULL.
* @param fnc function that originated the call, must @b not be @c NULL.
* @param line originating line in @a file.
* @param fmt printf-like format to use. Should not provide trailing
* '\n' as it is automatically included.
* @param args the arguments needed by the format.
*
* @note MT: this function may be called from different threads if
* eina_log_threads_enable() was called before.
*
* @see eina_log_print()
*/
EAPI void eina_log_vprint(int domain, EAPI void eina_log_vprint(int domain,
Eina_Log_Level level, Eina_Log_Level level,
const char *file, const char *file,
const char *fnc, const char *fnc,
int line, int line,
const char *fmt, const char *fmt,
va_list args) EINA_ARG_NONNULL(3, 4, 6) EI NA_NOINSTRUMENT; va_list args) EINA_ARG_NONNULL(3, 4, 6) EI NA_NOINSTRUMENT;
/* /*
* Logging methods (change how logging is done). * Logging methods (change how logging is done).
*/ */
/**
* Alternative logging method, this will output to standard output stream.
*
* @param d The domain.
* @param level The level.
* @param file The file which is logged.
* @param fnc The function which is logged.
* @param line The line which is logged.
* @param fmt The ouptut format to use.
* @param data Not used.
* @param args The arguments needed by the format.
*
* This method will colorize output based on domain provided color and
* message logging level. To disable color, set environment variable
* EINA_LOG_COLOR_DISABLE=1. Similarly, to disable file and line
* information, set EINA_LOG_FILE_DISABLE=1 or
* EINA_LOG_FUNCTION_DISABLE=1 to avoid function name in output. It is
* not acceptable to have both EINA_LOG_FILE_DISABLE and
* EINA_LOG_FUNCTION_DISABLE at the same time, in this case just
* EINA_LOG_FUNCTION_DISABLE will be considered and file information
* will be printed anyways.
*
* @note MT: if threads are enabled, this function is called within locks.
* @note MT: Threads different from main thread will have thread id
* appended to domain name.
*/
EAPI void eina_log_print_cb_stdout(const Eina_Log_Domain *d, EAPI void eina_log_print_cb_stdout(const Eina_Log_Domain *d,
Eina_Log_Level level, Eina_Log_Level level,
const char *file, const char *file,
const char *fnc, const char *fnc,
int line, int line,
const char *fmt, const char *fmt,
void *data, void *data,
va_list args); va_list args);
/**
* Default logging method, this will output to standard error stream.
*
* This method will colorize output based on domain provided color and
* message logging level.
*
* To disable color, set environment variable
* EINA_LOG_COLOR_DISABLE=1. To enable color, even if directing to a
* file or when using a non-supported color terminal, use
* EINA_LOG_COLOR_DISABLE=0. If EINA_LOG_COLOR_DISABLE is unset (or
* -1), then Eina will disable color if terminal ($TERM) is
* unsupported or if redirecting to a file.
. Similarly, to disable file and line
* information, set EINA_LOG_FILE_DISABLE=1 or
* EINA_LOG_FUNCTION_DISABLE=1 to avoid function name in output. It is
* not acceptable to have both EINA_LOG_FILE_DISABLE and
* EINA_LOG_FUNCTION_DISABLE at the same time, in this case just
* EINA_LOG_FUNCTION_DISABLE will be considered and file information
* will be printed anyways.
*
* @note MT: if threads are enabled, this function is called within locks.
* @note MT: Threads different from main thread will have thread id
* appended to domain name.
*/
EAPI void eina_log_print_cb_stderr(const Eina_Log_Domain *d, EAPI void eina_log_print_cb_stderr(const Eina_Log_Domain *d,
Eina_Log_Level level, Eina_Log_Level level,
const char *file, const char *file,
const char *fnc, const char *fnc,
int line, int line,
const char *fmt, const char *fmt,
void *data, void *data,
va_list args); va_list args);
/**
* Alternative logging method, this will output to given file stream.
*
* @param d The domain.
* @param level Not used.
* @param file The file which is logged.
* @param fnc The function which is logged.
* @param line The line which is logged.
* @param fmt The ouptut format to use.
* @param data The file which will store the output (as a FILE *).
* @param args The arguments needed by the format.
*
* This method will never output color.
*
* @note MT: if threads are enabled, this function is called within locks.
* @note MT: Threads different from main thread will have thread id
* appended to domain name.
*/
EAPI void eina_log_print_cb_file(const Eina_Log_Domain *d, EAPI void eina_log_print_cb_file(const Eina_Log_Domain *d,
Eina_Log_Level level, Eina_Log_Level level,
const char *file, const char *file,
const char *fnc, const char *fnc,
int line, int line,
const char *fmt, const char *fmt,
void *data, void *data,
va_list args); va_list args);
#include "eina_inline_log.x" #include "eina_inline_log.x"
 End of changes. 28 change blocks. 
2 lines changed or deleted 561 lines changed or added


 eina_magic.h   eina_magic.h 
skipping to change at line 26 skipping to change at line 26
* if not, see <http://www.gnu.org/licenses/>. * if not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef EINA_MAGIC_H_ #ifndef EINA_MAGIC_H_
#define EINA_MAGIC_H_ #define EINA_MAGIC_H_
#include "eina_config.h" #include "eina_config.h"
#include "eina_types.h" #include "eina_types.h"
/** /**
* @page eina_magic_example_01_page
* @dontinclude eina_magic_01.c
*
* Whenever using Eina we must include it:
* @skipline #include
*
* For this example we are going to define two classes, person and pilot, a
nd
* since every pilot is a person we use inheritance. To be type safe we are
* going to add EINA_MAGIC to our classes:
* @until struct _pilot pilot
* @note The values of BASETYPE_MAGIC and SUBTYPE_MAGIC have no meaning, th
e
* only important thing about them is that they be unique.
*
* Here we have a function to create a perso given a name, nothing too fanc
y:
* @until }
*
* And now the counterpart, a function the free a person.
* @until {
* Before we start releasing resources we check that the pointer we were gi
ven
* actually points to a person, and if not we will print an error message a
nd
* quit:
* @until }
* @note EINA_MAGIC_FAIL is a macro that make's it easy to print an appropr
iate
* (and consistent) error message.
* Now knowing that ptr is indeed of type person we prooced to set EINA_MAG
IC to
* EINA_MAGIC_NONE and free alocated memory:
* @until }
* @note Setting EINA_MAGIC to EINA_MAGIC_NONE is important to prevent the
* struct from being used after freed.
*
* Now we have our function to create a pilot, this one is a little more co
mplex
* because we need to set EINA_MAGIC for the pilot and pilot->base, this is
very
* important so that checking the EINA_MAGIC of (person*)my_pilot will work
:
* @until }
*
* The function to free a pilot is not too different from the one that free
s a
* person:
* @until }
* @until }
*
* We also create functions to print a person or a pilot that check the typ
e of
* the pointers they receive:
* @until }
* @until }
*
* And on to our main function where we declare some variables and initiali
ze
* Eina:
* @until eina_init
*
* For Eina to be able to provide more informative error messages we are go
ing
* to give names to our EINA_MAGIC types:
* @until string_set
*
* Since our types won't live longer than the scope of the current function
we
* can set the name without eina making a copy of the string:
* @until static_set
*
* Now we create a person, a pilot and print both as persons:
* @until person *
*
* Now we try to print both as pilots, which will obvisouly not work since
base
* is not a pilot:
* @until pilot(sub
*
* That's all folks:
* @until }
*
* See full source @ref eina_magic_example_01_c "here".
*/
/**
* @page eina_magic_example_01_c Eina_Magic
* @include eina_magic_01.c
* @example eina_magic_01.c
*/
/**
* @addtogroup Eina_Tools_Group Tools * @addtogroup Eina_Tools_Group Tools
* *
* @{ * @{
*/ */
/** /**
* @defgroup Eina_Magic_Group Magic * @defgroup Eina_Magic_Group Magic
* *
* @brief Eina_Magic provides run-time type-checking.
*
* C is a weak statically typed language, in other words, it will just chec
k for
* types during compile time and any cast will make the compiler believe th
e
* type is correct.
*
* In real world code we often need to deal with casts, either explicit or
* implicit by means of @c void*. We also need to resort to casts when doin
g
* inheritance in C.
*
* Eina_Magic give us a way to do casts and still be certain of the type we
are
* opearting on.
*
* @note It should be noted that it is considered good practice to @b disab
le
* Eina_Magic for production code. The reasoning is that any Eina_Magic err
ors
* should have been caught during testing and therefore there is no reason
to
* incur the performance downside of Eina_Magic.
*
* An @ref eina_magic_example_01_page "example" should elucidate matters.
*
* @{ * @{
*/ */
/**
* An abstract type for a magic number.
*/
typedef unsigned int Eina_Magic; typedef unsigned int Eina_Magic;
/** /**
* @typedef Eina_Magic * @brief Return the string associated to the given magic identifier.
* An abstract type for a magic number. *
* @param magic The magic identifier.
* @return The string associated to the identifier.
*
* This function returns the string associated to @p magic. Even if none ar
e
* found this function still returns non @c NULL, in this case an identifie
r
* such as "(none)", "(undefined)" or "(unknown)".
*
* The following identifiers may be returned whenever magic is
* invalid, with their meanings:
*
* - (none): no magic was registered exists at all.
* - (undefined): magic was registered and found, but no string associate
d.
* - (unknown): magic was not found in the registry.
*
* @warning The returned value must not be freed.
*/
EAPI const char *eina_magic_string_get(Eina_Magic magic) EINA_WARN_UNUSED_R
ESULT;
/**
* @brief Set the string associated to the given magic identifier.
*
* @param magic The magic identifier.
* @param magic_name The string associated to the identifier, must not
* be @c NULL.
*
* @return #EINA_TRUE on success, #EINA_FALSE on failure.
*
* This function sets the string @p magic_name to @p magic. It is not
* checked if number or string are already set, in which case you will end
with
* duplicates. Internally, eina will make a copy of @p magic_name.
*
* @see eina_magic_string_static_set()
*/ */
EAPI const char *eina_magic_string_get(Eina_Magic magic) EINA_PURE EINA_WAR N_UNUSED_RESULT;
EAPI Eina_Bool eina_magic_string_set(Eina_Magic magic, EAPI Eina_Bool eina_magic_string_set(Eina_Magic magic,
const char *magic_name) EINA_ARG_NON NULL(2); const char *magic_name) EINA_ARG_NON NULL(2);
/**
* @brief Set the string associated to the given magic identifier.
*
* @param magic The magic identifier.
* @param magic_name The string associated to the identifier, must not be
* @c NULL.
*
* @return #EINA_TRUE on success, #EINA_FALSE on failure.
*
* This function sets the string @p magic_name to @p magic. It is not check
ed if
* number or string are already set, in which case you might end with
* duplicates. Eina will @b not make a copy of @p magic_name, this means th
at
* @p magic_name has to be a valid pointer for as long as @p magic is used.
*
* @see eina_magic_string_set()
*/
EAPI Eina_Bool eina_magic_string_static_set(Eina_Magic magic, EAPI Eina_Bool eina_magic_string_static_set(Eina_Magic magic,
const char *magic_name) EINA_ ARG_NONNULL(2); const char *magic_name) EINA_ ARG_NONNULL(2);
/** /**
* @def EINA_MAGIC_NONE * @def EINA_MAGIC_NONE
* Random value for specifying that a structure using the magic * Random value for specifying that a structure using the magic
* feature has already been freed. It is used by eina_magic_fail(). * feature has already been freed. It is used by eina_magic_fail().
* *
* If the magic feature of Eina is disabled, #EINA_MAGIC_NONE is just * If the magic feature of Eina is disabled, #EINA_MAGIC_NONE is just
* @c 0. * @c 0.
skipping to change at line 121 skipping to change at line 265
* nothing. * nothing.
*/ */
#define EINA_MAGIC_FAIL(d, m) \ #define EINA_MAGIC_FAIL(d, m) \
eina_magic_fail((void *)(d), \ eina_magic_fail((void *)(d), \
(d) ? (d)->__magic : 0, \ (d) ? (d)->__magic : 0, \
(m), \ (m), \
__FILE__, \ __FILE__, \
__FUNCTION__, \ __FUNCTION__, \
__LINE__); __LINE__);
/**
* @brief Display a message or abort if a magic check failed.
*
* @param d The checked data pointer.
* @param m The magic identifer to check.
* @param req_m The requested magic identifier to check.
* @param file The file in which the magic check failed.
* @param fnc The function in which the magic check failed.
* @param line The line at which the magic check failed.
*
* @warning You should @b strongly consider using @ref EINA_MAGIC_FAIL(d, m
)
* instead.
*
* This function displays an error message if a magic check has
* failed, using the following logic in the following order:
* @li If @p d is @c NULL, a message warns about a @c NULL pointer.
* @li Otherwise, if @p m is equal to #EINA_MAGIC_NONE, a message
* warns about a handle that was already freed.
* @li Otherwise, if @p m is equal to @p req_m, a message warns about
* a handle that is of wrong type.
* @li Otherwise, a message warns you about ab-using that function...
*
* If the environment variable EINA_LOG_ABORT is set, abort() is
* called and the program stops. It is useful for debugging programs
* with gdb.
*/
EAPI void eina_magic_fail(void *d, Eina_Magic m, Eina_Magic req_m, EAPI void eina_magic_fail(void *d, Eina_Magic m, Eina_Magic req_m,
const char *file, const char *fnc, const char *file, const char *fnc,
int line) EINA_ARG_NONNULL(4, 5); int line) EINA_ARG_NONNULL(4, 5);
#else #else
/** /**
* @cond LOCAL * @cond LOCAL
*/ */
 End of changes. 8 change blocks. 
4 lines changed or deleted 205 lines changed or added


 eina_main.h   eina_main.h 
skipping to change at line 25 skipping to change at line 25
* License along with this library; * License along with this library;
* if not, see <http://www.gnu.org/licenses/>. * if not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef EINA_MAIN_H_ #ifndef EINA_MAIN_H_
#define EINA_MAIN_H_ #define EINA_MAIN_H_
#include "eina_types.h" #include "eina_types.h"
/** /**
* @addtogroup Eina_Main_Group Main
*
* @brief These functions provide general initialisation and shut down
* functions.
*/
/**
* @addtogroup Eina_Core_Group Core * @addtogroup Eina_Core_Group Core
* *
* @{ * @{
*/ */
/** /**
* @defgroup Eina_Main_Group Main * @defgroup Eina_Main_Group Main
* *
* @{ * @{
*/ */
skipping to change at line 62 skipping to change at line 69
typedef struct _Eina_Version typedef struct _Eina_Version
{ {
int major; /**< Major component of the version */ int major; /**< Major component of the version */
int minor; /**< Minor component of the version */ int minor; /**< Minor component of the version */
int micro; /**< Micro component of the version */ int micro; /**< Micro component of the version */
int revision; /**< Revision component of the version */ int revision; /**< Revision component of the version */
} Eina_Version; } Eina_Version;
EAPI extern Eina_Version *eina_version; EAPI extern Eina_Version *eina_version;
/**
* @brief Initialize the Eina library.
*
* @return 1 or greater on success, 0 on error.
*
* This function sets up all the eina modules. It returns 0 on
* failure (that is, when one of the module fails to initialize),
* otherwise it returns the number of times it has already been
* called.
*
* When Eina is not used anymore, call eina_shutdown() to shut down
* the Eina library.
*/
EAPI int eina_init(void); EAPI int eina_init(void);
/**
* @brief Shut down the Eina library.
*
* @return 0 when all the modules is completely shut down, 1 or
* greater otherwise.
*
* This function shuts down the Eina library. It returns 0 when it has
* been called the same number of times than eina_init(). In that case
* it shut down all the Eina modules.
*
* Once this function succeeds (that is, @c 0 is returned), you must
* not call any of the Eina function anymore. You must call
* eina_init() again to use the Eina functions again.
*/
EAPI int eina_shutdown(void); EAPI int eina_shutdown(void);
/**
* @brief Initialize the mutexes of the Eina library.
*
* @return 1 or greater on success, 0 on error.
*
* This function sets up all the mutexes in all eina modules. It returns 0
on
* failure (that is, when one of the module fails to initialize),
* otherwise it returns the number of times it has already been
* called.
*
* When the mutexes are not used anymore, call eina_threads_shutdown() to s
hut down
* the mutexes.
*
* This function should never be called outside of the main loop.
*/
EAPI int eina_threads_init(void); EAPI int eina_threads_init(void);
/**
* @brief Shut down mutexes in the Eina library.
*
* @return 0 when all mutexes are completely shut down, 1 or
* greater otherwise.
*
* This function shuts down the mutexes in the Eina library. It returns 0 w
hen it has
* been called the same number of times than eina_threads_init(). In that c
ase
* it shut down all the mutexes.
*
* Once this function succeeds (that is, @c 0 is returned), you must
* not call any of the Eina function in a thread anymore. You must call
* eina_threads_init() again to use the Eina functions in a thread again.
*
* This function should never be called outside of the main loop.
*/
EAPI int eina_threads_shutdown(void); EAPI int eina_threads_shutdown(void);
/** /**
* @brief Check if you are calling this function from the same thread Eina
was initialized or not
* @since 1.1.0
*
* Most EFL function are not thread safe and all the call need to happen in
* the main loop. With this call you could know if you can call an EFL
* function or not.
*/
EAPI Eina_Bool eina_main_loop_is(void);
/**
* @brief You should never use that function excpet if you really really kn
ow what your are doing.
* @since 1.1.0
*
* If you are reading this documentation, that certainly means you don't kn
ow what is the purpose of
* this call and you should just not use it.
*/
EAPI void eina_main_loop_define(void);
/**
* @} * @}
*/ */
/** /**
* @} * @}
*/ */
#endif /* EINA_MAIN_H_ */ #endif /* EINA_MAIN_H_ */
 End of changes. 6 change blocks. 
0 lines changed or deleted 94 lines changed or added


 eina_matrixsparse.h   eina_matrixsparse.h 
skipping to change at line 31 skipping to change at line 31
#include <stdlib.h> #include <stdlib.h>
#include "eina_config.h" #include "eina_config.h"
#include "eina_types.h" #include "eina_types.h"
#include "eina_iterator.h" #include "eina_iterator.h"
#include "eina_accessor.h" #include "eina_accessor.h"
/** /**
* @addtogroup Eina_Matrixsparse_Group Sparse Matrix
*
* @brief These functions provide matrix sparse management.
*
* For more information, you can look at the @ref tutorial_matrixsparse_pag
e.
*/
/**
* @addtogroup Eina_Data_Types_Group Data Types * @addtogroup Eina_Data_Types_Group Data Types
* *
* @{ * @{
*/ */
/** /**
* @addtogroup Eina_Containers_Group Containers * @addtogroup Eina_Containers_Group Containers
* *
* @{ * @{
*/ */
skipping to change at line 67 skipping to change at line 75
*/ */
typedef struct _Eina_Matrixsparse_Row Eina_Matrixsparse_Row; typedef struct _Eina_Matrixsparse_Row Eina_Matrixsparse_Row;
/** /**
* @typedef Eina_Matrixsparse_Cell * @typedef Eina_Matrixsparse_Cell
* Type for a generic sparse matrix cell, opaque for users. * Type for a generic sparse matrix cell, opaque for users.
*/ */
typedef struct _Eina_Matrixsparse_Cell Eina_Matrixsparse_Cell; typedef struct _Eina_Matrixsparse_Cell Eina_Matrixsparse_Cell;
/* constructors and destructors */ /* constructors and destructors */
/**
* @brief Create a new Sparse Matrix.
*
* @param rows number of rows in matrix. Operations with rows greater than
this
* value will fail.
* @param cols number of columns in matrix. Operations with columns greater
* than this value will fail.
* @param free_func used to delete cell data contents, used by
* eina_matrixsparse_free(), eina_matrixsparse_size_set(),
* eina_matrixsparse_row_idx_clear(),
* eina_matrixsparse_column_idx_clear(),
* eina_matrixsparse_cell_idx_clear() and possible others.
* @param user_data given to @a free_func as first parameter.
*
* @return newly allocated matrix or NULL if allocation failed and eina_err
or
* is set.
*/
EAPI Eina_Matrixsparse *eina_matrixsparse_new(unsigned long rows, EAPI Eina_Matrixsparse *eina_matrixsparse_new(unsigned long rows,
unsigned long cols, unsigned long cols,
void (*free_func)(void *user_ data, void (*free_func)(void *user_ data,
void *cell_ data), void *cell_ data),
const void *user_data); const void *user_data);
/**
* @brief Free resources allocated to Sparse Matrix.
*
* @param m The Sparse Matrix instance to free, must @b not be @c NULL.
*/
EAPI void eina_matrixsparse_free(Eina_Matrixsparse *m); EAPI void eina_matrixsparse_free(Eina_Matrixsparse *m);
/* size manipulation */ /* size manipulation */
/**
* @brief Get the current size of Sparse Matrix.
*
* The given parameters are guaranteed to be set if they're not NULL,
* even if this function fails (ie: @a m is not a valid matrix instance).
*
* @param m the sparse matrix to operate on.
* @param rows returns the number of rows, may be NULL. If @a m is invalid,
* returned value is zero, otherwise it's a positive integer.
* @param cols returns the number of columns, may be NULL. If @a m is
* invalid, returned value is zero, otherwise it's a positive intege
r.
*/
EAPI void eina_matrixsparse_size_get(const Eina_Matrixsparse *m, EAPI void eina_matrixsparse_size_get(const Eina_Matrixsparse *m,
unsigned long *rows, unsigned long *rows,
unsigned long *cols); unsigned long *cols);
/**
* @brief Resize the Sparse Matrix.
*
* This will resize the sparse matrix, possibly freeing cells on rows
* and columns that will cease to exist.
*
* @param m the sparse matrix to operate on.
* @param rows the new number of rows, must be greater than zero.
* @param cols the new number of columns, must be greater than zero.
* @return 1 on success, 0 on failure.
*
* @warning cells, rows or columns are not reference counted and thus
* after this call any reference might be invalid if instance were
* freed.
*/
EAPI Eina_Bool eina_matrixsparse_size_set(Eina_Matrixsparse *m, EAPI Eina_Bool eina_matrixsparse_size_set(Eina_Matrixsparse *m,
unsigned long rows, unsigned long rows,
unsigned long cols); unsigned long cols);
/* data getting */ /* data getting */
/**
* Get the cell reference inside Sparse Matrix.
*
* @param m the sparse matrix to operate on.
* @param row the new number of row to clear.
* @param col the new number of column to clear.
* @param cell pointer to return cell reference, if any exists.
*
* @return 1 on success, 0 on failure. It is considered success if did not
* exist but index is inside matrix size, in this case @c *cell == NULL
*
* @see eina_matrixsparse_cell_data_get()
* @see eina_matrixsparse_data_idx_get()
*/
EAPI Eina_Bool eina_matrixsparse_cell_idx_get(const Eina_Matrixsparse *m, u nsigned long row, unsigned long col, Eina_Matrixsparse_Cell **cell); EAPI Eina_Bool eina_matrixsparse_cell_idx_get(const Eina_Matrixsparse *m, u nsigned long row, unsigned long col, Eina_Matrixsparse_Cell **cell);
/**
* Get data associated with given cell reference.
*
* @param cell given cell reference, must @b not be @c NULL.
*
* @return data associated with given cell.
*
* @see eina_matrixsparse_cell_idx_get()
* @see eina_matrixsparse_data_idx_get()
*/
EAPI void *eina_matrixsparse_cell_data_get(const Eina_Matrixsparse_Cell *cell); EAPI void *eina_matrixsparse_cell_data_get(const Eina_Matrixsparse_Cell *cell);
/**
* Get data associated with given cell given its indexes.
*
* @param m the sparse matrix to operate on.
* @param row the new number of row to clear.
* @param col the new number of column to clear.
*
* @return data associated with given cell or NULL if nothing is associated
.
*
* @see eina_matrixsparse_cell_idx_get()
* @see eina_matrixsparse_cell_data_get()
*/
EAPI void *eina_matrixsparse_data_idx_get(const Eina_Matrixsparse *m, u nsigned long row, unsigned long col); EAPI void *eina_matrixsparse_data_idx_get(const Eina_Matrixsparse *m, u nsigned long row, unsigned long col);
/**
* Get position (indexes) of the given cell.
*
* @param cell the cell reference, must @b not be @c NULL.
* @param row where to store cell row number, may be @c NULL.
* @param col where to store cell column number, may be @c NULL.
*
* @return 1 on success, 0 otherwise (@c cell is @c NULL).
*/
EAPI Eina_Bool eina_matrixsparse_cell_position_get(const Eina_Matrixsparse_ Cell *cell, unsigned long *row, unsigned long *col); EAPI Eina_Bool eina_matrixsparse_cell_position_get(const Eina_Matrixsparse_ Cell *cell, unsigned long *row, unsigned long *col);
/* data setting */ /* data setting */
/**
* Change cell reference value without freeing the possibly existing old va
lue.
*
* @param cell the cell reference, must @b not be @c NULL.
* @param data new data to set.
* @param p_old returns the old value intact (not freed).
*
* @return 1 on success, 0 otherwise (@a cell is @c NULL).
*
* @see eina_matrixsparse_cell_data_set()
* @see eina_matrixsparse_data_idx_replace()
*/
EAPI Eina_Bool eina_matrixsparse_cell_data_replace(Eina_Matrixsparse_Cell * cell, const void *data, void **p_old); EAPI Eina_Bool eina_matrixsparse_cell_data_replace(Eina_Matrixsparse_Cell * cell, const void *data, void **p_old);
/**
* Change cell value freeing the possibly existing old value.
*
* In contrast to eina_matrixsparse_cell_data_replace(), this function will
* call @c free_func() on existing value.
*
* @param cell the cell reference, must @b not be @c NULL.
* @param data new data to set.
*
* @return 1 on success, 0 otherwise (@a cell is @c NULL).
*
* @see eina_matrixsparse_cell_data_replace()
* @see eina_matrixsparse_data_idx_set()
*/
EAPI Eina_Bool eina_matrixsparse_cell_data_set(Eina_Matrixsparse_Cell *cell , const void *data); EAPI Eina_Bool eina_matrixsparse_cell_data_set(Eina_Matrixsparse_Cell *cell , const void *data);
/**
* Change cell value without freeing the possibly existing old value, using
* indexes.
*
* @param m the sparse matrix, must @b not be @c NULL.
* @param row the row number to set the value.
* @param col the column number to set the value.
* @param data new data to set.
* @param p_old returns the old value intact (not freed).
*
* @return 1 on success, 0 otherwise (@a m is @c NULL, indexes are not vali
d).
*
* @see eina_matrixsparse_cell_data_replace()
* @see eina_matrixsparse_data_idx_set()
*/
EAPI Eina_Bool eina_matrixsparse_data_idx_replace(Eina_Matrixsparse *m, uns igned long row, unsigned long col, const void *data, void **p_old); EAPI Eina_Bool eina_matrixsparse_data_idx_replace(Eina_Matrixsparse *m, uns igned long row, unsigned long col, const void *data, void **p_old);
/**
* Change cell value freeing the possibly existing old value, using
* indexes.
*
* In contrast to eina_matrixsparse_data_idx_replace(), this function will
* call @c free_func() on existing value.
*
* @param m the sparse matrix, must @b not be @c NULL.
* @param row the row number to set the value.
* @param col the column number to set the value.
* @param data new data to set.
*
* @return 1 on success, 0 otherwise (@a m is @c NULL, indexes are not vali
d).
*
* @see eina_matrixsparse_cell_data_replace()
*/
EAPI Eina_Bool eina_matrixsparse_data_idx_set(Eina_Matrixsparse *m, unsigne d long row, unsigned long col, const void *data); EAPI Eina_Bool eina_matrixsparse_data_idx_set(Eina_Matrixsparse *m, unsigne d long row, unsigned long col, const void *data);
/* data deleting */ /* data deleting */
/**
* Clear (erase all cells) of row given its index.
*
* Existing cells will be cleared with @c free_func() given to
* eina_matrixsparse_new().
*
* @param m the sparse matrix to operate on.
* @param row the new number of row to clear.
*
* @return 1 on success, 0 on failure. It is considered success if row
* had no cells filled. Failure is asking for clear row outside
* matrix size.
*
* @warning cells, rows or columns are not reference counted and thus
* after this call any reference might be invalid if instance were
* freed.
*/
EAPI Eina_Bool eina_matrixsparse_row_idx_clear(Eina_Matrixsparse *m, unsign ed long row); EAPI Eina_Bool eina_matrixsparse_row_idx_clear(Eina_Matrixsparse *m, unsign ed long row);
/**
* Clear (erase all cells) of column given its index.
*
* Existing cells will be cleared with @c free_func() given to
* eina_matrixsparse_new().
*
* @param m the sparse matrix to operate on.
* @param col the new number of column to clear.
*
* @return 1 on success, 0 on failure. It is considered success if column
* had no cells filled. Failure is asking for clear column outside
* matrix size.
*
* @warning cells, rows or columns are not reference counted and thus
* after this call any reference might be invalid if instance were
* freed.
*/
EAPI Eina_Bool eina_matrixsparse_column_idx_clear(Eina_Matrixsparse *m, uns igned long col); EAPI Eina_Bool eina_matrixsparse_column_idx_clear(Eina_Matrixsparse *m, uns igned long col);
/**
* Clear (erase) cell given its indexes.
*
* Existing cell will be cleared with @c free_func() given to
* eina_matrixsparse_new().
*
* @param m the sparse matrix to operate on.
* @param row the new number of row to clear.
* @param col the new number of column to clear.
*
* @return 1 on success, 0 on failure. It is considered success if did not
* exist but index is inside matrix size.
*
* @warning cells, rows or columns are not reference counted and thus
* after this call any reference might be invalid if instance were
* freed. Note that this call might delete container column and
* row if this cell was the last remainder.
*/
EAPI Eina_Bool eina_matrixsparse_cell_idx_clear(Eina_Matrixsparse *m, unsig ned long row, unsigned long col); EAPI Eina_Bool eina_matrixsparse_cell_idx_clear(Eina_Matrixsparse *m, unsig ned long row, unsigned long col);
/**
* Clear (erase) cell given its reference.
*
* @param cell the cell reference, must @b not be @c NULL.
*
* @return 1 on success, 0 on failure.
*
* @warning cells, rows or columns are not reference counted and thus
* after this call any reference might be invalid if instance were
* freed. Note that this call might delete container column and
* row if this cell was the last remainder.
*/
EAPI Eina_Bool eina_matrixsparse_cell_clear(Eina_Matrixsparse_Cell *cell); EAPI Eina_Bool eina_matrixsparse_cell_clear(Eina_Matrixsparse_Cell *cell);
/* iterators */ /* iterators */
/**
* Creates a new iterator over existing matrix cells.
*
* This is a cheap walk, it will just report existing cells and holes
* in the sparse matrix will be ignored. That means the reported
* indexes will not be sequential.
*
* The iterator data will be the cell reference, one may query current
* position with eina_matrixsparse_cell_position_get() and cell value
* with eina_matrixsparse_cell_data_get().
*
* @param m The Sparse Matrix reference, must @b not be @c NULL.
* @return A new iterator.
*
* @warning if the matrix structure changes then the iterator becomes
* invalid! That is, if you add or remove cells this iterator
* behavior is undefined and your program may crash!
*/
EAPI Eina_Iterator *eina_matrixsparse_iterator_new(const Eina_Matrixsparse *m); EAPI Eina_Iterator *eina_matrixsparse_iterator_new(const Eina_Matrixsparse *m);
/**
* Creates a new iterator over all matrix cells.
*
* Unlike eina_matrixsparse_iterator_new() this one will report all
* matrix cells, even those that are still empty (holes). These will
* be reported as dummy cells that contains no data.
*
* Be aware that iterating a big matrix (1000x1000) will call your
* function that number of times (1000000 times in that case) even if
* your matrix have no elements at all!
*
* The iterator data will be the cell reference, one may query current
* position with eina_matrixsparse_cell_position_get() and cell value
* with eina_matrixsparse_cell_data_get(). If cell is empty then the
* reference will be a dummy/placeholder, thus setting value with
* eina_matrixsparse_cell_data_set() will leave pointer unreferenced.
*
* @param m The Sparse Matrix reference, must @b not be @c NULL.
* @return A new iterator.
*
* @warning if the matrix structure changes then the iterator becomes
* invalid! That is, if you add or remove cells this iterator
* behavior is undefined and your program may crash!
*/
EAPI Eina_Iterator *eina_matrixsparse_iterator_complete_new(const Eina_Matr ixsparse *m); EAPI Eina_Iterator *eina_matrixsparse_iterator_complete_new(const Eina_Matr ixsparse *m);
/** /**
* @} * @}
*/ */
/** /**
* @} * @}
*/ */
 End of changes. 19 change blocks. 
0 lines changed or deleted 291 lines changed or added


 eina_mempool.h   eina_mempool.h 
skipping to change at line 27 skipping to change at line 27
*/ */
#ifndef EINA_MEMPOOL_H_ #ifndef EINA_MEMPOOL_H_
#define EINA_MEMPOOL_H_ #define EINA_MEMPOOL_H_
#include "eina_types.h" #include "eina_types.h"
#include "eina_error.h" #include "eina_error.h"
#include "eina_module.h" #include "eina_module.h"
/** /**
* @addtogroup Eina_Memory_Pool_Group Memory Pool
*
* @brief These functions provide memory pool management.
*
* Several mempool are available:
*
* @li @c buddy: It uses the
* <a href="http://en.wikipedia.org/wiki/Buddy_memory_allocation">"buddy
* allocator" algorithm</a> but the Eina implementation differs in the
* sense that the chunk information is not stored on the chunk itself,
* but on another memory area. This is useful for cases where the
* memory to manage might be slower to access, or limited (like video
* memory).
* @li @c chained_pool: It is the default one. It allocates a big
* chunk of memory with malloc() and split the result in chunks of the
* requested size that are pushed inside a stack. When requested, it
* takes this pointer from the stack to give them to whoever wants
* them.
* @li @c ememoa_fixed and @c ememoa_unknown: experimental allocators
* which could be useful when a fixed amount of memory is needed.
* @li @c fixed_bitmap: It allocates with malloc) 32* the requested
* size and push the pool pointer in an rbtree. To find empty space in
* a pool, it will just search for the first bit set in an int (32
* bits). Then, when a pointer is freed, it will do a search inside
* the rbtree.
* @li @c pass_through: it just call malloc() and free(). It may be
* faster on some computers than using our own allocators (like having
* a huge L2 cache, over 4MB).
* @li @c one_big: It call just one time malloc for the requested number
* of items. Useful when you know in advance how many object of some
* type will live during the life of the mempool.
*/
/**
* @addtogroup Eina_Tools_Group Tools * @addtogroup Eina_Tools_Group Tools
* *
* @{ * @{
*/ */
/** /**
* @defgroup Eina_Memory_Pool_Group Memory Pool * @defgroup Eina_Memory_Pool_Group Memory Pool
* *
* @{ * @{
*/ */
skipping to change at line 50 skipping to change at line 84
* Mempool type. * Mempool type.
*/ */
typedef struct _Eina_Mempool Eina_Mempool; typedef struct _Eina_Mempool Eina_Mempool;
/** /**
* @typedef Eina_Mempool_Backend * @typedef Eina_Mempool_Backend
* Mempool backend type. * Mempool backend type.
*/ */
typedef struct _Eina_Mempool_Backend Eina_Mempool_Backend; typedef struct _Eina_Mempool_Backend Eina_Mempool_Backend;
/**
* @typedef Eina_Mempool_Repack_Cb
* Type for a callback who need to unreference an old object from a mempool
* and reference the new one instead. Memcpy is taken care by the mempool.
*/
typedef void (*Eina_Mempool_Repack_Cb)(void *dst, void *src, void *data);
EAPI extern Eina_Error EINA_ERROR_NOT_MEMPOOL_MODULE; EAPI extern Eina_Error EINA_ERROR_NOT_MEMPOOL_MODULE;
EAPI Eina_Mempool *eina_mempool_add(const char *module, const char *contex t, const char *options, ...) EINA_MALLOC EINA_WARN_UNUSED_RESULT EINA_ARG_N ONNULL(1); EAPI Eina_Mempool *eina_mempool_add(const char *module, const char *contex t, const char *options, ...) EINA_MALLOC EINA_WARN_UNUSED_RESULT EINA_ARG_N ONNULL(1);
EAPI void eina_mempool_del(Eina_Mempool *mp) EINA_ARG_NONNULL(1); EAPI void eina_mempool_del(Eina_Mempool *mp) EINA_ARG_NONNULL(1);
static inline void *eina_mempool_realloc(Eina_Mempool *mp, void *element, u nsigned int size) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT; static inline void *eina_mempool_realloc(Eina_Mempool *mp, void *element, u nsigned int size) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
static inline void *eina_mempool_malloc(Eina_Mempool *mp, unsigned int size ) EINA_MALLOC EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT; static inline void *eina_mempool_malloc(Eina_Mempool *mp, unsigned int size ) EINA_MALLOC EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
static inline void eina_mempool_free(Eina_Mempool *mp, void *element) EINA _ARG_NONNULL(1); static inline void eina_mempool_free(Eina_Mempool *mp, void *element) EINA _ARG_NONNULL(1);
EAPI void eina_mempool_repack(Eina_Mempool *mp,
Eina_Mempool_Repack_Cb cb,
void *data) EINA_ARG_NONNULL(1, 2);
EAPI void eina_mempool_gc(Eina_Mempool *mp) EINA_ARG_NONNULL(1); EAPI void eina_mempool_gc(Eina_Mempool *mp) EINA_ARG_NONNULL(1);
EAPI void eina_mempool_statistics(Eina_Mempool *mp) EINA_ARG_NONN ULL(1); EAPI void eina_mempool_statistics(Eina_Mempool *mp) EINA_ARG_NONN ULL(1);
EAPI Eina_Bool eina_mempool_register(Eina_Mempool_Backend *be) EINA_AR G_NONNULL(1); EAPI Eina_Bool eina_mempool_register(Eina_Mempool_Backend *be) EINA_AR G_NONNULL(1);
EAPI void eina_mempool_unregister(Eina_Mempool_Backend *be) EINA_ ARG_NONNULL(1); EAPI void eina_mempool_unregister(Eina_Mempool_Backend *be) EINA_ ARG_NONNULL(1);
EAPI unsigned int eina_mempool_alignof(unsigned int size); EAPI unsigned int eina_mempool_alignof(unsigned int size);
#include "eina_inline_mempool.x" #include "eina_inline_mempool.x"
 End of changes. 3 change blocks. 
0 lines changed or deleted 44 lines changed or added


 eina_module.h   eina_module.h 
skipping to change at line 27 skipping to change at line 27
*/ */
#ifndef EINA_MODULE_H_ #ifndef EINA_MODULE_H_
#define EINA_MODULE_H_ #define EINA_MODULE_H_
#include "eina_types.h" #include "eina_types.h"
#include "eina_array.h" #include "eina_array.h"
#include "eina_error.h" #include "eina_error.h"
/** /**
* @addtogroup Eina_Module_Group Module
*
* @brief These functions provide module management.
*/
/**
* @addtogroup Eina_Tools_Group Tools * @addtogroup Eina_Tools_Group Tools
* *
* @{ * @{
*/ */
/** /**
* @defgroup Eina_Module_Group Module * @defgroup Eina_Module_Group Module
* *
* Eina module provides some helpers over POSIX dlopen(). It is not * Eina module provides some helpers over POSIX dlopen(). It is not
* meant to replace, abstract or make a "portable" version of the * meant to replace, abstract or make a "portable" version of the
skipping to change at line 89 skipping to change at line 95
* __eina_module_shutdown, it will be called before calling dlclose() * __eina_module_shutdown, it will be called before calling dlclose()
* @see Eina_Module_Init * @see Eina_Module_Init
*/ */
typedef void (*Eina_Module_Shutdown)(void); typedef void (*Eina_Module_Shutdown)(void);
/** /**
* @def EINA_MODULE_INIT * @def EINA_MODULE_INIT
* declares the given function as the module initializer (__eina_module_ini t). * declares the given function as the module initializer (__eina_module_ini t).
* It must be of signature #Eina_Module_Init * It must be of signature #Eina_Module_Init
*/ */
#define EINA_MODULE_INIT(f) EAPI Eina_Module_Init __eina_module_init = &f #define EINA_MODULE_INIT(f) EAPI Eina_Module_Init __eina_module_init = &f
/** /**
* @def EINA_MODULE_SHUTDOWN * @def EINA_MODULE_SHUTDOWN
* declares the given function as the module shutdownializer * declares the given function as the module shutdownializer
* (__eina_module_shutdown). It must be of signature * (__eina_module_shutdown). It must be of signature
* #Eina_Module_Shutdown * #Eina_Module_Shutdown
*/ */
#define EINA_MODULE_SHUTDOWN(f) EAPI Eina_Module_Shutdown __eina_module_shu tdown = &f #define EINA_MODULE_SHUTDOWN(f) EAPI Eina_Module_Shutdown __eina_module_shu tdown = &f
/** /**
skipping to change at line 111 skipping to change at line 117
* Error identifier corresponding to a wrong module. * Error identifier corresponding to a wrong module.
*/ */
extern EAPI Eina_Error EINA_ERROR_WRONG_MODULE; extern EAPI Eina_Error EINA_ERROR_WRONG_MODULE;
/** /**
* @var EINA_ERROR_MODULE_INIT_FAILED * @var EINA_ERROR_MODULE_INIT_FAILED
* Error identifier corresponding to a failure during the initialisation of a module. * Error identifier corresponding to a failure during the initialisation of a module.
*/ */
extern EAPI Eina_Error EINA_ERROR_MODULE_INIT_FAILED; extern EAPI Eina_Error EINA_ERROR_MODULE_INIT_FAILED;
/**
* @brief Return a new module.
*
* @param file The name of the file module to load.
*
* This function returns a new module. If @p file is @c NULL, the
* function returns @c NULL, otherwise, it allocates an Eina_Module,
* stores a duplicate string of @p file, sets its reference to @c 0
* and its handle to @c NULL.
*
* When the new module is not needed anymore, use eina_module_free()
* to free the allocated memory.
*
* @see eina_module_load
*/
EAPI Eina_Module * EAPI Eina_Module *
eina_module_new(const char *file) EINA_MALLOC EINA_WARN_UNUSED_RESULT EINA _ARG_NONNULL(1); eina_module_new(const char *file) EINA_MALLOC EINA_WARN_UNUSED_RESULT EINA _ARG_NONNULL(1);
/**
* @brief Delete a module.
*
* @param m The module to delete.
* @return EINA_TRUE on success, EINA_FALSE otherwise.
*
* This function calls eina_module_unload() if @p m has been previously
* loaded and frees the allocated memory. On success this function
* returns EINA_TRUE and EINA_FALSE otherwise. If @p m is @c NULL, the
* function returns immediately.
*/
EAPI Eina_Bool EAPI Eina_Bool
eina_module_free(Eina_Module *m) EINA_ARG_NONNULL(1); eina_module_free(Eina_Module *m) EINA_ARG_NONNULL(1);
/**
* @brief Load a module.
*
* @param m The module to load.
* @return EINA_TRUE on success, EINA_FALSE otherwise.
*
* This function load the shared file object passed in
* eina_module_new(). If it is a internal Eina module (like the
* mempools), it also initialize it. It the shared file object can not
* be loaded, the error #EINA_ERROR_WRONG_MODULE is set and
* #EINA_FALSE is returned. If it is a internal Eina module and the
* module can not be initialized, the error
* #EINA_ERROR_MODULE_INIT_FAILED is set and #EINA_FALSE is
* returned. If the module has already been loaded, it's refeence
* counter is increased by one and #EINA_TRUE is returned. If @p m is
* @c NULL, the function returns immediately #EINA_FALSE.
*
* When the symbols of the shared file objetcts are not needed
* anymore, call eina_module_unload() to unload the module.
*/
EAPI Eina_Bool EAPI Eina_Bool
eina_module_load(Eina_Module *module) EINA_ARG_NONNULL(1); eina_module_load(Eina_Module *module) EINA_ARG_NONNULL(1);
/**
* @brief Unload a module.
*
* @param m The module to load.
* @return EINA_TRUE on success, EINA_FALSE otherwise.
*
* This function unload the module @p m that has been previously
* loaded by eina_module_load(). If the reference counter of @p m is
* strictly greater than @c 1, #EINA_FALSE is returned. Otherwise, the
* shared object file is closed and if it is a internal Eina module, it
* is shutted down just before. In that case, #EINA_TRUE is
* returned. In all case, the reference counter is decreased. If @p m
* is @c NULL, the function returns immediately #EINA_FALSE.
*/
EAPI Eina_Bool EAPI Eina_Bool
eina_module_unload(Eina_Module *m) EINA_ARG_NONNULL(1); eina_module_unload(Eina_Module *m) EINA_ARG_NONNULL(1);
/**
* @brief Retrive the data associated to a symbol.
*
* @param m The module.
* @param symbol The symbol.
* @return The data associated to the symbol, or @c NULL on failure.
*
* This function returns the data associated to @p symbol of @p m. @p
* m must have been loaded before with eina_module_load(). If @p m
* is @c NULL, or if it has not been correctly loaded before, the
* function returns immediately @c NULL.
*/
EAPI void * EAPI void *
eina_module_symbol_get(const Eina_Module *module, const char *symbol) EINA _PURE EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT; eina_module_symbol_get(const Eina_Module *module, const char *symbol) EINA _PURE EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
/**
* @brief Return the file name associated to the module.
*
* @param m The module.
* @return The file name.
*
* This function returns the file name passed in eina_module_new(). If
* @p m is @c NULL, the function returns immediately @c NULL. The
* returned value must no be freed.
*/
EAPI const char * EAPI const char *
eina_module_file_get(const Eina_Module *m) EINA_PURE EINA_WARN_UNUSED_RESU LT EINA_ARG_NONNULL(1); eina_module_file_get(const Eina_Module *m) EINA_PURE EINA_WARN_UNUSED_RESU LT EINA_ARG_NONNULL(1);
/**
* @brief Return the path built from the location of a library and a
* given sub directory.
*
* @param symbol The symbol to search for.
* @param sub_dir The subdirectory to append.
* @return The built path on success, @c NULL otherwise.
*
* This function returns the path built by concatenating the path of
* the library containing the symbol @p symbol and @p sub_dir. @p sub_dir
* can be @c NULL. The returned path must be freed when not used
* anymore. If the symbol is not found, or dl_addr() is not supported,
* or allocation fails, this function returns @c NULL.
*/
EAPI char * EAPI char *
eina_module_symbol_path_get(const void *symbol, const char *sub_dir) EINA_ PURE EINA_MALLOC EINA_ARG_NONNULL(1, 2); eina_module_symbol_path_get(const void *symbol, const char *sub_dir) EINA_ PURE EINA_MALLOC EINA_ARG_NONNULL(1, 2);
/**
* @brief Return the path built from the value of an environment varialbe a
nd a
* given sub directory.
*
* @param env The environment variable to expand.
* @param sub_dir The subdirectory to append.
* @return The built path on success, @c NULL otherwise.
*
* This function returns the path built by concatenating the value of
* the environment variable named @p env and @p sub_dir. @p sub_dir
* can be @c NULL. The returned path must be freed when not used
* anymore. If the symbol is not found, or @p env does not exist, or
* allocation fails, this function returns @c NULL.
*/
EAPI char * EAPI char *
eina_module_environment_path_get(const char *env, const char *sub_dir) EIN A_PURE EINA_MALLOC EINA_ARG_NONNULL(1, 2); eina_module_environment_path_get(const char *env, const char *sub_dir) EIN A_PURE EINA_MALLOC EINA_ARG_NONNULL(1, 2);
/**
* @brief Get an array of modules found on the directory path matching an a
rch type.
*
* @param array The array that stores the list of the modules.
* @param path The directory's path to search for modules.
* @param arch The architecture string.
*
* This function adds to @p array the module names found in @p path
* which match the cpu architecture @p arch. If @p path or @p arch is
* @c NULL, the function returns immediately @p array. @p array can be
* @c NULL. In that case, it is created with 4 elements.
*/
EAPI Eina_Array * EAPI Eina_Array *
eina_module_arch_list_get(Eina_Array *array, const char *path, const char *arch); eina_module_arch_list_get(Eina_Array *array, const char *path, const char *arch);
/**
* @brief Get a list of modules found on the directory path.
*
* @param array The array that stores the list of the modules.
* @param path The directory's path to search for modules.
* @param recursive Iterate recursively on the path.
* @param cb Callback function to call on each module.
* @param data Data passed to the callback function.
*
* This function adds to @p array the list of modules found in
* @p path. If @p recursive is #EINA_TRUE, then recursive search is
* done. The callback @p cb is called on each module found, and @p data
* is passed to @p cb. If @p path is @c NULL, the function returns
* immediately @p array. If the returned value of @p cb is 0, the
* module will not be added to the list, otherwise it will be added.
* @p array can be @c NULL. In that case, it is created with 4
* elements. @p cb can be @c NULL.
*/
EAPI Eina_Array * EAPI Eina_Array *
eina_module_list_get(Eina_Array *array, const char *path, Eina_Bool recurs ive, Eina_Module_Cb cb, void *data) EINA_MALLOC EINA_WARN_UNUSED_RESULT; eina_module_list_get(Eina_Array *array, const char *path, Eina_Bool recurs ive, Eina_Module_Cb cb, void *data) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
/**
* @brief Load every module on the list of modules.
*
* @param array The array of modules to load.
*
* This function calls eina_module_load() on each element found in
* @p array. If @p array is @c NULL, this function does nothing.
*/
EAPI void EAPI void
eina_module_list_load(Eina_Array *list) EINA_ARG_NONNULL(1); eina_module_list_load(Eina_Array *list) EINA_ARG_NONNULL(1);
/**
* @brief Unload every module on the list of modules.
*
* @param array The array of modules to unload.
*
* This function calls eina_module_unload() on each element found in
* @p array. If @p array is @c NULL, this function does nothing.
*/
EAPI void EAPI void
eina_module_list_unload(Eina_Array *list) EINA_ARG_NONNULL(1); eina_module_list_unload(Eina_Array *list) EINA_ARG_NONNULL(1);
/**
* @p Free every module on the list of modules.
*
* @param array The array of modules to free.
*
* This function calls eina_module_free() on each element found in
* @p array. If @p array is @c NULL, this function does nothing.
*/
EAPI void EAPI void
eina_module_list_free(Eina_Array *list) EINA_ARG_NONNULL(1); eina_module_list_free(Eina_Array *list) EINA_ARG_NONNULL(1);
/**
* @brief Find an module in array.
*
* @param array The array to find the module.
* @param module The name of module to be searched.
*
* This function finds an @p module in @p array.
* If the element is found the function returns the module, else
* @c NULL is returned.
*/
EAPI Eina_Module * EAPI Eina_Module *
eina_module_find(const Eina_Array *array, const char *module) EINA_ARG_NON NULL(1, 2); eina_module_find(const Eina_Array *array, const char *module) EINA_ARG_NON NULL(1, 2);
/** /**
* @} * @}
*/ */
/** /**
* @} * @}
*/ */
 End of changes. 16 change blocks. 
1 lines changed or deleted 194 lines changed or added


 eina_rbtree.h   eina_rbtree.h 
skipping to change at line 29 skipping to change at line 29
#ifndef EINA_RBTREE_H__ #ifndef EINA_RBTREE_H__
#define EINA_RBTREE_H__ #define EINA_RBTREE_H__
#include <stdlib.h> #include <stdlib.h>
#include "eina_types.h" #include "eina_types.h"
#include "eina_error.h" #include "eina_error.h"
#include "eina_iterator.h" #include "eina_iterator.h"
/** /**
* @addtogroup Eina_Rbtree_Group Red-Black tree
*
* @brief These functions provide Red-Black trees management.
*
* For a brief description look at http://en.wikipedia.org/wiki/Red-black_t
ree .
* This code is largely inspired from a tutorial written by Julienne Walker
at :
* http://eternallyconfuzzled.com/tuts/datastructures/jsw_tut_rbtree.aspx .
The
* main difference is that this set of function never allocate any data, ma
king
* them particularly useful for memory management.
*/
/**
* @addtogroup Eina_Data_Types_Group Data Types * @addtogroup Eina_Data_Types_Group Data Types
* *
* @{ * @{
*/ */
/** /**
* @addtogroup Eina_Containers_Group Containers * @addtogroup Eina_Containers_Group Containers
* *
* @{ * @{
*/ */
skipping to change at line 96 skipping to change at line 108
* @endcode * @endcode
* *
* @see EINA_RBTREE_GET() * @see EINA_RBTREE_GET()
*/ */
#define EINA_RBTREE Eina_Rbtree __rbtree #define EINA_RBTREE Eina_Rbtree __rbtree
/** /**
* @def EINA_RBTREE_GET * @def EINA_RBTREE_GET
* access the inlined node if it was created with #EINA_RBTREE. * access the inlined node if it was created with #EINA_RBTREE.
*/ */
#define EINA_RBTREE_GET(Rbtree) & ((Rbtree)->__rbtree) #define EINA_RBTREE_GET(Rbtree) (&((Rbtree)->__rbtree))
/**
* @def EINA_RBTREE_CONTAINER_GET
* find back the container of an red black tree.
*/
#define EINA_RBTREE_CONTAINER_GET(Ptr, Type) ((Type *)((char *)Ptr - offset
of(Type, __rbtree)))
/** /**
* @typedef Eina_Rbtree_Cmp_Node_Cb * @typedef Eina_Rbtree_Cmp_Node_Cb
* Function used compare two nodes and see which direction to navigate. * Function used compare two nodes and see which direction to navigate.
*/ */
typedef Eina_Rbtree_Direction (*Eina_Rbtree_Cmp_Node_Cb)(const Eina_Rbtree *left, const Eina_Rbtree *right, void *data); typedef Eina_Rbtree_Direction (*Eina_Rbtree_Cmp_Node_Cb)(const Eina_Rbtree *left, const Eina_Rbtree *right, void *data);
/** /**
* @def EINA_RBTREE_CMP_NODE_CB * @def EINA_RBTREE_CMP_NODE_CB
* Cast using #Eina_Rbtree_Cmp_Node_Cb * Cast using #Eina_Rbtree_Cmp_Node_Cb
skipping to change at line 132 skipping to change at line 150
* @typedef Eina_Rbtree_Free_Cb * @typedef Eina_Rbtree_Free_Cb
* Function used free a node. * Function used free a node.
*/ */
typedef void (*Eina_Rbtree_Free_Cb)(Eina_Rbtree *node, void *data); typedef void (*Eina_Rbtree_Free_Cb)(Eina_Rbtree *node, void *data);
/** /**
* @def EINA_RBTREE_FREE_CB * @def EINA_RBTREE_FREE_CB
* Cast using #Eina_Rbtree_Free_Cb * Cast using #Eina_Rbtree_Free_Cb
*/ */
#define EINA_RBTREE_FREE_CB(Function) ((Eina_Rbtree_Free_Cb)Function) #define EINA_RBTREE_FREE_CB(Function) ((Eina_Rbtree_Free_Cb)Function)
/**
* @brief Insert a new node inside an existing red black tree.
*
* @param root The root of an exisiting valid red black tree.
* @param node The new node to insert.
* @param cmp The callback that is able to compare two nodes.
* @param data Private data to help the compare function.
* @return The new root of the red black tree.
*
* This function insert a new node in a valid red black tree. NULL is
* an empty valid red black tree. The resulting new tree is a valid red
* black tree. This function doesn't allocate any data.
*/
EAPI Eina_Rbtree *eina_rbtree_inline_insert(Eina_Rbtree *root, Ein a_Rbtree *node, Eina_Rbtree_Cmp_Node_Cb cmp, const void *data) EINA_ARG_NON NULL(2, 3) EINA_WARN_UNUSED_RESULT; EAPI Eina_Rbtree *eina_rbtree_inline_insert(Eina_Rbtree *root, Ein a_Rbtree *node, Eina_Rbtree_Cmp_Node_Cb cmp, const void *data) EINA_ARG_NON NULL(2, 3) EINA_WARN_UNUSED_RESULT;
/**
* @brief Remove a node from an existing red black tree.
*
* @param root The root of a valid red black tree.
* @param node The node to remove from the tree.
* @param cmp The callback that is able to compare two nodes.
* @param data Private data to help the compare function.
* @return The new root of the red black tree.
*
* This function remove a new node in a valid red black tree that should
* contain the node that you are removing. This function will return NULL
* when the red black tree got empty. This function doesn't free any data.
*/
EAPI Eina_Rbtree *eina_rbtree_inline_remove(Eina_Rbtree *root, Ein a_Rbtree *node, Eina_Rbtree_Cmp_Node_Cb cmp, const void *data) EINA_ARG_NON NULL(2, 3) EINA_WARN_UNUSED_RESULT; EAPI Eina_Rbtree *eina_rbtree_inline_remove(Eina_Rbtree *root, Ein a_Rbtree *node, Eina_Rbtree_Cmp_Node_Cb cmp, const void *data) EINA_ARG_NON NULL(2, 3) EINA_WARN_UNUSED_RESULT;
/**
* @brief Delete all nodes from a valid red black tree.
*
* @param root The root of a valid red black tree.
* @param func The callback that will free each node.
* @param data Private data to help the compare function.
*
*/
EAPI void eina_rbtree_delete(Eina_Rbtree *root, Eina_Rbtre e_Free_Cb func, void *data) EINA_ARG_NONNULL(2); EAPI void eina_rbtree_delete(Eina_Rbtree *root, Eina_Rbtre e_Free_Cb func, void *data) EINA_ARG_NONNULL(2);
static inline Eina_Rbtree *eina_rbtree_inline_lookup(const Eina_Rbtree *roo t, const void *key, int length, Eina_Rbtree_Cmp_Key_Cb cmp, const void *dat a) EINA_PURE EINA_ARG_NONNULL(2, 4) EINA_WARN_UNUSED_RESULT; static inline Eina_Rbtree *eina_rbtree_inline_lookup(const Eina_Rbtree *roo t, const void *key, int length, Eina_Rbtree_Cmp_Key_Cb cmp, const void *dat a) EINA_PURE EINA_ARG_NONNULL(2, 4) EINA_WARN_UNUSED_RESULT;
/**
* @brief Returned a new prefix iterator associated to a rbtree.
*
* @param root The root of rbtree.
* @return A new iterator.
*
* This function returns a newly allocated iterator associated to @p
* root. It will iterate the tree using prefix walk. If @p root is @c
* NULL, this function still returns a valid iterator that will always
* return false on eina_iterator_next(), thus keeping API sane.
*
* If the memory can not be allocated, NULL is returned and
* #EINA_ERROR_OUT_OF_MEMORY is set. Otherwise, a valid iterator is
* returned.
*
* @warning if the rbtree structure changes then the iterator becomes
* invalid! That is, if you add or remove nodes this iterator
* behavior is undefined and your program may crash!
*/
EAPI Eina_Iterator *eina_rbtree_iterator_prefix(const Eina_Rbtree *r oot) EINA_MALLOC EINA_WARN_UNUSED_RESULT; EAPI Eina_Iterator *eina_rbtree_iterator_prefix(const Eina_Rbtree *r oot) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
/**
* @brief Returned a new prefix iterator associated to a rbtree.
*
* @param root The root of rbtree.
* @return A new iterator.
*
* This function returns a newly allocated iterator associated to @p
* root. It will iterate the tree using infix walk. If @p root is @c
* NULL, this function still returns a valid iterator that will always
* return false on eina_iterator_next(), thus keeping API sane.
*
* If the memory can not be allocated, NULL is returned and
* #EINA_ERROR_OUT_OF_MEMORY is set. Otherwise, a valid iterator is
* returned.
*
* @warning if the rbtree structure changes then the iterator becomes
* invalid! That is, if you add or remove nodes this iterator
* behavior is undefined and your program may crash!
*/
EAPI Eina_Iterator *eina_rbtree_iterator_infix(const Eina_Rbtree *ro ot) EINA_MALLOC EINA_WARN_UNUSED_RESULT; EAPI Eina_Iterator *eina_rbtree_iterator_infix(const Eina_Rbtree *ro ot) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
/**
* @brief Returned a new prefix iterator associated to a rbtree.
*
* @param root The root of rbtree.
* @return A new iterator.
*
* This function returns a newly allocated iterator associated to @p
* root. It will iterate the tree using postfix walk. If @p root is @c
* NULL, this function still returns a valid iterator that will always
* return false on eina_iterator_next(), thus keeping API sane.
*
* If the memory can not be allocated, NULL is returned and
* #EINA_ERROR_OUT_OF_MEMORY is set. Otherwise, a valid iterator is
* returned.
*
* @warning if the rbtree structure changes then the iterator becomes
* invalid! That is, if you add or remove nodes this iterator
* behavior is undefined and your program may crash!
*/
EAPI Eina_Iterator *eina_rbtree_iterator_postfix(const Eina_Rbtree * root) EINA_MALLOC EINA_WARN_UNUSED_RESULT; EAPI Eina_Iterator *eina_rbtree_iterator_postfix(const Eina_Rbtree * root) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
#include "eina_inline_rbtree.x" #include "eina_inline_rbtree.x"
/** /**
* @} * @}
*/ */
/** /**
* @} * @}
 End of changes. 8 change blocks. 
1 lines changed or deleted 119 lines changed or added


 eina_rectangle.h   eina_rectangle.h 
skipping to change at line 25 skipping to change at line 25
* License along with this library; * License along with this library;
* if not, see <http://www.gnu.org/licenses/>. * if not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef EINA_RECTANGLE_H_ #ifndef EINA_RECTANGLE_H_
#define EINA_RECTANGLE_H_ #define EINA_RECTANGLE_H_
#include "eina_types.h" #include "eina_types.h"
/** /**
* @addtogroup Eina_Rectangle_Group Rectangle
*
* @brief These functions provide rectangle management.
*/
/**
* @addtogroup Eina_Tools_Group Tools * @addtogroup Eina_Tools_Group Tools
* *
* @{ * @{
*/ */
/** /**
* @defgroup Eina_Rectangle_Group Rectangle * @defgroup Eina_Rectangle_Group Rectangle
* *
* @{ * @{
*/ */
skipping to change at line 66 skipping to change at line 72
static inline void eina_rectangle_coords_from(Eina_Rectangle *r, int x, int y, int w, int h) EINA_ARG_NONNULL(1); static inline void eina_rectangle_coords_from(Eina_Rectangle *r, int x, int y, int w, int h) EINA_ARG_NONNULL(1);
static inline Eina_Bool eina_rectangles_intersect(const Eina_Rectangle *r 1, const Eina_Rectangle *r2) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT ; static inline Eina_Bool eina_rectangles_intersect(const Eina_Rectangle *r 1, const Eina_Rectangle *r2) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT ;
static inline Eina_Bool eina_rectangle_xcoord_inside(const Eina_Rectangle *r, int x) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT; static inline Eina_Bool eina_rectangle_xcoord_inside(const Eina_Rectangle *r, int x) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
static inline Eina_Bool eina_rectangle_ycoord_inside(const Eina_Rectangle *r, int y) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT; static inline Eina_Bool eina_rectangle_ycoord_inside(const Eina_Rectangle *r, int y) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
static inline Eina_Bool eina_rectangle_coords_inside(const Eina_Rectangle *r, int x, int y) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT; static inline Eina_Bool eina_rectangle_coords_inside(const Eina_Rectangle *r, int x, int y) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
static inline void eina_rectangle_union(Eina_Rectangle *dst, const E ina_Rectangle *src) EINA_ARG_NONNULL(1, 2); static inline void eina_rectangle_union(Eina_Rectangle *dst, const E ina_Rectangle *src) EINA_ARG_NONNULL(1, 2);
static inline Eina_Bool eina_rectangle_intersection(Eina_Rectangle *dst, const Eina_Rectangle *src) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT; static inline Eina_Bool eina_rectangle_intersection(Eina_Rectangle *dst, const Eina_Rectangle *src) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
static inline void eina_rectangle_rescale_in(const Eina_Rectangle *o ut, const Eina_Rectangle *in, Eina_Rectangle *res) EINA_ARG_NONNULL(1, 2, 3 ); static inline void eina_rectangle_rescale_in(const Eina_Rectangle *o ut, const Eina_Rectangle *in, Eina_Rectangle *res) EINA_ARG_NONNULL(1, 2, 3 );
static inline void eina_rectangle_rescale_out(const Eina_Rectangle * out, const Eina_Rectangle *in, Eina_Rectangle *res) EINA_ARG_NONNULL(1, 2, 3); static inline void eina_rectangle_rescale_out(const Eina_Rectangle * out, const Eina_Rectangle *in, Eina_Rectangle *res) EINA_ARG_NONNULL(1, 2, 3);
/**
* @brief Add a rectangle in a new pool.
*
* @param w The width of the rectangle.
* @param h The height of the rectangle.
* @return A newly allocated pool on success, @c NULL otherwise.
*
* This function adds the rectangle of size (@p width, @p height) to a
* new pool. If the pool can not be created, @c NULL is
* returned. Otherwise the newly allocated pool is returned.
*/
EAPI Eina_Rectangle_Pool *eina_rectangle_pool_new(int w, int h) EINA_MALLOC EINA_WARN_UNUSED_RESULT; EAPI Eina_Rectangle_Pool *eina_rectangle_pool_new(int w, int h) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
/**
* @brief Return the pool of the given rectangle.
*
* @param rect The rectangle.
* @return The pool of the given rectangle.
*
* This function returns the pool in which @p rect is. If @p rect is
* @c NULL, @c NULL is returned.
*/
EAPI Eina_Rectangle_Pool *eina_rectangle_pool_get(Eina_Rectangle *rect) EIN A_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); EAPI Eina_Rectangle_Pool *eina_rectangle_pool_get(Eina_Rectangle *rect) EIN A_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
/**
* @brief Return the width and height of the given pool.
*
* @param pool The pool.
* @param w The returned width.
* @param h The returned height.
* @return #EINA_TRUE on success, #EINA_FALSE otherwise.
*
* This function returns the width and height of @p pool and store
* them in respectively @p w and @p h if they are not @c NULL. If
* @p pool is @c NULL, #EINA_FALSE is returned. Otherwise #EINA_TRUE is
* returned.
*/
EAPI Eina_Bool eina_rectangle_pool_geometry_get(Eina_Rectangle_P ool *pool, int *w, int *h) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA _WARN_UNUSED_RESULT; EAPI Eina_Bool eina_rectangle_pool_geometry_get(Eina_Rectangle_P ool *pool, int *w, int *h) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA _WARN_UNUSED_RESULT;
/**
* @brief Get the data from the given pool.
*
* @param pool The pool.
* @return The returned data.
*
* This function gets the data from @p pool set by
* eina_rectangle_pool_data_set(). If @p pool is @c NULL, this
* function returns @c NULL.
*/
EAPI void *eina_rectangle_pool_data_get(Eina_Rectangle_Pool *pool) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); EAPI void *eina_rectangle_pool_data_get(Eina_Rectangle_Pool *pool) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
/**
* @brief Set the data to the given pool.
*
* @param pool The pool.
* @param data The data to set.
*
* This function sets @p data to @p pool. If @p pool is @c NULL, this
* function does nothing.
*/
EAPI void eina_rectangle_pool_data_set(Eina_Rectangle_Pool *pool, const void *data) EINA_ARG_NONNULL(1); EAPI void eina_rectangle_pool_data_set(Eina_Rectangle_Pool *pool, const void *data) EINA_ARG_NONNULL(1);
/**
* @brief Free the given pool.
*
* @param pool The pool to free.
*
* This function frees the allocated data of @p pool. If @p pool is
* @c NULL, ths function returned immediately.
*/
EAPI void eina_rectangle_pool_free(Eina_Rectangle_Pool *poo l) EINA_ARG_NONNULL(1); EAPI void eina_rectangle_pool_free(Eina_Rectangle_Pool *poo l) EINA_ARG_NONNULL(1);
/**
* @brief Return the number of rectangles in the given pool.
*
* @param pool The pool.
* @return The number of rectangles in the pool.
*
* This function returns the number of rectangles in @p pool.
*/
EAPI int eina_rectangle_pool_count(Eina_Rectangle_Pool *po ol) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT; EAPI int eina_rectangle_pool_count(Eina_Rectangle_Pool *po ol) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
/**
* @brief Request a rectangle of given size in the given pool.
*
* @param pool The pool.
* @param w The width of the rectangle to request.
* @param h The height of the rectangle to request.
* @return The requested rectangle on success, @c NULL otherwise.
*
* This function retrieve from @p pool the rectangle of width @p w and
* height @p h. If @p pool is @c NULL, or @p w or @p h are non-positive,
* the function returns @c NULL. If @p w or @p h are greater than the
* pool size, the function returns @c NULL. On success, the function
* returns the rectangle which matches the size (@p w, @p h).
* Otherwise it returns @c NULL.
*/
EAPI Eina_Rectangle *eina_rectangle_pool_request(Eina_Rectangle_Pool * pool, int w, int h) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); EAPI Eina_Rectangle *eina_rectangle_pool_request(Eina_Rectangle_Pool * pool, int w, int h) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
/**
* @brief Remove the given rectangle from the pool.
*
* @param rect The rectangle to remove from the pool.
*
* This function removes @p rect from the pool. If @p rect is
* @c NULL, the function returns immediately. Otherwise it remoes @p
* rect from the pool.
*/
EAPI void eina_rectangle_pool_release(Eina_Rectangle *rect) EINA_ARG_NONNULL(1); EAPI void eina_rectangle_pool_release(Eina_Rectangle *rect) EINA_ARG_NONNULL(1);
/** /**
* @def EINA_RECTANGLE_SET * @def EINA_RECTANGLE_SET
* @brief Macro to set the values of a #Eina_Rectangle. * @brief Macro to set the values of a #Eina_Rectangle.
* *
* @param Rectangle The rectangle to set the values. * @param Rectangle The rectangle to set the values.
* @param X The X coordinate of the top left corner of the rectangle. * @param X The X coordinate of the top left corner of the rectangle.
* @param Y The Y coordinate of the top left corner of the rectangle. * @param Y The Y coordinate of the top left corner of the rectangle.
* @param W The width of the rectangle. * @param W The width of the rectangle.
skipping to change at line 96 skipping to change at line 202
* This macro set the values of @p Rectangle. (@p X, @p Y) is the * This macro set the values of @p Rectangle. (@p X, @p Y) is the
* coordinates of the top left corner of @p Rectangle, @p W is its * coordinates of the top left corner of @p Rectangle, @p W is its
* width and @p H is its height. * width and @p H is its height.
*/ */
#define EINA_RECTANGLE_SET(Rectangle, X, Y, W, H) \ #define EINA_RECTANGLE_SET(Rectangle, X, Y, W, H) \
(Rectangle)->x = X; \ (Rectangle)->x = X; \
(Rectangle)->y = Y; \ (Rectangle)->y = Y; \
(Rectangle)->w = W; \ (Rectangle)->w = W; \
(Rectangle)->h = H; (Rectangle)->h = H;
/**
* @brief Create a new rectangle.
*
* @param x The X coordinate of the top left corner of the rectangle.
* @param y The Y coordinate of the top left corner of the rectangle.
* @param w The width of the rectangle.
* @param h The height of the rectangle.
* @return The new rectangle on success, @ NULL otherwise.
*
* This function creates a rectangle which top left corner has the
* coordinates (@p x, @p y), with height @p w and height @p h and adds
* it to the rectangles pool. No check is done on @p w and @p h. This
* function returns a new rectangle on success, @c NULL otherwhise.
*/
EAPI Eina_Rectangle *eina_rectangle_new(int x, int y, int w, int h) EINA_MA LLOC EINA_WARN_UNUSED_RESULT; EAPI Eina_Rectangle *eina_rectangle_new(int x, int y, int w, int h) EINA_MA LLOC EINA_WARN_UNUSED_RESULT;
/**
* @brief Free the given rectangle.
*
* @param rect The rectangle to free.
*
* This function removes @p rect from the rectangles pool.
*/
EAPI void eina_rectangle_free(Eina_Rectangle *rect) EINA_ARG_NON NULL(1); EAPI void eina_rectangle_free(Eina_Rectangle *rect) EINA_ARG_NON NULL(1);
#include "eina_inline_rectangle.x" #include "eina_inline_rectangle.x"
/** /**
* @} * @}
*/ */
/** /**
* @} * @}
 End of changes. 12 change blocks. 
0 lines changed or deleted 128 lines changed or added


 eina_safety_checks.h   eina_safety_checks.h 
skipping to change at line 63 skipping to change at line 63
* #include <eina_error.h> // eina own header * #include <eina_error.h> // eina own header
* *
* #include <eina_safety_checks.h> * #include <eina_safety_checks.h>
* // all these files below will NOT emit warning from EINA_ARG_NONNULL(), * // all these files below will NOT emit warning from EINA_ARG_NONNULL(),
* // but this is required to have the functions defined there to be checke d * // but this is required to have the functions defined there to be checke d
* // for NULL pointers * // for NULL pointers
* #include "my_functions1.h" * #include "my_functions1.h"
* #include "my_functions2.h" * #include "my_functions2.h"
* *
* @endcode * @endcode
*/
/**
* @addtogroup Eina_Safety_Checks_Group Safety Checks
*
* Safety checks are a set of macros to check for parameters or values
* that should never happen, it is similar in concept to assert(), but
* will log and return instead of abort() your program.
*
* Since these cases should never happen, one may wantto keep safety
* checks enabled during tests but disable then during deploy, not
* doing any checks at all. This is a common requirement for embedded
* systems. Whenever to check or not should be set during compile time
* by using @c --disable-safety-checks or @c --enable-safety-checks
* options to @c configure script.
*
* Whenever these macros capture an error, EINA_LOG_ERR() will be
* called and @c eina_error set to @c EINA_ERROR_SAFETY_FAILED and can
* be checked with eina_error_get() after call.
*
* @see EINA_SAFETY_ON_NULL_RETURN(), EINA_SAFETY_ON_NULL_RETURN_VAL()
* and other macros.
* *
* @{ * @{
*/ */
#include "eina_config.h" #include "eina_config.h"
#include "eina_error.h" #include "eina_error.h"
/** /**
* @var EINA_ERROR_SAFETY_FAILED * @var EINA_ERROR_SAFETY_FAILED
* Error identifier corresponding to safety check failure. * Error identifier corresponding to safety check failure.
 End of changes. 1 change blocks. 
0 lines changed or deleted 22 lines changed or added


 eina_sched.h   eina_sched.h 
skipping to change at line 24 skipping to change at line 24
* You should have received a copy of the GNU Lesser General Public * You should have received a copy of the GNU Lesser General Public
* License along with this library; * License along with this library;
* if not, see <http://www.gnu.org/licenses/>. * if not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef EINA_SCHED_H_ #ifndef EINA_SCHED_H_
#define EINA_SCHED_H_ #define EINA_SCHED_H_
#include "eina_types.h" #include "eina_types.h"
/**
* @brief Lower priority of current thread.
*
* It's used by worker threads so they use up background cpu and do not sta
ll
* the main thread If current thread is running with real-time priority, we
* decrease our priority by @c RTNICENESS. This is done in a portable way.
*
* Otherwise (we are running with SCHED_OTHER policy) there's no portable w
ay to
* set the nice level on current thread. In Linux, it does work and it's th
e
* only one that is implemented as of now. In this case the nice level is
* incremented on this thread by @c NICENESS.
*/
EAPI void eina_sched_prio_drop(void); EAPI void eina_sched_prio_drop(void);
#endif /* EINA_SCHED_H_ */ #endif /* EINA_SCHED_H_ */
 End of changes. 1 change blocks. 
0 lines changed or deleted 15 lines changed or added


 eina_str.h   eina_str.h 
#ifndef _EINA_STR_H #ifndef _EINA_STR_H
#define _EINA_STR_H #define _EINA_STR_H
#include <stddef.h> #include <stddef.h>
#include <string.h> #include <string.h>
#include "eina_types.h" #include "eina_types.h"
/** /**
* @page tutorial_eina_string Eina String example
* @dontinclude eina_str_01.c
*
* Whenever using eina we need to include it:
* @skipline #include
* @line #include
*
* In our main function we declare(and initialize) some variables and initi
alize
* eina:
* @until eina_init
*
* It's frequentely necessary to split a string into its constituent parts,
* eina_str_split() make's it easy to do so:
* @until printf
*
* Another common need is to make a string uppercase or lowercase, so let's
* create a string and make it uppercase and then make it lowercase again:
* @until printf
* @until printf
*
* Next we use eina to check if our @p names string starts or ends with som
e
* values:
* @until Has
*
* When strings will be used in a terminal(or a number of other places) it
* necessary to escape certain characters that appear in them:
* @until printf
*
* Much as we previously split a string we will now join two strings:
* @until printf
*
* With strlcpy() we can copy what portion of the @p prologue fits in @p st
r and
* be sure that it's still NULL terminated:
* @until printf
*
* Since we are done with @p prologue and @p str we should free them:
* @until free(str
*
* Finally we see strlcat in action:
* @until printf("
*
* And then shut eina down and exit:
* @until }
* @example eina_str_01.c
*/
/**
* @addtogroup Eina_String_Group String
*
* @brief Provide useful functions for C string manipulation.
*
* This group of functions allow you to more easily manipulate strings, the
y
* provide functionality not available through string.h.
*
* @warning Since these functions modify the strings they can't be used wit
h
* shared strings(eina_stringshare).
*
* See an example @ref tutorial_eina_string "here".
*/
/**
* @addtogroup Eina_Tools_Group Tools * @addtogroup Eina_Tools_Group Tools
* *
* For more information refer to the @ref tutorial_eina_string "string exam
ple".
*
* @{ * @{
*/ */
/** /**
* @defgroup Eina_String_Group String * @defgroup Eina_String_Group String
* *
* @{ * @{
*/ */
/* strlcpy implementation for libc's lacking it */ /* strlcpy implementation for libc's lacking it */
/**
* @brief Copy a c-string to another.
*
* @param dst The destination string.
* @param src The source string.
* @param siz The size of the destination string.
* @return The length of the source string.
*
* This function copies up to @p siz - 1 characters from the
* NUL-terminated string @p src to @p dst, NUL-terminating the result
* (unless @p siz is equal to 0). The returned value is the length of
* @p src. If the returned value is greater than @p siz, truncation
* occurred.
*
* @note The main difference between eina_strlcpy and strncpy is that this
* ensures @p dst is NULL terminated even if no NULL byte is found in the f
irst
* @p siz bytes of src.
*/
EAPI size_t eina_strlcpy(char *dst, const char *src, size_t siz) E INA_ARG_NONNULL(1, 2); EAPI size_t eina_strlcpy(char *dst, const char *src, size_t siz) E INA_ARG_NONNULL(1, 2);
/**
* @brief Append a c-string.
*
* @param dst The destination string.
* @param src The source string.
* @param siz The size of the destination string.
* @return The length of the source string plus MIN(siz, strlen(initial dst
))
*
* This function appends @p src to @p dst of size @p siz (unlike
* strncat, @p siz is the full size of @p dst, not space left). At
* most @p siz - 1 characters will be copied. Always NUL terminates
* (unless @p siz <= strlen(dst)). This function returns strlen(src) +
* MIN(siz, strlen(initial dst)). If the returned value is greater or
* equal than @p siz, truncation occurred.
*/
EAPI size_t eina_strlcat(char *dst, const char *src, size_t siz) E INA_ARG_NONNULL(1, 2); EAPI size_t eina_strlcat(char *dst, const char *src, size_t siz) E INA_ARG_NONNULL(1, 2);
/**
* @brief Check if the given string has the given prefix.
*
* @param str The string to work with.
* @param prefix The prefix to check for.
* @return #EINA_TRUE if the string has the given prefix, #EINA_FALSE other
wise.
*
* This function returns #EINA_TRUE if @p str has the prefix
* @p prefix, #EINA_FALSE otherwise. If the length of @p prefix is
* greater than @p str, #EINA_FALSE is returned.
*/
EAPI Eina_Bool eina_str_has_prefix(const char *str, const char *prefi x) EINA_PURE EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT; EAPI Eina_Bool eina_str_has_prefix(const char *str, const char *prefi x) EINA_PURE EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
/**
* @brief Check if the given string has the given suffix.
*
* @param str The string to work with.
* @param suffix The suffix to check for.
* @return #EINA_TRUE if the string has the given suffix, #EINA_FALSE other
wise.
*
* This function returns #EINA_TRUE if @p str has the suffix
* @p suffix, #EINA_FALSE otherwise. If the length of @p suffix is
* greater than @p str, #EINA_FALSE is returned.
*/
EAPI Eina_Bool eina_str_has_suffix(const char *str, const char *suffi x) EINA_PURE EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT; EAPI Eina_Bool eina_str_has_suffix(const char *str, const char *suffi x) EINA_PURE EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
/**
* @brief Check if the given string has the given extension.
*
* @param str The string to work with.
* @param ext The extension to check for.
* @return #EINA_TRUE if the string has the given extension, #EINA_FALSE ot
herwise.
*
* This function does the same as eina_str_has_suffix(), except it's case
* insensitive.
*/
EAPI Eina_Bool eina_str_has_extension(const char *str, const char *ex t) EINA_PURE EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT; EAPI Eina_Bool eina_str_has_extension(const char *str, const char *ex t) EINA_PURE EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
/**
* @brief Split a string using a delimiter.
*
* @param str The string to split.
* @param delim The string which specifies the places at which to split the
string.
* @param max_tokens The maximum number of strings to split string into.
* @return A newly-allocated NULL-terminated array of strings or NULL if it
* fails to allocate the array.
*
* This functin splits @p str into a maximum of @p max_tokens pieces,
* using the given delimiter @p delim. @p delim is not included in any
* of the resulting strings, unless @p max_tokens is reached. If
* @p max_tokens is less than @c 1, the string is splitted completely. If
* @p max_tokens is reached, the last string in the returned string
* array contains the remainder of string. The returned value is a
* newly allocated NULL-terminated array of strings or NULL if it fails to
* allocate the array. To free it, free the first element of the array and
the
* array itself.
*
* @note If you need the number of elements in the returned array see
* eina_str_split_full().
*/
EAPI char **eina_str_split(const char *string, const char *delimit er, int max_tokens) EINA_ARG_NONNULL(1, 2) EINA_MALLOC EINA_WARN_UNUSED_RES ULT; EAPI char **eina_str_split(const char *string, const char *delimit er, int max_tokens) EINA_ARG_NONNULL(1, 2) EINA_MALLOC EINA_WARN_UNUSED_RES ULT;
/**
* @brief Split a string using a delimiter and returns number of elements.
*
* @param str The string to split.
* @param delim The string which specifies the places at which to split the
string.
* @param max_tokens The maximum number of strings to split string into.
* @param elements Where to return the number of elements in returned
* array (not counting the terminating @c NULL). May be @c NULL.
* @return A newly-allocated NULL-terminated array of strings or NULL if it
* fails to allocate the array.
*
* This function splits @p str into a maximum of @p max_tokens pieces,
* using the given delimiter @p delim. @p delim is not included in any
* of the resulting strings, unless @p max_tokens is reached. If
* @p max_tokens is less than @c 1, the string is splitted completely. If
* @p max_tokens is reached, the last string in the returned string
* array contains the remainder of string. The returned value is a
* newly allocated NULL-terminated array of strings or NULL if it fails to
* allocate the array. To free it, free the first element of the array and
the
* array itself.
*
* @see eina_str_split()
*/
EAPI char **eina_str_split_full(const char *string, const char *de limiter, int max_tokens, unsigned int *elements) EINA_ARG_NONNULL(1, 2, 4) EINA_MALLOC EINA_WARN_UNUSED_RESULT; EAPI char **eina_str_split_full(const char *string, const char *de limiter, int max_tokens, unsigned int *elements) EINA_ARG_NONNULL(1, 2, 4) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
/**
* @brief Join two strings of known length.
*
* @param dst The buffer to store the result.
* @param size Size (in byte) of the buffer.
* @param sep The separator character to use.
* @param a First string to use, before @p sep.
* @param a_len length of @p a.
* @param b Second string to use, after @p sep.
* @param b_len length of @p b.
* @return The number of characters printed.
*
* This function joins the strings @p a and @p b (in that order) and
* separate them with @p sep. The result is stored in the buffer
* @p dst and at most @p size - 1 characters will be written and the
* string is NULL-terminated. @p a_len is the length of @p a (not
* including '\\0') and @p b_len is the length of @p b (not including
* '\\0'). This function returns the number of characters printed (not
* including the trailing '\\0' used to end output to strings). Just
* like snprintf(), it will not write more than @p size bytes, thus a
* returned value of @p size or more means that the output was
* truncated.
*
* @see eina_str_join()
* @see eina_str_join_static()
*/
EAPI size_t eina_str_join_len(char *dst, size_t size, char sep, co nst char *a, size_t a_len, const char *b, size_t b_len) EINA_ARG_NONNULL(1, 4, 6); EAPI size_t eina_str_join_len(char *dst, size_t size, char sep, co nst char *a, size_t a_len, const char *b, size_t b_len) EINA_ARG_NONNULL(1, 4, 6);
/**
* @brief Use Iconv to convert a text string from one encoding to another.
*
* @param enc_from Encoding to convert from.
* @param enc_to Encoding to convert to.
* @param text The text to convert.
* @return The converted text.
*
* This function converts @p text, encoded in @p enc_from. On success,
* the converted text is returned and is encoded in @p enc_to. On
* failure, @c NULL is returned. Iconv is used to convert @p text. If
* Iconv is not available, @c NULL is returned. When not used anymore,
* the returned value must be freed.
*/
EAPI char *eina_str_convert(const char *enc_from, const char *enc _to, const char *text) EINA_WARN_UNUSED_RESULT EINA_MALLOC EINA_ARG_NONNULL (1, 2, 3); EAPI char *eina_str_convert(const char *enc_from, const char *enc _to, const char *text) EINA_WARN_UNUSED_RESULT EINA_MALLOC EINA_ARG_NONNULL (1, 2, 3);
/**
* @brief Escape slashes, spaces and apostrophes in strings.
*
* @param str The string to escape.
* @return The escaped string.
*
* Escaping is done by adding a slash "\" before any occurrence of slashes
"\",
* spaces " " or apostrophes "'". This function returns a newly allocated
* escaped string on success, @c NULL on failure. When not used anymore, th
e
* returned value must be freed.
*/
EAPI char *eina_str_escape(const char *str) EINA_WARN_UNUSED_RESU LT EINA_MALLOC EINA_ARG_NONNULL(1); EAPI char *eina_str_escape(const char *str) EINA_WARN_UNUSED_RESU LT EINA_MALLOC EINA_ARG_NONNULL(1);
/**
* @brief Lowercase all the characters in range [A-Z] in the given string.
*
* @param str The string to lowercase.
*
* This function modifies the original string, changing all characters
* in [A-Z] to lowercase. If @p str is @c NULL or is an empty string,
* this function does nothing.
*/
EAPI void eina_str_tolower(char **str); EAPI void eina_str_tolower(char **str);
/**
* @brief Uppercase all the characters in range [a-z] in the given string.
*
* @param str The string to uppercase.
*
* This function modifies the original string, changing all characters
* in [a-z] to uppercase. If @p str is @c NULL or is an empty string,
* this function does nothing.
*/
EAPI void eina_str_toupper(char **str); EAPI void eina_str_toupper(char **str);
static inline size_t eina_str_join(char *dst, size_t size, char sep, const char *a, const char *b) EINA_ARG_NONNULL(1, 4, 5); static inline size_t eina_str_join(char *dst, size_t size, char sep, const char *a, const char *b) EINA_ARG_NONNULL(1, 4, 5);
/** /**
* @def eina_str_join_static(dst, sep, a, b) * @def eina_str_join_static(dst, sep, a, b)
* @brief Join two static strings and store the result in a static buffer. * @brief Join two static strings and store the result in a static buffer.
* *
* @param dst The buffer to store the result. * @param dst The buffer to store the result.
* @param sep The separator character to use. * @param sep The separator character to use.
 End of changes. 14 change blocks. 
0 lines changed or deleted 264 lines changed or added


 eina_strbuf.h   eina_strbuf.h 
#ifndef EINA_STRBUF_H #ifndef EINA_STRBUF_H
#define EINA_STRBUF_H #define EINA_STRBUF_H
#include <stddef.h> #include <stddef.h>
#include <stdarg.h> #include <stdarg.h>
#include "eina_types.h" #include "eina_types.h"
/** /**
* @page tutorial_strbuf Eina_Strbuf example
* @dontinclude eina_strbuf_01.c
*
* First thing always is including Eina:
* @skipline #include
* @until #include
*
* Next we initialize eina and create a string buffer to play with:
* @until strbuf_new
*
* Here you can see two different ways of creating a buffer with the same
* contents. We could create them in simpler ways, but this gives us an
* opportunity to demonstrate several functions in action:
* @until strbuf_reset
* @until strbuf_reset
*
* Next we use the printf family of functions to create a formated string,
* add, remove and replace some content:
* @until strbuf_string_get
* @until strbuf_string_get
* @until strbuf_string_get
*
* Once done we free our string buffer, shut down Eina and end the applicat
ion:
* @until }
*
* @example eina_strbuf_01.c
*/
/**
* @addtogroup Eina_String_Buffer_Group String Buffer
*
* @brief These functions provide string buffers management.
*
* The String Buffer data type is designed to be a mutable string,
* allowing to append, prepend or insert a string to a buffer.
*
* For more information see @ref tutorial_strbuf "this example".
*/
/**
* @addtogroup Eina_Data_Types_Group Data Types * @addtogroup Eina_Data_Types_Group Data Types
* *
* @{ * @{
*/ */
/** /**
* @defgroup Eina_String_Buffer_Group String Buffer * @defgroup Eina_String_Buffer_Group String Buffer
* *
* @{ * @{
*/ */
skipping to change at line 43 skipping to change at line 82
* returned and Eina error is set to #EINA_ERROR_OUT_OF_MEMORY. To * returned and Eina error is set to #EINA_ERROR_OUT_OF_MEMORY. To
* free the resources, use eina_strbuf_free(). * free the resources, use eina_strbuf_free().
* *
* @see eina_strbuf_free() * @see eina_strbuf_free()
* @see eina_strbuf_append() * @see eina_strbuf_append()
* @see eina_strbuf_string_get() * @see eina_strbuf_string_get()
*/ */
EAPI Eina_Strbuf *eina_strbuf_new(void) EINA_MALLOC EINA_WARN_UNUSED_RESULT ; EAPI Eina_Strbuf *eina_strbuf_new(void) EINA_MALLOC EINA_WARN_UNUSED_RESULT ;
/** /**
* @brief Create a new string buffer using the passed string. The passed
* string is used directly as the buffer, it's somehow the opposite functio
n of
* @ref eina_strbuf_string_steal . The passed string must be malloced.
*
* @param str the string to manage
* @return Newly allocated string buffer instance.
*
* This function creates a new string buffer. On error, @c NULL is
* returned and Eina error is set to #EINA_ERROR_OUT_OF_MEMORY. To
* free the resources, use eina_strbuf_free().
*
* @see eina_strbuf_free()
* @see eina_strbuf_append()
* @see eina_strbuf_string_get()
* @since 1.1.0
*/
EAPI Eina_Strbuf *eina_strbuf_manage_new(char *str) EINA_MALLOC EINA_WARN_U
NUSED_RESULT;
/**
* @brief Free a string buffer. * @brief Free a string buffer.
* *
* @param buf The string buffer to free. * @param buf The string buffer to free.
* *
* This function frees the memory of @p buf. @p buf must have been * This function frees the memory of @p buf. @p buf must have been
* created by eina_strbuf_new(). * created by eina_strbuf_new().
*/ */
EAPI void eina_strbuf_free(Eina_Strbuf *buf) EINA_ARG_NONNULL(1); EAPI void eina_strbuf_free(Eina_Strbuf *buf) EINA_ARG_NONNULL(1);
/** /**
skipping to change at line 87 skipping to change at line 145
*/ */
EAPI Eina_Bool eina_strbuf_append(Eina_Strbuf *buf, const char *str) EINA_A RG_NONNULL(1, 2); EAPI Eina_Bool eina_strbuf_append(Eina_Strbuf *buf, const char *str) EINA_A RG_NONNULL(1, 2);
/** /**
* @brief Append an escaped string to a buffer, reallocating as necessary. * @brief Append an escaped string to a buffer, reallocating as necessary.
* *
* @param buf The string buffer to append to. * @param buf The string buffer to append to.
* @param str The string to append. * @param str The string to append.
* @return #EINA_TRUE on success, #EINA_FALSE on failure. * @return #EINA_TRUE on success, #EINA_FALSE on failure.
* *
* This function appends the escaped string @p str to @p buf. If @p * This function escapes and then appends the string @p str to @p buf. If @
* str can not be appended, #EINA_FALSE is returned, otherwise, p str
* #EINA_TRUE is returned. * can not be appended, #EINA_FALSE is returned, otherwise, #EINA_TRUE is
* returned.
*/ */
EAPI Eina_Bool eina_strbuf_append_escaped(Eina_Strbuf *buf, const char *str ) EINA_ARG_NONNULL(1, 2); EAPI Eina_Bool eina_strbuf_append_escaped(Eina_Strbuf *buf, const char *str ) EINA_ARG_NONNULL(1, 2);
/** /**
* @brief Append a string to a buffer, reallocating as necessary, * @brief Append a string to a buffer, reallocating as necessary,
* limited by the given length. * limited by the given length.
* *
* @param buf The string buffer to append to. * @param buf The string buffer to append to.
* @param str The string to append. * @param str The string to append.
* @param maxlen The maximum number of characters to append. * @param maxlen The maximum number of characters to append.
* @return #EINA_TRUE on success, #EINA_FALSE on failure. * @return #EINA_TRUE on success, #EINA_FALSE on failure.
* *
* This function appends at most @p maxlen characters of @p str to * This function appends at most @p maxlen characters of @p str to
* @p buf. It can't appends more than the length of @p str. It * @p buf. It can't append more than the length of @p str. It
* computes the length of @p str, so is slightly slower than * computes the length of @p str, so it is slightly slower than
* eina_strbuf_append_length(). If the length is known beforehand, * eina_strbuf_append_length(). If the length is known beforehand,
* consider using that variant (@p maxlen should then be checked so * consider using that variant (@p maxlen should then be checked so
* that it is greater than the size of @p str). If @p str can not be * that it is greater than the size of @p str). If @p str can not be
* appended, #EINA_FALSE is returned, otherwise, #EINA_TRUE is * appended, #EINA_FALSE is returned, otherwise, #EINA_TRUE is
* returned. * returned.
* *
* @see eina_strbuf_append() * @see eina_strbuf_append()
* @see eina_strbuf_append_length() * @see eina_strbuf_append_length()
*/ */
EAPI Eina_Bool eina_strbuf_append_n(Eina_Strbuf *buf, const char *str, size _t maxlen) EINA_ARG_NONNULL(1, 2); EAPI Eina_Bool eina_strbuf_append_n(Eina_Strbuf *buf, const char *str, size _t maxlen) EINA_ARG_NONNULL(1, 2);
skipping to change at line 127 skipping to change at line 185
* @brief Append a string of exact length to a buffer, reallocating as nece ssary. * @brief Append a string of exact length to a buffer, reallocating as nece ssary.
* *
* @param buf The string buffer to append to. * @param buf The string buffer to append to.
* @param str The string to append. * @param str The string to append.
* @param length The exact length to use. * @param length The exact length to use.
* @return #EINA_TRUE on success, #EINA_FALSE on failure. * @return #EINA_TRUE on success, #EINA_FALSE on failure.
* *
* This function appends @p str to @p buf. @p str must be of size at * This function appends @p str to @p buf. @p str must be of size at
* most @p length. It is slightly faster than eina_strbuf_append() as * most @p length. It is slightly faster than eina_strbuf_append() as
* it does not compute the size of @p str. It is useful when dealing * it does not compute the size of @p str. It is useful when dealing
* with strings of known size, such as eina_strngshare. If @p buf * with strings of known size, such as eina_stringshare. If @p buf
* can't append it, #EINA_FALSE is returned, otherwise #EINA_TRUE is * can't append it, #EINA_FALSE is returned, otherwise #EINA_TRUE is
* returned. * returned.
* *
* @see eina_stringshare_length() * @see eina_stringshare_length()
* @see eina_strbuf_append() * @see eina_strbuf_append()
* @see eina_strbuf_append_n() * @see eina_strbuf_append_n()
*/ */
EAPI Eina_Bool eina_strbuf_append_length(Eina_Strbuf *buf, const char *str, size_t length) EINA_ARG_NONNULL(1, 2); EAPI Eina_Bool eina_strbuf_append_length(Eina_Strbuf *buf, const char *str, size_t length) EINA_ARG_NONNULL(1, 2);
/** /**
skipping to change at line 157 skipping to change at line 215
*/ */
EAPI Eina_Bool eina_strbuf_append_char(Eina_Strbuf *buf, char c) EINA_ARG_N ONNULL(1); EAPI Eina_Bool eina_strbuf_append_char(Eina_Strbuf *buf, char c) EINA_ARG_N ONNULL(1);
/** /**
* @brief Append a string to a buffer, reallocating as necessary. * @brief Append a string to a buffer, reallocating as necessary.
* *
* @param buf The string buffer to append to. * @param buf The string buffer to append to.
* @param fmt The string to append. * @param fmt The string to append.
* @return #EINA_TRUE on success, #EINA_FALSE on failure. * @return #EINA_TRUE on success, #EINA_FALSE on failure.
* *
* This function appends the string defined by the format @p fmt to @p buf.
@p
* fmt must be of a valid format for printf family of functions. If it can'
t
* insert it, #EINA_FALSE is returned, otherwise #EINA_TRUE is returned.
*
* @see eina_strbuf_append() * @see eina_strbuf_append()
*/ */
EAPI Eina_Bool eina_strbuf_append_printf(Eina_Strbuf *buf, const char *fmt, ...) EINA_ARG_NONNULL(1, 2) EINA_PRINTF(2, 3); EAPI Eina_Bool eina_strbuf_append_printf(Eina_Strbuf *buf, const char *fmt, ...) EINA_ARG_NONNULL(1, 2) EINA_PRINTF(2, 3);
/** /**
* @brief Append a string to a buffer, reallocating as necessary. * @brief Append a string to a buffer, reallocating as necessary.
* *
* @param buf The string buffer to append to. * @param buf The string buffer to append to.
* @param fmt The string to append. * @param fmt The string to append.
* @param args The variable arguments. * @param args The variable arguments.
* @return #EINA_TRUE on success, #EINA_FALSE on failure. * @return #EINA_TRUE on success, #EINA_FALSE on failure.
* *
* @see eina_strbuf_append() * @see eina_strbuf_append_printf()
*/ */
EAPI Eina_Bool eina_strbuf_append_vprintf(Eina_Strbuf *buf, const char *fmt , va_list args) EINA_ARG_NONNULL(1, 2); EAPI Eina_Bool eina_strbuf_append_vprintf(Eina_Strbuf *buf, const char *fmt , va_list args) EINA_ARG_NONNULL(1, 2);
/** /**
* @brief Insert a string to a buffer, reallocating as necessary. * @brief Insert a string to a buffer, reallocating as necessary.
* *
* @param buf The string buffer to insert. * @param buf The string buffer to insert.
* @param str The string to insert. * @param str The string to insert.
* @param pos The position to insert the string. * @param pos The position to insert the string.
* @return #EINA_TRUE on success, #EINA_FALSE on failure. * @return #EINA_TRUE on success, #EINA_FALSE on failure.
skipping to change at line 198 skipping to change at line 260
/** /**
* @brief Insert an escaped string to a buffer, reallocating as * @brief Insert an escaped string to a buffer, reallocating as
* necessary. * necessary.
* *
* @param buf The string buffer to insert to. * @param buf The string buffer to insert to.
* @param str The string to insert. * @param str The string to insert.
* @param pos The position to insert the string. * @param pos The position to insert the string.
* @return #EINA_TRUE on success, #EINA_FALSE on failure. * @return #EINA_TRUE on success, #EINA_FALSE on failure.
* *
* This function inserts the escaped string @p str to @p buf at * This function escapes and inserts the string @p str to @p buf at
* position @p pos. If @p buf can't insert @p str, #EINA_FALSE is * position @p pos. If @p buf can't insert @p str, #EINA_FALSE is
* returned, otherwise #EINA_TRUE is returned. * returned, otherwise #EINA_TRUE is returned.
*/ */
EAPI Eina_Bool eina_strbuf_insert_escaped(Eina_Strbuf *buf, const char *str , size_t pos) EINA_ARG_NONNULL(1, 2); EAPI Eina_Bool eina_strbuf_insert_escaped(Eina_Strbuf *buf, const char *str , size_t pos) EINA_ARG_NONNULL(1, 2);
/** /**
* @brief Insert a string to a buffer, reallocating as necessary. Limited b y maxlen. * @brief Insert a string to a buffer, reallocating as necessary. Limited b y maxlen.
* *
* @param buf The string buffer to insert to. * @param buf The string buffer to insert to.
* @param str The string to insert. * @param str The string to insert.
* @param maxlen The maximum number of chars to insert. * @param maxlen The maximum number of chars to insert.
* @param pos The position to insert the string. * @param pos The position to insert the string.
* @return #EINA_TRUE on success, #EINA_FALSE on failure. * @return #EINA_TRUE on success, #EINA_FALSE on failure.
* *
* This function inserts @p str ot @p buf at position @p pos, with at * This function inserts @p str to @p buf at position @p pos, with at
* most @p maxlen bytes. The number of inserted characters can not be * most @p maxlen bytes. The number of inserted characters can not be
* greater than the length of @p str. It computes the length of * greater than the length of @p str. It computes the length of
* @p str, so is slightly slower than eina_strbuf_insert_length(). If the * @p str, so is slightly slower than eina_strbuf_insert_length(). If the
* length is known beforehand, consider using that variant (@p maxlen * length is known beforehand, consider using that variant (@p maxlen
* should then be checked so that it is greater than the size of * should then be checked so that it is greater than the size of
* @p str). If @p str can not be inserted, #EINA_FALSE is returned, * @p str). If @p str can not be inserted, #EINA_FALSE is returned,
* otherwise, #EINA_TRUE is returned. * otherwise, #EINA_TRUE is returned.
*/ */
EAPI Eina_Bool eina_strbuf_insert_n(Eina_Strbuf *buf, const char *str, size _t maxlen, size_t pos) EINA_ARG_NONNULL(1, 2); EAPI Eina_Bool eina_strbuf_insert_n(Eina_Strbuf *buf, const char *str, size _t maxlen, size_t pos) EINA_ARG_NONNULL(1, 2);
skipping to change at line 268 skipping to change at line 330
*/ */
EAPI Eina_Bool eina_strbuf_insert_char(Eina_Strbuf *buf, char c, size_t pos ) EINA_ARG_NONNULL(1); EAPI Eina_Bool eina_strbuf_insert_char(Eina_Strbuf *buf, char c, size_t pos ) EINA_ARG_NONNULL(1);
/** /**
* @brief Insert a string to a buffer, reallocating as necessary. * @brief Insert a string to a buffer, reallocating as necessary.
* *
* @param buf The string buffer to insert. * @param buf The string buffer to insert.
* @param fmt The string to insert. * @param fmt The string to insert.
* @param pos The position to insert the string. * @param pos The position to insert the string.
* @return #EINA_TRUE on success, #EINA_FALSE on failure. * @return #EINA_TRUE on success, #EINA_FALSE on failure.
*
* This function insert a string as described by the format @p fmt to @p bu
f at
* the position @p pos. @p fmt must be of a valid format for printf family
of
* functions. If it can't insert it, #EINA_FALSE is returned, otherwise
* #EINA_TRUE is returned.
*/ */
EAPI Eina_Bool eina_strbuf_insert_printf(Eina_Strbuf *buf, const char *fmt, size_t pos, ...) EINA_ARG_NONNULL(1, 2) EINA_PRINTF(2, 4); EAPI Eina_Bool eina_strbuf_insert_printf(Eina_Strbuf *buf, const char *fmt, size_t pos, ...) EINA_ARG_NONNULL(1, 2) EINA_PRINTF(2, 4);
/** /**
* @brief Insert a string to a buffer, reallocating as necessary. * @brief Insert a string to a buffer, reallocating as necessary.
* *
* @param buf The string buffer to insert. * @param buf The string buffer to insert.
* @param fmt The string to insert. * @param fmt The string to insert.
* @param pos The position to insert the string. * @param pos The position to insert the string.
* @param args The variable arguments. * @param args The variable arguments.
* @return #EINA_TRUE on success, #EINA_FALSE on failure. * @return #EINA_TRUE on success, #EINA_FALSE on failure.
*
* @see eina_strbuf_insert_printf
*/ */
EAPI Eina_Bool eina_strbuf_insert_vprintf(Eina_Strbuf *buf, const char *fmt , size_t pos, va_list args) EINA_ARG_NONNULL(1, 2); EAPI Eina_Bool eina_strbuf_insert_vprintf(Eina_Strbuf *buf, const char *fmt , size_t pos, va_list args) EINA_ARG_NONNULL(1, 2);
/** /**
* @def eina_strbuf_prepend(buf, str) * @def eina_strbuf_prepend(buf, str)
* @brief Prepend the given string to the given buffer * @brief Prepend the given string to the given buffer
* *
* @param buf The string buffer to prepend to. * @param buf The string buffer to prepend to.
* @param str The string to prepend. * @param str The string to prepend.
* @return #EINA_TRUE on success, #EINA_FALSE on failure. * @return #EINA_TRUE on success, #EINA_FALSE on failure.
* *
* This macro is calling eina_strbuf_insert() at position 0.If @p buf * This macro is calling eina_strbuf_insert() at position 0. If @p buf
* can't prepend it, #EINA_FALSE is returned, otherwise #EINA_TRUE is * can't prepend it, #EINA_FALSE is returned, otherwise #EINA_TRUE is
* returned. * returned.
*/ */
#define eina_strbuf_prepend(buf, str) eina_strbuf_insert(buf , str, 0) #define eina_strbuf_prepend(buf, str) eina_strbuf_insert(buf , str, 0)
/** /**
* @def eina_strbuf_prepend_escaped(buf, str) * @def eina_strbuf_prepend_escaped(buf, str)
* @brief Prepend the given escaped string to the given buffer * @brief Prepend the given escaped string to the given buffer
* *
* @param buf The string buffer to prepend to. * @param buf The string buffer to prepend to.
skipping to change at line 409 skipping to change at line 478
/** /**
* @brief Retrieve a pointer to the contents of a string buffer * @brief Retrieve a pointer to the contents of a string buffer
* *
* @param buf The string buffer. * @param buf The string buffer.
* @return The current string in the string buffer. * @return The current string in the string buffer.
* *
* This function returns the string contained in @p buf. The returned * This function returns the string contained in @p buf. The returned
* value must not be modified and will no longer be valid if @p buf is * value must not be modified and will no longer be valid if @p buf is
* modified. In other words, any eina_strbuf_append() or similar will * modified. In other words, any eina_strbuf_append() or similar will
* make that pointer invalid. * make that pointer invalid. The pointer returned by this function <b>must
* not</b> be freed.
* *
* @see eina_strbuf_string_steal() * @see eina_strbuf_string_steal()
*/ */
EAPI const char *eina_strbuf_string_get(const Eina_Strbuf *buf) EINA_ARG_NO NNULL(1) EINA_WARN_UNUSED_RESULT; EAPI const char *eina_strbuf_string_get(const Eina_Strbuf *buf) EINA_ARG_NO NNULL(1) EINA_WARN_UNUSED_RESULT;
/** /**
* @brief Steal the contents of a string buffer. * @brief Steal the contents of a string buffer.
* *
* @param buf The string buffer to steal. * @param buf The string buffer to steal.
* @return The current string in the string buffer. * @return The current string in the string buffer.
skipping to change at line 450 skipping to change at line 520
/** /**
* @brief Retrieve the length of the string buffer content. * @brief Retrieve the length of the string buffer content.
* *
* @param buf The string buffer. * @param buf The string buffer.
* @return The current length of the string, in bytes. * @return The current length of the string, in bytes.
* *
* This function returns the length of @p buf. * This function returns the length of @p buf.
*/ */
EAPI size_t eina_strbuf_length_get(const Eina_Strbuf *buf) EINA_ARG_NONN ULL(1) EINA_WARN_UNUSED_RESULT; EAPI size_t eina_strbuf_length_get(const Eina_Strbuf *buf) EINA_ARG_NONN ULL(1) EINA_WARN_UNUSED_RESULT;
/**
* @brief Replace the n-th string with an other string.
*
* @param buf The string buffer to work with.
* @param str The string to replace.
* @param with The replaceing string.
* @param n The number of the fitting string.
* @return #EINA_TRUE on success, #EINA_FALSE on failure.
*
* This function replaces the n-th occurrence of @p str in @p buf with
* @p with. It returns #EINA_FALSE on failure, #EINA_TRUE otherwise.
*/
EAPI Eina_Bool eina_strbuf_replace(Eina_Strbuf *buf, const char *str, const char *with, unsigned int n) EINA_ARG_NONNULL(1, 2, 3); EAPI Eina_Bool eina_strbuf_replace(Eina_Strbuf *buf, const char *str, const char *with, unsigned int n) EINA_ARG_NONNULL(1, 2, 3);
/** /**
* @def eina_strbuf_replace_first(buf, str, with) * @def eina_strbuf_replace_first(buf, str, with)
* @brief Prepend the given character to the given buffer * @brief Prepend the given character to the given buffer
* *
* @param buf The string buffer to work with. * @param buf The string buffer to work with.
* @param str The string to replace. * @param str The string to replace.
* @param with The replaceing string. * @param with The replaceing string.
* @return #EINA_TRUE on success, #EINA_FALSE on failure. * @return #EINA_TRUE on success, #EINA_FALSE on failure.
* *
* This macro is calling eina_strbuf_replace() with the n-th occurrence * This macro is calling eina_strbuf_replace() with the n-th occurrence
* equal to @c 1. If @p buf can't replace it, #EINA_FALSE is returned, * equal to @c 1. If @p buf can't replace it, #EINA_FALSE is returned,
* otherwise #EINA_TRUE is returned. * otherwise #EINA_TRUE is returned.
*/ */
#define eina_strbuf_replace_first(buf, str, with) eina_strbuf_replace(buf, str, with, 1) #define eina_strbuf_replace_first(buf, str, with) eina_strbuf_replace(buf, str, with, 1)
/**
* @brief Replace all strings with an other string.
* @param buf the string buffer to work with.
* @param str The string to replace.
* @param with The replaceing string.
* @return How often the string was replaced.
*
* This function replaces all the occurrences of @p str in @p buf with
* the string @p with. This function returns the number of times @p str
* has been replaced. On failure, it returns 0.
*/
EAPI int eina_strbuf_replace_all(Eina_Strbuf *buf, const char *str, const c har *with) EINA_ARG_NONNULL(1, 2, 3); EAPI int eina_strbuf_replace_all(Eina_Strbuf *buf, const char *str, const c har *with) EINA_ARG_NONNULL(1, 2, 3);
/** /**
* @brief Trim the string buffer
* @param buf the string buffer to work with.
*
* This function skips whitespaces in the beginning and the end of the buff
er.
*/
EAPI void eina_strbuf_trim(Eina_Strbuf *buf) EINA_ARG_NONNULL(1);
/**
* @brief Left trim the string buffer
* @param buf the string buffer to work with.
*
* This function skips whitespaces in the beginning of the buffer.
*/
EAPI void eina_strbuf_ltrim(Eina_Strbuf *buf) EINA_ARG_NONNULL(1);
/**
* @brief Right trim the string buffer
* @param buf the string buffer to work with.
*
* This function skips whitespaces in the end of the buffer.
*/
EAPI void eina_strbuf_rtrim(Eina_Strbuf *buf) EINA_ARG_NONNULL(1);
/**
* @}
*/
/**
* @} * @}
*/ */
/** /**
* @} * @}
*/ */
#endif /* EINA_STRBUF_H */ #endif /* EINA_STRBUF_H */
 End of changes. 16 change blocks. 
11 lines changed or deleted 145 lines changed or added


 eina_stringshare.h   eina_stringshare.h 
skipping to change at line 59 skipping to change at line 59
*/ */
#ifndef EINA_STRINGSHARE_H_ #ifndef EINA_STRINGSHARE_H_
#define EINA_STRINGSHARE_H_ #define EINA_STRINGSHARE_H_
#include <stdarg.h> #include <stdarg.h>
#include "eina_types.h" #include "eina_types.h"
/** /**
* @page eina_stringshare_example_01_page
* @dontinclude eina_stringshare_01.c
*
* Like all examples we start by including Eina:
* @skip #include
* @line #include
*
* Here we declare some variables and initialize eina:
* @until eina_init
*
* We start the substantive part of the example by showing how to make a pa
rt
* of a string shared and how to get the length of a shared string:
* @until stringshare_strlen
* As we add shared strings we also need to delete them when done using the
m:
* @line del
*
* There are many ways of creating shared strings including an equivalent t
o
* sprintf:
* @until del
*
* An equivalent to snprintf:
* @until printf
*
* But the simplest way of creating a shared string is through
* eina_stringshare_add():
* @until printf
*
* Sometimes you already have a pointer to a shared string and want to use
it,
* so to make sure the provider of the pointer won't free it while you're u
sing
* it you can increase the shared string's ref count:
* @until printf
*
* Whenever you have a pointer to a shared string and would like to change
it's
* value you should use eina_stringshare_replace():
* @until printf
* @warning @b Don't use eina_stringshare_del() followed by
* eina_share_common_add(), under some circunstances you might end up delet
ing
* a shared string some other piece of code is using.
*
* We created str but haven't deleted it yet, and while we called
* eina_stringshare_del() on str2, we created it and then increased the ref
* count so it's still alive:
* @until str2
*
* You can see the full source code @ref eina_stringshare_example_01 "here"
.
*/
/**
* @page eina_stringshare_example_01
* @include eina_stringshare_01.c
* @example eina_stringshare_01.c
*/
/**
* @addtogroup Eina_Stringshare_Group Stringshare
*
* These functions allow you to store a single copy of a string, and use in
* multiple places throughout your program.
*
* This is a method to reduce the number of duplicated strings kept in
* memory. It's pretty common for the same strings to be dynamically
* allocated repeatedly between applications and libraries, especially in
* circumstances where you could have multiple copies of a structure that
* allocates the string. So rather than duplicating and freeing these
* strings, you request a read-only pointer to an existing string and
* only incur the overhead of a hash lookup.
*
* It sounds like micro-optimizing, but profiling has shown this can have
* a significant impact as you scale the number of copies up. It improves
* string creation/destruction speed, reduces memory use and decreases
* memory fragmentation, so a win all-around.
*
* The following diagram gives an idea of what happens as you create string
s
* with eina_stringshare_add():
*
* @image html eina_stringshare.png
* @image latex eina_stringshare.eps height=\textheight
*
* For more information, see @ref eina_stringshare_example_01_page
* "this example".
*/
/**
* @addtogroup Eina_Data_Types_Group Data Types * @addtogroup Eina_Data_Types_Group Data Types
* *
* @{ * @{
*/ */
/** /**
* @defgroup Eina_Stringshare_Group Stringshare * @defgroup Eina_Stringshare_Group Stringshare
* *
* @{ * @{
*/ */
/**
* @brief Retrieve an instance of a string for use in a program.
*
* @param str The string to retrieve an instance of.
* @param slen The string size (<= strlen(str)).
* @return A pointer to an instance of the string on success.
* @c NULL on failure.
*
* This function retrieves an instance of @p str. If @p str is
* @c NULL, then @c NULL is returned. If @p str is already stored, it
* is just returned and its reference counter is increased. Otherwise
* a duplicated string of @p str is returned.
*
* This function does not check string size, but uses the
* exact given size. This can be used to share_common part of a larger
* buffer or substring.
*
* @see eina_share_common_add()
*/
EAPI const char *eina_stringshare_add_length(const char *str, unsign ed int slen) EINA_WARN_UNUSED_RESULT; EAPI const char *eina_stringshare_add_length(const char *str, unsign ed int slen) EINA_WARN_UNUSED_RESULT;
/**
* @brief Retrieve an instance of a string for use in a program.
*
* @param str The NULL terminated string to retrieve an instance of.
* @return A pointer to an instance of the string on success.
* @c NULL on failure.
*
* This function retrieves an instance of @p str. If @p str is
* @c NULL, then @c NULL is returned. If @p str is already stored, it
* is just returned and its reference counter is increased. Otherwise
* a duplicated string of @p str is returned.
*
* The string @p str must be NULL terminated ('@\0') and its full
* length will be used. To use part of the string or non-null
* terminated, use eina_stringshare_add_length() instead.
*
* @see eina_stringshare_add_length()
*/
EAPI const char *eina_stringshare_add(const char *str) EINA_WARN_UNU SED_RESULT; EAPI const char *eina_stringshare_add(const char *str) EINA_WARN_UNU SED_RESULT;
/**
* @brief Retrieve an instance of a string for use in a program
* from a format string.
*
* @param fmt The NULL terminated format string to retrieve an instance o
f.
* @return A pointer to an instance of the string on success.
* @c NULL on failure.
*
* This function retrieves an instance of @p fmt. If @p fmt is
* @c NULL, then @c NULL is returned. If @p fmt is already stored, it
* is just returned and its reference counter is increased. Otherwise
* a duplicated string is returned.
*
* The format string @p fmt must be NULL terminated ('@\0') and its full
* length will be used. To use part of the format string or non-null
* terminated, use eina_stringshare_nprintf() instead.
*
* @see eina_stringshare_nprintf()
*/
EAPI const char *eina_stringshare_printf(const char *fmt, ...) EINA_ WARN_UNUSED_RESULT EINA_PRINTF(1, 2); EAPI const char *eina_stringshare_printf(const char *fmt, ...) EINA_ WARN_UNUSED_RESULT EINA_PRINTF(1, 2);
/**
* @brief Retrieve an instance of a string for use in a program
* from a format string.
*
* @param fmt The NULL terminated format string to retrieve an instance o
f.
* @param args The va_args for @p fmt
* @return A pointer to an instance of the string on success.
* @c NULL on failure.
*
* This function retrieves an instance of @p fmt with @p args. If @p fmt is
* @c NULL, then @c NULL is returned. If @p fmt with @p args is already sto
red, it
* is just returned and its reference counter is increased. Otherwise
* a duplicated string is returned.
*
* The format string @p fmt must be NULL terminated ('@\0') and its full
* length will be used. To use part of the format string or non-null
* terminated, use eina_stringshare_nprintf() instead.
*
* @see eina_stringshare_nprintf()
*/
EAPI const char *eina_stringshare_vprintf(const char *fmt, va_list a rgs) EINA_WARN_UNUSED_RESULT; EAPI const char *eina_stringshare_vprintf(const char *fmt, va_list a rgs) EINA_WARN_UNUSED_RESULT;
/**
* @brief Retrieve an instance of a string for use in a program
* from a format string with size limitation.
* @param len The length of the format string to use
* @param fmt The format string to retrieve an instance of.
* @return A pointer to an instance of the string on success.
* @c NULL on failure.
*
* This function retrieves an instance of @p fmt limited by @p len. If @p f
mt is
* @c NULL or @p len is < 1, then @c NULL is returned. If the resulting str
ing
* is already stored, it is returned and its reference counter is increased
.
* Otherwise a duplicated string is returned.
*
* @p len length of the format string will be used. To use the
* entire format string, use eina_stringshare_printf() instead.
*
* @see eina_stringshare_printf()
*/
EAPI const char *eina_stringshare_nprintf(unsigned int len, const ch ar *fmt, ...) EINA_WARN_UNUSED_RESULT EINA_PRINTF(2, 3); EAPI const char *eina_stringshare_nprintf(unsigned int len, const ch ar *fmt, ...) EINA_WARN_UNUSED_RESULT EINA_PRINTF(2, 3);
/**
* Increment references of the given shared string.
*
* @param str The shared string.
* @return A pointer to an instance of the string on success.
* @c NULL on failure.
*
* This is similar to eina_share_common_add(), but it's faster since it wil
l
* avoid lookups if possible, but on the down side it requires the paramete
r
* to be shared string. In other words, it must be the return of a previous
* call to one of the stringshare functions.
*
* There is no unref since this is the work of eina_share_common_del().
*/
EAPI const char *eina_stringshare_ref(const char *str); EAPI const char *eina_stringshare_ref(const char *str);
/**
* @brief Note that the given string has lost an instance.
*
* @param str string The given string.
*
* This function decreases the reference counter associated to @p str
* if it exists. If that counter reaches 0, the memory associated to
* @p str is freed. If @p str is NULL, the function returns
* immediately.
*
* Note that if the given pointer is not shared or NULL, bad things
* will happen, likely a segmentation fault.
*/
EAPI void eina_stringshare_del(const char *str); EAPI void eina_stringshare_del(const char *str);
/**
* @brief Note that the given string @b must be shared.
*
* @param str the shared string to know the length. It is safe to
* give NULL, in that case -1 is returned.
*
* This function is a cheap way to known the length of a shared
* string. Note that if the given pointer is not shared, bad
* things will happen, likely a segmentation fault. If in doubt, try
* strlen().
*/
EAPI int eina_stringshare_strlen(const char *str) EINA_PURE EINA_WARN_UNUSED_RESULT; EAPI int eina_stringshare_strlen(const char *str) EINA_PURE EINA_WARN_UNUSED_RESULT;
/**
* @brief Dump the contents of the share_common.
*
* This function dumps all strings in the share_common to stdout with a
* DDD: prefix per line and a memory usage summary.
*/
EAPI void eina_stringshare_dump(void); EAPI void eina_stringshare_dump(void);
static inline Eina_Bool eina_stringshare_replace(const char **p_str, const char *news) EINA_ARG_NONNULL(1); static inline Eina_Bool eina_stringshare_replace(const char **p_str, const char *news) EINA_ARG_NONNULL(1);
static inline Eina_Bool eina_stringshare_replace_length(const char **p_str, const char *news, unsigned int slen) EINA_ARG_NONNULL(1); static inline Eina_Bool eina_stringshare_replace_length(const char **p_str, const char *news, unsigned int slen) EINA_ARG_NONNULL(1);
#include "eina_inline_stringshare.x" #include "eina_inline_stringshare.x"
/** /**
* @} * @}
*/ */
 End of changes. 10 change blocks. 
0 lines changed or deleted 244 lines changed or added


 eina_tiler.h   eina_tiler.h 
skipping to change at line 27 skipping to change at line 27
*/ */
#ifndef EINA_TILER_H_ #ifndef EINA_TILER_H_
#define EINA_TILER_H_ #define EINA_TILER_H_
#include "eina_types.h" #include "eina_types.h"
#include "eina_iterator.h" #include "eina_iterator.h"
#include "eina_rectangle.h" #include "eina_rectangle.h"
/** /**
* @page eina_tiler_example_01
* @dontinclude eina_tiler_01.c
*
* This is an example that illustrates how Eina_Tiler works for a given set
of
* rectangles. The rectangles must be given in the command line in the form
:
* <width>x<height>+<x offset>+<y offset>
* The example will show two panels, the first(input) will show the given
* rectangles(in different colors) and in the seconds(output) it will show
the
* rectangles given by the tiler. The rectangles will be added one by one e
very
* two seconds. A lot of the example deals with actually painting the recta
ngles
* so we'll skip over quite a bit of code, but you can see all of it in @re
f
* eina_tiler_01.c "eina_tiler_01.c".
*
* The first thing of note in our example is the creation of the tiler:
* @skipline eina_tiler_new
* @note @p maxw and @p maxh are calculated such that the tiler's size will
* fully encompass all given rectangles.
*
* We'll now look at the function that actually adds rectangles to our tile
r. It
* first checks if we added all rectangles already and if so stops right th
ere:
* @dontinclude eina_tiler_01.c
* @skip static Eina_Bool
* @until }
*
* Our function then clears all rectangles given to us by tiler from the la
st
* execution. It does this because each rectangle we add may change everyth
ing
* about the output of eina_tiler:
* @until output_rects_reset
*
* Next we get another rectangle, print it and show it in the input panel:
* @until add_input_rect
*
* We now come to the tiler stuff, we add our new rectangle to it and get a
new
* iterator for the tiler:
* @until itr
*
* We now iterate over our tiler printing every rect it gives us and sowing
it
* in the output panel:
* @until }
*
* We of course must remember to free our iterator and that's it for this
* function:
* @until }
*
* You should try many different inputs to see how the tiler works, here ar
e a
* few suggestions:
* @li 100x100+0+0 100x100+200+200
* @li 100x100+0+0 100x100+5+5 100x100+10+10 100x100+15+15 100x100+20+20
* @li 100x100+0+0 100x100+100+100 100x100+200+0 100x100+0+200 100x100+200+
200
* @li 10x10+0+0 10x10+10+10 10x10+20+0 10x10+0+20 10x10+20+20
*
* @example eina_tiler_01.c
*/
/**
* @addtogroup Eina_Data_Types_Group Data Types * @addtogroup Eina_Data_Types_Group Data Types
* *
* @{ * @{
*/ */
/** /**
* @defgroup Eina_Tiler_Group Tiler * @defgroup Eina_Tiler_Group Tiler
* *
* @warning This is a very low level tool, in most situations(for example i
f
* you're using evas) you won't need this.
*
* @section basic Basic usage
*
* Eina_Tiler is a tool to facilitate calculations of which areas are damag
ed
* and thus need to be re-rendered. The basic usage of Eina_Tiler is to giv
e it
* the size of your canvas and a set of rectangular areas that need
* re-rendering, from that and using heuristics it'll tell you an efficient
way
* to re-render in the form of a set of non-overlapping rectangles that cov
ers
* the whole area that needs re-rendering.
*
* The following is pseudo-code showing some simple use of Eina_Tiler:
* @code
* tiler = eina_tiler_new(MY_CANVAS_WIDTH, MY_CANVAS_HEIGHT);
* EINA_LIST_FOREACH(list_of_areas_that_need_re_rendering, l, rect)
* eina_tiler_add(tiler, rect);
* itr = eina_tiler_iterator_new(tiler);
* EINA_ITERATOR_FOREACH(itr, rect)
* my_function_that_repaints_areas_of_the_canvas(rect);
* @endcode
*
* @see eina_tiler_new()
* @see eina_tiler_rect_add()
* @see eina_tiler_iterator_new()
*
* @warning There are no guarantees that this will be the most efficient wa
y to
* re-render for any particular case.
*
* @section grid_slicer Grid Slicer
*
* Grid slicer and Eina_Tiler are usually used together, that is however @b
not
* nescessary, they can be used independently. Grid slicer provides an easy
API
* to divide an area in tiles which is usefull in certain applications to d
ivide
* the area that will be rendered into tiles. It's customary to, then creat
e one
* Eina_Tiler for each tile.
*
* The following is pseudo-code showing a very simplified use of grid slice
r
* together with Eina_Tiler:
* @code
* itr = eina_tile_grid_slicer_iterator_new(0, 0, MY_CANVAS_WIDTH, MY_CANVA
S_HEIGHT, TILE_WIDTH, TILE_HEIGHT);
* EINA_ITERATOR_FOREACH(itr, grid_info)
* {
* tiler = eina_tiler_new(grid_info->rect.w, grid_info->rect.w);
* EINA_LIST_FOREACH(list_of_areas_that_need_re_rendering_in_this_tile
, l, rect)
* eina_tiler_add(tiler, rect);
* itr = eina_tiler_iterator_new(tiler);
* EINA_ITERATOR_FOREACH(itr, rect)
* my_function_that_repaints_areas_of_the_canvas(rect);
* }
* @endcode
*
* @see eina_tiler_new()
* @see eina_tiler_rect_add()
* @see eina_tile_grid_slicer_setup()
* @see eina_tile_grid_slicer_next()
* @see eina_tile_grid_slicer_iterator_new()
*
* @{ * @{
*/ */
/** /**
* @typedef Eina_Tiler * @typedef Eina_Tiler
* Tiler type. * Tiler type.
*/ */
typedef struct _Eina_Tiler Eina_Tiler; typedef struct _Eina_Tiler Eina_Tiler;
/** /**
skipping to change at line 56 skipping to change at line 168
* Grid type of a tiler. * Grid type of a tiler.
*/ */
typedef struct Eina_Tile_Grid_Info Eina_Tile_Grid_Info; typedef struct Eina_Tile_Grid_Info Eina_Tile_Grid_Info;
/** /**
* @struct Eina_Tile_Grid_Info * @struct Eina_Tile_Grid_Info
* Grid type of a tiler. * Grid type of a tiler.
*/ */
struct Eina_Tile_Grid_Info struct Eina_Tile_Grid_Info
{ {
unsigned long col; /**< column of the tiler grid */ unsigned long col; /**< column of the tile grid */
unsigned long row; /**< row of the tiler grid*/ unsigned long row; /**< row of the tile grid*/
Eina_Rectangle rect; /**< rectangle of the tiler grid*/ Eina_Rectangle rect; /**< rectangle of the tile grid, coordinates are
relative to tile*/
Eina_Bool full; /**< whether the grid is full or not */ Eina_Bool full; /**< whether the grid is full or not */
}; };
typedef struct _Eina_Tile_Grid_Slicer Eina_Tile_Grid_Slicer; typedef struct _Eina_Tile_Grid_Slicer Eina_Tile_Grid_Slicer;
/**
* @brief Creates a new tiler with @p w width and @p h height.
*
* @param w Width of the tiler
* @param h Height of the tiler
* @return The newly created tiler
*
* @see eina_tiler_free()
*/
EAPI Eina_Tiler *eina_tiler_new(int w, int h); EAPI Eina_Tiler *eina_tiler_new(int w, int h);
/**
* @brief Frees a tiler.
*
* @param t The tiler to free.
*
* This function frees @p t. It does not free the memory allocated for the
* elements of @p t.
*/
EAPI void eina_tiler_free(Eina_Tiler *t); EAPI void eina_tiler_free(Eina_Tiler *t);
/**
* @brief Sets the size of tiles for a tiler.
*
* @param t The tiler whose tile size will be set.
* @param w Width of the tiles.
* @param h Height of the tiles.
*
* @warning @p w and @p h @b must be greater than zero, otherwise tile size
* won't be changed.
* @warning Tile size is not used!
*/
EAPI void eina_tiler_tile_size_set(Eina_Tiler *t, int w, int h); EAPI void eina_tiler_tile_size_set(Eina_Tiler *t, int w, int h);
/**
* @brief Adds a rectangle to a tiler.
*
* @param t The tiler in which to add a container.
* @param r The rectangle to be added.
*
* @see eina_tiler_rect_del()
*/
EAPI Eina_Bool eina_tiler_rect_add(Eina_Tiler *t, const Eina_Recta ngle *r); EAPI Eina_Bool eina_tiler_rect_add(Eina_Tiler *t, const Eina_Recta ngle *r);
/**
* @brief Removes a rectangle from a tiler.
*
* @param t The tiler in which to add a container.
* @param r The rectangle to be removed.
*
* @see eina_tiler_rect_add()
* @see eina_tiler_clear()
*/
EAPI void eina_tiler_rect_del(Eina_Tiler *t, const Eina_Recta ngle *r); EAPI void eina_tiler_rect_del(Eina_Tiler *t, const Eina_Recta ngle *r);
/**
* @brief Removes all rectangles from tiles.
*
* @param t The tiler to clear.
*
* @see eina_tiler_rect_del()
*/
EAPI void eina_tiler_clear(Eina_Tiler *t); EAPI void eina_tiler_clear(Eina_Tiler *t);
/**
* @brief Create a iterator to access the tilers calculated rectangles.
*
* @param t The tiler to iterate over.
* @return A iterator containing Eina_Rectangle.
*/
EAPI Eina_Iterator *eina_tiler_iterator_new(const Eina_Tiler *t); EAPI Eina_Iterator *eina_tiler_iterator_new(const Eina_Tiler *t);
/**
* @brief Creates a new Eina_Iterator that iterates over a list of tiles.
*
* @param x X axis coordinate.
* @param y Y axis coordinate.
* @param w width.
* @param h height.
* @param tile_w tile width.
* @param tile_h tile height.
* @return A pointer to the Eina_Iterator. @c NULL on failure.
*
* The region defined by @a x, @a y, @a w, @a h will be divided in to a gri
d of
* tiles of width @a tile_w and height @p tile_h, the returned iterator wil
l
* iterate over every tile in the grid having as its data a
* #Eina_Tile_Grid_Info.
*
* @note This is a convinience function, iterating over the returned iterat
or is
* equivalent to calling eina_tile_grid_slicer_setup() and calling
* eina_tile_grid_slicer_next() untill it returns EINA_FALSE.
*/
EAPI Eina_Iterator *eina_tile_grid_slicer_iterator_new(int x, int y, in t w, int h, int tile_w, int tile_h); EAPI Eina_Iterator *eina_tile_grid_slicer_iterator_new(int x, int y, in t w, int h, int tile_w, int tile_h);
/**
* @brief Iterates over the tiles set by eina_tile_grid_slicer_setup().
*
* @param slc Pointer to an Eina_Tile_Grid_Slicer struct.
* @param rect Pointer to a struct Eina_Tile_Grid_Info *.
* @return @c EINA_TRUE if the current rect is valid.
* @c EINA_FALSE if there is no more rects to iterate over (and
* thus the current one isn't valid).
*
* This functions iterates over each Eina_Tile_Grid_Info *rect of the grid.
* eina_tile_grid_slicer_setup() must be called first, and *rect is only va
lid
* if this function returns EINA_TRUE. Its content shouldn't be modified.
*
* @note Consider using eina_tile_grid_slicer_iterator_new() instead.
*/
static inline Eina_Bool eina_tile_grid_slicer_next(Eina_Tile_Grid_Slicer *s lc, const Eina_Tile_Grid_Info **rect); static inline Eina_Bool eina_tile_grid_slicer_next(Eina_Tile_Grid_Slicer *s lc, const Eina_Tile_Grid_Info **rect);
/**
* @brief Setup an Eina_Tile_Grid_Slicer struct.
*
* @param slc Pointer to an Eina_Tile_Grid_Slicer struct.
* @param x X axis coordinate.
* @param y Y axis coordinate.
* @param w width.
* @param h height.
* @param tile_w tile width.
* @param tile_h tile height.
* @return A pointer to the Eina_Iterator. @c NULL on failure.
*
* The region defined by @a x, @a y, @a w, @a h will be divided in to a gri
d of
* tiles of width @a tile_w and height @p tile_h, @p slc can then be used w
ith
* eina_tile_grid_slicer_next() to access each tile.
*
* @note Consider using eina_tile_grid_slicer_iterator_new() instead.
*/
static inline Eina_Bool eina_tile_grid_slicer_setup(Eina_Tile_Grid_Slicer * slc, int x, int y, int w, int h, int tile_w, int tile_h); static inline Eina_Bool eina_tile_grid_slicer_setup(Eina_Tile_Grid_Slicer * slc, int x, int y, int w, int h, int tile_w, int tile_h);
#include "eina_inline_tiler.x" #include "eina_inline_tiler.x"
/** /**
* @} * @}
*/ */
/** /**
* @} * @}
 End of changes. 13 change blocks. 
3 lines changed or deleted 261 lines changed or added


 eina_unicode.h   eina_unicode.h 
skipping to change at line 42 skipping to change at line 42
# include <inttypes.h> # include <inttypes.h>
typedef uint32_t Eina_Unicode; typedef uint32_t Eina_Unicode;
#elif defined(EINA_HAVE_STDINT_H) #elif defined(EINA_HAVE_STDINT_H)
# include <stdint.h> # include <stdint.h>
typedef uint32_t Eina_Unicode; typedef uint32_t Eina_Unicode;
#else #else
/* Hope that int is big enough */ /* Hope that int is big enough */
typedef unsigned int Eina_Unicode; typedef unsigned int Eina_Unicode;
#endif #endif
/**
* @brief Same as the standard strlen just with Eina_Unicode instead of cha
r.
*/
EAPI extern const Eina_Unicode *EINA_UNICODE_EMPTY_STRING; EAPI extern const Eina_Unicode *EINA_UNICODE_EMPTY_STRING;
EAPI size_t eina_unicode_strlen(const Eina_Unicode *ustr) EINA_ARG_N ONNULL(1) EINA_WARN_UNUSED_RESULT EINA_PURE; EAPI size_t eina_unicode_strlen(const Eina_Unicode *ustr) EINA_ARG_N ONNULL(1) EINA_WARN_UNUSED_RESULT EINA_PURE;
/**
* @brief Returns the length of a Eina_Unicode string, up to a limit.
*
* This function returns the number of characters in string, up to a maximu
m
* of n. If the terminating character is not found in the string, it retur
ns
* n.
*
* @param ustr String to search
* @param n Max length to search
* @return Number of characters or n.
*/
EAPI size_t eina_unicode_strnlen(const Eina_Unicode *ustr, int n) EI NA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT EINA_PURE; EAPI size_t eina_unicode_strnlen(const Eina_Unicode *ustr, int n) EI NA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT EINA_PURE;
/**
* @brief Same as the standard strdup just with Eina_Unicode instead of cha
r.
*/
EAPI Eina_Unicode *eina_unicode_strdup(const Eina_Unicode *text) EINA_WARN_ UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_MALLOC; EAPI Eina_Unicode *eina_unicode_strdup(const Eina_Unicode *text) EINA_WARN_ UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_MALLOC;
/**
* @brief Same as strdup but cuts on n. Assumes n < len
* @since 1.1.0
*/
EAPI Eina_Unicode *eina_unicode_strndup(const Eina_Unicode *text, size_t n)
EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_MALLOC;
/**
* @brief Same as the standard strcmp just with Eina_Unicode instead of cha
r.
*/
EAPI int eina_unicode_strcmp(const Eina_Unicode *a, const Eina_Un icode *b) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1, 2) EINA_PURE; EAPI int eina_unicode_strcmp(const Eina_Unicode *a, const Eina_Un icode *b) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1, 2) EINA_PURE;
/**
* @brief Same as the standard strcpy just with Eina_Unicode instead of cha
r.
*/
EAPI Eina_Unicode *eina_unicode_strcpy(Eina_Unicode *dest, const Eina_Unico de *source) EINA_ARG_NONNULL(1, 2); EAPI Eina_Unicode *eina_unicode_strcpy(Eina_Unicode *dest, const Eina_Unico de *source) EINA_ARG_NONNULL(1, 2);
/**
* @brief Same as the standard strstr just with Eina_Unicode instead of cha
r.
*/
EAPI Eina_Unicode *eina_unicode_strstr(const Eina_Unicode *haystack, const Eina_Unicode *needle) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1, 2) EINA_P URE; EAPI Eina_Unicode *eina_unicode_strstr(const Eina_Unicode *haystack, const Eina_Unicode *needle) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1, 2) EINA_P URE;
/**
* @brief Same as the standard strncpy just with Eina_Unicode instead of ch
ar.
*/
EAPI Eina_Unicode *eina_unicode_strncpy(Eina_Unicode *dest, const Eina_Unic ode *source, size_t n) EINA_ARG_NONNULL(1, 2); EAPI Eina_Unicode *eina_unicode_strncpy(Eina_Unicode *dest, const Eina_Unic ode *source, size_t n) EINA_ARG_NONNULL(1, 2);
/**
* @see eina_str_escape()
*/
EAPI Eina_Unicode *eina_unicode_escape(const Eina_Unicode *str) EINA_ARG_NO NNULL(1) EINA_MALLOC EINA_WARN_UNUSED_RESULT; EAPI Eina_Unicode *eina_unicode_escape(const Eina_Unicode *str) EINA_ARG_NO NNULL(1) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
/* UTF-8 Handling */
/**
* Reads UTF8 bytes from @buf, starting at *@index and returns
* the decoded code point at iindex offset, and advances iindex
* to the next code point after this. iindex is always advanced,
* unless if the advancement is after the NULL.
* On error: return a codepoint between DC80 to DCFF where the low 8 bits
* are the byte's value.
*
* @param buf the string
* @param iindex the index to look at and return by.
* @return the codepoint found.
* @since 1.1.0
*/
EAPI Eina_Unicode eina_unicode_utf8_get_next(const char *buf, int *iindex)
EINA_ARG_NONNULL(1, 2);
/**
* Reads UTF8 bytes from @buf, starting at *@iindex and returns
* the decoded code point at iindex offset, and moves iindex
* to the previous code point. iindex is always moved, as long
* as it's not past the start of the string.
* On error: return a codepoint between DC80 to DCFF where the low 8 bits
* are the byte's value.
*
* @param buf the string
* @param iindex the index to look at and return by.
* @return the codepoint found.
* @since 1.1.0
*/
EAPI Eina_Unicode eina_unicode_utf8_get_prev(const char *buf, int *iindex)
EINA_ARG_NONNULL(1, 2);
/**
* Returns the number of unicode characters in the string. That is,
* the number of Eina_Unicodes it'll take to store this string in
* an Eina_Unicode string.
*
* @param buf the string
* @return the number of unicode characters (not bytes) in the string
* @since 1.1.0
*/
EAPI int eina_unicode_utf8_get_len(const char *buf) EINA_ARG_NONNULL(1);
/**
* Converts a utf-8 string to a newly allocated Eina_Unicode string.
*
* @param utf the string in utf-8
* @param _len the length of the returned Eina_Unicode string.
* @return the newly allocated Eina_Unicode string.
* @since 1.1.0
*/
EAPI Eina_Unicode *eina_unicode_utf8_to_unicode(const char *utf, int *_len)
EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_MALLOC;
/**
* Converts an Eina_Unicode string to a newly allocated utf-8 string.
*
* @param uni the Eina_Unicode string
* @param _len the length byte length of the return utf8 string.
* @return the newly allocated utf-8 string.
* @since 1.1.0
*/
EAPI char * eina_unicode_unicode_to_utf8(const Eina_Unicode *uni, int *_len
) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_MALLOC;
/** /**
* @} * @}
*/ */
/** /**
* @} * @}
*/ */
#endif #endif
 End of changes. 9 change blocks. 
0 lines changed or deleted 115 lines changed or added


 eina_ustrbuf.h   eina_ustrbuf.h 
#ifndef EINA_USTRBUF_H #ifndef EINA_USTRBUF_H
#define EINA_USTRBUF_H #define EINA_USTRBUF_H
#include <stddef.h> #include <stddef.h>
#include "eina_types.h" #include "eina_types.h"
#include "eina_unicode.h" #include "eina_unicode.h"
/** /**
* @addtogroup Eina_Unicode_String_Buffer_Group Unicode String Buffer
*
* @brief These functions provide unicode string buffers management.
*
* The Unicode String Buffer data type is designed to be a mutable string,
* allowing to append, prepend or insert a string to a buffer.
*/
/**
* @addtogroup Eina_Data_Types_Group Data Types * @addtogroup Eina_Data_Types_Group Data Types
* *
* @{ * @{
*/ */
/** /**
* @defgroup Eina_Unicode_String_Buffer_Group Unicode String Buffer * @defgroup Eina_Unicode_String_Buffer_Group Unicode String Buffer
* *
* @{ * @{
*/ */
skipping to change at line 43 skipping to change at line 52
* returned and Eina error is set to #EINA_ERROR_OUT_OF_MEMORY. To * returned and Eina error is set to #EINA_ERROR_OUT_OF_MEMORY. To
* free the resources, use eina_ustrbuf_free(). * free the resources, use eina_ustrbuf_free().
* *
* @see eina_ustrbuf_free() * @see eina_ustrbuf_free()
* @see eina_ustrbuf_append() * @see eina_ustrbuf_append()
* @see eina_ustrbuf_string_get() * @see eina_ustrbuf_string_get()
*/ */
EAPI Eina_UStrbuf *eina_ustrbuf_new(void) EINA_MALLOC EINA_WARN_UNUSED_RESU LT; EAPI Eina_UStrbuf *eina_ustrbuf_new(void) EINA_MALLOC EINA_WARN_UNUSED_RESU LT;
/** /**
* @brief Create a new string buffer using the passed string. The passed
* string is used directly as the buffer, it's somehow the opposite functio
n of
* @ref eina_ustrbuf_string_steal . The passed string must be malloced.
*
* @param str the string to manage
* @return Newly allocated string buffer instance.
*
* This function creates a new string buffer. On error, @c NULL is
* returned and Eina error is set to #EINA_ERROR_OUT_OF_MEMORY. To
* free the resources, use eina_strbuf_free().
*
* @see eina_ustrbuf_free()
* @see eina_ustrbuf_append()
* @see eina_ustrbuf_string_get()
* @since 1.1.0
*/
EAPI Eina_Strbuf *eina_ustrbuf_manage_new(Eina_Unicode *str) EINA_MALLOC EI
NA_WARN_UNUSED_RESULT;
/**
* @brief Free a string buffer. * @brief Free a string buffer.
* *
* @param buf The string buffer to free. * @param buf The string buffer to free.
* *
* This function frees the memory of @p buf. @p buf must have been * This function frees the memory of @p buf. @p buf must have been
* created by eina_ustrbuf_new(). * created by eina_ustrbuf_new().
*/ */
EAPI void eina_ustrbuf_free(Eina_UStrbuf *buf) EINA_ARG_NONNULL(1); EAPI void eina_ustrbuf_free(Eina_UStrbuf *buf) EINA_ARG_NONNULL(1);
/** /**
skipping to change at line 297 skipping to change at line 325
* @param length The exact length to use. * @param length The exact length to use.
* @return #EINA_TRUE on success, #EINA_FALSE on failure. * @return #EINA_TRUE on success, #EINA_FALSE on failure.
* *
* This macro is calling eina_ustrbuf_insert_length() at position 0. If * This macro is calling eina_ustrbuf_insert_length() at position 0. If
* @p buf can't prepend it, #EINA_FALSE is returned, otherwise * @p buf can't prepend it, #EINA_FALSE is returned, otherwise
* #EINA_TRUE is returned. * #EINA_TRUE is returned.
*/ */
#define eina_ustrbuf_prepend_length(buf, str, length) eina_ustrbuf_insert_l ength(buf, str, length, 0) #define eina_ustrbuf_prepend_length(buf, str, length) eina_ustrbuf_insert_l ength(buf, str, length, 0)
/** /**
* @def eina_ustrbuf_prepend_Eina_Unicode *(buf, str) * @def eina_ustrbuf_prepend_char(buf, c)
* @brief Prepend the given Eina_Unicode *acter to the given buffer * @brief Prepend the given unicode character to the given buffer
* *
* @param buf The string buffer to prepend to. * @param buf The string buffer to prepend to.
* @param c The Eina_Unicode *acter to prepend. * @param c The Eina_Unicode character to prepend.
* @return #EINA_TRUE on success, #EINA_FALSE on failure. * @return #EINA_TRUE on success, #EINA_FALSE on failure.
* *
* This macro is calling eina_ustrbuf_insert_Eina_Unicode *() at position 0 . If * This macro is calling eina_ustrbuf_insert_Eina_Unicode *() at position 0 . If
* @p buf can't prepend it, #EINA_FALSE is returned, otherwise * @p buf can't prepend it, #EINA_FALSE is returned, otherwise
* #EINA_TRUE is returned. * #EINA_TRUE is returned.
*/ */
#define eina_ustrbuf_prepend_Eina_Unicode *(buf, c)eina_ustrbuf_insert_Eina _Unicode * (buf, c, 0) #define eina_ustrbuf_prepend_char(buf, c) eina_ustrbuf_insert_char(buf, c, 0)
/** /**
* @def eina_ustrbuf_prepend_printf(buf, fmt, ...) * @def eina_ustrbuf_prepend_printf(buf, fmt, ...)
* @brief Prepend the given string to the given buffer * @brief Prepend the given string to the given buffer
* *
* @param buf The string buffer to prepend to. * @param buf The string buffer to prepend to.
* @param fmt The string to prepend. * @param fmt The string to prepend.
* @return #EINA_TRUE on success, #EINA_FALSE on failure. * @return #EINA_TRUE on success, #EINA_FALSE on failure.
* *
* This macro is calling eina_ustrbuf_insert_printf() at position 0.If @p b uf * This macro is calling eina_ustrbuf_insert_printf() at position 0.If @p b uf
 End of changes. 5 change blocks. 
4 lines changed or deleted 34 lines changed or added


 eina_ustringshare.h   eina_ustringshare.h 
skipping to change at line 58 skipping to change at line 58
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWA RE. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWA RE.
*/ */
#ifndef EINA_USTRINGSHARE_H_ #ifndef EINA_USTRINGSHARE_H_
#define EINA_USTRINGSHARE_H_ #define EINA_USTRINGSHARE_H_
#include "eina_types.h" #include "eina_types.h"
#include "eina_unicode.h" #include "eina_unicode.h"
/** /**
* @addtogroup Eina_UStringshare_Group Unicode Stringshare
*
* These functions allow you to store one copy of a string, and use it
* throughout your program.
*
* This is a method to reduce the number of duplicated strings kept in
* memory. It's pretty common for the same strings to be dynamically
* allocated repeatedly between applications and libraries, especially in
* circumstances where you could have multiple copies of a structure that
* allocates the string. So rather than duplicating and freeing these
* strings, you request a read-only pointer to an existing string and
* only incur the overhead of a hash lookup.
*
* It sounds like micro-optimizing, but profiling has shown this can have
* a significant impact as you scale the number of copies up. It improves
* string creation/destruction speed, reduces memory use and decreases
* memory fragmentation, so a win all-around.
*
* For more information, you can look at the @ref tutorial_ustringshare_pag
e.
*/
/**
* @addtogroup Eina_Data_Types_Group Data Types * @addtogroup Eina_Data_Types_Group Data Types
* *
* @{ * @{
*/ */
/** /**
* @defgroup Eina_UStringshare_Group Unicode Stringshare * @defgroup Eina_UStringshare_Group Unicode Stringshare
* *
* @{ * @{
*/ */
/**
* @brief Retrieve an instance of a string for use in a program.
*
* @param str The string to retrieve an instance of.
* @param slen The string size (<= strlen(str)).
* @return A pointer to an instance of the string on success.
* @c NULL on failure.
*
* This function retrieves an instance of @p str. If @p str is
* @c NULL, then @c NULL is returned. If @p str is already stored, it
* is just returned and its reference counter is increased. Otherwise
* it is added to the strings to be searched and a duplicated string
* of @p str is returned.
*
* This function does not check string size, but uses the
* exact given size. This can be used to share_common part of a larger
* buffer or substring.
*
* @see eina_ustringshare_add()
*/
EAPI const Eina_Unicode *eina_ustringshare_add_length(const Eina_Unicode *s tr, unsigned int slen) EINA_WARN_UNUSED_RESULT; EAPI const Eina_Unicode *eina_ustringshare_add_length(const Eina_Unicode *s tr, unsigned int slen) EINA_WARN_UNUSED_RESULT;
/**
* @brief Retrieve an instance of a string for use in a program.
*
* @param str The NULL terminated string to retrieve an instance of.
* @return A pointer to an instance of the string on success.
* @c NULL on failure.
*
* This function retrieves an instance of @p str. If @p str is
* @c NULL, then @c NULL is returned. If @p str is already stored, it
* is just returned and its reference counter is increased. Otherwise
* it is added to the strings to be searched and a duplicated string
* of @p str is returned.
*
* The string @p str must be NULL terminated ('@\0') and its full
* length will be used. To use part of the string or non-null
* terminated, use eina_stringshare_add_length() instead.
*
* @see eina_ustringshare_add_length()
*/
EAPI const Eina_Unicode *eina_ustringshare_add(const Eina_Unicode *str) EIN A_WARN_UNUSED_RESULT; EAPI const Eina_Unicode *eina_ustringshare_add(const Eina_Unicode *str) EIN A_WARN_UNUSED_RESULT;
/**
* Increment references of the given shared string.
*
* @param str The shared string.
* @return A pointer to an instance of the string on success.
* @c NULL on failure.
*
* This is similar to eina_share_common_add(), but it's faster since it wil
l
* avoid lookups if possible, but on the down side it requires the paramete
r
* to be shared before, in other words, it must be the return of a previous
* eina_ustringshare_add().
*
* There is no unref since this is the work of eina_ustringshare_del().
*/
EAPI const Eina_Unicode *eina_ustringshare_ref(const Eina_Unicode *str); EAPI const Eina_Unicode *eina_ustringshare_ref(const Eina_Unicode *str);
/**
* @brief Note that the given string has lost an instance.
*
* @param str string The given string.
*
* This function decreases the reference counter associated to @p str
* if it exists. If that counter reaches 0, the memory associated to
* @p str is freed. If @p str is NULL, the function returns
* immediately.
*
* Note that if the given pointer is not shared or NULL, bad things
* will happen, likely a segmentation fault.
*/
EAPI void eina_ustringshare_del(const Eina_Unicode *str); EAPI void eina_ustringshare_del(const Eina_Unicode *str);
/**
* @brief Note that the given string @b must be shared.
*
* @param str the shared string to know the length. It is safe to
* give NULL, in that case -1 is returned.
*
* This function is a cheap way to known the length of a shared
* string. Note that if the given pointer is not shared, bad
* things will happen, likely a segmentation fault. If in doubt, try
* strlen().
*/
EAPI int eina_ustringshare_strlen(const Eina_Unicode *str) EINA_PURE EINA_WARN_UNUSED_RESULT; EAPI int eina_ustringshare_strlen(const Eina_Unicode *str) EINA_PURE EINA_WARN_UNUSED_RESULT;
/**
* @brief Dump the contents of the share_common.
*
* This function dumps all strings in the share_common to stdout with a
* DDD: prefix per line and a memory usage summary.
*/
EAPI void eina_ustringshare_dump(void); EAPI void eina_ustringshare_dump(void);
static inline Eina_Bool eina_ustringshare_replace(const Eina_Unicode **p_s tr, const Eina_Unicode *news) EINA_ARG_NONNULL(1); static inline Eina_Bool eina_ustringshare_replace(const Eina_Unicode **p_s tr, const Eina_Unicode *news) EINA_ARG_NONNULL(1);
static inline Eina_Bool eina_ustringshare_replace_length(const Eina_Unicod e **p_str, const Eina_Unicode *news, unsigned int slen) EINA_ARG_NONNULL(1) ; static inline Eina_Bool eina_ustringshare_replace_length(const Eina_Unicod e **p_str, const Eina_Unicode *news, unsigned int slen) EINA_ARG_NONNULL(1) ;
#include "eina_inline_ustringshare.x" #include "eina_inline_ustringshare.x"
/** /**
* @} * @}
*/ */
 End of changes. 7 change blocks. 
0 lines changed or deleted 113 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/