EINA_MAGIC
};
-EAPI int eina_array_init (void);
-EAPI int eina_array_shutdown (void);
-
EAPI Eina_Array *eina_array_new (unsigned int step) EINA_WARN_UNUSED_RESULT EINA_MALLOC EINA_WARN_UNUSED_RESULT;
EAPI void eina_array_free (Eina_Array *array) EINA_ARG_NONNULL(1);
EAPI void eina_array_step_set (Eina_Array *array, unsigned int step) EINA_ARG_NONNULL(1);
*/
#define EINA_BENCHMARK(function) ((Eina_Benchmark_Specimens)function)
-EAPI int eina_benchmark_init(void);
-EAPI int eina_benchmark_shutdown(void);
-
EAPI Eina_Benchmark *eina_benchmark_new(const char *name, const char *run);
EAPI void eina_benchmark_free(Eina_Benchmark *bench);
*/
EAPI extern Eina_Error EINA_ERROR_CONVERT_OUTRUN_STRING_LENGTH;
-EAPI int eina_convert_init(void);
-EAPI int eina_convert_shutdown(void);
-
EAPI int eina_convert_itoa(int n, char *s) EINA_ARG_NONNULL(2);
EAPI int eina_convert_xtoa(unsigned int n, char *s) EINA_ARG_NONNULL(2);
EAPI int eina_convert_dtoa(double d, char *des) EINA_ARG_NONNULL(2);
*/
typedef struct _Eina_Counter Eina_Counter;
-EAPI int eina_counter_init(void);
-EAPI int eina_counter_shutdown(void);
-
EAPI Eina_Counter *eina_counter_new(const char *name) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
EAPI void eina_counter_free(Eina_Counter *counter) EINA_ARG_NONNULL(1);
*/
EAPI extern Eina_Error EINA_ERROR_OUT_OF_MEMORY;
-EAPI int eina_error_init(void);
-EAPI int eina_error_shutdown(void);
EAPI Eina_Error eina_error_msg_register(const char *msg) EINA_ARG_NONNULL(1);
EAPI Eina_Error eina_error_get(void);
EAPI void eina_error_set(Eina_Error err);
typedef int (*Eina_Key_Hash)(const void *key, int key_length);
#define EINA_KEY_HASH(Function) ((Eina_Key_Hash)Function)
-EAPI int eina_hash_init(void);
-EAPI int eina_hash_shutdown(void);
-
EAPI Eina_Hash * eina_hash_new(Eina_Key_Length key_length_cb,
Eina_Key_Cmp key_cmp_cb,
Eina_Key_Hash key_hash_cb,
EINA_MAGIC
};
-EAPI int eina_list_init(void);
-EAPI int eina_list_shutdown(void);
-
EAPI Eina_List *eina_list_append (Eina_List *list, const void *data) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
EAPI Eina_List *eina_list_prepend (Eina_List *list, const void *data) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
EAPI Eina_List *eina_list_append_relative (Eina_List *list, const void *data, const void *relative) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
Eina_Bool deleted:1; /**< Flags deletion of domain, a free slot */
};
-/**
- * @typedef Eina_Log_Level
- * List of available logging levels.
- */
+EAPI void eina_log_threads_enable(void);
/**
* @enum _Eina_Log_Level
const char *file, const char *fnc, int line,
const char *fmt, void *data, va_list args);
-/**
- * @var EINA_LOG_OUT_OF_MEMORY
- * Log identifier corresponding to a lack of memory.
- */
-
-EAPI int eina_log_init(void);
-EAPI int eina_log_shutdown(void);
-EAPI void eina_log_threads_enable(void);
-
/*
* Customization
*/
typedef unsigned int Eina_Magic;
-EAPI int eina_magic_string_init(void);
-EAPI int eina_magic_string_shutdown(void);
-
/**
* @typedef Eina_Magic
* An abstract type for a magic number.
typedef struct _Eina_Matrixsparse_Item_Row Eina_Matrixsparse_Item_Row;
-/* init */
-EAPI int eina_matrixsparse_init(void);
-EAPI int eina_matrixsparse_shutdown(void);
-
/* constructors and destructors */
EAPI Eina_Matrixsparse *eina_matrixsparse_new(unsigned long rows, unsigned long cols, void (*free_func)(void *user_data, void *cell_data), const void *user_data);
EAPI void eina_matrixsparse_free(Eina_Matrixsparse *m);
EAPI extern Eina_Error EINA_ERROR_NOT_MEMPOOL_MODULE;
-EAPI int eina_mempool_init(void);
-EAPI int eina_mempool_shutdown(void);
-
EAPI Eina_Mempool * eina_mempool_add(const char *module, const char *context, const char *options, ...) EINA_MALLOC EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
EAPI void eina_mempool_del(Eina_Mempool *mp) EINA_ARG_NONNULL(1);
*/
extern EAPI Eina_Error EINA_ERROR_MODULE_INIT_FAILED;
-EAPI int eina_module_init(void);
-EAPI int eina_module_shutdown(void);
-
EAPI Eina_Module * eina_module_new(const char *file) EINA_MALLOC EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
EAPI Eina_Bool eina_module_free(Eina_Module *m) EINA_ARG_NONNULL(1);
EAPI Eina_Bool eina_module_load(Eina_Module *module) EINA_ARG_NONNULL(1);
static inline void eina_rectangle_rescale_in(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);
-EAPI int eina_rectangle_init(void);
-EAPI int eina_rectangle_shutdown(void);
-
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_get(Eina_Rectangle *rect) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
EAPI Eina_Bool eina_rectangle_pool_geometry_get(Eina_Rectangle_Pool *pool, int *w, int *h) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
#include "eina_config.h"
#include "eina_error.h"
-EAPI int eina_safety_checks_init(void);
-EAPI int eina_safety_checks_shutdown(void);
-
/**
* @var EINA_ERROR_SAFETY_FAILED
* Error identifier corresponding to safety check failure.
* @{
*/
-EAPI int eina_stringshare_init(void);
-EAPI int eina_stringshare_shutdown(void);
EAPI const char *eina_stringshare_add_length(const char *str, unsigned int slen) EINA_WARN_UNUSED_RESULT;
EAPI const char *eina_stringshare_add(const char *str) EINA_WARN_UNUSED_RESULT;
EAPI const char *eina_stringshare_ref(const char *str);
#include "eina_config.h"
#include "eina_private.h"
+
+/* undefs EINA_ARG_NONULL() so NULL checks are not compiled out! */
#include "eina_safety_checks.h"
#include "eina_accessor.h"
*
* @section tutorial_error_basic_usage Basic Usage
*
- * The first thing to do when using arrays is to initialize the array
- * module with eina_array_init() and, when no more arrays are used, the
- * module is shut down with eina_array_shutdown(). So a basic program
- * would look like that:
- *
- * @code
- * #include <stdlib.h>
- * #include <stdio.h>
- *
- * #include <eina_array.h>
- *
- * int main(void)
- * {
- * if (!eina_array_init())
- * {
- * printf ("Error during the initialization of eina_error module\n");
- * return EXIT_FAILURE;
- * }
- *
- * eina_array_shutdown();
- *
- * return EXIT_SUCCESS;
- * }
- * @endcode
- *
- * All program using any module of eina must be compiled with the
- * following command:
- *
- * @code
- * gcc -o my_bin my_source.c `pkg-config --cflags --libs eina-0`
- * @endcode
- *
- * Then, an array must created with eina_array_new(). That function
+ * An array must created with eina_array_new(). That function
* takes an integer as parameter, which is the count of pointers to
* add when increasing the array size. Once the array is not used
* anymore, it must be destroyed with eina_array_free().
* Eina_Array_Iterator iterator;
* unsigned int i;
*
- * if (!eina_array_init())
+ * if (!eina_init())
* {
- * printf ("Error during the initialization of eina_error module\n");
+ * printf ("Error during the initialization of eina\n");
* return EXIT_FAILURE;
* }
*
* array = eina_array_new(16);
* if (!array)
- * goto shutdown_array;
+ * goto shutdown;
*
* for (i = 0; i < 4; i++)
* {
* }
*
* eina_array_free(array);
- * eina_array_shutdown();
+ * eina_shutdown();
*
* return EXIT_SUCCESS;
*
- * shutdown_array:
- * eina_array_shutdown();
+ * shutdown:
+ * eina_shutdown();
*
* return EXIT_FAILURE;
* }
#include "eina_config.h"
#include "eina_private.h"
-#include "eina_safety_checks.h"
#include "eina_error.h"
+
+/* undefs EINA_ARG_NONULL() so NULL checks are not compiled out! */
+#include "eina_safety_checks.h"
#include "eina_array.h"
-#include "eina_inline_array.x"
/*============================================================================*
* Local *
EINA_MAGIC
};
-static int _eina_array_init_count = 0;
static int _eina_array_log_dom = -1;
#define ERR(...) EINA_LOG_DOM_ERR(_eina_array_log_dom, __VA_ARGS__)
#define DBG(...) EINA_LOG_DOM_DBG(_eina_array_log_dom, __VA_ARGS__)
* data at any place, the Eina @ref Eina_List_Group is the correct container
* to use.
*
- * To use the array data type, eina_array_init() must be called before
- * any other array functions. When no more array function is used,
- * eina_array_shutdown() must be called to free all the resources.
+ * To use the array data type, eina_init() must be called before any
+ * other array functions. When eina is no more array function is used,
+ * eina_shutdown() must be called to free all the resources.
*
* An array must be created with eina_array_new(). It allocated all
* the necessary data for an array. When not needed anymore, an array
*/
/**
+ * @internal
* @brief Initialize the array module.
*
- * @return 1 or greater on success, 0 on error.
+ * @return #EINA_TRUE on success, #EINA_FALSE on failure.
*
* This function sets up the error and magic modules or Eina. It is
- * also called by eina_init(). It returns 0 on failure, otherwise it
- * returns the number of times it has already been called. See
- * eina_error_init() and eina_magic_string_init() for the
- * documentation of the initialisation of the dependency modules.
+ * called by eina_init().
*
- * When no more Eina arrays are used, call eina_array_shutdown() to shut
- * down the array module.
- *
- * @see eina_error_init()
- * @see eina_magic_string_init()
* @see eina_init()
*/
-EAPI int
+Eina_Bool
eina_array_init(void)
{
- if (!_eina_array_init_count)
+ _eina_array_log_dom = eina_log_domain_register("eina_array", EINA_LOG_COLOR_DEFAULT);
+ if (_eina_array_log_dom < 0)
{
- if (!eina_log_init())
- {
- fprintf(stderr, "Could not initialize eina logging system.\n");
- return 0;
- }
-
- _eina_array_log_dom = eina_log_domain_register("eina_array", EINA_LOG_COLOR_DEFAULT);
- if (_eina_array_log_dom < 0)
- {
- EINA_LOG_ERR("Could not register log domain: eina_array");
- eina_log_shutdown();
- return 0;
- }
-
- if (!eina_error_init())
- {
- ERR("Could not initialize eina error module.");
- goto error_init_error;
- }
-
- if (!eina_safety_checks_init())
- {
- ERR("Could not initialize eina safety checks.");
- goto safety_checks_init_error;
- }
-
- if (!eina_magic_string_init())
- {
- ERR("ERROR: Could not initialize eina magic string module.");
- goto magic_string_init_error;
- }
-
- eina_magic_string_set(EINA_MAGIC_ITERATOR,
- "Eina Iterator");
- eina_magic_string_set(EINA_MAGIC_ACCESSOR,
- "Eina Accessor");
- eina_magic_string_set(EINA_MAGIC_ARRAY,
- "Eina Array");
- eina_magic_string_set(EINA_MAGIC_ARRAY_ITERATOR,
- "Eina Array Iterator");
- eina_magic_string_set(EINA_MAGIC_ARRAY_ACCESSOR,
- "Eina Array Accessor");
+ EINA_LOG_ERR("Could not register log domain: eina_array");
+ return EINA_FALSE;
}
- return ++_eina_array_init_count;
-
- magic_string_init_error:
- eina_safety_checks_shutdown();
- safety_checks_init_error:
- eina_error_shutdown();
- error_init_error:
- eina_log_domain_unregister(_eina_array_log_dom);
- _eina_array_log_dom = -1;
- eina_log_shutdown();
- return 0;
+ eina_magic_string_set(EINA_MAGIC_ITERATOR, "Eina Iterator");
+ eina_magic_string_set(EINA_MAGIC_ACCESSOR, "Eina Accessor");
+ eina_magic_string_set(EINA_MAGIC_ARRAY, "Eina Array");
+ eina_magic_string_set(EINA_MAGIC_ARRAY_ITERATOR, "Eina Array Iterator");
+ eina_magic_string_set(EINA_MAGIC_ARRAY_ACCESSOR, "Eina Array Accessor");
+ return EINA_TRUE;
}
/**
+ * @internal
* @brief Shut down the array module.
*
- * @return 0 when the list module is completely shut down, 1 or
- * greater otherwise.
+ * @return #EINA_TRUE on success, #EINA_FALSE on failure.
*
- * This function shuts down the array module. It returns 0 when it has
- * been called the same number of times than eina_array_init(). In
- * that case it shut down the magic and error modules. This function
- * is also called by eina_shutdown(). See eina_error_shutdown() and
- * eina_magic_string_shutdown() for the documentation of the
- * shutting down of the dependency modules.
+ * This function shuts down the array module set up by
+ * eina_array_init(). It is called by eina_shutdown().
*
- * @see eina_error_shutdown()
- * @see eina_magic_string_shutdown()
* @see eina_shutdown()
*/
-EAPI int
+Eina_Bool
eina_array_shutdown(void)
{
- --_eina_array_init_count;
- if (!_eina_array_init_count)
- {
- eina_magic_string_shutdown();
- eina_safety_checks_shutdown();
- eina_error_shutdown();
- eina_log_domain_unregister(_eina_array_log_dom);
- _eina_array_log_dom = -1;
- eina_log_shutdown();
- }
-
- return _eina_array_init_count;
+ eina_log_domain_unregister(_eina_array_log_dom);
+ _eina_array_log_dom = -1;
+ return EINA_TRUE;
}
/**
Eina_Inlist *runs;
};
-static int _eina_benchmark_count = 0;
static int _log_dom = -1;
#define ERR(...) EINA_LOG_DOM_ERR(_log_dom, __VA_ARGS__)
* in Eina to compare the time used by eina, glib, evas and ecore data
* types.
*
- * The benchmark module must be initialized with eina_benchmark_init()
- * and shut down with eina_benchmark_shutdown(). A benchmark is
- * created with eina_benchmark_new() and freed with
+ * 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
*/
/**
+ * @internal
* @brief Initialize the benchmark module.
*
- * @return 1 or greater on success, 0 on error.
+ * @return #EINA_TRUE on success, #EINA_FALSE on failure.
*
- * This function sets up the error, array and counter modules or
- * Eina. It is also called by eina_init(). It returns 0 on failure,
- * otherwise it returns the number of times it has already been
- * called. See eina_error_init(), eina_array_init() and
- * eina_counter_init() for the documentation of the initialisation of
- * the dependency modules.
+ * This function sets up the benchmark module of Eina. It is called by
+ * eina_init().
*
- * When no more Eina benchmarks are used, call
- * eina_benchmark_shutdown() to shut down the benchmark module.
- *
- * @see eina_error_init()
- * @see eina_array_init()
- * @see eina_counter_init()
* @see eina_init()
*/
-EAPI int
+Eina_Bool
eina_benchmark_init(void)
{
- _eina_benchmark_count++;
-
- if (_eina_benchmark_count > 1) return _eina_benchmark_count;
-
- if (!eina_log_init())
- {
- fprintf(stderr, "Could not initialize eina logging system.\n");
- return 0;
- }
-
_log_dom = eina_log_domain_register("eina_benchmark", EINA_LOG_COLOR_DEFAULT);
if (_log_dom < 0)
{
EINA_LOG_ERR("Could not register log domain: eina_benchmark");
- eina_log_shutdown();
- return 0;
- }
-
- if (!eina_error_init())
- {
- ERR("Could not initialize eina error module.");
- goto error_init_error;
- }
- if (!eina_array_init())
- {
- ERR("Could not initialize eina array module.");
- goto array_init_error;
- }
- if (!eina_counter_init())
- {
- ERR("Could not initialize eina counter module.");
- goto counter_init_error;
+ return EINA_FALSE;
}
- return _eina_benchmark_count;
-
- counter_init_error:
- eina_array_shutdown();
- array_init_error:
- eina_error_shutdown();
- error_init_error:
- eina_log_domain_unregister(_log_dom);
- eina_log_shutdown();
- return 0;
+ return EINA_TRUE;
}
/**
+ * @internal
* @brief Shut down the benchmark module.
*
- * @return 0 when the error module is completely shut down, 1 or
- * greater otherwise.
+ * @return #EINA_TRUE on success, #EINA_FALSE on failure.
*
- * This function shut down the error, array and counter modules set up
- * by eina_array_init(). It is also called by eina_shutdown(). It returns
- * 0 when it is called the same number of times than eina_benchmark_init().
+ * This function shuts down the benchmark module set up by
+ * eina_benchmark_init(). It is called by eina_shutdown().
*
- * @see eina_error_shutdown()
- * @see eina_array_shutdown()
- * @see eina_counter_shutdown()
* @see eina_shutdown()
*/
-EAPI int
+Eina_Bool
eina_benchmark_shutdown(void)
{
- _eina_benchmark_count--;
-
- if (_eina_benchmark_count != 0) return _eina_benchmark_count;
-
- eina_counter_shutdown();
- eina_array_shutdown();
- eina_error_shutdown();
eina_log_domain_unregister(_log_dom);
- eina_log_shutdown();
-
- return 0;
+ _log_dom = -1;
+ return EINA_TRUE;
}
/**
#include "eina_config.h"
#include "eina_private.h"
#include "eina_log.h"
+
+/* undefs EINA_ARG_NONULL() so NULL checks are not compiled out! */
#include "eina_safety_checks.h"
#include "eina_convert.h"
static const char look_up_table[] = {'0', '1', '2', '3', '4',
'5', '6', '7', '8', '9',
'a', 'b', 'c', 'd', 'e', 'f'};
-static int _eina_convert_init_count = 0;
static int _eina_convert_log_dom = -1;
#define ERR(...) EINA_LOG_DOM_ERR(_eina_convert_log_dom, __VA_ARGS__)
* These functions allow you to convert integer or real numbers to
* string or conversely.
*
- * To use these function, you have to call eina_convert_init()
- * first, and eina_convert_shutdown() when they are not used anymore.
+ * 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 string
*
* {
* char *tmp[128];
*
- * if (!eina_convert_init())
+ * if (!eina_init())
* {
- * printf ("Error during the initialization of eina_convert module\n");
+ * printf ("Error during the initialization of eina.\n");
* return EXIT_FAILURE;
* }
*
* eina_convert_xtoa(0xA1, tmp);
* printf("value: %s\n", tmp);
*
- * eina_convert_shutdown();
+ * eina_shutdown();
*
* return EXIT_SUCCESS;
* }
* long int e = 0;
* doule r;
*
- * if (!eina_convert_init())
+ * if (!eina_init())
* {
- * printf ("Error during the initialization of eina_convert module\n");
+ * printf ("Error during the initialization of eina.\n");
* return EXIT_FAILURE;
* }
*
* r = ldexp((double)m, e);
* printf("value: %s\n", tmp);
*
- * eina_convert_shutdown();
+ * eina_shutdown();
*
* return EXIT_SUCCESS;
* }
*/
/**
- * @brief Initialize the eina convert internal structure.
+ * @internal
+ * @brief Initialize the convert module.
+ *
+ * @return #EINA_TRUE on success, #EINA_FALSE on failure.
*
- * @return 1 or greater on success, 0 on error.
+ * This function sets up the convert module of Eina. It is called by
+ * eina_init().
*
* This function sets up the error module of Eina and registers the
* errors #EINA_ERROR_CONVERT_0X_NOT_FOUND,
* #EINA_ERROR_CONVERT_P_NOT_FOUND and
- * #EINA_ERROR_CONVERT_OUTRUN_STRING_LENGTH. It is also called by
- * eina_init(). It returns 0 on failure, otherwise it returns the
- * number of times it has already been called.
+ * #EINA_ERROR_CONVERT_OUTRUN_STRING_LENGTH.
+ *
+ * @see eina_init()
*/
-EAPI int
+Eina_Bool
eina_convert_init(void)
{
- _eina_convert_init_count++;
-
- if (_eina_convert_init_count > 1) goto init_out;
-
- eina_error_init();
- EINA_ERROR_CONVERT_0X_NOT_FOUND = eina_error_msg_register("Error during string convertion to float, First '0x' was not found.");
- EINA_ERROR_CONVERT_P_NOT_FOUND = eina_error_msg_register("Error during string convertion to float, First 'p' was not found.");
- EINA_ERROR_CONVERT_OUTRUN_STRING_LENGTH = eina_error_msg_register("Error outrun string limit during convertion string convertion to float.");
-
- if (!eina_log_init())
- {
- fprintf(stderr, "Could not initialize eina logging system.\n");
- eina_error_shutdown();
- return 0;
- }
-
_eina_convert_log_dom = eina_log_domain_register("eina_convert", EINA_LOG_COLOR_DEFAULT);
if (_eina_convert_log_dom < 0)
{
EINA_LOG_ERR("Could not register log domain: eina_convert");
- eina_log_shutdown();
- eina_error_shutdown();
- return 0;
+ return EINA_FALSE;
}
- if (!eina_safety_checks_init())
- {
- ERR("Could not initialize eina safety checks.");
- eina_log_shutdown();
- eina_error_shutdown();
- return 0;
- }
+ EINA_ERROR_CONVERT_0X_NOT_FOUND = eina_error_msg_register("Error during string convertion to float, First '0x' was not found.");
+ EINA_ERROR_CONVERT_P_NOT_FOUND = eina_error_msg_register("Error during string convertion to float, First 'p' was not found.");
+ EINA_ERROR_CONVERT_OUTRUN_STRING_LENGTH = eina_error_msg_register("Error outrun string limit during convertion string convertion to float.");
- init_out:
- return _eina_convert_init_count;
+ return EINA_TRUE;
}
/**
- * @brief Shut down the eina convert internal structures
+ * @internal
+ * @brief Shut down the convert module.
*
- * @return 0 when the convert module is completely shut down, 1 or
- * greater otherwise.
+ * @return #EINA_TRUE on success, #EINA_FALSE on failure.
*
- * This function just shuts down the error module. It is also called by
- * eina_shutdown(). It returns 0 when it is called the same number of
- * times than eina_convert_init().
+ * This function shuts down the convert module set up by
+ * eina_convert_init(). It is called by eina_shutdown().
+ *
+ * @see eina_shutdown()
*/
-EAPI int
+Eina_Bool
eina_convert_shutdown(void)
{
- _eina_convert_init_count--;
-
- if (_eina_convert_init_count > 0) goto shutdown_out;
-
- eina_safety_checks_shutdown();
eina_log_domain_unregister(_eina_convert_log_dom);
- eina_log_shutdown();
- eina_error_shutdown();
-
- shutdown_out:
- return _eina_convert_init_count;
+ _eina_convert_log_dom = -1;
+ return EINA_TRUE;
}
/*
#include "eina_config.h"
#include "eina_private.h"
-#include "eina_safety_checks.h"
-#include "eina_counter.h"
#include "eina_inlist.h"
#include "eina_error.h"
+/* undefs EINA_ARG_NONULL() so NULL checks are not compiled out! */
+#include "eina_safety_checks.h"
+#include "eina_counter.h"
+
/*============================================================================*
* Local *
*============================================================================*/
Eina_Bool valid;
};
-static int _eina_counter_init_count = 0;
-
#ifndef _WIN32
static inline int
_eina_counter_time_get(Eina_Nano_Time *tp)
*
* @brief These functions allow you to get the time spent in a part of a code.
*
- * The counter system must be initialized with eina_counter_init() and
- * shut down with eina_counter_shutdown(). The create a counter, use
- * eina_counter_new(). To free it, use eina_counter_free().
+ * 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
* {
* Eina_Counter *counter;
*
- * if (!eina_counter_init())
+ * if (!eina_init())
* {
- * printf("Error during the initialization of eina_counter module\n");
+ * printf("Error during the initialization of eina\n");
* return EXIT_FAILURE;
* }
*
* eina_counter_dump(counter);
*
* eina_counter_free(counter);
- * eina_counter_shutdown();
+ * eina_shutdown();
*
* return EXIT_SUCCESS;
* }
*/
/**
+ * @internal
* @brief Initialize the eina counter internal structure.
*
- * @return 1 or greater on success, 0 on error.
+ * @return #EINA_TRUE on success, #EINA_FALSE on failure.
+ *
+ * This function shuts down the counter module set up by
+ * eina_counter_init(). It is called by eina_init().
*
* This function sets up the error module of Eina and only on Windows,
* it initializes the high precision timer. It also registers, only on
* Windows, the error #EINA_ERROR_COUNTER_WINDOWS. It is also called
* by eina_init(). It returns 0 on failure, otherwise it returns the
- * number of times it has already been called. See eina_error_init()
- * for the documentation of the initialisation of the dependency
- * modules.
- *
- * Once the counter module is not used anymore, then
- * eina_counter_shutdown() must be called to shut down the counter
- * module.
+ * number of times it has already been called.
*
- * @see eina_error_init()
* @see eina_init()
*/
-EAPI int
+Eina_Bool
eina_counter_init(void)
{
- _eina_counter_init_count++;
-
- if (_eina_counter_init_count == 1)
- {
- if (!eina_error_init())
- {
- fprintf(stderr, "Could not initialize eina error module.\n");
- return 0;
- }
#ifdef _WIN32
- EINA_ERROR_COUNTER_WINDOWS = eina_error_msg_register("Change your OS, you moron !");
- if (!QueryPerformanceFrequency(&_eina_counter_frequency))
- {
- eina_error_set(EINA_ERROR_COUNTER_WINDOWS);
- eina_error_shutdown();
- return 0;
- }
-#endif /* _WIN2 */
-
-
- if (!eina_safety_checks_init())
- {
- fprintf(stderr, "Could not initialize eina safety checks.\n");
- eina_error_shutdown();
- return 0;
- }
+ EINA_ERROR_COUNTER_WINDOWS = eina_error_msg_register("Change your OS, you moron !");
+ if (!QueryPerformanceFrequency(&_eina_counter_frequency))
+ {
+ eina_error_set(EINA_ERROR_COUNTER_WINDOWS);
+ return EINA_FALSE;
}
-
- return _eina_counter_init_count;
+#endif /* _WIN2 */
+ return EINA_TRUE;
}
/**
- * @brief Shut down the eina counter internal structures
+ * @internal
+ * @brief Shut down the counter module.
*
- * @return 0 when the counter module is completely shut down, 1 or
- * greater otherwise.
+ * @return #EINA_TRUE on success, #EINA_FALSE on failure.
*
* This function shuts down the counter module set up by
- * eina_counter_init(). It is called by eina_shutdown(). It
- * returns 0 when it is called the same number of times than
- * eina_counter_init().
+ * eina_counter_init(). It is called by eina_shutdown().
*
- * @see eina_error_shutdown()
* @see eina_shutdown()
*/
-EAPI int
+Eina_Bool
eina_counter_shutdown(void)
{
- _eina_counter_init_count--;
-
- if (_eina_counter_init_count == 0)
- {
- eina_error_shutdown();
- eina_safety_checks_shutdown();
- }
-
- return _eina_counter_init_count;
+ return EINA_TRUE;
}
/**
* itself. Similar to libC's @c errno and strerror() facilities, this
* is extensible and recommended for other libraries and applications.
*
- * @section tutorial_error_basic_usage Basic Usage
- *
- * The first thing to do when using the error module is to initialize
- * it with eina_error_init() and, when the error module is not used
- * anymore, to shut down it with eina_error_shutdown(). So a basic
- * program would look like that:
- *
- * @code
- * #include <stdlib.h>
- * #include <stdio.h>
- *
- * #include <eina_error.h>
- *
- * int main(void)
- * {
- * if (!eina_error_init())
- * {
- * printf ("Error during the initialization of eina_error module\n");
- * return EXIT_FAILURE;
- * }
- *
- * eina_error_shutdown();
- *
- * return EXIT_SUCCESS;
- * }
- * @endcode
- *
- * All program using any module of eina must be compiled with the
- * following command:
- *
- * @code
- * gcc -Wall -o my_exe my_source.c `pkg-config --cflags --libs eina`
- * @endcode
- *
- *
* @section tutorial_error_registering_msg Registering messages
*
* The error module can provide a system that mimic the errno system
* {
* void *data;
*
- * if (!eina_error_init())
+ * if (!eina_init())
* {
* printf ("Error during the initialization of eina_error module\n");
* return EXIT_FAILURE;
* eina_error_msg_get(err));
* }
*
- * eina_error_shutdown();
+ * eina_shutdown();
*
* return EXIT_SUCCESS;
* }
#include "eina_config.h"
#include "eina_private.h"
-#include "eina_safety_checks.h"
-#include "eina_error.h"
#include "eina_inlist.h"
#include "eina_log.h" /* remove me when eina_error_print is removed! */
+
+/* undefs EINA_ARG_NONULL() so NULL checks are not compiled out! */
+#include "eina_safety_checks.h"
+#include "eina_error.h"
+
/* TODO
* + printing errors to stdout or stderr can be implemented
* using a queue, useful for multiple threads printing
* @cond LOCAL
*/
-static int _eina_error_init_count = 0;
static Eina_Inlist *_error_list = NULL;
static int _error_list_count = 0;
static Eina_Error _err;
*
* @brief These functions provide error management for projects.
*
- * The error system must be initialized with eina_error_init() and
- * shut down with eina_error_shutdown(). Error codes are registered
- * with eina_error_msg_register() and converted from identifier to
- * original message string with eina_error_msg_get().
+ * To use the error system Eina must be initialized with eina_init()
+ * and later shut down with eina_shutdown(). Error codes are
+ * registered with eina_error_msg_register() and converted from
+ * identifier to original message string with eina_error_msg_get().
*
* Logging functions are not in eina_error anymore, see
* eina_log_print() instead.
*/
/**
+ * @internal
* @brief Initialize the error module.
*
- * @return 1 or greater on success, 0 on error.
+ * @return #EINA_TRUE on success, #EINA_FALSE on failure.
*
* This function sets up the error module of Eina. It is called by
- * eina_init() and by all modules initialization functions. It returns
- * @c 0 on failure, otherwise it returns the number of times it is
- * called.
- *
- * The default error level value is set by default to
- * #EINA_ERROR_LEVEL_DBG if Eina is compiled with debug mode, or to
- * #EINA_ERROR_LEVEL_ERR otherwise. That value can be overwritten by
- * setting the environment variable EINA_ERROR_LEVEL. This function
- * checks the value of that environment variable in the first
- * call. Its value must be a number between 0 and 3, to match the
- * error levels #EINA_ERROR_LEVEL_ERR, #EINA_ERROR_LEVEL_WARN,
- * #EINA_ERROR_LEVEL_INFO and #EINA_ERROR_LEVEL_DBG. That value can
- * also be set later with eina_error_log_level_set().
+ * eina_init().
*
* This function registers the error #EINA_ERROR_OUT_OF_MEMORY.
*
- * Once the error module is not used anymore, then
- * eina_error_shutdown() must be called to shut down the error
- * module.
- *
* @see eina_init()
*/
-EAPI int eina_error_init(void)
+Eina_Bool
+eina_error_init(void)
{
- _eina_error_init_count++;
- if (_eina_error_init_count != 1)
- return _eina_error_init_count;
-
/* TODO register the eina's basic errors */
EINA_ERROR_OUT_OF_MEMORY = eina_error_msg_register("Out of memory");
-
- if (!eina_safety_checks_init())
- {
- fprintf(stderr, "Could not initialize eina safety checks.\n");
- _eina_error_init_count = 0;
- return 0;
- }
- return 1;
+ return EINA_TRUE;
}
/**
+ * @internal
* @brief Shut down the error module.
*
- * @return 0 when the error module is completely shut down, 1 or
- * greater otherwise.
+ * @return #EINA_TRUE on success, #EINA_FALSE on failure.
*
* This function shuts down the error module set up by
- * eina_error_init(). It is called by eina_shutdown() and by all
- * modules shutdown functions. It returns 0 when it is called the
- * same number of times than eina_error_init(). In that case it clears
- * the error list.
+ * eina_error_init(). It is called by eina_shutdown().
*
* @see eina_shutdown()
*/
-EAPI int eina_error_shutdown(void)
+Eina_Bool
+eina_error_shutdown(void)
{
- Eina_Inlist *tmp;
-
- _eina_error_init_count--;
- if (!_eina_error_init_count)
- {
- /* remove the error strings */
- while (_error_list)
- {
- tmp = _error_list;
-
- _error_list = _error_list->next;
- free(tmp);
- }
- _error_list_count = 0;
- eina_safety_checks_shutdown();
- }
- return _eina_error_init_count;
+ /* remove the error strings */
+ while (_error_list)
+ {
+ Eina_Inlist *tmp = _error_list;
+ _error_list = _error_list->next;
+ free(tmp);
+ }
+ _error_list_count = 0;
+ return EINA_TRUE;
}
/**
#include "eina_config.h"
#include "eina_private.h"
+
+/* undefs EINA_ARG_NONULL() so NULL checks are not compiled out! */
#include "eina_safety_checks.h"
#include "eina_file.h"
* @li eina_file_split() split a path into all the subdirectories that
* compose it, according to the separator of the file system.
*
- * @warning eina_file_split() uses the @ref Eina_Array_Group module
- * but does not initialize it. eina_array_init() and
- * eina_array_shutdown() must be called if this function is used.
- *
* @{
*/
* filesystem. If @p path is @c NULL or if the array can not be
* created, @c NULL is returned, otherwise, an array with the
* different parts of @p path is returned.
- *
- * @warning This function uses the @ref Eina_Array_Group module but
- * does not initialize it. eina_array_init() and eina_array_shutdown()
- * must be called if this function is used.
*/
EAPI Eina_Array *
eina_file_split(char *path)
#include "eina_config.h"
#include "eina_private.h"
-#include "eina_safety_checks.h"
-#include "eina_hash.h"
#include "eina_rbtree.h"
#include "eina_error.h"
+/* undefs EINA_ARG_NONULL() so NULL checks are not compiled out! */
+#include "eina_safety_checks.h"
+#include "eina_hash.h"
+
/*============================================================================*
* Local *
*============================================================================*/
const void *data;
};
-static int _eina_hash_init_count = 0;
-
#undef get16bits
#if (defined(__GNUC__) && defined(__i386__)) || defined(__WATCOMC__) \
|| defined(_MSC_VER) || defined (__BORLANDC__) || defined (__TURBOC__)
* @{
*/
-/**
- * @brief Initialize the hash table module.
- *
- * @return 1 or greater on success, 0 on error.
- *
- * This function sets up the error module of Eina. It is also called
- * by eina_init(). It returns 0 on failure, otherwise it returns the
- * number of times it has already been called. See eina_error_init()
- * for the documentation of the initialisation of the dependency
- * module.
- *
- * When no more Eina hash tables are used, call eina_hash_shutdown()
- * to shut down the array module.
- *
- * @see eina_error_init()
- */
-EAPI int
-eina_hash_init(void)
-{
- if (!_eina_hash_init_count)
- {
- if (!eina_error_init())
- {
- fprintf(stderr, "Could not initialize eina error module\n");
- return 0;
- }
-
- if (!eina_safety_checks_init())
- {
- fprintf(stderr, "Could not initialize eina safety checks.\n");
- eina_error_shutdown();
- return 0;
- }
- }
-
- return ++_eina_hash_init_count;
-}
-
-/**
- * @brief Shut down the hash table module.
- *
- * @return 0 when the error module is completely shut down, 1 or
- * greater otherwise.
- *
- * This function just shut down the error module set up by
- * eina_hash_init(). It is also called by eina_shutdown(). It returns
- * 0 when it is called the same number of times than
- * eina_error_init().
- */
-EAPI int
-eina_hash_shutdown(void)
-{
- if (_eina_hash_init_count == 1)
- {
- eina_safety_checks_shutdown();
- eina_error_shutdown();
- }
- return --_eina_hash_init_count;
-}
-
EAPI Eina_Hash *
eina_hash_new(Eina_Key_Length key_length_cb,
Eina_Key_Cmp key_cmp_cb,
#include "eina_config.h"
#include "eina_private.h"
+#include "eina_error.h"
+
+/* undefs EINA_ARG_NONULL() so NULL checks are not compiled out! */
#include "eina_safety_checks.h"
#include "eina_inlist.h"
-#include "eina_error.h"
/* FIXME: TODO please, refactor this :) */
#include "eina_config.h"
#include "eina_private.h"
+
+/* undefs EINA_ARG_NONULL() so NULL checks are not compiled out! */
#include "eina_safety_checks.h"
#include "eina_iterator.h"
#include "eina_config.h"
#include "eina_private.h"
+
+/* undefs EINA_ARG_NONULL() so NULL checks are not compiled out! */
#include "eina_safety_checks.h"
#include "eina_lalloc.h"
#include "eina_config.h"
#include "eina_private.h"
-#include "eina_safety_checks.h"
#include "eina_error.h"
-#include "eina_list.h"
#include "eina_mempool.h"
+/* undefs EINA_ARG_NONULL() so NULL checks are not compiled out! */
+#include "eina_safety_checks.h"
+#include "eina_list.h"
+
/*============================================================================*
* Local *
EINA_MAGIC
};
-static int _eina_list_init_count = 0;
static Eina_Mempool *_eina_list_mp = NULL;
static Eina_Mempool *_eina_list_accounting_mp = NULL;
static int _eina_list_log_dom = -1;
*/
/**
+ * @internal
* @brief Initialize the list module.
*
- * @return 1 or greater on success, 0 on error.
- *
- * This function sets up the error, magic and mempool modules of
- * Eina. It is also called by eina_init(). It returns 0 on failure,
- * otherwise it returns the number of times it has already been
- * called. If Eina has been configured with the default memory pool,
- * then the memory pool used in an Eina list will be
- * "pass_through". Otherwise, the environment variable EINA_MEMPOOL is
- * read and its value is chosen as memory pool ; if EINA_MEMPOOL is
- * not defined, then the "chained_mempool" memory pool is chosen. If
- * the memory pool is not found, then eina_list_init() return @c 0.
- * See eina_error_init(), eina_magic_string_init() and
- * eina_mempool_init() for the documentation of the initialisation of
- * the dependency modules.
- *
- * When no more Eina lists are used, call eina_list_shutdown() to shut
- * down the list module.
- *
- * @see eina_error_init()
- * @see eina_magic_string_init()
- * @see eina_mempool_init()
+ * @return #EINA_TRUE on success, #EINA_FALSE on failure.
+ *
+ * This function sets up the list module of Eina. It is called by
+ * eina_init().
+ *
+ * This function creates mempool to speed up list node and accounting
+ * management, using EINA_MEMPOOL environment variable if it is set to
+ * choose the memory pool type to use.
+ *
+ * @see eina_init()
*/
-EAPI int
+Eina_Bool
eina_list_init(void)
{
- const char *choice;
+ const char *choice, *tmp;
- if (!_eina_list_init_count)
+ _eina_list_log_dom = eina_log_domain_register("eina_list", EINA_LOG_COLOR_DEFAULT);
+ if (_eina_list_log_dom < 0)
{
- if (!eina_log_init())
- {
- fprintf(stderr, "Could not initialize eina logging system.\n");
- return 0;
- }
-
- _eina_list_log_dom = eina_log_domain_register("eina_list", EINA_LOG_COLOR_DEFAULT);
- if (_eina_list_log_dom < 0)
- {
- EINA_LOG_ERR("Could not register log domain: eina_list");
- eina_log_shutdown();
- return 0;
- }
-
- if (!eina_error_init())
- {
- ERR("Could not initialize eina error module.");
- goto on_error_fail;
- }
-
- if (!eina_safety_checks_init())
- {
- ERR("Could not initialize eina safety checks.");
- goto on_safety_checks_fail;
- }
-
- if (!eina_magic_string_init())
- {
- ERR("ERROR: Could not initialize eina magic string module.");
- goto on_magic_string_fail;
- }
-
- if (!eina_mempool_init())
- {
- ERR("ERROR: Could not initialize eina mempool module.");
- goto on_mempool_fail;
- }
+ EINA_LOG_ERR("Could not register log domain: eina_list");
+ return EINA_FALSE;
+ }
#ifdef EINA_DEFAULT_MEMPOOL
- choice = "pass_through";
+ choice = "pass_through";
#else
- if (!(choice = getenv("EINA_MEMPOOL")))
- choice = "chained_mempool";
+ choice = "chained_mempool";
#endif
+ tmp = getenv("EINA_MEMPOOL");
+ if (tmp && tmp[0])
+ choice = tmp;
- _eina_list_mp = eina_mempool_add(choice, "list", NULL,
- sizeof (Eina_List), 320);
- if (!_eina_list_mp)
- {
- ERR("ERROR: Mempool for list cannot be allocated in list init.");
- goto on_init_fail;
- }
- _eina_list_accounting_mp = eina_mempool_add(choice, "list_accounting", NULL,
- sizeof (Eina_List_Accounting), 80);
- if (!_eina_list_accounting_mp)
- {
- ERR("ERROR: Mempool for list accounting cannot be allocated in list init.");
- eina_mempool_del(_eina_list_mp);
- goto on_init_fail;
- }
-
- eina_magic_string_set(EINA_MAGIC_ITERATOR,
- "Eina Iterator");
- eina_magic_string_set(EINA_MAGIC_ACCESSOR,
- "Eina Accessor");
- eina_magic_string_set(EINA_MAGIC_LIST,
- "Eina List");
- eina_magic_string_set(EINA_MAGIC_LIST_ITERATOR,
- "Eina List Iterator");
- eina_magic_string_set(EINA_MAGIC_LIST_ACCESSOR,
- "Eina List Accessor");
- eina_magic_string_set(EINA_MAGIC_LIST_ACCOUNTING,
- "Eina List Accounting");
+ _eina_list_mp = eina_mempool_add
+ (choice, "list", NULL, sizeof(Eina_List), 320);
+ if (!_eina_list_mp)
+ {
+ ERR("ERROR: Mempool for list cannot be allocated in list init.");
+ goto on_init_fail;
}
+ _eina_list_accounting_mp = eina_mempool_add
+ (choice, "list_accounting", NULL, sizeof(Eina_List_Accounting), 80);
+ if (!_eina_list_accounting_mp)
+ {
+ ERR("ERROR: Mempool for list accounting cannot be allocated in list init.");
+ eina_mempool_del(_eina_list_mp);
+ goto on_init_fail;
+ }
+
+ eina_magic_string_set(EINA_MAGIC_ITERATOR, "Eina Iterator");
+ eina_magic_string_set(EINA_MAGIC_ACCESSOR, "Eina Accessor");
+ eina_magic_string_set(EINA_MAGIC_LIST, "Eina List");
+ eina_magic_string_set(EINA_MAGIC_LIST_ITERATOR, "Eina List Iterator");
+ eina_magic_string_set(EINA_MAGIC_LIST_ACCESSOR, "Eina List Accessor");
+ eina_magic_string_set(EINA_MAGIC_LIST_ACCOUNTING, "Eina List Accounting");
- return ++_eina_list_init_count;
+ return EINA_TRUE;
on_init_fail:
- eina_mempool_shutdown();
- on_mempool_fail:
- eina_magic_string_shutdown();
- on_magic_string_fail:
- eina_safety_checks_shutdown();
- on_safety_checks_fail:
- eina_error_shutdown();
- on_error_fail:
eina_log_domain_unregister(_eina_list_log_dom);
_eina_list_log_dom = -1;
- eina_log_shutdown();
- return 0;
+ return EINA_FALSE;
}
/**
+ * @internal
* @brief Shut down the list module.
*
- * @return 0 when the list module is completely shut down, 1 or
- * greater otherwise.
+ * @return #EINA_TRUE on success, #EINA_FALSE on failure.
+ *
+ * This function shuts down the list module set up by
+ * eina_list_init(). It is called by eina_shutdown().
*
- * This function shuts down the mempool, magic and error modules set
- * up by eina_list_init(). It is also called by eina_shutdown(). It
- * returns 0 when it is called the same number of times than
- * eina_list_init().
+ * @see eina_shutdown()
*/
-EAPI int
+Eina_Bool
eina_list_shutdown(void)
{
- --_eina_list_init_count;
-
- if (!_eina_list_init_count)
- {
- eina_mempool_del(_eina_list_accounting_mp);
- eina_mempool_del(_eina_list_mp);
+ eina_mempool_del(_eina_list_accounting_mp);
+ eina_mempool_del(_eina_list_mp);
- eina_mempool_shutdown();
- eina_magic_string_shutdown();
- eina_safety_checks_shutdown();
- eina_error_shutdown();
- eina_log_domain_unregister(_eina_list_log_dom);
- _eina_list_log_dom = -1;
- eina_log_shutdown();
- }
-
- return _eina_list_init_count;
+ eina_log_domain_unregister(_eina_list_log_dom);
+ _eina_list_log_dom = -1;
+ return EINA_TRUE;
}
/**
*
* @section tutorial_log_basic_usage Basic Usage
*
- * The first thing to do when using the log module is to initialize
- * it with eina_log_init() and when the log module is not used
- * anymore, shut it down with eina_log_shutdown(). Here's a basic example:
- *
- * @code
- * #include <stdlib.h>
- * #include <stdio.h>
- *
- * #include <eina_log.h>
- *
- * int main(void)
- * {
- * if (!eina_log_init())
- * {
- * printf ("Error initializing Eina Log module\n");
- * return EXIT_FAILURE;
- * }
- *
- * eina_log_shutdown();
- *
- * return EXIT_SUCCESS;
- * }
- * @endcode
- *
- * Every program using any module of eina must be compiled with the
- * following command:
- *
- * @code
- * gcc -Wall -o my_exe my_source.c `pkg-config --cflags --libs eina`
- * @endcode
- *
- * After the module has been initialized, log messages can be displayed using
- * the following macros:
+ * Log messages can be displayed using the following macros:
*
* @li EINA_LOG_ERR(),
* @li EINA_LOG_INFO(),
* #include <stdlib.h>
* #include <stdio.h>
*
- * #include <eina_log.h>
+ * #include <Eina.h>
*
* void test(int i)
* {
- * EINA_LOG_DBG("Entering test\n");
+ * EINA_LOG_DBG("Entering test");
*
* if (i < 0)
* {
- * EINA_LOG_ERR("Argument is negative\n");
+ * EINA_LOG_ERR("Argument is negative");
* return;
* }
*
- * EINA_LOG_INFO("argument non negative\n");
+ * EINA_LOG_INFO("argument non negative");
*
- * EINA_LOG_DBG("Exiting test\n");
+ * EINA_LOG_DBG("Exiting test");
* }
*
* int main(void)
* {
- * if (!eina_log_init())
+ * if (!eina_init())
* {
- * printf ("log during the initialization of Eina_Log module\n");
+ * printf("log during the initialization of Eina_Log module\n");
* return EXIT_FAILURE;
* }
*
* test(-1);
* test(0);
*
- * eina_log_shutdown();
+ * eina_shutdown();
*
* return EXIT_SUCCESS;
* }
* The global level (EINA_LOG_LEVEL) can also be set through code, using
* eina_log_level_set() function.
*
- * // TODO rewrite this section
* @section tutorial_log_advanced_display Advanced usage of print callbacks
*
* The log module allows the user to change the way
* int to_stderr;
* };
*
- * void print_cb(Eina_Log_Level level,
+ * void print_cb(const Eina_Log_Domain *domain,
+ * Eina_Log_Level level,
* const char *file,
* const char *fnc,
* int line,
* str = "stdout";
* }
*
- * fprintf(output, "%s:%s (%d) %s: ", file, fnc, line, str);
+ * fprintf(output, "%s:%s:%s (%d) %s: ",
+ * domain->domain_str, file, fnc, line, str);
* vfprintf(output, fmt, args);
+ * putc('\n', output);
* }
*
* void test(Data *data, int i)
* else
* data->to_stderr = 1;
*
- * log("log message...\n");
+ * log("log message...");
* }
*
* int main(void)
* {
- * Data *data;
- *
- * if (!eina_log_init())
- * {
- * printf ("log during the initialization of Eina_Log module\n");
- * return EXIT_FAILURE;
- * }
+ * Data data;
*
- * data = (Data *)malloc(sizeof(Data));
- * if (!data)
+ * if (!eina_init())
* {
- * printf ("log during memory allocation\n");
- * eina_log_shutdown();
+ * printf("log during the initialization of Eina_Log module\n");
* return EXIT_FAILURE;
* }
*
- * eina_log_print_cb_set(print_cb, data);
+ * eina_log_print_cb_set(print_cb, &data);
*
- * test(data, -1);
- * test(data, 0);
+ * test(&data, -1);
+ * test(&data, 0);
*
- * eina_log_shutdown();
+ * eina_shutdown();
*
* return EXIT_SUCCESS;
* }
* @endcode
*
- * Of course, instead of printf(), eina_log_print() can be used to
- * have beautiful log messages.
+ * @addtogroup Eina_Log_Group Log
+ *
+ * @{
+ *
+ * The default log level value is set by default to
+ * #EINA_LOG_LEVEL_DBG if Eina is compiled with debug mode, or to
+ * #EINA_LOG_LEVEL_ERR otherwise. That value can be overwritten by
+ * setting the environment variable EINA_LOG_LEVEL. This function
+ * checks the value of that environment variable in the first
+ * call. Its value must be a number between 0 and 4, to match the log
+ * levels #EINA_LOG_LEVEL_CRITICAL, #EINA_LOG_LEVEL_ERR,
+ * #EINA_LOG_LEVEL_WARN, #EINA_LOG_LEVEL_INFO and
+ * #EINA_LOG_LEVEL_DBG. That value can also be set later with
+ * eina_log_log_level_set(). When logging domains are created, they
+ * will get either this value or specific value given with
+ * EINA_LOG_LEVELS that takes the format
+ * 'domain_name:level,another_name:other_level'.
+ *
+ * Format and verbosity of messages depend on the logging method, see
+ * eina_log_print_cb_set(). The default logging method is
+ * eina_log_print_cb_stderr(), which will output fancy colored
+ * messages to standard error stream. See its documentation on how to
+ * disable coloring, function or file/line print.
+ *
+ * This module will optionally abort program execution if message
+ * level is below or equal to @c EINA_LOG_LEVEL_CRITICAL and
+ * @c EINA_LOG_ABORT=1.
+ *
+ * @}
*/
#ifdef HAVE_CONFIG_H
#include "eina_config.h"
#include "eina_private.h"
+#include "eina_inlist.h"
+
+/* undefs EINA_ARG_NONULL() so NULL checks are not compiled out! */
#include "eina_safety_checks.h"
#include "eina_log.h"
-#include "eina_inlist.h"
#include <assert.h>
* + printing logs to stdout or stderr can be implemented
* using a queue, useful for multiple threads printing
* + add a wrapper for assert?
- * + improve doc
*/
/*============================================================================*
*/
static Eina_Inlist *_pending_list = NULL;
-// Initialization counter
-static int _eina_log_init_count = 0;
-
// Disable color flag (can be changed through the env var
// EINA_LOG_ENV_COLOR_DISABLE).
static Eina_Bool _disable_color = EINA_FALSE;
*
* @brief These functions provide log management for projects.
*
- * The log system must be initialized with eina_log_init() and
- * shut down with eina_log_shutdown(). The most generic way to print
+ * To use the log system Eina must be initialized with eina_init() and
+ * later shut down with eina_shutdown(). The most generic way to print
* logs is to use eina_log_print() but the helper macros
- * EINA_LOG_ERR(), EINA_LOG_INFO(), EINA_LOG_WARN() and
- * EINA_LOG_DBG() should be used instead.
+ * EINA_LOG_ERR(), EINA_LOG_INFO(), EINA_LOG_WARN() and EINA_LOG_DBG()
+ * should be used instead.
*
* Here is a straightforward example:
*
*
* void test_warn(void)
* {
- * EINA_LOG_WARN("Here is a warning message\n");
+ * EINA_LOG_WARN("Here is a warning message");
* }
*
* int main(void)
* {
- * if (!eina_log_init())
+ * if (!eina_init())
* {
- * printf ("log during the initialization of Eina_Log module\n");
+ * printf("log during the initialization of Eina_Log module\n");
* return EXIT_FAILURE;
* }
*
* test_warn();
*
- * eina_log_shutdown();
+ * eina_shutdown();
*
* return EXIT_SUCCESS;
* }
* with:
*
* @code
- * EINA_log_LEVEL=2 ./test_eina_log
+ * EINA_LOG_LEVEL=2 ./test_eina_log
* @endcode
*
* You should see a message displayed in the terminal.
*/
/**
+ * @internal
* @brief Initialize the log module.
*
- * @return 1 or greater on success, 0 on log.
+ * @return #EINA_TRUE on success, #EINA_FALSE on failure.
*
* This function sets up the log module of Eina. It is called by
- * eina_init() and by all modules initialization functions. It returns
- * @c 0 on failure, otherwise it returns the number of times it is
- * called.
- *
- * The default log level value is set by default to
- * #EINA_LOG_LEVEL_DBG if Eina is compiled with debug mode, or to
- * #EINA_LOG_LEVEL_ERR otherwise. That value can be overwritten by
- * setting the environment variable EINA_log_LEVEL. This function
- * checks the value of that environment variable in the first
- * call. Its value must be a number between 0 and 3, to match the
- * log levels #EINA_LOG_LEVEL_ERR, #EINA_LOG_LEVEL_WARN,
- * #EINA_LOG_LEVEL_INFO and #EINA_LOG_LEVEL_DBG. That value can
- * also be set later with eina_log_log_level_set().
- *
- * Once the log module is not used anymore, then
- * eina_log_shutdown() must be called to shut down the log
- * module.
- *
- * Format and verbosity of messages depend on the logging method, see
- * eina_log_print_cb_set(). The default logging method is
- * eina_log_print_cb_stderr(), which will output fancy colored
- * messages to standard error stream. See its documentation on how to
- * disable coloring, function or file/line print.
- *
- * This module will optionally abort program execution if message
- * level is below or equal to @c EINA_LOG_LEVEL_CRITICAL and
- * @c EINA_LOG_ABORT=1.
+ * eina_init().
*
* @see eina_init()
*
* place where this function was called the first time is
* considered the main thread.
*/
-EAPI int
+Eina_Bool
eina_log_init(void)
{
const char *level, *tmp;
- _eina_log_init_count++;
- if (_eina_log_init_count != 1)
- return _eina_log_init_count;
-
assert((sizeof(_names)/sizeof(_names[0])) == EINA_LOG_LEVELS);
assert((sizeof(_colors)/sizeof(_colors[0])) == EINA_LOG_LEVELS + 1);
// Global log level
if ((level = getenv(EINA_LOG_ENV_LEVEL)))
_log_level = atoi(level);
- else
- _log_level = EINA_LOG_LEVEL_ERR;
// Register UNKNOWN domain, the default logger
EINA_LOG_DOMAIN_GLOBAL = eina_log_domain_register("", NULL);
if (EINA_LOG_DOMAIN_GLOBAL < 0)
{
fprintf(stderr, "Failed to create global logging domain.\n");
- _eina_log_init_count = 0;
- return 0;
+ return EINA_FALSE;
}
// Parse pending domains passed through EINA_LOG_LEVELS
eina_log_domain_parse_pendings();
- if (!eina_safety_checks_init())
- {
- fprintf(stderr, "Could not initialize eina safety checks.\n");
- eina_log_shutdown(); /* zero _eina_log_init_count and free stuff */
- return 0;
- }
-
- return 1;
+ return EINA_TRUE;
}
/**
+ * @internal
* @brief Shut down the log module.
*
- * @return 0 when the log module is completely shut down, 1 or
- * greater otherwise.
+ * @return #EINA_TRUE on success, #EINA_FALSE on failure.
*
* This function shuts down the log module set up by
- * eina_log_init(). It is called by eina_shutdown() and by all
- * modules shutdown functions. It returns 0 when it is called the
- * same number of times than eina_log_init(). In that case it clears
- * the log list.
+ * eina_log_init(). It is called by eina_shutdown().
*
* @see eina_shutdown()
*
* @warning Not-MT: just call this function from main thread! The
- * place where eina_log_init() was called the first time is
- * considered the main thread.
+ * place where eina_log_init() (eina_init()) was called the
+ * first time is considered the main thread.
*/
-EAPI int
+Eina_Bool
eina_log_shutdown(void)
{
Eina_Inlist *tmp;
CHECK_MAIN(0);
- if (_eina_log_init_count != 1) return --_eina_log_init_count;
-
- eina_safety_checks_shutdown();
-
while (_log_domains_count--)
{
if (_log_domains[_log_domains_count].deleted)
_threads_enabled = 0;
#endif
- return --_eina_log_init_count;
+ return EINA_TRUE;
}
/**
* 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_log_shutdown().
+ * 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.
* printed.
*
* The main thread is considered the thread where the first
- * eina_log_init() was called.
+ * eina_init() was called.
*/
EAPI void
eina_log_threads_enable(void)
Eina_Magic magic;
};
-static int _eina_magic_string_count = 0;
static Eina_Inlist *strings = NULL;
/**
*/
/**
- * @brief Initialize the magic module.
+ * @internal
+ * @brief Initialize the magic string module.
*
- * @return 1 or greater.
+ * @return #EINA_TRUE on success, #EINA_FALSE on failure.
*
- * This function just increases a reference counter. If the magic
- * module is disabled at configure time, then it always returns @c 1.
- *
- * Once the magic module is not used anymore, then
- * eina_magic_shutdown() must be called to shut down the magic
- * module.
+ * This function sets up the magic string module of Eina. It is called by
+ * eina_init().
*
* @see eina_init()
*/
-EAPI int
+Eina_Bool
eina_magic_string_init(void)
{
- ++_eina_magic_string_count;
-
- return _eina_magic_string_count;
+ return EINA_TRUE;
}
/**
- * @brief Shut down the magic module.
+ * @internal
+ * @brief Shut down the magic string module.
*
- * @return 0 when the magic module is completely shut down, 1 or
- * greater otherwise.
+ * @return #EINA_TRUE on success, #EINA_FALSE on failure.
*
- * This function shuts down the magic module set up by
- * eina_magic_string_init(). It is called by eina_shutdown() and by
- * all modules shutdown functions. It returns 0 when it is called the
- * same number of times than eina_magic_string_init(). In that case it
- * clears the magic list and return @c 0. If the magic module is
- * disabled at configure time, then it always returns @c 0.
+ * This function shuts down the magic string module set up by
+ * eina_magic string_init(). It is called by eina_shutdown().
*
* @see eina_shutdown()
*/
-EAPI int
+Eina_Bool
eina_magic_string_shutdown(void)
{
- --_eina_magic_string_count;
-
- if (_eina_magic_string_count == 0)
+ /* Free all strings. */
+ while (strings)
{
- /* Free all strings. */
- while (strings)
- {
- Eina_Magic_String *tmp;
-
- tmp = (Eina_Magic_String*) strings;
- strings = eina_inlist_remove(strings, strings);
+ Eina_Magic_String *tmp = (Eina_Magic_String*) strings;
+ strings = eina_inlist_remove(strings, strings);
- free(tmp->string);
- free(tmp);
- }
+ free(tmp->string);
+ free(tmp);
}
- return _eina_magic_string_count;
+ return EINA_TRUE;
}
/**
#define ERR(...) EINA_LOG_DOM_ERR(_eina_log_dom, __VA_ARGS__)
#define DBG(...) EINA_LOG_DOM_DBG(_eina_log_dom, __VA_ARGS__)
+
+/* place module init/shutdown functions here to avoid other modules
+ * calling them by mistake.
+ */
+#define S(x) extern Eina_Bool eina_##x##_init(void); extern Eina_Bool eina_##x##_shutdown(void)
+S(log);
+S(error);
+S(safety_checks);
+S(magic_string);
+S(array);
+S(module);
+S(mempool);
+S(list);
+S(stringshare);
+S(matrixsparse);
+S(convert);
+S(counter);
+S(benchmark);
+S(rectangle);
+#undef S
+
+struct eina_desc_setup
+{
+ const char *name;
+ Eina_Bool (*init)(void);
+ Eina_Bool (*shutdown)(void);
+};
+
+static const struct eina_desc_setup _eina_desc_setup[] = {
+#define S(x) {#x, eina_##x##_init, eina_##x##_shutdown}
+ /* log is a special case as it needs printf */
+ S(error),
+ S(safety_checks),
+ S(magic_string),
+ S(array),
+ S(module),
+ S(mempool),
+ S(list),
+ S(stringshare),
+ S(matrixsparse),
+ S(convert),
+ S(counter),
+ S(benchmark),
+ S(rectangle)
+#undef S
+};
+static const size_t _eina_desc_setup_len = sizeof(_eina_desc_setup) / sizeof(_eina_desc_setup[0]);
+
+static void
+_eina_shutdown_from_desc(const struct eina_desc_setup *itr)
+{
+ for (itr--; itr >= _eina_desc_setup; itr--)
+ {
+ if (!itr->shutdown())
+ ERR("Problems shutting down eina module '%s', ignored.", itr->name);
+ }
+
+ eina_log_domain_unregister(_eina_log_dom);
+ _eina_log_dom = -1;
+ eina_log_shutdown();
+}
+
/**
* @endcond
*/
* 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. The list of initialisation functions that are called are
- * (in that order):
- *
- * @li eina_log_init()
- * @li eina_error_init()
- * @li eina_safety_checks_init()
- * @li eina_hash_init()
- * @li eina_stringshare_init()
- * @li eina_list_init()
- * @li eina_matrixsparse_init()
- * @li eina_array_init()
- * @li eina_counter_init()
- * @li eina_benchmark_init()
- * @li eina_magic_string_init()
- * @li eina_rectangle_init()
+ * called.
*
* When Eina is not used anymore, call eina_shutdown() to shut down
* the Eina library.
EAPI int
eina_init(void)
{
- if (_eina_main_count) goto finish_init;
+ const struct eina_desc_setup *itr, *itr_end;
+
+ if (EINA_LIKELY(_eina_main_count > 0))
+ return ++_eina_main_count;
if (!eina_log_init())
{
fprintf(stderr, "Could not initialize eina logging system.\n");
return 0;
}
-
_eina_log_dom = eina_log_domain_register("eina", EINA_LOG_COLOR_DEFAULT);
if (_eina_log_dom < 0)
{
return 0;
}
- if (!eina_error_init())
- {
- ERR("Could not initialize eina error module.");
- goto eina_init_error;
- }
-
- if (!eina_safety_checks_init())
+ itr = _eina_desc_setup;
+ itr_end = itr + _eina_desc_setup_len;
+ for (; itr < itr_end; itr++)
{
- ERR("Could not initialize eina safety checks module.");
- goto safety_checks_init_error;
+ if (!itr->init())
+ {
+ ERR("Could not initialize eina module '%s'.", itr->name);
+ _eina_shutdown_from_desc(itr);
+ return 0;
+ }
}
- if (!eina_hash_init())
- {
- ERR("Could not initialize eina hash module.");
- goto hash_init_error;
- }
- if (!eina_stringshare_init())
- {
- ERR("Could not initialize eina stringshare module.");
- goto stringshare_init_error;
- }
- if (!eina_list_init())
- {
- ERR("Could not initialize eina list module.");
- goto list_init_error;
- }
- if (!eina_matrixsparse_init())
- {
- ERR("Could not initialize eina matrixsparse module.");
- goto matrixsparse_init_error;
- }
- if (!eina_array_init())
- {
- ERR("Could not initialize eina array module.");
- goto array_init_error;
- }
- if (!eina_counter_init())
- {
- ERR("Could not initialize eina counter module.");
- goto counter_init_error;
- }
- if (!eina_benchmark_init())
- {
- ERR("Could not initialize eina benchmark module.");
- goto benchmark_init_error;
- }
- if (!eina_magic_string_init())
- {
- ERR("Could not initialize eina magic string module.");
- goto magic_string_init_error;
- }
- if (!eina_rectangle_init())
- {
- ERR("Could not initialize eina rectangle module.");
- goto rectangle_init_error;
- }
-
- finish_init:
- return ++_eina_main_count;
-
- rectangle_init_error:
- eina_magic_string_shutdown();
- magic_string_init_error:
- eina_benchmark_shutdown();
- benchmark_init_error:
- eina_counter_shutdown();
- counter_init_error:
- eina_array_shutdown();
- array_init_error:
- eina_matrixsparse_shutdown();
- matrixsparse_init_error:
- eina_list_shutdown();
- list_init_error:
- eina_stringshare_shutdown();
- stringshare_init_error:
- eina_hash_shutdown();
- hash_init_error:
- eina_safety_checks_shutdown();
- safety_checks_init_error:
- eina_error_shutdown();
- eina_init_error:
- _eina_log_dom = -1;
- eina_log_shutdown();
-
- return 0;
+ _eina_main_count = 1;
+ return 1;
}
/**
*
* 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. The list of shut down functions
- * that are called are (in that order):
- *
- * @li eina_rectangle_shutdown()
- * @li eina_magic_string_shutdown()
- * @li eina_benchmark_shutdown()
- * @li eina_counter_shutdown()
- * @li eina_array_shutdown()
- * @li eina_matrixsparse_shutdown()
- * @li eina_list_shutdown()
- * @li eina_stringshare_shutdown()
- * @li eina_hash_shutdown()
- * @li eina_safety_checks_shutdown()
- * @li eina_error_shutdown()
- * @li eina_log_shutdown()
+ * 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
EAPI int
eina_shutdown(void)
{
- if (_eina_main_count != 1) goto finish_shutdown;
-
- eina_rectangle_shutdown();
- eina_magic_string_shutdown();
- eina_benchmark_shutdown();
- eina_counter_shutdown();
- eina_array_shutdown();
- eina_matrixsparse_shutdown();
- eina_list_shutdown();
- eina_stringshare_shutdown();
- eina_hash_shutdown();
- eina_safety_checks_shutdown();
- eina_error_shutdown();
- eina_log_domain_unregister(_eina_log_dom);
- _eina_log_dom = -1;
- eina_log_shutdown();
-
- finish_shutdown:
- return --_eina_main_count;
+ _eina_main_count--;
+ if (EINA_UNLIKELY(_eina_main_count == 0))
+ _eina_shutdown_from_desc(_eina_desc_setup + _eina_desc_setup_len);
+ return _eina_main_count;
}
/**
#endif
#include "eina_config.h"
+#include "eina_private.h"
#include "eina_error.h"
-#include "eina_matrixsparse.h"
#include "eina_magic.h"
#include "eina_mempool.h"
-#include "eina_private.h"
+
+/* undefs EINA_ARG_NONULL() so NULL checks are not compiled out! */
#include "eina_safety_checks.h"
+#include "eina_matrixsparse.h"
/*============================================================================*
* @todo Eina_Matrixsparse_Cell_Accessor: accessor over cells in row
*/
-static int _eina_matrixsparse_init_count = 0;
static int _eina_matrixsparse_log_dom = -1;
#define ERR(...) EINA_LOG_DOM_ERR(_eina_matrixsparse_log_dom, __VA_ARGS__)
*
* @{
*/
+
/**
+ * @internal
* @brief Initialize the matrixsparse module.
*
- * @return 1 or greater on success, 0 on error.
- *
- * This function sets up the error, magic and mempool modules of
- * Eina. It is also called by eina_init(). It returns 0 on failure,
- * otherwise it returns the number of times it has already been
- * called. If Eina has been configured with the default memory pool,
- * then the memory pool used in an Eina matrixsparse will be
- * "pass_through". Otherwise, the environment variable EINA_MEMPOOL is
- * read and its value is chosen as memory pool ; if EINA_MEMPOOL is
- * not defined, then the "chained_mempool" memory pool is chosen. If
- * the memory pool is not found, then eina_matrixsparse_init() return @c 0.
- * See eina_error_init(), eina_magic_string_init() and
- * eina_mempool_init() for the documentation of the initialisation of
- * the dependency modules.
- *
- * When no more Eina matrixsparse are used, call eina_matrixsparse_shutdown()
- * to shut down the matrixsparse module.
- *
- * @see eina_error_init()
- * @see eina_magic_string_init()
- * @see eina_mempool_init()
+ * @return #EINA_TRUE on success, #EINA_FALSE on failure.
+ *
+ * This function sets up the matrixsparse module of Eina. It is called by
+ * eina_init().
+ *
+ * This function creates mempool to speed up matrix rows and cells
+ * management, using EINA_MEMPOOL environment variable if it is set to
+ * choose the memory pool type to use.
+ *
+ * @see eina_init()
*/
-EAPI int
+Eina_Bool
eina_matrixsparse_init(void)
{
- const char *choice;
+ const char *choice, *tmp;
- if (!_eina_matrixsparse_init_count)
+ _eina_matrixsparse_log_dom = eina_log_domain_register("eina_matrixsparse", EINA_LOG_COLOR_DEFAULT);
+ if (_eina_matrixsparse_log_dom < 0)
{
- if (!eina_log_init())
- {
- fprintf(stderr, "Could not initialize eina logging system.");
- return 0;
- }
-
- _eina_matrixsparse_log_dom = eina_log_domain_register("eina_matrixsparse", EINA_LOG_COLOR_DEFAULT);
- if (_eina_matrixsparse_log_dom < 0)
- {
- EINA_LOG_ERR("Could not register log domain: eina_matrixsparse");
- eina_log_shutdown();
- return 0;
- }
-
- if (!eina_error_init())
- {
- ERR("Could not initialize eina error module.");
- goto on_eina_error_fail;
- }
-
- if (!eina_magic_string_init())
- {
- ERR("Could not initialize eina magic string module.");
- goto on_magic_string_fail;
- }
-
- if (!eina_mempool_init())
- {
- ERR("Could not initialize eina mempool module.");
- goto on_mempool_fail;
- }
+ EINA_LOG_ERR("Could not register log domain: eina_matrixsparse");
+ return EINA_FALSE;
+ }
#ifdef EINA_DEFAULT_MEMPOOL
- choice = "pass_through";
+ choice = "pass_through";
#else
- if (!(choice = getenv("EINA_MEMPOOL")))
- choice = "chained_mempool";
+ choice = "chained_mempool";
#endif
+ tmp = getenv("EINA_MEMPOOL");
+ if (tmp && tmp[0])
+ choice = tmp;
- _eina_matrixsparse_cell_mp = eina_mempool_add
- (choice, "matrixsparse_cell", NULL, sizeof (Eina_Matrixsparse_Cell), 120);
- if (!_eina_matrixsparse_cell_mp)
- {
- ERR("Mempool for matrixsparse_cell cannot be allocated in matrixsparse init.");
- goto on_init_fail;
- }
-
- _eina_matrixsparse_row_mp = eina_mempool_add
- (choice, "matrixsparse_row", NULL, sizeof (Eina_Matrixsparse_Row), 120);
- if (!_eina_matrixsparse_row_mp)
- {
- ERR("Mempool for matrixsparse_row cannot be allocated in matrixsparse init.");
- goto on_init_fail;
- }
-
- eina_magic_string_set(EINA_MAGIC_MATRIXSPARSE,
- "Eina Matrixsparse");
- eina_magic_string_set(EINA_MAGIC_MATRIXSPARSE_ROW,
- "Eina Matrixsparse Row");
- eina_magic_string_set(EINA_MAGIC_MATRIXSPARSE_CELL,
- "Eina Matrixsparse Cell");
-
- eina_magic_string_set(EINA_MAGIC_MATRIXSPARSE_ITERATOR,
- "Eina Matrixsparse Iterator");
-
- eina_magic_string_set(EINA_MAGIC_MATRIXSPARSE_ROW_ACCESSOR,
- "Eina Matrixsparse Row Accessor");
- eina_magic_string_set(EINA_MAGIC_MATRIXSPARSE_ROW_ITERATOR,
- "Eina Matrixsparse Row Iterator");
-
- eina_magic_string_set(EINA_MAGIC_MATRIXSPARSE_CELL_ACCESSOR,
- "Eina Matrixsparse Cell Accessor");
- eina_magic_string_set(EINA_MAGIC_MATRIXSPARSE_CELL_ITERATOR,
- "Eina Matrixsparse Cell Iterator");
+ _eina_matrixsparse_cell_mp = eina_mempool_add
+ (choice, "matrixsparse_cell", NULL, sizeof (Eina_Matrixsparse_Cell), 120);
+ if (!_eina_matrixsparse_cell_mp)
+ {
+ ERR("Mempool for matrixsparse_cell cannot be allocated in matrixsparse init.");
+ goto on_init_fail;
}
- return ++_eina_matrixsparse_init_count;
+ _eina_matrixsparse_row_mp = eina_mempool_add
+ (choice, "matrixsparse_row", NULL, sizeof (Eina_Matrixsparse_Row), 120);
+ if (!_eina_matrixsparse_row_mp)
+ {
+ ERR("Mempool for matrixsparse_row cannot be allocated in matrixsparse init.");
+ goto on_init_fail;
+ }
+
+ eina_magic_string_set(EINA_MAGIC_MATRIXSPARSE, "Eina Matrixsparse");
+ eina_magic_string_set(EINA_MAGIC_MATRIXSPARSE_ROW, "Eina Matrixsparse Row");
+ eina_magic_string_set(EINA_MAGIC_MATRIXSPARSE_CELL, "Eina Matrixsparse Cell");
+ eina_magic_string_set(EINA_MAGIC_MATRIXSPARSE_ITERATOR, "Eina Matrixsparse Iterator");
+ eina_magic_string_set(EINA_MAGIC_MATRIXSPARSE_ROW_ACCESSOR, "Eina Matrixsparse Row Accessor");
+ eina_magic_string_set(EINA_MAGIC_MATRIXSPARSE_ROW_ITERATOR, "Eina Matrixsparse Row Iterator");
+ eina_magic_string_set(EINA_MAGIC_MATRIXSPARSE_CELL_ACCESSOR, "Eina Matrixsparse Cell Accessor");
+ eina_magic_string_set(EINA_MAGIC_MATRIXSPARSE_CELL_ITERATOR, "Eina Matrixsparse Cell Iterator");
+
+ return EINA_TRUE;
on_init_fail:
- eina_mempool_shutdown();
- on_mempool_fail:
- eina_magic_string_shutdown();
- on_magic_string_fail:
- eina_error_shutdown();
- on_eina_error_fail:
eina_log_domain_unregister(_eina_matrixsparse_log_dom);
_eina_matrixsparse_log_dom = -1;
- eina_log_shutdown();
- return 0;
+ return EINA_FALSE;
}
/**
+ * @internal
* @brief Shut down the matrixsparse module.
*
- * @return 0 when the matrixsparse module is completely shut down, 1 or
- * greater otherwise.
+ * @return #EINA_TRUE on success, #EINA_FALSE on failure.
+ *
+ * This function shuts down the matrixsparse module set up by
+ * eina_matrixsparse_init(). It is called by eina_shutdown().
*
- * This function shuts down the mempool, magic and error modules set
- * up by eina_matrixsparse_init(). It is also called by eina_shutdown(). It
- * returns 0 when it is called the same number of times than
- * eina_matrixsparse_init().
+ * @see eina_shutdown()
*/
-EAPI int
+Eina_Bool
eina_matrixsparse_shutdown(void)
{
- --_eina_matrixsparse_init_count;
-
- if (!_eina_matrixsparse_init_count)
- {
- eina_mempool_del(_eina_matrixsparse_row_mp);
- eina_mempool_del(_eina_matrixsparse_cell_mp);
-
- eina_mempool_shutdown();
- eina_magic_string_shutdown();
- eina_error_shutdown();
+ eina_mempool_del(_eina_matrixsparse_row_mp);
+ eina_mempool_del(_eina_matrixsparse_cell_mp);
- eina_log_domain_unregister(_eina_matrixsparse_log_dom);
- _eina_matrixsparse_log_dom = -1;
- eina_log_shutdown();
- }
-
- return _eina_matrixsparse_init_count;
+ eina_log_domain_unregister(_eina_matrixsparse_log_dom);
+ _eina_matrixsparse_log_dom = -1;
+ return EINA_TRUE;
}
/**
#include "eina_hash.h"
#include "eina_module.h"
#include "eina_log.h"
+#include "eina_main.h"
+
+/* undefs EINA_ARG_NONULL() so NULL checks are not compiled out! */
#include "eina_safety_checks.h"
#include "eina_mempool.h"
static Eina_Hash *_backends;
static Eina_Array *_modules;
-static int _init_count = 0;
static int _log_dom = -1;
#define ERR(...) EINA_LOG_DOM_ERR(_log_dom, __VA_ARGS__)
EAPI Eina_Error EINA_ERROR_NOT_MEMPOOL_MODULE = 0;
-EAPI int
+Eina_Bool
eina_mempool_init(void)
{
- if (!_init_count)
- {
- char *path;
-
- if (!eina_log_init())
- {
- fprintf(stderr, "Could not initialize eina logging system.\n");
- return 0;
- }
-
- _log_dom = eina_log_domain_register("eina_mempool", EINA_LOG_COLOR_DEFAULT);
- if (_log_dom < 0)
- {
- EINA_LOG_ERR("Could not register log domain: eina_mempool");
- eina_log_shutdown();
- return 0;
- }
-
- if (!eina_safety_checks_init())
- {
- ERR("Could not initialize eina safety checks.");
- goto safety_checks_init_error;
- }
-
- if (!eina_hash_init())
- {
- ERR("Could not initialize eina hash module.");
- goto hash_init_error;
- }
- if (!eina_module_init())
- {
- ERR("Could not initialize eina module module.");
- goto module_init_error;
- }
-
- EINA_ERROR_NOT_MEMPOOL_MODULE = eina_error_msg_register("Not a memory pool module.");
- _backends = eina_hash_string_superfast_new(NULL);
-
- /* dynamic backends */
- _modules = eina_module_list_get(NULL, PACKAGE_LIB_DIR "/eina/mp/", 0, NULL, NULL);
-
- path = eina_module_environment_path_get("HOME", "/.eina/mp/");
- _modules = eina_module_list_get(_modules, path, 0, NULL, NULL);
- if (path) free(path);
-
- path = eina_module_environment_path_get("EINA_MODULES_MEMPOOL_DIR", "/eina/mp/");
- _modules = eina_module_list_get(_modules, path, 0, NULL, NULL);
- if (path) free(path);
-
- path = eina_module_symbol_path_get(eina_mempool_init, "/eina/mp/");
- _modules = eina_module_list_get(_modules, path, 0, NULL, NULL);
- if (path) free(path);
-
- if (!_modules)
- {
- ERR("no mempool modules able to be loaded.");
- eina_hash_free(_backends);
- goto mempool_init_error;
- }
- eina_module_list_load(_modules);
- /* builtin backends */
+ char *path;
+
+ _log_dom = eina_log_domain_register("eina_mempool", EINA_LOG_COLOR_DEFAULT);
+ if (_log_dom < 0)
+ {
+ EINA_LOG_ERR("Could not register log domain: eina_mempool");
+ return 0;
+ }
+
+ EINA_ERROR_NOT_MEMPOOL_MODULE = eina_error_msg_register("Not a memory pool module.");
+ _backends = eina_hash_string_superfast_new(NULL);
+
+ /* dynamic backends */
+ _modules = eina_module_list_get(NULL, PACKAGE_LIB_DIR "/eina/mp/", 0, NULL, NULL);
+
+ path = eina_module_environment_path_get("HOME", "/.eina/mp/");
+ _modules = eina_module_list_get(_modules, path, 0, NULL, NULL);
+ if (path) free(path);
+
+ path = eina_module_environment_path_get("EINA_MODULES_MEMPOOL_DIR", "/eina/mp/");
+ _modules = eina_module_list_get(_modules, path, 0, NULL, NULL);
+ if (path) free(path);
+
+ path = eina_module_symbol_path_get(eina_init, "/eina/mp/");
+ _modules = eina_module_list_get(_modules, path, 0, NULL, NULL);
+ if (path) free(path);
+
+ if (!_modules)
+ {
+ ERR("no mempool modules able to be loaded.");
+ eina_hash_free(_backends);
+ goto mempool_init_error;
+ }
+ eina_module_list_load(_modules);
+ /* builtin backends */
#ifdef EINA_STATIC_BUILD_CHAINED_POOL
- chained_init();
+ chained_init();
#endif
#ifdef EINA_STATIC_BUILD_PASS_THROUGH
- pass_through_init();
+ pass_through_init();
#endif
#ifdef EINA_STATIC_BUILD_EMEMOA_UNKNOWN
- ememoa_unknown_init();
+ ememoa_unknown_init();
#endif
#ifdef EINA_STATIC_BUILD_EMEMOA_FIXED
- ememoa_fixed_init();
+ ememoa_fixed_init();
#endif
#ifdef EINA_STATIC_BUILD_FIXED_BITMAP
- fixed_bitmap_init();
+ fixed_bitmap_init();
#endif
- }
- return ++_init_count;
-
- mempool_init_error:
- eina_module_shutdown();
- module_init_error:
- eina_hash_shutdown();
- hash_init_error:
- eina_safety_checks_shutdown();
- safety_checks_init_error:
- eina_log_domain_unregister(_log_dom);
- eina_log_shutdown();
- return 0;
+ return EINA_TRUE;
+ mempool_init_error:
+ eina_log_domain_unregister(_log_dom);
+ _log_dom = -1;
+
+ return EINA_FALSE;
}
-EAPI int
+Eina_Bool
eina_mempool_shutdown(void)
{
- _init_count--;
- if (_init_count != 0) return _init_count;
-
- /* builtin backends */
+ /* builtin backends */
#ifdef EINA_STATIC_BUILD_CHAINED_POOL
- chained_shutdown();
+ chained_shutdown();
#endif
#ifdef EINA_STATIC_BUILD_PASS_THROUGH
- pass_through_shutdown();
+ pass_through_shutdown();
#endif
#ifdef EINA_STATIC_BUILD_EMEMOA_UNKNOWN
- ememoa_unknown_shutdown();
+ ememoa_unknown_shutdown();
#endif
#ifdef EINA_STATIC_BUILD_EMEMOA_FIXED
- ememoa_fixed_shutdown();
+ ememoa_fixed_shutdown();
#endif
#ifdef EINA_STATIC_BUILD_FIXED_BITMAP
- fixed_bitmap_shutdown();
+ fixed_bitmap_shutdown();
#endif
- /* dynamic backends */
- eina_module_list_flush(_modules);
- if (_modules)
- eina_array_free(_modules);
+ /* dynamic backends */
+ eina_module_list_flush(_modules);
+ if (_modules)
+ eina_array_free(_modules);
- eina_module_shutdown();
+ if (_backends)
+ eina_hash_free(_backends);
- if (_backends)
- eina_hash_free(_backends);
+ eina_log_domain_unregister(_log_dom);
+ _log_dom = -1;
- eina_hash_shutdown();
- eina_safety_checks_shutdown();
- eina_log_domain_unregister(_log_dom);
- eina_log_shutdown();
-
- return 0;
+ return EINA_TRUE;
}
EAPI Eina_Mempool *
#include "eina_config.h"
#include "eina_private.h"
-#include "eina_safety_checks.h"
#include "eina_error.h"
-#include "eina_module.h"
#include "eina_file.h"
#include "eina_log.h"
+/* undefs EINA_ARG_NONULL() so NULL checks are not compiled out! */
+#include "eina_safety_checks.h"
+#include "eina_module.h"
+
/*============================================================================*
* Local *
*============================================================================*/
eina_module_free(m);
}
}
-static int _eina_module_count = 0;
/**
* @endcond
*/
/**
- * @brief Initialize the eina module internal structure.
+ * @internal
+ * @brief Initialize the module loader module.
+ *
+ * @return #EINA_TRUE on success, #EINA_FALSE on failure.
*
- * @return 1 or greater on success, 0 on error.
+ * This function sets up the module loader module of Eina. It is
+ * called by eina_init().
*
* This function sets up the module module of Eina. It also registers
* the errors #EINA_ERROR_WRONG_MODULE and
- * #EINA_ERROR_MODULE_INIT_FAILED. It is also called by
- * eina_init(). It returns 0 on failure, otherwise it returns the
- * number of times it has already been called. See eina_error_init()
- * for the documentation of the initialisation of the dependency
- * modules.
+ * #EINA_ERROR_MODULE_INIT_FAILED.
*
- * Once the module module is not used anymore, then
- * eina_module_shutdown() must be called to shut down the module
- * module.
- *
- * @see eina_error_init()
* @see eina_init()
*/
-EAPI int
+Eina_Bool
eina_module_init(void)
{
- _eina_module_count++;
-
- if (_eina_module_count != 1)
- goto end_init;
-
- if (!eina_log_init())
- {
- fprintf(stderr, "Could not initialize eina logging module.\n");
- return 0;
- }
-
- if (!eina_safety_checks_init())
- {
- EINA_LOG_ERR("Could not initialize eina safety checks.");
- eina_log_shutdown();
- return 0;
- }
-
EINA_MODULE_LOG_DOM = eina_log_domain_register
("eina_module", EINA_LOG_COLOR_DEFAULT);
if (EINA_MODULE_LOG_DOM < 0)
{
EINA_LOG_ERR("Could not register log domain: eina_module");
- eina_safety_checks_shutdown();
- eina_log_shutdown();
- return 0;
- }
-
- if (!eina_error_init())
- {
- ERR("Could not initialize eina error module.");
- goto error_init_error;
+ return EINA_FALSE;
}
EINA_ERROR_WRONG_MODULE = eina_error_msg_register("Wrong file format or no file module found");
EINA_ERROR_MODULE_INIT_FAILED = eina_error_msg_register("Module initialisation function failed");
- if (!eina_array_init())
- {
- ERR("Could not initialize eina array module.");
- goto array_init_error;
- }
-
- end_init:
- return _eina_module_count;
-
- array_init_error:
- eina_error_shutdown();
- error_init_error:
- eina_safety_checks_shutdown();
- eina_log_domain_unregister(EINA_MODULE_LOG_DOM);
- EINA_MODULE_LOG_DOM = -1;
- eina_log_shutdown();
- return 0;
+ return EINA_TRUE;
}
/**
- * @brief Shut down the eina module internal structures
+ * @internal
+ * @brief Shut down the module loader module.
*
- * @return 0 when the module module is completely shut down, 1 or
- * greater otherwise.
+ * @return #EINA_TRUE on success, #EINA_FALSE on failure.
*
- * This function shuts down the module module set up by
- * eina_module_init(). It is called by eina_shutdown(). It
- * returns 0 when it is called the same number of times than
- * eina_module_init().
+ * This function shuts down the module loader module set up by
+ * eina_module_init(). It is called by eina_shutdown().
*
- * @see eina_error_shutdown()
* @see eina_shutdown()
*/
-EAPI int
+Eina_Bool
eina_module_shutdown(void)
{
- _eina_module_count--;
- if (_eina_module_count != 0)
- goto end_shutdown;
-
- eina_array_shutdown();
- eina_error_shutdown();
-
/* TODO should we store every module when "new" is called and
* delete the list of modules here
*/
- eina_safety_checks_shutdown();
-
eina_log_domain_unregister(EINA_MODULE_LOG_DOM);
EINA_MODULE_LOG_DOM = -1;
- eina_log_shutdown();
-
- end_shutdown:
- return _eina_module_count;
+ return EINA_TRUE;
}
/**
#include "eina_config.h"
#include "eina_private.h"
+#include "eina_array.h"
+
+/* undefs EINA_ARG_NONULL() so NULL checks are not compiled out! */
#include "eina_safety_checks.h"
#include "eina_rbtree.h"
-#include "eina_array.h"
/*============================================================================*
* Local *
#include "eina_config.h"
#include "eina_private.h"
-#include "eina_safety_checks.h"
-#include "eina_rectangle.h"
#include "eina_magic.h"
#include "eina_inlist.h"
#include "eina_mempool.h"
#include "eina_list.h"
#include "eina_trash.h"
+/* undefs EINA_ARG_NONULL() so NULL checks are not compiled out! */
+#include "eina_safety_checks.h"
+#include "eina_rectangle.h"
+
/*============================================================================*
* Local *
*============================================================================*/
EINA_MAGIC_FAIL((d), EINA_RECTANGLE_ALLOC_MAGIC); \
} while (0);
-static int _eina_rectangle_init_count = 0;
static Eina_Mempool *_eina_rectangle_alloc_mp = NULL;
static Eina_Mempool *_eina_rectangle_mp = NULL;
* API *
*============================================================================*/
-EAPI int
+Eina_Bool
eina_rectangle_init(void)
{
- const char *choice;
-
- _eina_rectangle_init_count++;
-
- if (_eina_rectangle_init_count > 1) return _eina_rectangle_init_count;
-
- if (!eina_log_init())
- {
- fprintf(stderr, "Could not initialize eina logging system.\n");
- return 0;
- }
+ const char *choice, *tmp;
_eina_rectangle_log_dom = eina_log_domain_register("eina_rectangle", EINA_LOG_COLOR_DEFAULT);
if (_eina_rectangle_log_dom < 0)
{
EINA_LOG_ERR("Could not register log domain: eina_rectangle");
- eina_log_shutdown();
- return 0;
- }
-
- if (!eina_error_init())
- {
- ERR("Could not initialize eina error module.");
- goto error_init_error;
- }
- if (!eina_safety_checks_init())
- {
- fprintf(stderr, "Could not initialize eina safety checks.");
- goto safety_checks_init_error;
- }
- if (!eina_mempool_init())
- {
- ERR("Could not initialize eina mempool module.");
- goto mempool_init_error;
- }
-
- if (!eina_list_init())
- {
- ERR("Could not initialize eina list module.");
- goto list_init_error;
+ return EINA_FALSE;
}
#ifdef EINA_DEFAULT_MEMPOOL
choice = "pass_through";
#else
- if (!(choice = getenv("EINA_MEMPOOL")))
- choice = "chained_mempool";
+ choice = "chained_mempool";
#endif
+ tmp = getenv("EINA_MEMPOOL");
+ if (tmp && tmp[0])
+ choice = tmp;
- _eina_rectangle_alloc_mp = eina_mempool_add(choice, "rectangle-alloc", NULL,
- sizeof (Eina_Rectangle_Alloc) + sizeof (Eina_Rectangle), 1024);
+ _eina_rectangle_alloc_mp = eina_mempool_add
+ (choice, "rectangle-alloc", NULL,
+ sizeof(Eina_Rectangle_Alloc) + sizeof(Eina_Rectangle), 1024);
if (!_eina_rectangle_alloc_mp)
{
ERR("Mempool for rectangle cannot be allocated in rectangle init.");
goto init_error;
}
- _eina_rectangle_mp = eina_mempool_add(choice, "rectangle", NULL, sizeof (Eina_Rectangle), 256);
+ _eina_rectangle_mp = eina_mempool_add
+ (choice, "rectangle", NULL, sizeof(Eina_Rectangle), 256);
if (!_eina_rectangle_mp)
{
ERR("Mempool for rectangle cannot be allocated in rectangle init.");
goto init_error;
}
- return _eina_rectangle_init_count;
+ return EINA_TRUE;
init_error:
- eina_list_shutdown();
- list_init_error:
- eina_mempool_shutdown();
- mempool_init_error:
- eina_safety_checks_shutdown();
- safety_checks_init_error:
- eina_error_shutdown();
- error_init_error:
eina_log_domain_unregister(_eina_rectangle_log_dom);
_eina_rectangle_log_dom = -1;
- eina_log_shutdown();
- return 0;
+ return EINA_FALSE;
}
-EAPI int
+Eina_Bool
eina_rectangle_shutdown(void)
{
Eina_Rectangle *del;
- --_eina_rectangle_init_count;
-
- if (_eina_rectangle_init_count) return _eina_rectangle_init_count;
-
- eina_list_shutdown();
-
while ((del = eina_trash_pop(&_eina_rectangles)))
eina_mempool_free(_eina_rectangle_mp, del);
_eina_rectangles_count = 0;
eina_mempool_del(_eina_rectangle_alloc_mp);
eina_mempool_del(_eina_rectangle_mp);
- eina_mempool_shutdown();
- eina_safety_checks_shutdown();
- eina_error_shutdown();
eina_log_domain_unregister(_eina_rectangle_log_dom);
_eina_rectangle_log_dom = -1;
- eina_log_shutdown();
- return 0;
+ return EINA_TRUE;
}
EAPI Eina_Rectangle *
EAPI Eina_Error EINA_ERROR_SAFETY_FAILED = 0;
-static int _eina_safety_checks_init_count = 0;
-
/**
* @endcond
*/
/**
+ * @internal
* @brief Initialize the safety checks module.
*
- * @return 1 or greater on success, 0 on error.
+ * @return #EINA_TRUE on success, #EINA_FALSE on failure.
*
* This function sets up the safety checks module of Eina. It is
- * called by eina_init() and by all modules initialization
- * functions. It returns @c 0 on failure, otherwise it returns the
- * number of times it is called.
+ * called by eina_init().
*
* @see eina_init()
*/
-EAPI int
+Eina_Bool
eina_safety_checks_init(void)
{
- if (_eina_safety_checks_init_count > 0)
- return ++_eina_safety_checks_init_count;
-
-#ifdef EINA_SAFETY_CHECKS
- if (!eina_log_init())
- return 0;
-#endif
- if (!eina_error_init())
- {
- eina_log_shutdown();
- return 0;
- }
EINA_ERROR_SAFETY_FAILED = eina_error_msg_register("Safety check failed.");
- _eina_safety_checks_init_count = 1;
- return 1;
+ return EINA_TRUE;
}
/**
+ * @internal
* @brief Shut down the safety checks module.
*
- * @return 0 when the error module is completely shut down, 1 or
- * greater otherwise.
+ * @return #EINA_TRUE on success, #EINA_FALSE on failure.
*
* This function shuts down the error module set up by
- * eina_safety_checks_init(). It is called by eina_shutdown() and by
- * all modules shutdown functions. It returns 0 when it is called the
- * same number of times than eina_safety_checks_init(). In that case
- * it clears the error list.
+ * eina_safety_checks_init(). It is called by eina_shutdown().
*
* @see eina_shutdown()
*/
-EAPI int
+Eina_Bool
eina_safety_checks_shutdown(void)
{
- _eina_safety_checks_init_count--;
- if (_eina_safety_checks_init_count != 0)
- return _eina_safety_checks_init_count;
-
- eina_error_shutdown();
-#ifdef EINA_SAFETY_CHECKS
- eina_log_shutdown();
-#endif
- return 0;
+ return EINA_TRUE;
}
/**
#include "eina_config.h"
#include "eina_private.h"
-#include "eina_safety_checks.h"
-#include "eina_stringshare.h"
#include "eina_hash.h"
#include "eina_rbtree.h"
#include "eina_error.h"
+/* undefs EINA_ARG_NONULL() so NULL checks are not compiled out! */
+#include "eina_safety_checks.h"
+#include "eina_stringshare.h"
+
/*============================================================================*
* Local *
*============================================================================*/
};
static Eina_Stringshare *share = NULL;
-static int _eina_stringshare_init_count = 0;
static int _eina_stringshare_log_dom = -1;
#define CRITICAL(...) EINA_LOG_DOM_CRIT(_eina_stringshare_log_dom, __VA_ARGS__)
*/
/**
- * @brief Initialize the eina stringshare internal structure.
+ * @internal
+ * @brief Initialize the stringshare module.
*
- * @return 1 or greater on success, 0 on error.
+ * @return #EINA_TRUE on success, #EINA_FALSE on failure.
*
- * This function allocates the memory needed by the stringshare
- * internal structure and sets up the error module of Eina. It is also
- * called by eina_init(). It returns 0 on failure, otherwise it
- * returns the number of times it has already been called.
+ * This function sets up the stringshare module of Eina. It is called by
+ * eina_init().
+ *
+ * @see eina_init()
*/
-EAPI int
+Eina_Bool
eina_stringshare_init(void)
{
- /*
- * No strings have been loaded at this point, so create the hash
- * table for storing string info for later.
- */
- if (!_eina_stringshare_init_count)
+ _eina_stringshare_log_dom = eina_log_domain_register("eina_stringshare", EINA_LOG_COLOR_DEFAULT);
+ if (_eina_stringshare_log_dom < 0)
{
- if (!eina_log_init())
- {
- fprintf(stderr, "Could not initialize eina logging system.\n");
- return 0;
- }
-
- _eina_stringshare_log_dom = eina_log_domain_register("eina_stringshare", EINA_LOG_COLOR_DEFAULT);
- if (_eina_stringshare_log_dom < 0)
- {
- EINA_LOG_ERR("Could not register log domain: eina_stringshare");
- eina_log_shutdown();
- return 0;
- }
-
- share = calloc(1, sizeof(Eina_Stringshare));
- if (!share)
- return 0;
-
- if (!eina_error_init())
- {
- ERR("Could not initialize eina error module.");
- goto error_init_error;
- }
-
- if (!eina_safety_checks_init())
- {
- ERR("Could not initialize eina safety checks.");
- goto safety_checks_init_error;
- }
+ EINA_LOG_ERR("Could not register log domain: eina_stringshare");
+ return EINA_FALSE;
+ }
- if (!eina_magic_string_init())
- {
- ERR("ERROR: Could not initialize eina magic string module.");
- goto magic_string_init_error;
- }
-
- eina_magic_string_set(EINA_MAGIC_STRINGSHARE,
- "Eina Stringshare");
- eina_magic_string_set(EINA_MAGIC_STRINGSHARE_HEAD,
- "Eina Stringshare Head");
- eina_magic_string_set(EINA_MAGIC_STRINGSHARE_NODE,
- "Eina Stringshare Node");
- EINA_MAGIC_SET(share, EINA_MAGIC_STRINGSHARE);
-
- _eina_stringshare_small_init();
- _eina_stringshare_population_init();
+ share = calloc(1, sizeof(Eina_Stringshare));
+ if (!share)
+ {
+ eina_log_domain_unregister(_eina_stringshare_log_dom);
+ _eina_stringshare_log_dom = -1;
+ return EINA_FALSE;
}
- return ++_eina_stringshare_init_count;
+ eina_magic_string_set(EINA_MAGIC_STRINGSHARE, "Eina Stringshare");
+ eina_magic_string_set(EINA_MAGIC_STRINGSHARE_HEAD, "Eina Stringshare Head");
+ eina_magic_string_set(EINA_MAGIC_STRINGSHARE_NODE, "Eina Stringshare Node");
+ EINA_MAGIC_SET(share, EINA_MAGIC_STRINGSHARE);
- magic_string_init_error:
- eina_safety_checks_shutdown();
- safety_checks_init_error:
- eina_error_shutdown();
- error_init_error:
- eina_log_domain_unregister(_eina_stringshare_log_dom);
- _eina_stringshare_log_dom = -1;
- eina_log_shutdown();
- return 0;
+ _eina_stringshare_small_init();
+ _eina_stringshare_population_init();
+ return EINA_TRUE;
}
/**
- * @brief Shut down the eina stringshare internal structures
+ * @internal
+ * @brief Shut down the stringshare module.
*
- * @return 0 when the stringshare module is completely shut down, 1 or
- * greater otherwise.
+ * @return #EINA_TRUE on success, #EINA_FALSE on failure.
*
- * This function frees the memory allocated by eina_stringshare_init()
- * and shuts down the error module. It is also called by
- * eina_shutdown(). It returns 0 when it is called the same number of
- * times than eina_stringshare_init().
+ * This function shuts down the stringshare module set up by
+ * eina_stringshare_init(). It is called by eina_shutdown().
+ *
+ * @see eina_shutdown()
*/
-EAPI int
+Eina_Bool
eina_stringshare_shutdown(void)
{
unsigned int i;
_eina_stringshare_population_stats();
- --_eina_stringshare_init_count;
- if (!_eina_stringshare_init_count)
+ /* remove any string still in the table */
+ for (i = 0; i < EINA_STRINGSHARE_BUCKETS; i++)
{
- /* remove any string still in the table */
- for (i = 0; i < EINA_STRINGSHARE_BUCKETS; i++)
- {
- eina_rbtree_delete(EINA_RBTREE_GET(share->buckets[i]), EINA_RBTREE_FREE_CB(_eina_stringshare_head_free), NULL);
- share->buckets[i] = NULL;
- }
- MAGIC_FREE(share);
-
- _eina_stringshare_population_shutdown();
- _eina_stringshare_small_shutdown();
- eina_magic_string_shutdown();
- eina_safety_checks_shutdown();
- eina_error_shutdown();
- eina_log_domain_unregister(_eina_stringshare_log_dom);
- _eina_stringshare_log_dom = -1;
- eina_log_shutdown();
+ eina_rbtree_delete(EINA_RBTREE_GET(share->buckets[i]), EINA_RBTREE_FREE_CB(_eina_stringshare_head_free), NULL);
+ share->buckets[i] = NULL;
}
+ MAGIC_FREE(share);
- return _eina_stringshare_init_count;
+ _eina_stringshare_population_shutdown();
+ _eina_stringshare_small_shutdown();
+ eina_log_domain_unregister(_eina_stringshare_log_dom);
+ _eina_stringshare_log_dom = -1;
+ return EINA_TRUE;
}
/**
static Eina_Array *_modules;
static void _mempool_init(void)
{
- eina_mempool_init();
+ eina_init();
/* force modules to be loaded in case they are not installed */
_modules = eina_module_list_get(NULL, PACKAGE_BUILD_DIR"/src/modules", 1, NULL, NULL);
eina_module_list_load(_modules);
{
eina_module_list_flush(_modules);
/* TODO delete the list */
- eina_mempool_shutdown();
+ eina_shutdown();
}
int
_mempool_init();
- eina_benchmark_init();
+ eina_init();
for (i = 0; etc[i].bench_case != NULL; ++i)
{
eina_bench_e17();
- eina_benchmark_shutdown();
+ eina_shutdown();
_mempool_shutdown();
return 0;
srand(time(NULL));
- eina_array_init();
+ eina_init();
array = eina_array_new(64);
eina_array_free(array);
- eina_array_shutdown();
+ eina_shutdown();
}
static Eina_Bool
srand(time(NULL));
- eina_array_init();
+ eina_init();
array = eina_array_new(64);
eina_array_free(array);
- eina_array_shutdown();
+ eina_shutdown();
}
static void
int i;
int j;
- eina_list_init();
+ eina_init();
for (i = 0; i < 1000; ++i)
{
list = eina_list_remove_list(list, list);
}
- eina_list_shutdown();
+ eina_shutdown();
}
static void
int i;
int j;
- eina_list_init();
+ eina_init();
for (i = 0; i < 1000; ++i)
{
list = eina_list_remove_list(list, list);
}
- eina_list_shutdown();
+ eina_shutdown();
}
static void
int i;
int j;
- eina_array_init();
+ eina_init();
array = eina_array_new(32);
for (i = 0; i < 100; ++i)
}
eina_array_free(array);
- eina_array_shutdown();
+ eina_shutdown();
}
static void
int i;
int j;
- eina_array_init();
+ eina_init();
array = eina_array_new(32);
for (i = 0; i < 100; ++i)
}
eina_array_free(array);
- eina_array_shutdown();
+ eina_shutdown();
}
#endif
Eina_List *list = NULL;
int i;
- eina_list_init();
- eina_rectangle_init();
+ eina_init();
+ eina_init();
pool = eina_rectangle_pool_new(2048, 2048);
if (!pool) return ;
eina_rectangle_pool_free(pool);
eina_list_free(list);
- eina_rectangle_shutdown();
- eina_list_shutdown();
+ eina_shutdown();
+ eina_shutdown();
}
void eina_bench_rectangle_pool(Eina_Benchmark *bench)
#endif
#include "eina_bench.h"
-#include "eina_list.h"
-#include "eina_convert.h"
+#include "Eina.h"
static int
_eina_cmp_str(const char *a, const char *b)
Eina_List *list = NULL;
int i;
- eina_list_init();
+ eina_init();
srand(time(NULL));
list = eina_list_remove_list(list, list);
}
- eina_list_shutdown();
+ eina_shutdown();
}
#ifdef EINA_BENCH_HAVE_EVAS
unsigned int j;
int i;
- eina_stringshare_init();
+ eina_init();
for (i = 0; i < request; ++i)
{
tmp = eina_stringshare_add(build);
}
- eina_stringshare_shutdown();
+ eina_shutdown();
}
#ifdef EINA_BENCH_HAVE_GLIB
# include <Ecore_Data.h>
#endif
-#include "eina_stringshare.h"
-#include "eina_counter.h"
+#include "Eina.h"
#if EINA_ENABLE_BENCH_E17
static const char *strings[30000];
static Eina_Stringshare_Test eina_str = {
"eina",
- eina_stringshare_init,
+ eina_init,
eina_stringshare_add,
eina_stringshare_del,
- eina_stringshare_shutdown
+ eina_shutdown
};
#ifdef EINA_BENCH_HAVE_EVAS
#if EINA_ENABLE_BENCH_E17
int i;
- eina_counter_init();
+ eina_init();
for (i = 0; str[i]; ++i)
eina_bench_e17_stringshare(str[i]);
- eina_counter_shutdown();
+ eina_shutdown();
#endif
}
#endif
#include "eina_suite.h"
-#include "eina_mempool.h"
+#include "Eina.h"
#include <stdio.h>
#include <string.h>
static Eina_Array *_modules;
static void _mempool_init(void)
{
- eina_mempool_init();
+ eina_init();
/* force modules to be loaded in case they are not installed */
_modules = eina_module_list_get(NULL, PACKAGE_BUILD_DIR"/src/modules", 1, NULL, NULL);
eina_module_list_load(_modules);
{
eina_module_list_flush(_modules);
/* TODO delete the list */
- eina_mempool_shutdown();
+ eina_shutdown();
}
int
#include <stdio.h>
#include "eina_suite.h"
-#include "eina_array.h"
-#include "eina_inlist.h"
-#include "eina_list.h"
-#include "eina_private.h"
+#include "Eina.h"
static Eina_Bool
eina_accessor_check(__UNUSED__ const Eina_Array *array,
int *tmp;
int i;
- eina_array_init();
+ eina_init();
ea = eina_array_new(11);
fail_if(!ea);
eina_array_free(ea);
- eina_array_shutdown();
+ eina_shutdown();
}
END_TEST
int *j;
int i = 0;
- eina_list_init();
+ eina_init();
list = eina_list_append(list, &data[0]);
fail_if(list == NULL);
#include <stdio.h>
#include "eina_suite.h"
-#include "eina_array.h"
-#include "eina_convert.h"
+#include "Eina.h"
START_TEST(eina_array_simple)
{
Eina_Array_Iterator it;
unsigned int i;
- eina_array_init();
+ eina_init();
ea = eina_array_new(11);
fail_if(!ea);
eina_array_flush(ea);
eina_array_free(ea);
- eina_array_shutdown();
+ eina_shutdown();
}
END_TEST
Eina_Array_Iterator it;
unsigned int i;
- eina_array_init();
+ eina_init();
eina_array_step_set(&sea, 10);
eina_array_clean(&sea);
eina_array_flush(&sea);
- eina_array_shutdown();
+ eina_shutdown();
}
END_TEST
Eina_Array_Iterator it;
unsigned int i;
- eina_array_init();
+ eina_init();
ea = eina_array_new(64);
fail_if(!ea);
eina_array_free(ea);
- eina_array_shutdown();
+ eina_shutdown();
}
END_TEST
#include <math.h>
#include <float.h>
-#include "eina_convert.h"
#include "eina_suite.h"
+#include "Eina.h"
START_TEST(eina_convert_simple)
{
long long int m = 0;
long e = 0;
- eina_convert_init();
+ eina_init();
_eina_convert_check(EET_TEST_DOUBLE0, 20);
_eina_convert_check(-EET_TEST_DOUBLE0, 21);
fail_if(eina_convert_atod("0xjo", 8, &m, &e) != EINA_FALSE);
fail_if(eina_convert_atod("0xp", 8, &m, &e) != EINA_FALSE);
- eina_convert_shutdown();
+ eina_shutdown();
}
END_TEST
#include <stdio.h>
#include <stdlib.h>
-#include "eina_counter.h"
#include "eina_suite.h"
-
-START_TEST(eina_counter_init_shutdown)
-{
- eina_counter_init();
- eina_counter_init();
- eina_counter_shutdown();
- eina_counter_init();
- eina_counter_init();
- eina_counter_shutdown();
- eina_counter_shutdown();
- eina_counter_shutdown();
-}
-END_TEST
+#include "Eina.h"
START_TEST(eina_counter_simple)
{
char *dump;
int i;
- eina_counter_init();
+ eina_init();
cnt = eina_counter_new("eina_test");
fail_if(!cnt);
eina_counter_free(cnt);
- eina_counter_shutdown();
+ eina_shutdown();
}
END_TEST
Eina_Counter *cnt;
char *dump;
- eina_counter_init();
+ eina_init();
cnt = eina_counter_new("eina_test");
fail_if(!cnt);
free(dump);
- eina_counter_shutdown();
+ eina_shutdown();
}
END_TEST
void eina_test_counter(TCase *tc)
{
- tcase_add_test(tc, eina_counter_init_shutdown);
tcase_add_test(tc, eina_counter_simple);
tcase_add_test(tc, eina_counter_break);
}
#include <string.h>
#include "eina_suite.h"
-#include "eina_error.h"
-
-START_TEST(eina_error_init_shutdown)
-{
- eina_error_init();
- eina_error_init();
- eina_error_shutdown();
- eina_error_init();
- eina_error_init();
- eina_error_shutdown();
- eina_error_shutdown();
- eina_error_shutdown();
-}
-END_TEST
+#include "Eina.h"
#define TEST_TEXT "The big test\n"
setenv("EINA_ERROR_LEVEL", "1", 0);
- eina_error_init();
+ eina_init();
test = eina_error_msg_register(TEST_TEXT);
fail_if(!eina_error_msg_get(test));
eina_error_set(test);
fail_if(eina_error_get() != test);
- eina_error_shutdown();
+ eina_shutdown();
}
END_TEST
void
eina_test_error(TCase *tc)
{
- tcase_add_test(tc, eina_error_init_shutdown);
tcase_add_test(tc, eina_error_errno);
}
#include <string.h>
#include "eina_suite.h"
-#include "eina_file.h"
+#include "Eina.h"
START_TEST(eina_file_split_simple)
{
Eina_Array *ea;
- eina_array_init();
+ eina_init();
ea = eina_file_split(NULL);
fail_if(ea);
eina_array_free(ea);
- eina_array_shutdown();
+ eina_shutdown();
}
END_TEST
#include <stdio.h>
#include <string.h>
-#include "eina_hash.h"
-#include "eina_convert.h"
#include "eina_suite.h"
-
-START_TEST(eina_hash_init_shutdown)
-{
- eina_hash_init();
- eina_hash_init();
- eina_hash_shutdown();
- eina_hash_init();
- eina_hash_init();
- eina_hash_shutdown();
- eina_hash_shutdown();
- eina_hash_shutdown();
-}
-END_TEST
+#include "Eina.h"
static Eina_Bool
eina_foreach_check(__UNUSED__ const Eina_Hash *hash, const void *key, void *data, __UNUSED__ void *fdata)
int array[] = { 1, 42, 4, 5, 6 };
/* As mempool is already initialized and it use hash, we should have 2 init. */
- fail_if(eina_hash_init() != 2);
+ fail_if(eina_init() != 2);
hash = eina_hash_string_superfast_new(NULL);
fail_if(hash == NULL);
eina_hash_free(hash);
- /* Same comment as eina_hash_init */
- fail_if(eina_hash_shutdown() != 1);
+ /* Same comment as eina_init */
+ fail_if(eina_shutdown() != 1);
}
END_TEST
Eina_Hash *hash = NULL;
int i;
- fail_if(eina_hash_init() != 2);
+ fail_if(eina_init() != 2);
hash = eina_hash_string_djb2_new(NULL);
fail_if(hash == NULL);
eina_hash_free(hash);
- fail_if(eina_hash_shutdown() != 1);
+ fail_if(eina_shutdown() != 1);
}
END_TEST
int i[] = { 7, 7 };
int *test;
- fail_if(eina_hash_init() != 2);
+ fail_if(eina_init() != 2);
hash = eina_hash_string_superfast_new(NULL);
fail_if(hash == NULL);
eina_hash_free(hash);
- fail_if(eina_hash_shutdown() != 1);
+ fail_if(eina_shutdown() != 1);
}
END_TEST
void eina_test_hash(TCase *tc)
{
- tcase_add_test(tc, eina_hash_init_shutdown);
tcase_add_test(tc, eina_hash_simple);
tcase_add_test(tc, eina_hash_extended);
tcase_add_test(tc, eina_hash_double_item);
#include <stdlib.h>
#include "eina_suite.h"
-#include "eina_inlist.h"
+#include "Eina.h"
typedef struct _Eina_Test_Inlist Eina_Test_Inlist;
struct _Eina_Test_Inlist
#include <stdio.h>
#include "eina_suite.h"
-#include "eina_array.h"
-#include "eina_hash.h"
-#include "eina_inlist.h"
-#include "eina_list.h"
-#include "eina_rbtree.h"
-#include "eina_private.h"
+#include "Eina.h"
static Eina_Bool
eina_iterator_array_check(__UNUSED__ const Eina_Array *array,
int *tmp;
int i;
- eina_array_init();
+ eina_init();
ea = eina_array_new(11);
fail_if(!ea);
eina_array_free(ea);
- eina_array_shutdown();
+ eina_shutdown();
}
END_TEST
Eina_Hash *hash;
int array[] = { 1, 42, 7, 8, 6 };
- eina_hash_init();
+ eina_init();
hash = eina_hash_string_superfast_new(NULL);
fail_if(hash == NULL);
eina_hash_free(hash);
- eina_hash_shutdown();
+ eina_shutdown();
}
END_TEST
int data[] = { 6, 9, 42, 1, 7, 1337, 81, 1664 };
int i = 0;
- eina_list_init();
+ eina_init();
list = eina_list_append(list, &data[0]);
fail_if(list == NULL);
#include <stdio.h>
#include "eina_suite.h"
-#include "eina_lalloc.h"
+#include "Eina.h"
typedef struct _Eina_Lazy_Allocator_Test Eina_Lazy_Allocator_Test;
struct _Eina_Lazy_Allocator_Test
#include <stdio.h>
-#include "eina_list.h"
#include "eina_suite.h"
+#include "Eina.h"
static Eina_Bool eina_list_sorted_check(const Eina_List *list)
{
int result[] = { 81, 9, 9, 7, 1 };
int i;
- eina_list_init();
+ eina_init();
list = eina_list_append(list, &data[0]);
fail_if(list == NULL);
list = eina_list_free(list);
fail_if(list != NULL);
- eina_list_shutdown();
+ eina_shutdown();
}
END_TEST
int data[] = { 6, 9, 42, 1, 7, 9, 81, 1664, 1337, 3, 21, 10, 0, 5, 2008 };
int i;
- eina_list_init();
+ eina_init();
l1 = eina_list_append(NULL, &data[0]);
l1 = eina_list_append(l1, &data[1]);
fail_if(!eina_list_sorted_check(l1));
- eina_list_shutdown();
+ eina_shutdown();
}
END_TEST
Eina_List *l1, *l2, *itr;
void *d;
- eina_list_init();
+ eina_init();
count = sizeof(data)/sizeof(data[0]);
fail_if(!eina_list_sorted_check(l1));
eina_list_free(l1);
- eina_list_shutdown();
+ eina_shutdown();
}
END_TEST
#include <string.h>
#include "eina_suite.h"
-#include "eina_log.h"
-
-START_TEST(eina_log_init_shutdown)
-{
- int initial_level = eina_log_init() - 1;
- fail_if(!(initial_level+1));
-
- fail_if(!eina_log_init());
- fail_if(!eina_log_shutdown());
- fail_if(!eina_log_init());
- fail_if(!eina_log_init());
- fail_if(!eina_log_shutdown());
- fail_if(!eina_log_shutdown());
-
- fail_if(initial_level != eina_log_shutdown());
-}
-END_TEST
+#include "Eina.h"
START_TEST(eina_log_macro)
{
- fail_if(!eina_log_init());
+ fail_if(!eina_init());
eina_log_level_set(EINA_LOG_LEVEL_DBG);
eina_log_print_cb_set(eina_log_print_cb_file, stderr);
EINA_LOG_WARN("A warning\n");
EINA_LOG_DBG("A debug\n");
- eina_log_shutdown();
+ eina_shutdown();
}
END_TEST
START_TEST(eina_log_domains_macros)
{
- fail_if(!eina_log_init());
+ fail_if(!eina_init());
int d = eina_log_domain_register("MyDomain", EINA_COLOR_GREEN);
fail_if(d < 0);
EINA_LOG_DOM_DBG(d, "A debug\n");
EINA_LOG_DOM_INFO(d, "An info\n");
- eina_log_shutdown();
+ eina_shutdown();
}
END_TEST
START_TEST(eina_log_domains_registry)
{
- fail_if(!eina_log_init());
+ fail_if(!eina_init());
int i;
int d[50];
for (i = 0; i < 50; i++)
eina_log_domain_unregister(d[i]);
- eina_log_shutdown();
+ eina_shutdown();
}
END_TEST
START_TEST(eina_log_domains_slot_reuse)
{
- fail_if(!eina_log_init());
+ fail_if(!eina_init());
// Create 9 domains
int idx[9];
// Check for slot reuse
fail_if(new != removed);
- eina_log_shutdown();
+ eina_shutdown();
}
END_TEST
START_TEST(eina_log_level_indexes)
{
- fail_if(!eina_log_init());
+ fail_if(!eina_init());
int d = eina_log_domain_register("Levels", EINA_COLOR_GREEN);
fail_if(d < 0);
// Displayed only if user sets level 6 or higher
EINA_LOG(d, 6, "Higher level debug\n");
- eina_log_shutdown();
+ eina_shutdown();
}
END_TEST
void
eina_test_log(TCase *tc)
{
- tcase_add_test(tc, eina_log_init_shutdown);
tcase_add_test(tc, eina_log_macro);
tcase_add_test(tc, eina_log_domains_macros);
tcase_add_test(tc, eina_log_domains_registry);
#define EINA_MAGIC_DEBUG
#include "eina_suite.h"
-#include "eina_magic.h"
-
-START_TEST(eina_magic_string_init_shutdown)
-{
- eina_magic_string_init();
- eina_magic_string_init();
- eina_magic_string_shutdown();
- eina_magic_string_init();
- eina_magic_string_init();
- eina_magic_string_shutdown();
- eina_magic_string_shutdown();
- eina_magic_string_shutdown();
-}
-END_TEST
+#include "Eina.h"
#define EINA_MAGIC_TEST 0x7781fee7
#define EINA_MAGIC_TEST2 0x42241664
{
Eina_Magic_Struct *ems = NULL;
- eina_magic_string_init();
+ eina_init();
eina_magic_string_set(EINA_MAGIC_TEST, EINA_MAGIC_STRING);
eina_magic_string_set(EINA_MAGIC_TEST2, NULL);
EINA_MAGIC_FAIL(ems, EINA_MAGIC_TEST);
#endif
- eina_magic_string_shutdown();
+ eina_shutdown();
}
END_TEST
void eina_test_magic(TCase *tc)
{
- tcase_add_test(tc, eina_magic_string_init_shutdown);
tcase_add_test(tc, eina_magic_simple);
}
#include <stdio.h>
-#include "Eina.h"
#include "eina_suite.h"
+#include "Eina.h"
START_TEST(eina_simple)
{
- fail_if(eina_init() != 1);
- fail_if(eina_shutdown() != 0);
+ fail_if(eina_init() != 2); /* one init by test suite */
+ fail_if(eina_shutdown() != 1);
}
END_TEST
#include <stdio.h>
-#include "eina_matrixsparse.h"
#include "eina_suite.h"
+#include "Eina.h"
#define MAX_ROWS 10
#define MAX_COLS 10
value3 = -3;
value4 = -4;
- eina_matrixsparse_init();
+ eina_init();
matrix = eina_matrixsparse_new(MAX_ROWS, MAX_COLS,
eina_matrixsparse_free_cell_cb, data);
matrixsparse_check(matrix, data, MAX_ROWS, MAX_COLS);
eina_matrixsparse_free(matrix);
- eina_matrixsparse_shutdown();
+ eina_shutdown();
}
END_TEST
for (j = 0; j < MAX_COLS; j++)
data[i][j] = 0;
- eina_matrixsparse_init();
+ eina_init();
matrix = eina_matrixsparse_new(MAX_ROWS, MAX_COLS,
eina_matrixsparse_free_cell_cb, data);
eina_matrixsparse_free(matrix);
- eina_matrixsparse_shutdown();
+ eina_shutdown();
}
END_TEST
printf("\n");
}
- eina_matrixsparse_init();
+ eina_init();
matrix = eina_matrixsparse_new(MAX_ROWS, MAX_COLS,
eina_matrixsparse_free_cell_cb, data);
eina_matrixsparse_free(matrix);
- eina_matrixsparse_shutdown();
+ eina_shutdown();
}
END_TEST
#endif
#include "eina_suite.h"
-#include "eina_mempool.h"
+#include "Eina.h"
static Eina_Array *_modules;
static void
_mempool_init(void)
{
- eina_mempool_init();
+ eina_init();
/* force modules to be loaded in case they are not installed */
_modules = eina_module_list_get(NULL, PACKAGE_BUILD_DIR"/src/modules", 1, NULL, NULL);
eina_module_list_load(_modules);
{
eina_module_list_flush(_modules);
/* TODO delete the list */
- eina_mempool_shutdown();
+ eina_shutdown();
}
static void
eina_mempool_del(mp);
}
-START_TEST(eina_mempool_init_shutdown)
-{
- Eina_Mempool *mp;
-
- _mempool_init();
-
- mp = eina_mempool_add("test", "test", NULL);
- fail_if(mp != NULL);
-
- _mempool_shutdown();
-}
-END_TEST
-
START_TEST(eina_mempool_chained_mempool)
{
Eina_Mempool *mp;
void
eina_test_mempool(TCase *tc)
{
- tcase_add_test(tc, eina_mempool_init_shutdown);
tcase_add_test(tc, eina_mempool_chained_mempool);
tcase_add_test(tc, eina_mempool_pass_through);
tcase_add_test(tc, eina_mempool_fixed_bitmap);
#include <stdio.h>
#include "eina_suite.h"
-#include "eina_module.h"
-
-START_TEST(eina_module_init_shutdown)
-{
- eina_module_init();
- eina_module_shutdown();
- eina_module_init();
- eina_module_init();
- eina_module_init();
- eina_module_shutdown();
- eina_module_init();
- eina_module_init();
- eina_module_shutdown();
- eina_module_shutdown();
- eina_module_shutdown();
- eina_module_shutdown();
-}
-END_TEST
+#include "Eina.h"
static Eina_Bool list_cb(Eina_Module *m, void *data)
{
{
Eina_Array *_modules;
- eina_module_init();
+ eina_init();
_modules = eina_module_list_get(NULL, PACKAGE_BUILD_DIR"/src/tests/", 1, &list_cb, NULL);
fail_if(!_modules);
eina_module_list_load(_modules);
eina_module_list_unload(_modules);
eina_module_list_flush(_modules);
/* TODO delete the list */
- eina_module_shutdown();
+ eina_shutdown();
}
END_TEST
void
eina_test_module(TCase *tc)
{
- tcase_add_test(tc, eina_module_init_shutdown);
tcase_add_test(tc, eina_module_load_unload);
}
#include <stdio.h>
#include <time.h>
-#include "eina_array.h"
#include "eina_suite.h"
-#include "eina_rbtree.h"
+#include "Eina.h"
static inline Eina_Bool
_eina_rbtree_is_red(Eina_Rbtree *tree)
Eina_Array_Iterator it;
unsigned int i;
- eina_array_init();
+ eina_init();
ea = eina_array_new(11);
fail_if(!ea);
fail_if(root != NULL);
- eina_array_shutdown();
+ eina_shutdown();
}
END_TEST
#include <stdio.h>
-#include "eina_rectangle.h"
#include "eina_suite.h"
+#include "Eina.h"
START_TEST(eina_rectangle_pool)
{
int w;
int h;
- fail_if(!eina_rectangle_init());
+ fail_if(!eina_init());
pool = eina_rectangle_pool_new(256, 256);
fail_if(pool == NULL);
eina_rectangle_pool_free(pool);
- eina_rectangle_shutdown();
+ eina_shutdown();
}
END_TEST
#include <time.h>
#include "eina_suite.h"
-#include "eina_stringshare.h"
-#include "eina_array.h"
-#include "eina_convert.h"
-
-START_TEST(eina_stringshare_init_shutdown)
-{
- eina_stringshare_init();
- eina_stringshare_init();
- eina_stringshare_shutdown();
- eina_stringshare_init();
- eina_stringshare_init();
- eina_stringshare_shutdown();
- eina_stringshare_shutdown();
- eina_stringshare_shutdown();
-}
-END_TEST
+#include "Eina.h"
#define TEST0 "test/0"
#define TEST1 "test/1"
const char *t0;
const char *t1;
- eina_stringshare_init();
+ eina_init();
t0 = eina_stringshare_add(TEST0);
t1 = eina_stringshare_add(TEST1);
eina_stringshare_del(t0);
eina_stringshare_del(t1);
- eina_stringshare_shutdown();
+ eina_shutdown();
}
END_TEST
char buf[4];
int i;
- eina_stringshare_init();
+ eina_init();
for (i = 0; i < 3; i++)
{
eina_stringshare_del(t1);
}
- eina_stringshare_shutdown();
+ eina_shutdown();
}
END_TEST
const char *t0;
const char *t1;
- eina_stringshare_init();
+ eina_init();
t0 = eina_stringshare_add(TEST0);
t1 = eina_stringshare_add(TEST0);
eina_stringshare_del(t0);
eina_stringshare_del(t1);
- eina_stringshare_shutdown();
+ eina_shutdown();
}
END_TEST
const char *tmp;
int i;
- eina_stringshare_init();
+ eina_init();
for (i = 10000; i > 0; --i)
{
fail_if(tmp != eina_stringshare_add(build));
}
- eina_stringshare_shutdown();
+ eina_shutdown();
}
END_TEST
srand(time(NULL));
- eina_stringshare_init();
+ eina_init();
ea = eina_array_new(256);
fail_if(!ea);
for (i = 0; i < 1000; ++i)
eina_stringshare_del(eina_array_pop(ea));
- eina_stringshare_shutdown();
+ eina_shutdown();
eina_array_free(ea);
}
void
eina_test_stringshare(TCase *tc)
{
- tcase_add_test(tc, eina_stringshare_init_shutdown);
tcase_add_test(tc, eina_stringshare_simple);
tcase_add_test(tc, eina_stringshare_small);
tcase_add_test(tc, eina_stringshare_test_share);