*/
typedef struct _Eina_Accessor Eina_Accessor;
-typedef Eina_Bool (*Eina_Accessor_Get_At_Callback)(Eina_Accessor *it, unsigned int index, void **data);
+typedef Eina_Bool (*Eina_Accessor_Get_At_Callback)(Eina_Accessor *it,
+ unsigned int index,
+ void **data);
typedef void *(*Eina_Accessor_Get_Container_Callback)(Eina_Accessor *it);
typedef void (*Eina_Accessor_Free_Callback)(Eina_Accessor *it);
struct _Eina_Accessor
{
- Eina_Accessor_Get_At_Callback get_at EINA_ARG_NONNULL(1, 3) EINA_WARN_UNUSED_RESULT;
- Eina_Accessor_Get_Container_Callback get_container EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
- Eina_Accessor_Free_Callback free EINA_ARG_NONNULL(1);
+ Eina_Accessor_Get_At_Callback get_at EINA_ARG_NONNULL(1,
+ 3)
+ EINA_WARN_UNUSED_RESULT;
+ Eina_Accessor_Get_Container_Callback get_container EINA_ARG_NONNULL(1)
+ EINA_WARN_UNUSED_RESULT;
+ Eina_Accessor_Free_Callback free EINA_ARG_NONNULL(1);
#define EINA_MAGIC_ACCESSOR 0x98761232
EINA_MAGIC
};
#define FUNC_ACCESSOR_GET_AT(Function) ((Eina_Accessor_Get_At_Callback)Function)
-#define FUNC_ACCESSOR_GET_CONTAINER(Function) ((Eina_Accessor_Get_Container_Callback)Function)
+#define FUNC_ACCESSOR_GET_CONTAINER(Function) (( \
+ Eina_Accessor_Get_Container_Callback) \
+ Function)
#define FUNC_ACCESSOR_FREE(Function) ((Eina_Accessor_Free_Callback)Function)
-EAPI void eina_accessor_free (Eina_Accessor *accessor) EINA_ARG_NONNULL(1);
+EAPI void eina_accessor_free (Eina_Accessor *accessor)
+EINA_ARG_NONNULL(1);
-EAPI Eina_Bool eina_accessor_data_get (Eina_Accessor *accessor, unsigned int position, void **data) EINA_ARG_NONNULL(1);
-EAPI void *eina_accessor_container_get (Eina_Accessor *accessor) EINA_ARG_NONNULL(1) EINA_PURE;
+EAPI Eina_Bool eina_accessor_data_get (Eina_Accessor *accessor,
+ unsigned int position,
+ void **data) EINA_ARG_NONNULL(1);
+EAPI void * eina_accessor_container_get (Eina_Accessor *accessor)
+EINA_ARG_NONNULL(1) EINA_PURE;
-EAPI void eina_accessor_over (Eina_Accessor *accessor,
- Eina_Each cb,
- unsigned int start,
- unsigned int end,
- const void *fdata) EINA_ARG_NONNULL(1, 2);
+EAPI void eina_accessor_over (Eina_Accessor *accessor,
+ Eina_Each cb,
+ unsigned int start,
+ unsigned int end,
+ const void *fdata)
+EINA_ARG_NONNULL(1, 2);
/**
* @def EINA_ACCESSOR_FOREACH
* rather in the accessors implementations to keep them as simple
* and fast as possible.
*/
-#define EINA_ACCESSOR_FOREACH(accessor, counter, data) for ((counter) = 0; eina_accessor_data_get((accessor), (counter), (void **)&(data)); (counter)++)
+#define EINA_ACCESSOR_FOREACH(accessor, counter, data) for ((counter) = 0; \
+ eina_accessor_data_get(( \
+ accessor), \
+ (counter), (void **)&(data)); (counter)++)
/**
* @}
*/
struct _Eina_Array
{
- void **data; /**< Pointer to a vector of pointer to payload */
- unsigned int total; /**< Total number of slot in the vector */
- unsigned int count; /**< Number of activ slot in the vector */
- unsigned int step; /**< How much must we grow the vector when it is full */
+ void **data; /**< Pointer to a vector of pointer to payload */
+ unsigned int total; /**< Total number of slot in the vector */
+ unsigned int count; /**< Number of activ slot in the vector */
+ unsigned int step; /**< How much must we grow the vector when it is full */
EINA_MAGIC
};
-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);
-EAPI void eina_array_clean (Eina_Array *array) EINA_ARG_NONNULL(1);
-EAPI void eina_array_flush (Eina_Array *array) EINA_ARG_NONNULL(1);
-EAPI Eina_Bool eina_array_remove (Eina_Array *array, Eina_Bool (*keep)(void *data, void *gdata), void *gdata) EINA_ARG_NONNULL(1, 2);
-
-static inline Eina_Bool eina_array_push (Eina_Array *array, const void *data) EINA_ARG_NONNULL(1, 2);
-static inline void *eina_array_pop (Eina_Array *array) EINA_ARG_NONNULL(1);
-static inline void *eina_array_data_get (const Eina_Array *array, unsigned int idx) EINA_ARG_NONNULL(1);
-static inline void eina_array_data_set (const Eina_Array *array, unsigned int idx, const void *data) EINA_ARG_NONNULL(1, 3);
-static inline unsigned int eina_array_count_get (const Eina_Array *array) EINA_ARG_NONNULL(1);
-
-EAPI Eina_Iterator *eina_array_iterator_new (const Eina_Array *array) EINA_MALLOC EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_Accessor *eina_array_accessor_new (const Eina_Array *array) EINA_MALLOC EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
+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);
+EAPI void
+eina_array_clean (
+ Eina_Array *array) EINA_ARG_NONNULL(1);
+EAPI void
+eina_array_flush (
+ Eina_Array *array) EINA_ARG_NONNULL(1);
+EAPI Eina_Bool
+eina_array_remove (
+ Eina_Array *array,
+ Eina_Bool (*keep)(void *data,
+ void *gdata),
+ void *gdata) EINA_ARG_NONNULL(1, 2);
+
+static inline Eina_Bool
+ eina_array_push (
+ Eina_Array *array,
+ const void *data) EINA_ARG_NONNULL(1, 2);
+static inline void *
+ eina_array_pop (
+ Eina_Array *array) EINA_ARG_NONNULL(1);
+static inline void *
+ eina_array_data_get (
+ const Eina_Array *array,
+ unsigned int idx) EINA_ARG_NONNULL(
+ 1);
+static inline void
+ eina_array_data_set (
+ const Eina_Array *array,
+ unsigned int idx,
+ const void *data) EINA_ARG_NONNULL(1, 3);
+static inline unsigned int
+ eina_array_count_get (
+ const Eina_Array *array) EINA_ARG_NONNULL(1);
+
+EAPI Eina_Iterator *
+ eina_array_iterator_new (
+ const Eina_Array *array) EINA_MALLOC EINA_ARG_NONNULL(1)
+EINA_WARN_UNUSED_RESULT;
+EAPI Eina_Accessor *
+ eina_array_accessor_new (
+ const Eina_Array *array) EINA_MALLOC EINA_ARG_NONNULL(1)
+EINA_WARN_UNUSED_RESULT;
/**
* @def EINA_ARRAY_ITER_NEXT
* free(item);
* @endcode
*/
-#define EINA_ARRAY_ITER_NEXT(array, index, item, iterator) \
- for (index = 0, iterator = (array)->data; \
- (index < eina_array_count_get(array)) && ((item = *((iterator)++))); \
- ++(index))
+#define EINA_ARRAY_ITER_NEXT(array, index, item, iterator) \
+ for (index = 0, iterator = (array)->data; \
+ (index < eina_array_count_get(array)) && ((item = *((iterator)++))); \
+ ++(index))
#include "eina_inline_array.x"
#define EINA_BENCHMARK(function) ((Eina_Benchmark_Specimens)function)
EAPI Eina_Benchmark *eina_benchmark_new(const char *name, const char *run);
-EAPI void eina_benchmark_free(Eina_Benchmark *bench);
+EAPI void eina_benchmark_free(Eina_Benchmark *bench);
-EAPI Eina_Bool eina_benchmark_register(Eina_Benchmark *bench, const char *name, Eina_Benchmark_Specimens bench_cb,
- int count_start, int count_end, int count_set);
+EAPI Eina_Bool eina_benchmark_register(Eina_Benchmark *bench,
+ const char *name,
+ Eina_Benchmark_Specimens bench_cb,
+ int count_start,
+ int count_end,
+ int count_set);
EAPI Eina_Array *eina_benchmark_run(Eina_Benchmark *bench);
* @{
*/
-EAPI Eina_Bool eina_binshare_init(void);
-EAPI Eina_Bool eina_binshare_shutdown(void);
-EAPI const char *eina_binshare_add_length(const char *str, unsigned int slen) EINA_WARN_UNUSED_RESULT;
+EAPI Eina_Bool eina_binshare_init(void);
+EAPI Eina_Bool eina_binshare_shutdown(void);
+EAPI const char *eina_binshare_add_length(const char *str,
+ unsigned int slen)
+EINA_WARN_UNUSED_RESULT;
EAPI const char *eina_binshare_ref(const char *str);
-EAPI void eina_binshare_del(const char *str);
-EAPI int eina_binshare_length(const char *str) EINA_CONST EINA_WARN_UNUSED_RESULT;
-EAPI void eina_binshare_dump(void);
+EAPI void eina_binshare_del(const char *str);
+EAPI int eina_binshare_length(const char *str) EINA_CONST
+EINA_WARN_UNUSED_RESULT;
+EAPI void eina_binshare_dump(void);
/**
* @brief Retrieve an instance of a blob for use in a program.
*/
EAPI extern Eina_Error EINA_ERROR_CONVERT_OUTRUN_STRING_LENGTH;
-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_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);
-EAPI Eina_Bool eina_convert_atod(const char *src, int length, long long *m, long *e) EINA_ARG_NONNULL(1,3,4);
+EAPI int eina_convert_dtoa(double d, char *des) EINA_ARG_NONNULL(2);
+EAPI Eina_Bool eina_convert_atod(const char *src,
+ int length,
+ long long *m,
+ long *e) EINA_ARG_NONNULL(1,3,4);
-EAPI int eina_convert_fptoa(Eina_F32p32 fp, char *des) EINA_ARG_NONNULL(2);
-EAPI Eina_Bool eina_convert_atofp(const char *src, int length, Eina_F32p32 *fp) EINA_ARG_NONNULL(1,3);
+EAPI int eina_convert_fptoa(Eina_F32p32 fp, char *des) EINA_ARG_NONNULL(2);
+EAPI Eina_Bool eina_convert_atofp(const char *src, int length,
+ Eina_F32p32 *fp) EINA_ARG_NONNULL(1,3);
/**
* @}
*/
typedef struct _Eina_Counter Eina_Counter;
-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 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 void eina_counter_start(Eina_Counter *counter) EINA_ARG_NONNULL(1);
-EAPI void eina_counter_stop(Eina_Counter *counter, int specimen) EINA_ARG_NONNULL(1);
-EAPI char *eina_counter_dump(Eina_Counter *counter) EINA_ARG_NONNULL(1);
+EAPI void
+ eina_counter_start(
+ Eina_Counter *counter) EINA_ARG_NONNULL(1);
+EAPI void
+ eina_counter_stop(
+ Eina_Counter *counter,
+ int specimen) EINA_ARG_NONNULL(1);
+EAPI char *
+ eina_counter_dump(
+ Eina_Counter *counter) EINA_ARG_NONNULL(1);
/**
* @}
typedef enum _Eina_Cpu_Features
{
- EINA_CPU_MMX = 0x00000001,
- EINA_CPU_SSE = 0x00000002,
- EINA_CPU_SSE2 = 0x00000004,
- EINA_CPU_SSE3 = 0x00000008,
- /* TODO 3DNow! */
- EINA_CPU_ALTIVEC = 0x00000010,
- EINA_CPU_VIS = 0x00000020,
- EINA_CPU_NEON = 0x00000040,
+ EINA_CPU_MMX = 0x00000001,
+ EINA_CPU_SSE = 0x00000002,
+ EINA_CPU_SSE2 = 0x00000004,
+ EINA_CPU_SSE3 = 0x00000008,
+ /* TODO 3DNow! */
+ EINA_CPU_ALTIVEC = 0x00000010,
+ EINA_CPU_VIS = 0x00000020,
+ EINA_CPU_NEON = 0x00000040,
} Eina_Cpu_Features;
EAPI Eina_Cpu_Features eina_cpu_features_get(void);
-EAPI int eina_cpu_count(void);
+EAPI int eina_cpu_count(void);
#endif /* EINA_CPU_H_ */
*/
EAPI extern Eina_Error EINA_ERROR_OUT_OF_MEMORY;
-EAPI Eina_Error eina_error_msg_register(const char *msg) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_Error eina_error_msg_static_register(const char *msg) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_Bool eina_error_msg_modify(Eina_Error error, const char *msg) EINA_ARG_NONNULL(1, 2);
-EAPI Eina_Error eina_error_get(void);
-EAPI void eina_error_set(Eina_Error err);
-EAPI const char * eina_error_msg_get(Eina_Error error) EINA_PURE;
+EAPI Eina_Error eina_error_msg_register(const char *msg) EINA_ARG_NONNULL(1)
+EINA_WARN_UNUSED_RESULT;
+EAPI Eina_Error eina_error_msg_static_register(const char *msg)
+EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
+EAPI Eina_Bool eina_error_msg_modify(Eina_Error error,
+ const char *msg) EINA_ARG_NONNULL(1, 2);
+EAPI Eina_Error eina_error_get(void);
+EAPI void eina_error_set(Eina_Error err);
+EAPI const char *eina_error_msg_get(Eina_Error error) EINA_PURE;
/**
* @}
#ifndef EINA_FILE_H_
#define EINA_FILE_H_
-#if defined (__MacOSX__) || defined (__FreeBSD__) || ( defined (__MACH__) && defined (__APPLE__))
+#if defined (__MacOSX__) || defined (__FreeBSD__) || (defined (__MACH__) && \
+ defined (__APPLE__))
# include <sys/syslimits.h>
#endif
* @typedef Eina_File_Dir_List_Cb
* Type for a callback.
*/
-typedef void (*Eina_File_Dir_List_Cb)(const char *name, const char *path, void *data);
+typedef void (*Eina_File_Dir_List_Cb)(const char *name, const char *path,
+ void *data);
/**
* @def EINA_FILE_DIR_LIST_CB
*/
#define EINA_FILE_DIR_LIST_CB(function) ((Eina_File_Dir_List_Cb)function)
-EAPI Eina_Bool eina_file_dir_list(const char *dir, Eina_Bool recursive, Eina_File_Dir_List_Cb cb, void *data) EINA_ARG_NONNULL(1, 3);
-EAPI Eina_Array *eina_file_split(char *path) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_MALLOC;
-EAPI Eina_Iterator *eina_file_ls(const char *dir) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_MALLOC;
+EAPI Eina_Bool
+eina_file_dir_list(
+ const char *dir,
+ Eina_Bool recursive,
+ Eina_File_Dir_List_Cb cb,
+ void *data) EINA_ARG_NONNULL(1, 3);
+EAPI Eina_Array *
+ eina_file_split(
+ char *path) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1)
+EINA_MALLOC;
+EAPI Eina_Iterator *
+ eina_file_ls(
+ const char *dir) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1)
+EINA_MALLOC;
typedef struct _Eina_File_Direct_Info Eina_File_Direct_Info;
const struct dirent *dirent;
};
-EAPI Eina_Iterator *eina_file_direct_ls(const char *dir) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_MALLOC;
+EAPI Eina_Iterator *
+ eina_file_direct_ls(
+ const char *dir) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1)
+EINA_MALLOC;
/**
* @}
typedef int32_t Eina_F16p16;
typedef int32_t Eina_F8p24;
-static inline Eina_F32p32 eina_f32p32_int_from(int32_t v);
-static inline int32_t eina_f32p32_int_to(Eina_F32p32 v);
-static inline Eina_F32p32 eina_f32p32_double_from(double v);
-static inline double eina_f32p32_double_to(Eina_F32p32 v);
-
-static inline Eina_F32p32 eina_f32p32_add(Eina_F32p32 a, Eina_F32p32 b);
-static inline Eina_F32p32 eina_f32p32_sub(Eina_F32p32 a, Eina_F32p32 b);
-static inline Eina_F32p32 eina_f32p32_mul(Eina_F32p32 a, Eina_F32p32 b);
-static inline Eina_F32p32 eina_f32p32_scale(Eina_F32p32 a, int b);
-static inline Eina_F32p32 eina_f32p32_div(Eina_F32p32 a, Eina_F32p32 b);
-static inline Eina_F32p32 eina_f32p32_sqrt(Eina_F32p32 a);
+static inline Eina_F32p32 eina_f32p32_int_from(int32_t v);
+static inline int32_t eina_f32p32_int_to(Eina_F32p32 v);
+static inline Eina_F32p32 eina_f32p32_double_from(double v);
+static inline double eina_f32p32_double_to(Eina_F32p32 v);
+
+static inline Eina_F32p32 eina_f32p32_add(Eina_F32p32 a, Eina_F32p32 b);
+static inline Eina_F32p32 eina_f32p32_sub(Eina_F32p32 a, Eina_F32p32 b);
+static inline Eina_F32p32 eina_f32p32_mul(Eina_F32p32 a, Eina_F32p32 b);
+static inline Eina_F32p32 eina_f32p32_scale(Eina_F32p32 a, int b);
+static inline Eina_F32p32 eina_f32p32_div(Eina_F32p32 a, Eina_F32p32 b);
+static inline Eina_F32p32 eina_f32p32_sqrt(Eina_F32p32 a);
static inline unsigned int eina_f32p32_fracc_get(Eina_F32p32 v);
// dont use llabs - issues if not on 64bit
#define eina_fp32p32_llabs(a) ((a < 0) ? -(a) : (a))
-EAPI Eina_F32p32 eina_f32p32_cos(Eina_F32p32 a);
-EAPI Eina_F32p32 eina_f32p32_sin(Eina_F32p32 a);
+EAPI Eina_F32p32 eina_f32p32_cos(Eina_F32p32 a);
+EAPI Eina_F32p32 eina_f32p32_sin(Eina_F32p32 a);
-static inline Eina_F16p16 eina_f16p16_int_from(int32_t v);
-static inline int32_t eina_f16p16_int_to(Eina_F16p16 v);
-static inline Eina_F16p16 eina_f16p16_float_from(float v);
-static inline float eina_f16p16_float_to(Eina_F16p16 v);
+static inline Eina_F16p16 eina_f16p16_int_from(int32_t v);
+static inline int32_t eina_f16p16_int_to(Eina_F16p16 v);
+static inline Eina_F16p16 eina_f16p16_float_from(float v);
+static inline float eina_f16p16_float_to(Eina_F16p16 v);
-static inline Eina_F16p16 eina_f16p16_add(Eina_F16p16 a, Eina_F16p16 b);
-static inline Eina_F16p16 eina_f16p16_sub(Eina_F16p16 a, Eina_F16p16 b);
-static inline Eina_F16p16 eina_f16p16_mul(Eina_F16p16 a, Eina_F16p16 b);
-static inline Eina_F16p16 eina_f16p16_scale(Eina_F16p16 a, int b);
-static inline Eina_F16p16 eina_f16p16_div(Eina_F16p16 a, Eina_F16p16 b);
-static inline Eina_F16p16 eina_f16p16_sqrt(Eina_F16p16 a);
+static inline Eina_F16p16 eina_f16p16_add(Eina_F16p16 a, Eina_F16p16 b);
+static inline Eina_F16p16 eina_f16p16_sub(Eina_F16p16 a, Eina_F16p16 b);
+static inline Eina_F16p16 eina_f16p16_mul(Eina_F16p16 a, Eina_F16p16 b);
+static inline Eina_F16p16 eina_f16p16_scale(Eina_F16p16 a, int b);
+static inline Eina_F16p16 eina_f16p16_div(Eina_F16p16 a, Eina_F16p16 b);
+static inline Eina_F16p16 eina_f16p16_sqrt(Eina_F16p16 a);
static inline unsigned int eina_f16p16_fracc_get(Eina_F16p16 v);
-static inline Eina_F8p24 eina_f8p24_int_from(int32_t v);
-static inline int32_t eina_f8p24_int_to(Eina_F8p24 v);
-static inline Eina_F8p24 eina_f8p24_float_from(float v);
-static inline float eina_f8p24_float_to(Eina_F8p24 v);
-
-static inline Eina_F8p24 eina_f8p24_add(Eina_F8p24 a, Eina_F8p24 b);
-static inline Eina_F8p24 eina_f8p24_sub(Eina_F8p24 a, Eina_F8p24 b);
-static inline Eina_F8p24 eina_f8p24_mul(Eina_F8p24 a, Eina_F8p24 b);
-static inline Eina_F8p24 eina_f8p24_scale(Eina_F8p24 a, int b);
-static inline Eina_F8p24 eina_f8p24_div(Eina_F8p24 a, Eina_F8p24 b);
-static inline Eina_F8p24 eina_f8p24_sqrt(Eina_F8p24 a);
+static inline Eina_F8p24 eina_f8p24_int_from(int32_t v);
+static inline int32_t eina_f8p24_int_to(Eina_F8p24 v);
+static inline Eina_F8p24 eina_f8p24_float_from(float v);
+static inline float eina_f8p24_float_to(Eina_F8p24 v);
+
+static inline Eina_F8p24 eina_f8p24_add(Eina_F8p24 a, Eina_F8p24 b);
+static inline Eina_F8p24 eina_f8p24_sub(Eina_F8p24 a, Eina_F8p24 b);
+static inline Eina_F8p24 eina_f8p24_mul(Eina_F8p24 a, Eina_F8p24 b);
+static inline Eina_F8p24 eina_f8p24_scale(Eina_F8p24 a, int b);
+static inline Eina_F8p24 eina_f8p24_div(Eina_F8p24 a, Eina_F8p24 b);
+static inline Eina_F8p24 eina_f8p24_sqrt(Eina_F8p24 a);
static inline unsigned int eina_f8p24_fracc_get(Eina_F8p24 v);
-static inline Eina_F32p32 eina_f16p16_to_f32p32(Eina_F16p16 a);
-static inline Eina_F32p32 eina_f8p24_to_f32p32(Eina_F8p24 a);
-static inline Eina_F16p16 eina_f32p32_to_f16p16(Eina_F32p32 a);
-static inline Eina_F16p16 eina_f8p24_to_f16p16(Eina_F8p24 a);
-static inline Eina_F8p24 eina_f32p32_to_f8p24(Eina_F32p32 a);
-static inline Eina_F8p24 eina_f16p16_to_f8p24(Eina_F16p16 a);
+static inline Eina_F32p32 eina_f16p16_to_f32p32(Eina_F16p16 a);
+static inline Eina_F32p32 eina_f8p24_to_f32p32(Eina_F8p24 a);
+static inline Eina_F16p16 eina_f32p32_to_f16p16(Eina_F32p32 a);
+static inline Eina_F16p16 eina_f8p24_to_f16p16(Eina_F8p24 a);
+static inline Eina_F8p24 eina_f32p32_to_f8p24(Eina_F32p32 a);
+static inline Eina_F8p24 eina_f16p16_to_f8p24(Eina_F16p16 a);
#include "eina_inline_f32p32.x"
#include "eina_inline_f16p16.x"
typedef unsigned int (*Eina_Key_Length)(const void *key);
#define EINA_KEY_LENGTH(Function) ((Eina_Key_Length)Function)
typedef int (*Eina_Key_Cmp)(const void *key1, int key1_length,
- const void *key2, int key2_length);
+ const void *key2, int key2_length);
#define EINA_KEY_CMP(Function) ((Eina_Key_Cmp)Function)
typedef int (*Eina_Key_Hash)(const void *key, int key_length);
#define EINA_KEY_HASH(Function) ((Eina_Key_Hash)Function)
-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_Free_Cb data_free_cb,
- int buckets_power_size) EINA_MALLOC EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(2, 3);
-EAPI Eina_Hash * eina_hash_string_djb2_new(Eina_Free_Cb data_free_cb);
-EAPI Eina_Hash * eina_hash_string_superfast_new(Eina_Free_Cb data_free_cb);
-EAPI Eina_Hash * eina_hash_string_small_new(Eina_Free_Cb data_free_cb);
-EAPI Eina_Hash * eina_hash_int32_new(Eina_Free_Cb data_free_cb);
-EAPI Eina_Hash * eina_hash_int64_new(Eina_Free_Cb data_free_cb);
-EAPI Eina_Hash * eina_hash_pointer_new(Eina_Free_Cb data_free_cb);
-EAPI Eina_Hash * eina_hash_stringshared_new(Eina_Free_Cb data_free_cb);
-
-EAPI Eina_Bool eina_hash_add(Eina_Hash *hash, const void *key, const void *data) EINA_ARG_NONNULL(1, 2, 3);
-EAPI Eina_Bool eina_hash_direct_add(Eina_Hash *hash, const void *key, const void *data) EINA_ARG_NONNULL(1, 2, 3);
-EAPI Eina_Bool eina_hash_del(Eina_Hash *hash, const void *key, const void *data) EINA_ARG_NONNULL(1);
-EAPI void * eina_hash_find(const Eina_Hash *hash, const void *key) EINA_ARG_NONNULL(1, 2);
-EAPI void * eina_hash_modify(Eina_Hash *hash, const void *key, const void *data) EINA_ARG_NONNULL(1, 2, 3);
-EAPI void * eina_hash_set(Eina_Hash *hash, const void *key, const void *data) EINA_ARG_NONNULL(1, 2, 3);
-EAPI void eina_hash_free(Eina_Hash *hash) EINA_ARG_NONNULL(1);
-EAPI void eina_hash_free_buckets(Eina_Hash *hash) EINA_ARG_NONNULL(1);
-EAPI int eina_hash_population(const Eina_Hash *hash) EINA_ARG_NONNULL(1);
-
-EAPI Eina_Bool eina_hash_add_by_hash(Eina_Hash *hash,
- const void *key, int key_length, int key_hash,
- const void *data) EINA_ARG_NONNULL(1, 2, 5);
-EAPI Eina_Bool eina_hash_direct_add_by_hash(Eina_Hash *hash,
- const void *key, int key_length, int key_hash,
- const void *data) EINA_ARG_NONNULL(1, 2, 5);
-
-EAPI Eina_Bool eina_hash_del_by_key_hash(Eina_Hash *hash, const void *key, int key_length, int key_hash) EINA_ARG_NONNULL(1, 2);
-
-EAPI Eina_Bool eina_hash_del_by_key(Eina_Hash *hash, const void *key) EINA_ARG_NONNULL(1, 2);
-EAPI Eina_Bool eina_hash_del_by_data(Eina_Hash *hash, const void *data) EINA_ARG_NONNULL(1, 2);
-
-EAPI Eina_Bool eina_hash_del_by_hash(Eina_Hash *hash,
- const void *key, int key_length, int key_hash,
- const void *data) EINA_ARG_NONNULL(1);
-EAPI void * eina_hash_find_by_hash(const Eina_Hash *hash,
- const void *key, int key_length, int key_hash) EINA_ARG_NONNULL(1, 2);
-EAPI void * eina_hash_modify_by_hash(Eina_Hash *hash,
- const void *key, int key_length, int key_hash,
- const void *data) EINA_ARG_NONNULL(1, 2, 5);
-
-EAPI Eina_Iterator * eina_hash_iterator_key_new(const Eina_Hash *hash) EINA_MALLOC EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_Iterator * eina_hash_iterator_data_new(const Eina_Hash *hash) EINA_MALLOC EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_Iterator * eina_hash_iterator_tuple_new(const Eina_Hash *hash) EINA_MALLOC EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
-
-typedef Eina_Bool (*Eina_Hash_Foreach)(const Eina_Hash *hash, const void *key, void *data, void *fdata);
-EAPI void eina_hash_foreach(const Eina_Hash *hash,
- Eina_Hash_Foreach cb,
- const void *fdata) EINA_ARG_NONNULL(1, 2);
+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_Free_Cb
+ data_free_cb,
+ int
+ buckets_power_size) EINA_MALLOC EINA_WARN_UNUSED_RESULT
+EINA_ARG_NONNULL(2, 3);
+EAPI Eina_Hash *
+eina_hash_string_djb2_new(
+ Eina_Free_Cb data_free_cb);
+EAPI Eina_Hash *
+eina_hash_string_superfast_new(
+ Eina_Free_Cb data_free_cb);
+EAPI Eina_Hash *
+eina_hash_string_small_new(
+ Eina_Free_Cb data_free_cb);
+EAPI Eina_Hash *
+eina_hash_int32_new(
+ Eina_Free_Cb data_free_cb);
+EAPI Eina_Hash *
+eina_hash_int64_new(
+ Eina_Free_Cb data_free_cb);
+EAPI Eina_Hash *
+eina_hash_pointer_new(
+ Eina_Free_Cb data_free_cb);
+EAPI Eina_Hash *
+eina_hash_stringshared_new(
+ Eina_Free_Cb data_free_cb);
+
+EAPI Eina_Bool
+eina_hash_add(
+ Eina_Hash *hash,
+ const void *key,
+ const void *data) EINA_ARG_NONNULL(1, 2, 3);
+EAPI Eina_Bool
+eina_hash_direct_add(
+ Eina_Hash *hash,
+ const void *key,
+ const void *data) EINA_ARG_NONNULL(1, 2, 3);
+EAPI Eina_Bool
+eina_hash_del(
+ Eina_Hash *hash,
+ const void *key,
+ const void *data) EINA_ARG_NONNULL(1);
+EAPI void *
+eina_hash_find(
+ const Eina_Hash *hash,
+ const void *key) EINA_ARG_NONNULL(1, 2);
+EAPI void *
+eina_hash_modify(
+ Eina_Hash *hash,
+ const void *key,
+ const void *data) EINA_ARG_NONNULL(1, 2, 3);
+EAPI void *
+eina_hash_set(
+ Eina_Hash *hash,
+ const void *key,
+ const void *data) EINA_ARG_NONNULL(1, 2, 3);
+EAPI void
+eina_hash_free(
+ Eina_Hash *hash) EINA_ARG_NONNULL(1);
+EAPI void
+eina_hash_free_buckets(
+ Eina_Hash *hash) EINA_ARG_NONNULL(1);
+EAPI int
+eina_hash_population(
+ const Eina_Hash *hash) EINA_ARG_NONNULL(1);
+
+EAPI Eina_Bool
+eina_hash_add_by_hash(
+ Eina_Hash *hash,
+ const
+ void *key,
+ int key_length,
+ int key_hash,
+ const
+ void *data) EINA_ARG_NONNULL(1, 2, 5);
+EAPI Eina_Bool
+eina_hash_direct_add_by_hash(Eina_Hash *hash,
+ const
+ void *key,
+ int key_length,
+ int key_hash,
+ const
+ void *data) EINA_ARG_NONNULL(1, 2, 5);
+
+EAPI Eina_Bool
+eina_hash_del_by_key_hash(Eina_Hash *hash,
+ const void *key,
+ int key_length,
+ int key_hash) EINA_ARG_NONNULL(1, 2);
+
+EAPI Eina_Bool
+eina_hash_del_by_key(Eina_Hash *hash, const void *key) EINA_ARG_NONNULL(1, 2);
+EAPI Eina_Bool
+eina_hash_del_by_data(Eina_Hash *hash, const void *data) EINA_ARG_NONNULL(1, 2);
+
+EAPI Eina_Bool
+eina_hash_del_by_hash(Eina_Hash *hash,
+ const
+ void *key,
+ int key_length,
+ int key_hash,
+ const
+ void *data) EINA_ARG_NONNULL(1);
+EAPI void *
+eina_hash_find_by_hash(const Eina_Hash *hash,
+ const
+ void *key,
+ int key_length,
+ int key_hash) EINA_ARG_NONNULL(1, 2);
+EAPI void *
+eina_hash_modify_by_hash(Eina_Hash *hash,
+ const
+ void *key,
+ int key_length,
+ int key_hash,
+ const
+ void *data) EINA_ARG_NONNULL(1, 2, 5);
+
+EAPI Eina_Iterator *
+ eina_hash_iterator_key_new(
+ const Eina_Hash *hash) EINA_MALLOC EINA_ARG_NONNULL(1)
+EINA_WARN_UNUSED_RESULT;
+EAPI Eina_Iterator *
+ eina_hash_iterator_data_new(
+ const Eina_Hash *hash) EINA_MALLOC EINA_ARG_NONNULL(
+ 1) EINA_WARN_UNUSED_RESULT;
+EAPI Eina_Iterator *
+ eina_hash_iterator_tuple_new(
+ const Eina_Hash *hash) EINA_MALLOC EINA_ARG_NONNULL(
+ 1) EINA_WARN_UNUSED_RESULT;
+
+typedef Eina_Bool (*Eina_Hash_Foreach)(const Eina_Hash *hash, const void *key,
+ void *data, void *fdata);
+EAPI void
+eina_hash_foreach(const Eina_Hash *hash,
+ Eina_Hash_Foreach
+ cb,
+ const
+ void *fdata) EINA_ARG_NONNULL(1, 2);
/* Paul Hsieh (http://www.azillionmonkeys.com/qed/hash.html) hash function
used by WebCore (http://webkit.org/blog/8/hashtables-part-2/) */
-EAPI int eina_hash_superfast(const char *key, int len) EINA_ARG_NONNULL(1);
+EAPI int
+eina_hash_superfast(const char *key, int len) EINA_ARG_NONNULL(1);
/* Hash function first reported by dan bernstein many years ago in comp.lang.c */
-static inline int eina_hash_djb2(const char *key, int len) EINA_ARG_NONNULL(1);
-static inline int eina_hash_djb2_len(const char *key, int *plen) EINA_ARG_NONNULL(1, 2);
+static inline int
+eina_hash_djb2(const char *key, int len) EINA_ARG_NONNULL(1);
+static inline int
+eina_hash_djb2_len(const char *key, int *plen) EINA_ARG_NONNULL(1, 2);
/* Hash function from http://www.concentric.net/~Ttwang/tech/inthash.htm */
-static inline int eina_hash_int32(const unsigned int *pkey, int len) EINA_ARG_NONNULL(1);
-static inline int eina_hash_int64(const unsigned long int *pkey, int len) EINA_ARG_NONNULL(1);
+static inline int
+eina_hash_int32(const unsigned int *pkey, int len) EINA_ARG_NONNULL(1);
+static inline int
+eina_hash_int64(const unsigned long int *pkey, int len) EINA_ARG_NONNULL(1);
#include "eina_inline_hash.x"
};
#define EINA_INLIST Eina_Inlist __in_list
-#define EINA_INLIST_GET(Inlist) (&((Inlist)->__in_list))
-#define EINA_INLIST_CONTAINER_GET(ptr, type) ((type *) ((char *) ptr - offsetof(type, __in_list)))
-
-EAPI Eina_Inlist * eina_inlist_append(Eina_Inlist *in_list, Eina_Inlist *in_item) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_Inlist * eina_inlist_prepend(Eina_Inlist *in_list, Eina_Inlist *in_item) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_Inlist * eina_inlist_append_relative(Eina_Inlist *in_list, Eina_Inlist *in_item, Eina_Inlist *in_relative) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_Inlist * eina_inlist_prepend_relative(Eina_Inlist *in_list, Eina_Inlist *in_item, Eina_Inlist *in_relative) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_Inlist * eina_inlist_remove(Eina_Inlist *in_list, Eina_Inlist *in_item) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_Inlist * eina_inlist_find(Eina_Inlist *in_list, Eina_Inlist *in_item) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_Inlist * eina_inlist_promote(Eina_Inlist *list, Eina_Inlist *item) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_Inlist * eina_inlist_demote(Eina_Inlist *list, Eina_Inlist *item) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
-EAPI unsigned int eina_inlist_count(const Eina_Inlist *list) EINA_WARN_UNUSED_RESULT;
-
-EAPI Eina_Iterator *eina_inlist_iterator_new(const Eina_Inlist *in_list) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
-EAPI Eina_Accessor *eina_inlist_accessor_new(const Eina_Inlist *in_list) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
+#define EINA_INLIST_GET(Inlist) (& ((Inlist)->__in_list))
+#define EINA_INLIST_CONTAINER_GET(ptr, \
+ type) ((type *)((char *)ptr - \
+ offsetof(type, __in_list)))
+
+EAPI Eina_Inlist * eina_inlist_append(Eina_Inlist *in_list,
+ Eina_Inlist *in_item) EINA_ARG_NONNULL(2)
+EINA_WARN_UNUSED_RESULT;
+EAPI Eina_Inlist * eina_inlist_prepend(Eina_Inlist *in_list,
+ Eina_Inlist *in_item) EINA_ARG_NONNULL(
+ 2) EINA_WARN_UNUSED_RESULT;
+EAPI Eina_Inlist * eina_inlist_append_relative(Eina_Inlist *in_list,
+ Eina_Inlist *in_item,
+ Eina_Inlist *in_relative)
+EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
+EAPI Eina_Inlist * eina_inlist_prepend_relative(Eina_Inlist *in_list,
+ Eina_Inlist *in_item,
+ Eina_Inlist *in_relative)
+EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
+EAPI Eina_Inlist * eina_inlist_remove(Eina_Inlist *in_list,
+ Eina_Inlist *in_item) EINA_ARG_NONNULL(1,
+ 2)
+EINA_WARN_UNUSED_RESULT;
+EAPI Eina_Inlist * eina_inlist_find(Eina_Inlist *in_list,
+ Eina_Inlist *in_item) EINA_ARG_NONNULL(2)
+EINA_WARN_UNUSED_RESULT;
+EAPI Eina_Inlist * eina_inlist_promote(Eina_Inlist *list,
+ Eina_Inlist *item) EINA_ARG_NONNULL(1,
+ 2)
+EINA_WARN_UNUSED_RESULT;
+EAPI Eina_Inlist * eina_inlist_demote(Eina_Inlist *list,
+ Eina_Inlist *item) EINA_ARG_NONNULL(1,
+ 2)
+EINA_WARN_UNUSED_RESULT;
+EAPI unsigned int eina_inlist_count(const Eina_Inlist *list)
+EINA_WARN_UNUSED_RESULT;
+
+EAPI Eina_Iterator *eina_inlist_iterator_new(const Eina_Inlist *in_list)
+EINA_MALLOC EINA_WARN_UNUSED_RESULT;
+EAPI Eina_Accessor *eina_inlist_accessor_new(const Eina_Inlist *in_list)
+EINA_MALLOC EINA_WARN_UNUSED_RESULT;
/* This two macros are helpers for the _FOREACH ones, don't use them */
-#define _EINA_INLIST_OFFSET(ref) ((char*)&(ref)->__in_list - (char*)(ref))
-#define _EINA_INLIST_CONTAINER(ref, ptr) (void*)((char*)(ptr) - _EINA_INLIST_OFFSET(ref))
-
-#define EINA_INLIST_FOREACH(list, l) for (l = NULL, l = (list ? _EINA_INLIST_CONTAINER(l, list) : NULL); l; l = (EINA_INLIST_GET(l)->next ? _EINA_INLIST_CONTAINER(l, EINA_INLIST_GET(l)->next) : NULL))
-#define EINA_INLIST_REVERSE_FOREACH(list, l) for (l = NULL, l = (list ? _EINA_INLIST_CONTAINER(l, list->last) : NULL); l; l = (EINA_INLIST_GET(l)->prev ? _EINA_INLIST_CONTAINER(l, EINA_INLIST_GET(l)->prev) : NULL))
+#define _EINA_INLIST_OFFSET(ref) ((char *)&(ref)->__in_list - (char *)(ref))
+#define _EINA_INLIST_CONTAINER(ref, ptr) (void *)((char *)(ptr) - \
+ _EINA_INLIST_OFFSET(ref))
+
+#define EINA_INLIST_FOREACH(list, l) for (l = NULL, \
+ l = \
+ (list ? _EINA_INLIST_CONTAINER(l, \
+ list) : NULL); \
+ l; \
+ l = \
+ (EINA_INLIST_GET(l)->next ? \
+ _EINA_INLIST_CONTAINER(l, \
+ EINA_INLIST_GET( \
+ l)-> \
+ next) : NULL))
+#define EINA_INLIST_REVERSE_FOREACH(list, l) for (l = NULL, \
+ l = \
+ (list ? \
+ _EINA_INLIST_CONTAINER(l, list->last) : NULL); \
+ l; \
+ l = \
+ (EINA_INLIST_GET(l)->prev \
+ ? _EINA_INLIST_CONTAINER( \
+ l, \
+ EINA_INLIST_GET( \
+ l) \
+ ->prev) : NULL))
/**
struct _Eina_Iterator
{
- Eina_Iterator_Next_Callback next EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
- Eina_Iterator_Get_Container_Callback get_container EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
- Eina_Iterator_Free_Callback free EINA_ARG_NONNULL(1);
+ Eina_Iterator_Next_Callback next EINA_ARG_NONNULL(1,
+ 2)
+ EINA_WARN_UNUSED_RESULT;
+ Eina_Iterator_Get_Container_Callback get_container EINA_ARG_NONNULL(1)
+ EINA_WARN_UNUSED_RESULT;
+ Eina_Iterator_Free_Callback free EINA_ARG_NONNULL(1);
#define EINA_MAGIC_ITERATOR 0x98761233
EINA_MAGIC
#define FUNC_ITERATOR_NEXT(Function) ((Eina_Iterator_Next_Callback)Function)
-#define FUNC_ITERATOR_GET_CONTAINER(Function) ((Eina_Iterator_Get_Container_Callback)Function)
+#define FUNC_ITERATOR_GET_CONTAINER(Function) (( \
+ Eina_Iterator_Get_Container_Callback) \
+ Function)
#define FUNC_ITERATOR_FREE(Function) ((Eina_Iterator_Free_Callback)Function)
-EAPI void eina_iterator_free (Eina_Iterator *iterator) EINA_ARG_NONNULL(1);
+EAPI void eina_iterator_free (Eina_Iterator *iterator)
+EINA_ARG_NONNULL(1);
-EAPI void *eina_iterator_container_get (Eina_Iterator *iterator) EINA_ARG_NONNULL(1) EINA_PURE;
-EAPI Eina_Bool eina_iterator_next (Eina_Iterator *iterator, void **data) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
+EAPI void * eina_iterator_container_get (Eina_Iterator *iterator)
+EINA_ARG_NONNULL(1) EINA_PURE;
+EAPI Eina_Bool eina_iterator_next (Eina_Iterator *iterator,
+ void **data) EINA_ARG_NONNULL(1,
+ 2)
+EINA_WARN_UNUSED_RESULT;
-EAPI void eina_iterator_foreach (Eina_Iterator *iterator,
- Eina_Each callback,
- const void *fdata) EINA_ARG_NONNULL(1, 2);
+EAPI void eina_iterator_foreach (Eina_Iterator *iterator,
+ Eina_Each callback,
+ const void *fdata)
+EINA_ARG_NONNULL(1, 2);
/**
* @def EINA_ITERATOR_FOREACH
* rather in the iterators implementations to keep them as simple
* and fast as possible.
*/
-#define EINA_ITERATOR_FOREACH(itr, data) while (eina_iterator_next((itr), (void **)&(data)))
+#define EINA_ITERATOR_FOREACH(itr, \
+ data) while (eina_iterator_next((itr), \
+ (void **)&(data)))
/**
* @}
* @{
*/
-typedef Eina_Bool (*Eina_Lalloc_Alloc) (void *user_data, int num);
+typedef Eina_Bool (*Eina_Lalloc_Alloc)(void *user_data, int num);
#define EINA_LALLOC_ALLOC(function) ((Eina_Lalloc_Alloc)function)
-typedef void (*Eina_Lalloc_Free) (void *user_data);
+typedef void (*Eina_Lalloc_Free)(void *user_data);
#define EINA_LALLOC_FREE(function) ((Eina_Lalloc_Free)function)
typedef struct _Eina_Lalloc Eina_Lalloc;
-EAPI Eina_Lalloc *eina_lalloc_new(void *data, Eina_Lalloc_Alloc alloc_cb, Eina_Lalloc_Free free_cb, int num_init) EINA_ARG_NONNULL(2, 3);
-EAPI void eina_lalloc_free(Eina_Lalloc *a) EINA_ARG_NONNULL(1);
-EAPI Eina_Bool eina_lalloc_elements_add(Eina_Lalloc *a, int num) EINA_ARG_NONNULL(1);
-EAPI Eina_Bool eina_lalloc_element_add(Eina_Lalloc *a) EINA_ARG_NONNULL(1);
+EAPI Eina_Lalloc *eina_lalloc_new(void *data,
+ Eina_Lalloc_Alloc alloc_cb,
+ Eina_Lalloc_Free free_cb,
+ int num_init) EINA_ARG_NONNULL(2, 3);
+EAPI void eina_lalloc_free(Eina_Lalloc *a) EINA_ARG_NONNULL(1);
+EAPI Eina_Bool eina_lalloc_elements_add(Eina_Lalloc *a,
+ int num) EINA_ARG_NONNULL(1);
+EAPI Eina_Bool eina_lalloc_element_add(Eina_Lalloc *a) EINA_ARG_NONNULL(1);
/**
* @}
*/
struct _Eina_List /** A linked list node */
{
- void *data; /**< Pointer to list element payload */
+ void *data; /**< Pointer to list element payload */
Eina_List *next; /**< Next member in the list */
Eina_List *prev; /**< Previous member in the list */
Eina_List_Accounting *accounting; /**< Private list accounting info - don't touch */
EINA_MAGIC
};
-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;
-EAPI Eina_List *eina_list_append_relative_list (Eina_List *list, const void *data, Eina_List *relative) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_List *eina_list_prepend_relative (Eina_List *list, const void *data, const void *relative) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_List *eina_list_prepend_relative_list (Eina_List *list, const void *data, Eina_List *relative) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_List *eina_list_sorted_insert(Eina_List *list, Eina_Compare_Cb func, const void *data) EINA_ARG_NONNULL(2, 3) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_List *eina_list_remove (Eina_List *list, const void *data) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_List *eina_list_remove_list (Eina_List *list, Eina_List *remove_list) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_List *eina_list_promote_list (Eina_List *list, Eina_List *move_list) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_List *eina_list_demote_list (Eina_List *list, Eina_List *move_list);
-EAPI void *eina_list_data_find(const Eina_List *list, const void *data) EINA_PURE EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_List *eina_list_data_find_list (const Eina_List *list, const void *data) EINA_PURE EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_List *eina_list_free (Eina_List *list);
-EAPI void *eina_list_nth(const Eina_List *list, unsigned int n) EINA_PURE EINA_WARN_UNUSED_RESULT;
-EAPI Eina_List *eina_list_nth_list (const Eina_List *list, unsigned int n) EINA_PURE EINA_WARN_UNUSED_RESULT;
-EAPI Eina_List *eina_list_reverse (Eina_List *list) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_List *eina_list_reverse_clone(const Eina_List *list) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_List *eina_list_clone(const Eina_List *list) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_List *eina_list_sort (Eina_List *list, unsigned int size, Eina_Compare_Cb func) EINA_ARG_NONNULL(3) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_List *eina_list_merge (Eina_List *left, Eina_List *right) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_List *eina_list_sorted_merge(Eina_List *left, Eina_List *right, Eina_Compare_Cb func) EINA_ARG_NONNULL(3) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_List *eina_list_split_list(Eina_List *list, Eina_List *relative, Eina_List **right) EINA_WARN_UNUSED_RESULT;
+EAPI Eina_List *
+eina_list_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;
+EAPI Eina_List *
+eina_list_append_relative_list (
+ Eina_List *list,
+ const void *data,
+ Eina_List *relative) EINA_ARG_NONNULL(2)
+EINA_WARN_UNUSED_RESULT;
+EAPI Eina_List *
+eina_list_prepend_relative (
+ Eina_List *list,
+ const void *data,
+ const void *relative) EINA_ARG_NONNULL(2)
+EINA_WARN_UNUSED_RESULT;
+EAPI Eina_List *
+eina_list_prepend_relative_list (
+ Eina_List *list,
+ const void *data,
+ Eina_List *relative) EINA_ARG_NONNULL(2)
+EINA_WARN_UNUSED_RESULT;
+EAPI Eina_List *
+eina_list_sorted_insert(
+ Eina_List *list,
+ Eina_Compare_Cb func,
+ const void *data) EINA_ARG_NONNULL(2,
+ 3) EINA_WARN_UNUSED_RESULT;
+EAPI Eina_List *
+ eina_list_remove (
+ Eina_List *list,
+ const void *data) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
+EAPI Eina_List *
+ eina_list_remove_list (
+ Eina_List *list,
+ Eina_List *remove_list) EINA_ARG_NONNULL(
+ 2) EINA_WARN_UNUSED_RESULT;
+EAPI Eina_List *
+ eina_list_promote_list (
+ Eina_List *list,
+ Eina_List *move_list) EINA_ARG_NONNULL(
+ 2) EINA_WARN_UNUSED_RESULT;
+EAPI Eina_List *
+ eina_list_demote_list (
+ Eina_List *list,
+ Eina_List *move_list);
+EAPI void *
+ eina_list_data_find(
+ const Eina_List *list,
+ const void *data) EINA_PURE EINA_ARG_NONNULL(2)
+EINA_WARN_UNUSED_RESULT;
+EAPI Eina_List *
+ eina_list_data_find_list (
+ const Eina_List *list,
+ const void *data) EINA_PURE EINA_ARG_NONNULL(2)
+EINA_WARN_UNUSED_RESULT;
+EAPI Eina_List *
+ eina_list_free (
+ Eina_List *list);
+EAPI void *
+ eina_list_nth(
+ const Eina_List *list,
+ unsigned int n) EINA_PURE EINA_WARN_UNUSED_RESULT;
+EAPI Eina_List *
+ eina_list_nth_list (
+ const Eina_List *list,
+ unsigned int n) EINA_PURE EINA_WARN_UNUSED_RESULT;
+EAPI Eina_List *
+ eina_list_reverse (
+ Eina_List *list) EINA_WARN_UNUSED_RESULT;
+EAPI Eina_List *
+ eina_list_reverse_clone(
+ const Eina_List *list) EINA_WARN_UNUSED_RESULT;
+EAPI Eina_List *
+ eina_list_clone(
+ const Eina_List *list) EINA_WARN_UNUSED_RESULT;
+EAPI Eina_List *
+ eina_list_sort (
+ Eina_List *list,
+ unsigned int size,
+ Eina_Compare_Cb func) EINA_ARG_NONNULL(3)
+EINA_WARN_UNUSED_RESULT;
+EAPI Eina_List *
+eina_list_merge (
+ Eina_List *left,
+ Eina_List *right) EINA_WARN_UNUSED_RESULT;
+EAPI Eina_List *
+eina_list_sorted_merge(
+ Eina_List *left,
+ Eina_List *right,
+ Eina_Compare_Cb func) EINA_ARG_NONNULL(3)
+EINA_WARN_UNUSED_RESULT;
+EAPI Eina_List *
+eina_list_split_list(
+ Eina_List *list,
+ Eina_List *relative,
+ Eina_List **right) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_List *eina_list_search_sorted_near_list(const Eina_List *list, Eina_Compare_Cb func, const void *data, int *result_cmp);
-EAPI Eina_List *eina_list_search_sorted_list(const Eina_List *list, Eina_Compare_Cb func, const void *data);
-EAPI void *eina_list_search_sorted(const Eina_List *list, Eina_Compare_Cb func, const void *data);
-EAPI Eina_List *eina_list_search_unsorted_list(const Eina_List *list, Eina_Compare_Cb func, const void *data);
-EAPI void *eina_list_search_unsorted(const Eina_List *list, Eina_Compare_Cb func, const void *data);
+EAPI Eina_List *
+eina_list_search_sorted_near_list(
+ const Eina_List *list,
+ Eina_Compare_Cb func,
+ const void *data,
+ int *result_cmp);
+EAPI Eina_List *
+eina_list_search_sorted_list(
+ const Eina_List *list,
+ Eina_Compare_Cb func,
+ const void *data);
+EAPI void *
+eina_list_search_sorted(
+ const Eina_List *list,
+ Eina_Compare_Cb func,
+ const void *data);
+EAPI Eina_List *
+eina_list_search_unsorted_list(
+ const Eina_List *list,
+ Eina_Compare_Cb func,
+ const void *data);
+EAPI void *
+eina_list_search_unsorted(
+ const Eina_List *list,
+ Eina_Compare_Cb func,
+ const void *data);
-static inline Eina_List *eina_list_last (const Eina_List *list) EINA_PURE EINA_WARN_UNUSED_RESULT;
-static inline Eina_List *eina_list_next (const Eina_List *list) EINA_PURE EINA_WARN_UNUSED_RESULT;
-static inline Eina_List *eina_list_prev (const Eina_List *list) EINA_PURE EINA_WARN_UNUSED_RESULT;
-static inline void *eina_list_data_get(const Eina_List *list) EINA_PURE EINA_WARN_UNUSED_RESULT;
-static inline unsigned int eina_list_count(const Eina_List *list) EINA_PURE;
+static inline Eina_List *
+eina_list_last (
+ const Eina_List *list) EINA_PURE EINA_WARN_UNUSED_RESULT;
+static inline Eina_List *
+eina_list_next (
+ const Eina_List *list) EINA_PURE EINA_WARN_UNUSED_RESULT;
+static inline Eina_List *
+eina_list_prev (
+ const Eina_List *list) EINA_PURE EINA_WARN_UNUSED_RESULT;
+static inline void *
+eina_list_data_get(
+ const Eina_List *list) EINA_PURE EINA_WARN_UNUSED_RESULT;
+static inline unsigned int
+eina_list_count(
+ const Eina_List *list) EINA_PURE;
-EAPI Eina_Iterator *eina_list_iterator_new(const Eina_List *list) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
-EAPI Eina_Iterator *eina_list_iterator_reversed_new(const Eina_List *list) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
-EAPI Eina_Accessor *eina_list_accessor_new(const Eina_List *list) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
+EAPI Eina_Iterator *
+eina_list_iterator_new(
+ const Eina_List *list) EINA_MALLOC
+EINA_WARN_UNUSED_RESULT;
+EAPI Eina_Iterator *
+eina_list_iterator_reversed_new(
+ const Eina_List *list) EINA_MALLOC
+EINA_WARN_UNUSED_RESULT;
+EAPI Eina_Accessor *
+eina_list_accessor_new(
+ const Eina_List *list) EINA_MALLOC
+EINA_WARN_UNUSED_RESULT;
/**
* @def EINA_LIST_FOREACH
* For destructive operations such as this, consider
* using EINA_LIST_FOREACH_SAFE().
*/
-#define EINA_LIST_FOREACH(list, l, data) for (l = list, data = eina_list_data_get(l); l; l = eina_list_next(l), data = eina_list_data_get(l))
+#define EINA_LIST_FOREACH(list, l, data) for (l = list, \
+ data = eina_list_data_get(l); \
+ l; \
+ l = eina_list_next(l), data = \
+ eina_list_data_get(l))
/**
* @def EINA_LIST_REVERSE_FOREACH
* For destructive operations such as this, consider
* using EINA_LIST_REVERSE_FOREACH_SAFE().
*/
-#define EINA_LIST_REVERSE_FOREACH(list, l, data) for (l = eina_list_last(list), data = eina_list_data_get(l); l; l = eina_list_prev(l), data = eina_list_data_get(l))
+#define EINA_LIST_REVERSE_FOREACH(list, l, data) for (l = eina_list_last(list), \
+ data = \
+ eina_list_data_get(l); \
+ l; \
+ l = eina_list_prev(l), \
+ data = eina_list_data_get(l))
/**
* @def EINA_LIST_FOREACH_SAFE
* }
* @endcode
*/
-#define EINA_LIST_FOREACH_SAFE(list, l, l_next, data) for (l = list, l_next = eina_list_next(l), data = eina_list_data_get(l); l; l = l_next, l_next = eina_list_next(l), data = eina_list_data_get(l))
+#define EINA_LIST_FOREACH_SAFE(list, l, l_next, data) for (l = list, \
+ l_next = \
+ eina_list_next(l), \
+ data = eina_list_data_get(l); \
+ l; \
+ l = l_next, l_next = \
+ eina_list_next(l), data = eina_list_data_get(l))
/**
* @def EINA_LIST_REVERSE_FOREACH_SAFE
* }
* @endcode
*/
-#define EINA_LIST_REVERSE_FOREACH_SAFE(list, l, l_prev, data) for (l = eina_list_last(list), l_prev = eina_list_prev(l), data = eina_list_data_get(l); l; l = l_prev, l_prev = eina_list_prev(l), data = eina_list_data_get(l))
+#define EINA_LIST_REVERSE_FOREACH_SAFE(list, l, l_prev, data) for (l = \
+ eina_list_last( \
+ list), \
+ l_prev = eina_list_prev(l), data = eina_list_data_get(l); \
+ l; \
+ l = l_prev, \
+ l_prev = eina_list_prev(l), data = eina_list_data_get(l))
/**
* @def EINA_LIST_FREE
*
* @see eina_list_free()
*/
-#define EINA_LIST_FREE(list, data) for (data = eina_list_data_get(list); list; list = eina_list_remove_list(list, list), data = eina_list_data_get(list))
+#define EINA_LIST_FREE(list, data) for (data = eina_list_data_get(list); list; \
+ list = \
+ eina_list_remove_list(list, \
+ list), data = eina_list_data_get(list))
#include "eina_inline_list.x"
* header files.
*/
#ifdef EINA_LOG_LEVEL_MAXIMUM
-#define EINA_LOG(DOM, LEVEL, fmt, ...) \
- do { \
- if (LEVEL <= EINA_LOG_LEVEL_MAXIMUM) \
- eina_log_print(DOM, LEVEL, __FILE__, __FUNCTION__, __LINE__, \
- fmt, ##__VA_ARGS__); \
- } while (0)
+#define EINA_LOG(DOM, LEVEL, fmt, ...) \
+ do { \
+ if (LEVEL <= EINA_LOG_LEVEL_MAXIMUM) { \
+ eina_log_print(DOM, LEVEL, __FILE__, __FUNCTION__, __LINE__, \
+ fmt, ## __VA_ARGS__); } \
+ } while (0)
#else
#define EINA_LOG(DOM, LEVEL, fmt, ...) \
- eina_log_print(DOM, LEVEL, __FILE__, __FUNCTION__, __LINE__, fmt, ##__VA_ARGS__)
+ eina_log_print(DOM, \
+ LEVEL, \
+ __FILE__, \
+ __FUNCTION__, \
+ __LINE__, \
+ fmt, \
+ ## __VA_ARGS__)
#endif
/**
* Logs a message with level CRITICAL on the specified domain and format.
*/
#define EINA_LOG_DOM_CRIT(DOM, fmt, ...) \
- EINA_LOG(DOM, EINA_LOG_LEVEL_CRITICAL, fmt, ##__VA_ARGS__)
+ EINA_LOG(DOM, EINA_LOG_LEVEL_CRITICAL, fmt, ## __VA_ARGS__)
/**
* @def EINA_LOG_DOM_ERR(DOM, fmt, ...)
* Logs a message with level ERROR on the specified domain and format.
*/
#define EINA_LOG_DOM_ERR(DOM, fmt, ...) \
- EINA_LOG(DOM, EINA_LOG_LEVEL_ERR, fmt, ##__VA_ARGS__)
+ EINA_LOG(DOM, EINA_LOG_LEVEL_ERR, fmt, ## __VA_ARGS__)
/**
* @def EINA_LOG_DOM_INFO(DOM, fmt, ...)
* Logs a message with level INFO on the specified domain and format.
*/
#define EINA_LOG_DOM_INFO(DOM, fmt, ...) \
- EINA_LOG(DOM, EINA_LOG_LEVEL_INFO, fmt, ##__VA_ARGS__)
+ EINA_LOG(DOM, EINA_LOG_LEVEL_INFO, fmt, ## __VA_ARGS__)
/**
* @def EINA_LOG_DOM_DBG(DOM, fmt, ...)
* Logs a message with level DEBUG on the specified domain and format.
*/
#define EINA_LOG_DOM_DBG(DOM, fmt, ...) \
- EINA_LOG(DOM, EINA_LOG_LEVEL_DBG, fmt, ##__VA_ARGS__)
+ EINA_LOG(DOM, EINA_LOG_LEVEL_DBG, fmt, ## __VA_ARGS__)
/**
* @def EINA_LOG_DOM_WARN(DOM, fmt, ...)
* Logs a message with level WARN on the specified domain and format.
*/
#define EINA_LOG_DOM_WARN(DOM, fmt, ...) \
- EINA_LOG(DOM, EINA_LOG_LEVEL_WARN, fmt, ##__VA_ARGS__)
+ EINA_LOG(DOM, EINA_LOG_LEVEL_WARN, fmt, ## __VA_ARGS__)
/**
* @def EINA_LOG_CRIT(fmt, ...)
* format.
*/
#define EINA_LOG_CRIT(fmt, ...) \
- EINA_LOG(EINA_LOG_DOMAIN_DEFAULT, EINA_LOG_LEVEL_CRITICAL, fmt, ##__VA_ARGS__)
+ EINA_LOG(EINA_LOG_DOMAIN_DEFAULT, \
+ EINA_LOG_LEVEL_CRITICAL, \
+ fmt, \
+ ## __VA_ARGS__)
/**
* @def EINA_LOG_ERR(fmt, ...)
* format.
*/
#define EINA_LOG_ERR(fmt, ...) \
- EINA_LOG(EINA_LOG_DOMAIN_DEFAULT, EINA_LOG_LEVEL_ERR, fmt, ##__VA_ARGS__)
+ EINA_LOG(EINA_LOG_DOMAIN_DEFAULT, EINA_LOG_LEVEL_ERR, fmt, ## __VA_ARGS__)
/**
* @def EINA_LOG_INFO(fmt, ...)
* format.
*/
#define EINA_LOG_INFO(fmt, ...) \
- EINA_LOG(EINA_LOG_DOMAIN_DEFAULT, EINA_LOG_LEVEL_INFO, fmt, ##__VA_ARGS__)
+ EINA_LOG(EINA_LOG_DOMAIN_DEFAULT, EINA_LOG_LEVEL_INFO, fmt, ## __VA_ARGS__)
/**
* @def EINA_LOG_WARN(fmt, ...)
* format.
*/
#define EINA_LOG_WARN(fmt, ...) \
- EINA_LOG(EINA_LOG_DOMAIN_DEFAULT, EINA_LOG_LEVEL_WARN, fmt, ##__VA_ARGS__)
+ EINA_LOG(EINA_LOG_DOMAIN_DEFAULT, EINA_LOG_LEVEL_WARN, fmt, ## __VA_ARGS__)
/**
* @def EINA_LOG_DBG(fmt, ...)
* format.
*/
#define EINA_LOG_DBG(fmt, ...) \
- EINA_LOG(EINA_LOG_DOMAIN_DEFAULT, EINA_LOG_LEVEL_DBG, fmt, ##__VA_ARGS__)
+ EINA_LOG(EINA_LOG_DOMAIN_DEFAULT, EINA_LOG_LEVEL_DBG, fmt, ## __VA_ARGS__)
/**
* @typedef Eina_Log_Domain
*/
struct _Eina_Log_Domain
{
- int level; /**< Max level to log */
+ int level; /**< Max level to log */
const char *domain_str; /**< Formatted string with color to print */
- const char *name; /**< Domain name */
- size_t namelen; /**< strlen(name) */
+ const char *name; /**< Domain name */
+ size_t namelen; /**< strlen(name) */
/* Private */
- Eina_Bool deleted:1; /**< Flags deletion of domain, a free slot */
+ Eina_Bool deleted : 1; /**< Flags deletion of domain, a free slot */
};
EAPI void eina_log_threads_enable(void);
*/
typedef enum _Eina_Log_Level
{
- EINA_LOG_LEVEL_CRITICAL, /**< Critical log level */
- EINA_LOG_LEVEL_ERR, /**< Error log level */
- EINA_LOG_LEVEL_WARN, /**< Warning log level */
- EINA_LOG_LEVEL_INFO, /**< Information log level */
- EINA_LOG_LEVEL_DBG, /**< Debug log level */
- EINA_LOG_LEVELS, /**< Count of default log levels */
- EINA_LOG_LEVEL_UNKNOWN = (-2147483647-1) /**< Unknown level */
+ EINA_LOG_LEVEL_CRITICAL, /**< Critical log level */
+ EINA_LOG_LEVEL_ERR, /**< Error log level */
+ EINA_LOG_LEVEL_WARN, /**< Warning log level */
+ EINA_LOG_LEVEL_INFO, /**< Information log level */
+ EINA_LOG_LEVEL_DBG, /**< Debug log level */
+ EINA_LOG_LEVELS, /**< Count of default log levels */
+ EINA_LOG_LEVEL_UNKNOWN = (-2147483647 - 1) /**< Unknown level */
} Eina_Log_Level;
/**
* @typedef Eina_Log_Print_Cb
* Type for print callbacks.
*/
-typedef void (*Eina_Log_Print_Cb)(const Eina_Log_Domain *d, Eina_Log_Level level,
- const char *file, const char *fnc, int line,
- const char *fmt, void *data, va_list args);
+typedef void (*Eina_Log_Print_Cb)(const Eina_Log_Domain *d,
+ Eina_Log_Level level,
+ const char *file, const char *fnc, int line,
+ const char *fmt, void *data, va_list args);
/*
* Customization
*/
-EAPI void eina_log_print_cb_set(Eina_Log_Print_Cb cb, void *data) EINA_ARG_NONNULL(1);
-
-EAPI void eina_log_level_set(int level);
-EAPI int eina_log_level_get(void) EINA_WARN_UNUSED_RESULT;
-
-static inline Eina_Bool eina_log_level_check(int level);
-
-EAPI Eina_Bool eina_log_main_thread_check(void) EINA_CONST EINA_WARN_UNUSED_RESULT;
-
-EAPI void eina_log_color_disable_set(Eina_Bool disabled);
-EAPI Eina_Bool eina_log_color_disable_get(void) EINA_WARN_UNUSED_RESULT;
-EAPI void eina_log_file_disable_set(Eina_Bool disabled);
-EAPI Eina_Bool eina_log_file_disable_get(void) EINA_WARN_UNUSED_RESULT;
-EAPI void eina_log_function_disable_set(Eina_Bool disabled);
-EAPI Eina_Bool eina_log_function_disable_get(void) EINA_WARN_UNUSED_RESULT;
-EAPI void eina_log_abort_on_critical_set(Eina_Bool abort_on_critical);
-EAPI Eina_Bool eina_log_abort_on_critical_get(void) EINA_WARN_UNUSED_RESULT;
-EAPI void eina_log_abort_on_critical_level_set(int critical_level);
-EAPI int eina_log_abort_on_critical_level_get(void) EINA_WARN_UNUSED_RESULT;
-
-EAPI void eina_log_domain_level_set(const char *domain_name, int level) EINA_ARG_NONNULL(1);
-EAPI int eina_log_domain_level_get(const char *domain_name) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
-EAPI int eina_log_domain_registered_level_get(int domain) EINA_WARN_UNUSED_RESULT;
-static inline Eina_Bool eina_log_domain_level_check(int domain, int level);
+EAPI void
+eina_log_print_cb_set(Eina_Log_Print_Cb cb, void *data) EINA_ARG_NONNULL(1);
+
+EAPI void
+eina_log_level_set(int level);
+EAPI int
+eina_log_level_get(void) EINA_WARN_UNUSED_RESULT;
+
+static inline Eina_Bool
+eina_log_level_check(int level);
+
+EAPI Eina_Bool
+eina_log_main_thread_check(void) EINA_CONST EINA_WARN_UNUSED_RESULT;
+
+EAPI void
+eina_log_color_disable_set(Eina_Bool disabled);
+EAPI Eina_Bool
+eina_log_color_disable_get(void) EINA_WARN_UNUSED_RESULT;
+EAPI void
+eina_log_file_disable_set(Eina_Bool disabled);
+EAPI Eina_Bool
+eina_log_file_disable_get(void) EINA_WARN_UNUSED_RESULT;
+EAPI void
+eina_log_function_disable_set(Eina_Bool disabled);
+EAPI Eina_Bool
+eina_log_function_disable_get(void) EINA_WARN_UNUSED_RESULT;
+EAPI void
+eina_log_abort_on_critical_set(Eina_Bool abort_on_critical);
+EAPI Eina_Bool
+eina_log_abort_on_critical_get(void) EINA_WARN_UNUSED_RESULT;
+EAPI void
+eina_log_abort_on_critical_level_set(int critical_level);
+EAPI int
+eina_log_abort_on_critical_level_get(void) EINA_WARN_UNUSED_RESULT;
+
+EAPI void
+eina_log_domain_level_set(const char *domain_name, int level) EINA_ARG_NONNULL(
+ 1);
+EAPI int
+eina_log_domain_level_get(const char *domain_name) EINA_WARN_UNUSED_RESULT
+EINA_ARG_NONNULL(1);
+EAPI int
+eina_log_domain_registered_level_get(int domain) EINA_WARN_UNUSED_RESULT;
+static inline Eina_Bool
+eina_log_domain_level_check(int domain, int level);
/*
* Logging domains
*/
-EAPI int eina_log_domain_register(const char *name, const char *color) EINA_ARG_NONNULL(1);
-EAPI void eina_log_domain_unregister(int domain);
+EAPI int
+eina_log_domain_register(const char *name, const char *color) EINA_ARG_NONNULL(
+ 1);
+EAPI void
+eina_log_domain_unregister(int domain);
/*
* Logging functions.
*/
-EAPI void eina_log_print(int domain, Eina_Log_Level level, const char *file, const char *function, int line, const char *fmt, ...) EINA_ARG_NONNULL(3, 4, 6) EINA_PRINTF(6, 7) EINA_NOINSTRUMENT;
-EAPI void eina_log_vprint(int domain, Eina_Log_Level level, const char *file, const char *fnc, int line, const char *fmt, va_list args) EINA_ARG_NONNULL(3, 4, 6) EINA_NOINSTRUMENT;
+EAPI void
+eina_log_print(int domain,
+ Eina_Log_Level level,
+ const char *file,
+ const char *function,
+ int line,
+ const char *fmt,
+ ...) EINA_ARG_NONNULL(3, 4, 6) EINA_PRINTF(6,
+ 7) EINA_NOINSTRUMENT;
+EAPI void
+eina_log_vprint(int domain,
+ Eina_Log_Level level,
+ const char *file,
+ const char *fnc,
+ int line,
+ const char *fmt,
+ va_list args) EINA_ARG_NONNULL(3, 4, 6) EINA_NOINSTRUMENT;
/*
* Logging methods (change how logging is done).
*/
-EAPI void eina_log_print_cb_stdout(const Eina_Log_Domain *d, Eina_Log_Level level, const char *file, const char *fnc, int line, const char *fmt, void *data, va_list args);
-EAPI void eina_log_print_cb_stderr(const Eina_Log_Domain *d, Eina_Log_Level level, const char *file, const char *fnc, int line, const char *fmt, void *data, va_list args);
-EAPI void eina_log_print_cb_file(const Eina_Log_Domain *d, Eina_Log_Level level, const char *file, const char *fnc, int line, const char *fmt, void *data, va_list args);
+EAPI void
+eina_log_print_cb_stdout(const Eina_Log_Domain *d,
+ Eina_Log_Level level,
+ const char *file,
+ const char *fnc,
+ int line,
+ const char *fmt,
+ void *data,
+ va_list args);
+EAPI void
+eina_log_print_cb_stderr(const Eina_Log_Domain *d,
+ Eina_Log_Level level,
+ const char *file,
+ const char *fnc,
+ int line,
+ const char *fmt,
+ void *data,
+ va_list args);
+EAPI void
+eina_log_print_cb_file(const Eina_Log_Domain *d,
+ Eina_Log_Level level,
+ const char *file,
+ const char *fnc,
+ int line,
+ const char *fmt,
+ void *data,
+ va_list args);
#include "eina_inline_log.x"
* @{
*/
-typedef unsigned int Eina_Magic;
+typedef unsigned int Eina_Magic;
/**
* @typedef Eina_Magic
* An abstract type for a magic number.
*/
-EAPI const char* eina_magic_string_get(Eina_Magic magic) EINA_PURE EINA_WARN_UNUSED_RESULT;
-EAPI Eina_Bool eina_magic_string_set(Eina_Magic magic, const char *magic_name) EINA_ARG_NONNULL(2);
-EAPI Eina_Bool eina_magic_string_static_set(Eina_Magic magic, const char *magic_name) EINA_ARG_NONNULL(2);
+EAPI const char *eina_magic_string_get(Eina_Magic magic) EINA_PURE
+EINA_WARN_UNUSED_RESULT;
+EAPI Eina_Bool eina_magic_string_set(Eina_Magic magic,
+ const char *magic_name) EINA_ARG_NONNULL(
+ 2);
+EAPI Eina_Bool eina_magic_string_static_set(Eina_Magic magic,
+ const char *magic_name)
+EINA_ARG_NONNULL(2);
/**
* @def EINA_MAGIC_NONE
*
* If the magic feature of Eina is disabled, #EINA_MAGIC does nothing.
*/
-#define EINA_MAGIC Eina_Magic __magic;
+#define EINA_MAGIC Eina_Magic __magic;
/**
* @def EINA_MAGIC_SET(d, m)
* If the magic feature of Eina is disabled, #EINA_MAGIC_FAIL does
* nothing.
*/
-#define EINA_MAGIC_FAIL(d, m) eina_magic_fail((void*)(d), (d) ? (d)->__magic : 0, (m), __FILE__, __FUNCTION__, __LINE__);
+#define EINA_MAGIC_FAIL(d, m) eina_magic_fail((void *)(d), \
+ (d) ? (d)->__magic : 0, \
+ (m), \
+ __FILE__, \
+ __FUNCTION__, \
+ __LINE__);
EAPI void eina_magic_fail(void *d, Eina_Magic m, Eina_Magic req_m,
- const char *file, const char *fnc, int line) EINA_ARG_NONNULL(4, 5);
+ const char *file, const char *fnc,
+ int line) EINA_ARG_NONNULL(4, 5);
#else
*/
#define EINA_MAGIC
-#define EINA_MAGIC_SET(d, m) ((void) 0)
-#define EINA_MAGIC_CHECK(d, m) (1)
-#define EINA_MAGIC_FAIL(d, m) ((void) 0)
+#define EINA_MAGIC_SET(d, m) ((void)0)
+#define EINA_MAGIC_CHECK(d, m) (1)
+#define EINA_MAGIC_FAIL(d, m) ((void)0)
-#define eina_magic_fail(d, m, req_m, file, fnx, line) ((void) 0)
+#define eina_magic_fail(d, m, req_m, file, fnx, line) ((void)0)
/**
* @endcond
*/
typedef struct _Eina_Matrixsparse_Cell Eina_Matrixsparse_Cell;
-typedef struct _Eina_Matrixsparse_Item_Cell Eina_Matrixsparse_Item_Cell;
-typedef struct _Eina_Matrixsparse_Item_Row Eina_Matrixsparse_Item_Row;
+typedef struct _Eina_Matrixsparse_Item_Cell Eina_Matrixsparse_Item_Cell;
+typedef struct _Eina_Matrixsparse_Item_Row Eina_Matrixsparse_Item_Row;
/* 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 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);
/* size manipulation */
-EAPI void eina_matrixsparse_size_get(const Eina_Matrixsparse *m, unsigned long *rows, unsigned long *cols);
-EAPI Eina_Bool eina_matrixsparse_size_set(Eina_Matrixsparse *m, unsigned long rows, unsigned long cols);
+EAPI void eina_matrixsparse_size_get(const Eina_Matrixsparse *m,
+ unsigned long *rows,
+ unsigned long *cols);
+EAPI Eina_Bool eina_matrixsparse_size_set(Eina_Matrixsparse *m,
+ unsigned long rows,
+ unsigned long cols);
/* data getting */
-EAPI Eina_Bool eina_matrixsparse_cell_idx_get(const Eina_Matrixsparse *m, unsigned long row, unsigned long col, Eina_Matrixsparse_Cell **cell);
-EAPI void *eina_matrixsparse_cell_data_get(const Eina_Matrixsparse_Cell *cell);
-EAPI void *eina_matrixsparse_data_idx_get(const Eina_Matrixsparse *m, unsigned long row, unsigned long col);
-EAPI Eina_Bool eina_matrixsparse_cell_position_get(const Eina_Matrixsparse_Cell *cell, unsigned long *row, unsigned long *col);
+EAPI Eina_Bool eina_matrixsparse_cell_idx_get(
+ const Eina_Matrixsparse *m,
+ unsigned long row,
+ unsigned long col,
+ Eina_Matrixsparse_Cell **cell);
+EAPI void * eina_matrixsparse_cell_data_get(
+ const Eina_Matrixsparse_Cell *cell);
+EAPI void * eina_matrixsparse_data_idx_get(
+ const Eina_Matrixsparse *m,
+ unsigned long row,
+ unsigned long col);
+EAPI Eina_Bool eina_matrixsparse_cell_position_get(
+ const Eina_Matrixsparse_Cell *cell,
+ unsigned long *row,
+ unsigned long *col);
/* data setting */
-EAPI Eina_Bool eina_matrixsparse_cell_data_replace(Eina_Matrixsparse_Cell *cell, const void *data, void **p_old);
-EAPI Eina_Bool eina_matrixsparse_cell_data_set(Eina_Matrixsparse_Cell *cell, const void *data);
-EAPI Eina_Bool eina_matrixsparse_data_idx_replace(Eina_Matrixsparse *m, unsigned long row, unsigned long col, const void *data, void **p_old);
-EAPI Eina_Bool eina_matrixsparse_data_idx_set(Eina_Matrixsparse *m, unsigned long row, unsigned long col, const void *data);
+EAPI Eina_Bool eina_matrixsparse_cell_data_replace(
+ Eina_Matrixsparse_Cell *cell,
+ const void *data,
+ void **p_old);
+EAPI Eina_Bool eina_matrixsparse_cell_data_set(
+ Eina_Matrixsparse_Cell *cell,
+ const void *data);
+EAPI Eina_Bool eina_matrixsparse_data_idx_replace(Eina_Matrixsparse *m,
+ unsigned long row,
+ unsigned long col,
+ const void *data,
+ void **p_old);
+EAPI Eina_Bool eina_matrixsparse_data_idx_set(Eina_Matrixsparse *m,
+ unsigned long row,
+ unsigned long col,
+ const void *data);
/* data deleting */
-EAPI Eina_Bool eina_matrixsparse_row_idx_clear(Eina_Matrixsparse *m, unsigned long row);
-EAPI Eina_Bool eina_matrixsparse_column_idx_clear(Eina_Matrixsparse *m, unsigned long col);
-EAPI Eina_Bool eina_matrixsparse_cell_idx_clear(Eina_Matrixsparse *m, unsigned long row, unsigned long col);
-EAPI Eina_Bool eina_matrixsparse_cell_clear(Eina_Matrixsparse_Cell *cell);
+EAPI Eina_Bool eina_matrixsparse_row_idx_clear(Eina_Matrixsparse *m,
+ unsigned long row);
+EAPI Eina_Bool eina_matrixsparse_column_idx_clear(Eina_Matrixsparse *m,
+ unsigned long col);
+EAPI Eina_Bool eina_matrixsparse_cell_idx_clear(Eina_Matrixsparse *m,
+ unsigned long row,
+ unsigned long col);
+EAPI Eina_Bool eina_matrixsparse_cell_clear(
+ Eina_Matrixsparse_Cell *cell);
/* iterators */
-EAPI Eina_Iterator *eina_matrixsparse_iterator_new(const Eina_Matrixsparse *m);
-EAPI Eina_Iterator *eina_matrixsparse_iterator_complete_new(const Eina_Matrixsparse *m);
+EAPI Eina_Iterator *eina_matrixsparse_iterator_new(
+ const Eina_Matrixsparse *m);
+EAPI Eina_Iterator *eina_matrixsparse_iterator_complete_new(
+ const Eina_Matrixsparse *m);
/**
* @}
EAPI extern Eina_Error EINA_ERROR_NOT_MEMPOOL_MODULE;
-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);
-
-static inline void * eina_mempool_realloc(Eina_Mempool *mp, void *element, unsigned int size) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
-static inline void * eina_mempool_malloc(Eina_Mempool *mp, unsigned int size) EINA_MALLOC EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
-static inline void eina_mempool_free(Eina_Mempool *mp, void *element) EINA_ARG_NONNULL(1);
-
-EAPI void eina_mempool_gc(Eina_Mempool *mp) EINA_ARG_NONNULL(1);
-EAPI void eina_mempool_statistics(Eina_Mempool *mp) EINA_ARG_NONNULL(1);
-
-EAPI Eina_Bool eina_mempool_register(Eina_Mempool_Backend *be) EINA_ARG_NONNULL(1);
-EAPI void eina_mempool_unregister(Eina_Mempool_Backend *be) EINA_ARG_NONNULL(1);
-
-EAPI unsigned int eina_mempool_alignof(unsigned int size);
+EAPI 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);
+
+static inline void *
+ eina_mempool_realloc(
+ Eina_Mempool *mp,
+ void *element,
+ unsigned int size) EINA_ARG_NONNULL(1)
+EINA_WARN_UNUSED_RESULT;
+static inline void *
+ eina_mempool_malloc(
+ Eina_Mempool *mp,
+ unsigned int size) EINA_MALLOC EINA_ARG_NONNULL(1)
+EINA_WARN_UNUSED_RESULT;
+static inline void
+ eina_mempool_free(
+ Eina_Mempool *mp,
+ void *element) EINA_ARG_NONNULL(1);
+
+EAPI void
+ eina_mempool_gc(
+ Eina_Mempool *mp) EINA_ARG_NONNULL(1);
+EAPI void
+ eina_mempool_statistics(
+ Eina_Mempool *mp) EINA_ARG_NONNULL(1);
+
+EAPI Eina_Bool
+ eina_mempool_register(
+ Eina_Mempool_Backend *be) EINA_ARG_NONNULL(1);
+EAPI void
+ eina_mempool_unregister(
+ Eina_Mempool_Backend *be) EINA_ARG_NONNULL(1);
+
+EAPI unsigned int
+ eina_mempool_alignof(
+ unsigned int size);
#include "eina_inline_mempool.x"
* (__eina_module_shutdown). It must be of signature
* #Eina_Module_Shutdown
*/
-#define EINA_MODULE_SHUTDOWN(f) EAPI Eina_Module_Shutdown __eina_module_shutdown = &f
+#define EINA_MODULE_SHUTDOWN(f) EAPI Eina_Module_Shutdown \
+ __eina_module_shutdown = &f
/**
* @var EINA_ERROR_WRONG_MODULE
*/
extern EAPI Eina_Error EINA_ERROR_MODULE_INIT_FAILED;
-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);
-EAPI Eina_Bool eina_module_unload(Eina_Module *m) EINA_ARG_NONNULL(1);
-EAPI void *eina_module_symbol_get(const Eina_Module *module, const char *symbol) EINA_PURE EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
-EAPI const char * eina_module_file_get(const Eina_Module *m) EINA_PURE EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
-
-EAPI char *eina_module_symbol_path_get(const void *symbol, const char *sub_dir) EINA_PURE EINA_MALLOC EINA_ARG_NONNULL(1, 2);
-EAPI char *eina_module_environment_path_get(const char *env, const char *sub_dir) EINA_PURE EINA_MALLOC EINA_ARG_NONNULL(1, 2);
-
-EAPI Eina_Array * eina_module_arch_list_get(Eina_Array *array, const char *path, const char *arch);
-EAPI Eina_Array * eina_module_list_get(Eina_Array *array, const char *path, unsigned int recursive, Eina_Module_Cb cb, void *data) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
-EAPI void eina_module_list_load(Eina_Array *list) EINA_ARG_NONNULL(1);
-EAPI void eina_module_list_unload(Eina_Array *list) EINA_ARG_NONNULL(1);
-EAPI void eina_module_list_free(Eina_Array *list) EINA_ARG_NONNULL(1);
-EAPI Eina_Module * eina_module_find(const Eina_Array *array, const char *module) EINA_ARG_NONNULL(1, 2);
+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);
+EAPI Eina_Bool
+eina_module_unload(
+ Eina_Module *m) EINA_ARG_NONNULL(1);
+EAPI void *
+eina_module_symbol_get(
+ const Eina_Module *module,
+ const char *symbol) EINA_PURE
+EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
+EAPI const char *
+eina_module_file_get(
+ const Eina_Module *m) EINA_PURE EINA_WARN_UNUSED_RESULT
+EINA_ARG_NONNULL(
+ 1);
+
+EAPI char *
+eina_module_symbol_path_get(
+ const void *symbol,
+ const char *sub_dir) EINA_PURE EINA_MALLOC
+EINA_ARG_NONNULL(1, 2);
+EAPI char *
+eina_module_environment_path_get(
+ const char *env,
+ const char *sub_dir) EINA_PURE EINA_MALLOC
+EINA_ARG_NONNULL(1, 2);
+
+EAPI Eina_Array *
+eina_module_arch_list_get(
+ Eina_Array *array,
+ const char *path,
+ const char *arch);
+EAPI Eina_Array *
+eina_module_list_get(
+ Eina_Array *array,
+ const char *path,
+ unsigned int recursive,
+ Eina_Module_Cb cb,
+ void *data) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
+EAPI void
+eina_module_list_load(Eina_Array *list) EINA_ARG_NONNULL(1);
+EAPI void
+eina_module_list_unload(Eina_Array *list) EINA_ARG_NONNULL(1);
+EAPI void
+eina_module_list_free(Eina_Array *list) EINA_ARG_NONNULL(1);
+EAPI Eina_Module *
+eina_module_find(const Eina_Array *array, const char *module) EINA_ARG_NONNULL(
+ 1,
+ 2);
/**
* @}
#endif
#ifndef CLAMP
-# define CLAMP(x, min, max) (((x) > (max)) ? (max) : (((x) < (min)) ? (min) : (x)))
+# define CLAMP(x, min, \
+ max) (((x) > (max)) ? (max) : (((x) < (min)) ? (min) : (x)))
#endif
#define READBUFSIZ 65536
#define EINA_MAGIC_USTRINGSHARE_NODE 0x98761255
#define EINA_MAGIC_BINSHARE_NODE 0x98761256
-#define EINA_MAGIC_LIST 0x98761237
+#define EINA_MAGIC_LIST 0x98761237
#define EINA_MAGIC_LIST_ITERATOR 0x98761238
#define EINA_MAGIC_LIST_ACCESSOR 0x98761239
#define EINA_MAGIC_LIST_ACCOUNTING 0x9876123a
/* undef the following, we want out version */
#undef FREE
-#define FREE(ptr) \
- do { \
- free(ptr); \
- ptr = NULL; \
- } while(0);
+#define FREE(ptr) \
+ do { \
+ free(ptr); \
+ ptr = NULL; \
+ } while(0);
#undef IF_FREE
-#define IF_FREE(ptr) \
- do { \
- if (ptr) { \
- free(ptr); \
- ptr = NULL; \
- } \
- } while(0);
+#define IF_FREE(ptr) \
+ do { \
+ if (ptr) { \
+ free(ptr); \
+ ptr = NULL; \
+ } \
+ } while(0);
#undef IF_FN_DEL
-#define IF_FN_DEL(_fn, ptr) \
- do { \
- if (ptr) { \
- _fn(ptr); \
- ptr = NULL; \
- } \
- } while(0);
-
-#define MAGIC_FREE(ptr) \
- do { \
- if (ptr) { \
- EINA_MAGIC_SET(ptr, EINA_MAGIC_NONE); \
- FREE(ptr); \
- } \
- } while(0);
+#define IF_FN_DEL(_fn, ptr) \
+ do { \
+ if (ptr) { \
+ _fn(ptr); \
+ ptr = NULL; \
+ } \
+ } while(0);
+
+#define MAGIC_FREE(ptr) \
+ do { \
+ if (ptr) { \
+ EINA_MAGIC_SET(ptr, EINA_MAGIC_NONE); \
+ FREE(ptr); \
+ } \
+ } while(0);
#ifdef EFL_HAVE_THREADS
void eina_share_common_threads_init(void);
typedef struct _Eina_QuadTree_Item Eina_QuadTree_Item;
typedef enum {
- EINA_QUAD_LEFT,
- EINA_QUAD_RIGHT,
- EINA_QUAD_BOTH
+ EINA_QUAD_LEFT,
+ EINA_QUAD_RIGHT,
+ EINA_QUAD_BOTH
} Eina_Quad_Direction;
-typedef Eina_Quad_Direction (*Eina_Quad_Callback)(const void *object, size_t middle);
+typedef Eina_Quad_Direction (*Eina_Quad_Callback)(const void *object,
+ size_t middle);
-EAPI Eina_QuadTree *eina_quadtree_new(size_t w, size_t h,
- Eina_Quad_Callback vertical,
- Eina_Quad_Callback horizontal);
-EAPI void eina_quadtree_free(Eina_QuadTree *q);
-EAPI void eina_quadtree_resize(Eina_QuadTree *q, size_t w, size_t h);
+EAPI Eina_QuadTree * eina_quadtree_new(size_t w, size_t h,
+ Eina_Quad_Callback vertical,
+ Eina_Quad_Callback horizontal);
+EAPI void eina_quadtree_free(Eina_QuadTree *q);
+EAPI void eina_quadtree_resize(Eina_QuadTree *q,
+ size_t w,
+ size_t h);
-EAPI void eina_quadtree_cycle(Eina_QuadTree *q);
-EAPI void eina_quadtree_increase(Eina_QuadTree_Item *object);
+EAPI void eina_quadtree_cycle(Eina_QuadTree *q);
+EAPI void eina_quadtree_increase(Eina_QuadTree_Item *object);
EAPI Eina_QuadTree_Item *eina_quadtree_add(Eina_QuadTree *q, const void *object);
-EAPI Eina_Bool eina_quadtree_del(Eina_QuadTree_Item *object);
-EAPI Eina_Bool eina_quadtree_change(Eina_QuadTree_Item *object);
-EAPI Eina_Bool eina_quadtree_hide(Eina_QuadTree_Item *object);
-EAPI Eina_Bool eina_quadtree_show(Eina_QuadTree_Item *object);
-
-EAPI Eina_Inlist *eina_quadtree_collide(Eina_QuadTree *q,
- int x, int y, int w, int h);
-EAPI void *eina_quadtree_object(Eina_Inlist *list);
+EAPI Eina_Bool eina_quadtree_del(Eina_QuadTree_Item *object);
+EAPI Eina_Bool eina_quadtree_change(Eina_QuadTree_Item *object);
+EAPI Eina_Bool eina_quadtree_hide(Eina_QuadTree_Item *object);
+EAPI Eina_Bool eina_quadtree_show(Eina_QuadTree_Item *object);
+
+EAPI Eina_Inlist * eina_quadtree_collide(Eina_QuadTree *q,
+ int x, int y, int w, int h);
+EAPI void * eina_quadtree_object(Eina_Inlist *list);
#endif
* node color.
*/
typedef enum {
- EINA_RBTREE_RED,
- EINA_RBTREE_BLACK
+ EINA_RBTREE_RED,
+ EINA_RBTREE_BLACK
} Eina_Rbtree_Color;
/**
* walk direction.
*/
typedef enum {
- EINA_RBTREE_LEFT = 0,
- EINA_RBTREE_RIGHT = 1
+ EINA_RBTREE_LEFT = 0,
+ EINA_RBTREE_RIGHT = 1
} Eina_Rbtree_Direction;
/**
typedef struct _Eina_Rbtree Eina_Rbtree;
struct _Eina_Rbtree
{
- Eina_Rbtree *son[2];
+ Eina_Rbtree *son[2];
- Eina_Rbtree_Color color : 1;
+ Eina_Rbtree_Color color : 1;
};
/**
* @def EINA_RBTREE_GET
* access the inlined node if it was created with #EINA_RBTREE.
*/
-#define EINA_RBTREE_GET(Rbtree) &((Rbtree)->__rbtree)
+#define EINA_RBTREE_GET(Rbtree) & ((Rbtree)->__rbtree)
/**
* @typedef Eina_Rbtree_Cmp_Node_Cb
* Function used compare two nodes and see which direction to navigate.
*/
-typedef Eina_Rbtree_Direction (*Eina_Rbtree_Cmp_Node_Cb)(const Eina_Rbtree *left, const Eina_Rbtree *right, void *data);
+typedef Eina_Rbtree_Direction (*Eina_Rbtree_Cmp_Node_Cb)(const Eina_Rbtree *
+ left,
+ const Eina_Rbtree *
+ right, void *data);
/**
* @def EINA_RBTREE_CMP_NODE_CB
* Cast using #Eina_Rbtree_Cmp_Node_Cb
*/
-#define EINA_RBTREE_CMP_NODE_CB(Function) ((Eina_Rbtree_Cmp_Node_Cb) Function)
+#define EINA_RBTREE_CMP_NODE_CB(Function) ((Eina_Rbtree_Cmp_Node_Cb)Function)
/**
* @typedef Eina_Rbtree_Cmp_Key_Cb
* Function used compare node with a given key of specified length.
*/
-typedef int (*Eina_Rbtree_Cmp_Key_Cb)(const Eina_Rbtree *node, const void *key, int length, void *data);
+typedef int (*Eina_Rbtree_Cmp_Key_Cb)(const Eina_Rbtree *node, const void *key,
+ int length, void *data);
/**
* @def EINA_RBTREE_CMP_KEY_CB
* Cast using #Eina_Rbtree_Cmp_Key_Cb
*/
-#define EINA_RBTREE_CMP_KEY_CB(Function) ((Eina_Rbtree_Cmp_Key_Cb) Function)
+#define EINA_RBTREE_CMP_KEY_CB(Function) ((Eina_Rbtree_Cmp_Key_Cb)Function)
/**
* @typedef Eina_Rbtree_Free_Cb
* @def EINA_RBTREE_FREE_CB
* Cast using #Eina_Rbtree_Free_Cb
*/
-#define EINA_RBTREE_FREE_CB(Function) ((Eina_Rbtree_Free_Cb) Function)
-
-EAPI Eina_Rbtree *eina_rbtree_inline_insert(Eina_Rbtree *root, Eina_Rbtree *node, Eina_Rbtree_Cmp_Node_Cb cmp, const void *data) EINA_ARG_NONNULL(2, 3) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_Rbtree *eina_rbtree_inline_remove(Eina_Rbtree *root, Eina_Rbtree *node, Eina_Rbtree_Cmp_Node_Cb cmp, const void *data) EINA_ARG_NONNULL(2, 3) EINA_WARN_UNUSED_RESULT;
-EAPI void eina_rbtree_delete(Eina_Rbtree *root, Eina_Rbtree_Free_Cb func, void *data) EINA_ARG_NONNULL(2);
-
-static inline Eina_Rbtree *eina_rbtree_inline_lookup(const Eina_Rbtree *root, const void *key, int length, Eina_Rbtree_Cmp_Key_Cb cmp, const void *data) EINA_PURE EINA_ARG_NONNULL(2, 4) EINA_WARN_UNUSED_RESULT;
-
-EAPI Eina_Iterator *eina_rbtree_iterator_prefix(const Eina_Rbtree *root) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
-EAPI Eina_Iterator *eina_rbtree_iterator_infix(const Eina_Rbtree *root) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
-EAPI Eina_Iterator *eina_rbtree_iterator_postfix(const Eina_Rbtree *root) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
+#define EINA_RBTREE_FREE_CB(Function) ((Eina_Rbtree_Free_Cb)Function)
+
+EAPI Eina_Rbtree *
+eina_rbtree_inline_insert(
+ Eina_Rbtree *root,
+ Eina_Rbtree *node,
+ Eina_Rbtree_Cmp_Node_Cb cmp,
+ const void *data) EINA_ARG_NONNULL(2,
+ 3) EINA_WARN_UNUSED_RESULT;
+EAPI Eina_Rbtree *
+eina_rbtree_inline_remove(
+ Eina_Rbtree *root,
+ Eina_Rbtree *node,
+ Eina_Rbtree_Cmp_Node_Cb cmp,
+ const void *data) EINA_ARG_NONNULL(2,
+ 3) EINA_WARN_UNUSED_RESULT;
+EAPI void
+eina_rbtree_delete(
+ Eina_Rbtree *root,
+ Eina_Rbtree_Free_Cb func,
+ void *data) EINA_ARG_NONNULL(2);
+
+static inline Eina_Rbtree *
+ eina_rbtree_inline_lookup(
+ const Eina_Rbtree *root,
+ const void *key,
+ int length,
+ Eina_Rbtree_Cmp_Key_Cb cmp,
+ const void *data) EINA_PURE EINA_ARG_NONNULL(2,
+ 4) EINA_WARN_UNUSED_RESULT;
+
+EAPI Eina_Iterator *
+ eina_rbtree_iterator_prefix(
+ const Eina_Rbtree *root) EINA_MALLOC
+EINA_WARN_UNUSED_RESULT;
+EAPI Eina_Iterator *
+ eina_rbtree_iterator_infix(
+ const Eina_Rbtree *root) EINA_MALLOC
+EINA_WARN_UNUSED_RESULT;
+EAPI Eina_Iterator *
+ eina_rbtree_iterator_postfix(
+ const Eina_Rbtree *root) EINA_MALLOC
+EINA_WARN_UNUSED_RESULT;
#include "eina_inline_rbtree.x"
typedef struct _Eina_Rectangle_Pool Eina_Rectangle_Pool;
-static inline int eina_spans_intersect(int c1, int l1, int c2, int l2) EINA_WARN_UNUSED_RESULT;
-static inline Eina_Bool eina_rectangle_is_empty(const Eina_Rectangle *r) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
-static inline void eina_rectangle_coords_from(Eina_Rectangle *r, int x, int y, int w, int h) EINA_ARG_NONNULL(1);
-static inline Eina_Bool eina_rectangles_intersect(const Eina_Rectangle *r1, const Eina_Rectangle *r2) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
-static inline Eina_Bool eina_rectangle_xcoord_inside(const Eina_Rectangle *r, int x) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
-static inline Eina_Bool eina_rectangle_ycoord_inside(const Eina_Rectangle *r, int y) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
-static inline Eina_Bool eina_rectangle_coords_inside(const Eina_Rectangle *r, int x, int y) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
-static inline void eina_rectangle_union(Eina_Rectangle *dst, const Eina_Rectangle *src) EINA_ARG_NONNULL(1, 2);
-static inline Eina_Bool eina_rectangle_intersection(Eina_Rectangle *dst, const Eina_Rectangle *src) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
-static inline 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);
+static inline int
+eina_spans_intersect(
+ int c1,
+ int l1,
+ int c2,
+ int l2) EINA_WARN_UNUSED_RESULT;
+static inline Eina_Bool
+eina_rectangle_is_empty(
+ const Eina_Rectangle *r) EINA_ARG_NONNULL(1)
+EINA_WARN_UNUSED_RESULT;
+static inline void
+eina_rectangle_coords_from(
+ Eina_Rectangle *r,
+ int x,
+ int y,
+ int w,
+ int h) EINA_ARG_NONNULL(1);
+static inline Eina_Bool
+eina_rectangles_intersect(
+ const Eina_Rectangle *r1,
+ const Eina_Rectangle *r2) EINA_ARG_NONNULL(1,
+ 2) EINA_WARN_UNUSED_RESULT;
+static inline Eina_Bool
+eina_rectangle_xcoord_inside(
+ const Eina_Rectangle *r,
+ int x) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
+static inline Eina_Bool
+eina_rectangle_ycoord_inside(
+ const Eina_Rectangle *r,
+ int y) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
+static inline Eina_Bool
+eina_rectangle_coords_inside(
+ const Eina_Rectangle *r,
+ int x,
+ int y) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
+static inline void
+eina_rectangle_union(
+ Eina_Rectangle *dst,
+ const Eina_Rectangle *src) EINA_ARG_NONNULL(1, 2);
+static inline Eina_Bool
+eina_rectangle_intersection(
+ Eina_Rectangle *dst,
+ const Eina_Rectangle *src) EINA_ARG_NONNULL(1,
+ 2) EINA_WARN_UNUSED_RESULT;
+static inline 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 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;
-EAPI void *eina_rectangle_pool_data_get(Eina_Rectangle_Pool *pool) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
-EAPI void eina_rectangle_pool_data_set(Eina_Rectangle_Pool *pool, const void *data) EINA_ARG_NONNULL(1);
-EAPI void eina_rectangle_pool_free(Eina_Rectangle_Pool *pool) EINA_ARG_NONNULL(1);
-EAPI int eina_rectangle_pool_count(Eina_Rectangle_Pool *pool) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_Rectangle *eina_rectangle_pool_request(Eina_Rectangle_Pool *pool, int w, int h) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
-EAPI void eina_rectangle_pool_release(Eina_Rectangle *rect) EINA_ARG_NONNULL(1);
+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;
+EAPI void *
+eina_rectangle_pool_data_get(
+ Eina_Rectangle_Pool *pool) EINA_WARN_UNUSED_RESULT
+EINA_ARG_NONNULL(
+ 1);
+EAPI void
+eina_rectangle_pool_data_set(
+ Eina_Rectangle_Pool *pool,
+ const void *data) EINA_ARG_NONNULL(1);
+EAPI void
+eina_rectangle_pool_free(
+ Eina_Rectangle_Pool *pool) EINA_ARG_NONNULL(1);
+EAPI int
+eina_rectangle_pool_count(
+ Eina_Rectangle_Pool *pool) EINA_ARG_NONNULL(1)
+EINA_WARN_UNUSED_RESULT;
+EAPI Eina_Rectangle *
+eina_rectangle_pool_request(
+ Eina_Rectangle_Pool *pool,
+ int w,
+ int h) EINA_WARN_UNUSED_RESULT
+EINA_ARG_NONNULL(1);
+EAPI void
+eina_rectangle_pool_release(
+ Eina_Rectangle *rect) EINA_ARG_NONNULL(1);
/**
* @def EINA_RECTANGLE_SET
* width and @p H is its height.
*/
#define EINA_RECTANGLE_SET(Rectangle, X, Y, W, H) \
- (Rectangle)->x = X; \
- (Rectangle)->y = Y; \
- (Rectangle)->w = W; \
- (Rectangle)->h = H;
+ (Rectangle)->x = X; \
+ (Rectangle)->y = Y; \
+ (Rectangle)->w = W; \
+ (Rectangle)->h = H;
-EAPI Eina_Rectangle *eina_rectangle_new(int x, int y, int w, int h) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
-EAPI void eina_rectangle_free(Eina_Rectangle *rect) EINA_ARG_NONNULL(1);
+EAPI Eina_Rectangle *eina_rectangle_new(int x, int y, int w,
+ int h) EINA_MALLOC
+EINA_WARN_UNUSED_RESULT;
+EAPI void eina_rectangle_free(Eina_Rectangle *rect) EINA_ARG_NONNULL(
+ 1);
#include "eina_inline_rectangle.x"
#include "eina_log.h"
-#define EINA_SAFETY_ON_NULL_RETURN(exp) \
- do \
- { \
- if (EINA_UNLIKELY((exp) == NULL)) \
- { \
- eina_error_set(EINA_ERROR_SAFETY_FAILED); \
- EINA_LOG_ERR("%s", "safety check failed: " #exp " == NULL"); \
- return; \
- } \
- } \
- while (0)
-
-#define EINA_SAFETY_ON_NULL_RETURN_VAL(exp, val) \
- do \
- { \
- if (EINA_UNLIKELY((exp) == NULL)) \
- { \
- eina_error_set(EINA_ERROR_SAFETY_FAILED); \
- EINA_LOG_ERR("%s", "safety check failed: " #exp " == NULL"); \
- return (val); \
- } \
- } \
- while (0)
-
-#define EINA_SAFETY_ON_NULL_GOTO(exp, label) \
- do \
- { \
- if (EINA_UNLIKELY((exp) == NULL)) \
- { \
- eina_error_set(EINA_ERROR_SAFETY_FAILED); \
- EINA_LOG_ERR("%s", "safety check failed: " #exp " == NULL"); \
- goto label; \
- } \
- } \
- while (0)
-
-#define EINA_SAFETY_ON_TRUE_RETURN(exp) \
- do \
- { \
- if (EINA_UNLIKELY(exp)) \
- { \
- eina_error_set(EINA_ERROR_SAFETY_FAILED); \
- EINA_LOG_ERR("%s", "safety check failed: " #exp " is true"); \
- return; \
- } \
- } \
- while (0)
-
-#define EINA_SAFETY_ON_TRUE_RETURN_VAL(exp, val) \
- do \
- { \
- if (EINA_UNLIKELY(exp)) \
- { \
- eina_error_set(EINA_ERROR_SAFETY_FAILED); \
- EINA_LOG_ERR("%s", "safety check failed: " #exp " is true"); \
- return val; \
- } \
- } \
- while (0)
-
-#define EINA_SAFETY_ON_TRUE_GOTO(exp, label) \
- do \
- { \
- if (EINA_UNLIKELY(exp)) \
- { \
- eina_error_set(EINA_ERROR_SAFETY_FAILED); \
- EINA_LOG_ERR("%s", "safety check failed: " #exp " is true"); \
- goto label; \
- } \
- } \
- while (0)
-
-#define EINA_SAFETY_ON_FALSE_RETURN(exp) \
- do \
- { \
- if (EINA_UNLIKELY(!(exp))) \
- { \
- eina_error_set(EINA_ERROR_SAFETY_FAILED); \
- EINA_LOG_ERR("%s", "safety check failed: " #exp " is false"); \
- return; \
- } \
- } \
- while (0)
-
-#define EINA_SAFETY_ON_FALSE_RETURN_VAL(exp, val) \
- do \
- { \
- if (EINA_UNLIKELY(!(exp))) \
- { \
- eina_error_set(EINA_ERROR_SAFETY_FAILED); \
- EINA_LOG_ERR("%s", "safety check failed: " #exp " is false"); \
- return val; \
- } \
- } \
- while (0)
-
-#define EINA_SAFETY_ON_FALSE_GOTO(exp, label) \
- do \
- { \
- if (EINA_UNLIKELY(!(exp))) \
- { \
- eina_error_set(EINA_ERROR_SAFETY_FAILED); \
- EINA_LOG_ERR("%s", "safety check failed: " #exp " is false"); \
- goto label; \
- } \
- } \
- while (0)
+#define EINA_SAFETY_ON_NULL_RETURN(exp) \
+ do \
+ { \
+ if (EINA_UNLIKELY((exp) == NULL)) \
+ { \
+ eina_error_set(EINA_ERROR_SAFETY_FAILED); \
+ EINA_LOG_ERR("%s", "safety check failed: " # exp " == NULL"); \
+ return; \
+ } \
+ } \
+ while (0)
+
+#define EINA_SAFETY_ON_NULL_RETURN_VAL(exp, val) \
+ do \
+ { \
+ if (EINA_UNLIKELY((exp) == NULL)) \
+ { \
+ eina_error_set(EINA_ERROR_SAFETY_FAILED); \
+ EINA_LOG_ERR("%s", "safety check failed: " # exp " == NULL"); \
+ return (val); \
+ } \
+ } \
+ while (0)
+
+#define EINA_SAFETY_ON_NULL_GOTO(exp, label) \
+ do \
+ { \
+ if (EINA_UNLIKELY((exp) == NULL)) \
+ { \
+ eina_error_set(EINA_ERROR_SAFETY_FAILED); \
+ EINA_LOG_ERR("%s", "safety check failed: " # exp " == NULL"); \
+ goto label; \
+ } \
+ } \
+ while (0)
+
+#define EINA_SAFETY_ON_TRUE_RETURN(exp) \
+ do \
+ { \
+ if (EINA_UNLIKELY(exp)) \
+ { \
+ eina_error_set(EINA_ERROR_SAFETY_FAILED); \
+ EINA_LOG_ERR("%s", "safety check failed: " # exp " is true"); \
+ return; \
+ } \
+ } \
+ while (0)
+
+#define EINA_SAFETY_ON_TRUE_RETURN_VAL(exp, val) \
+ do \
+ { \
+ if (EINA_UNLIKELY(exp)) \
+ { \
+ eina_error_set(EINA_ERROR_SAFETY_FAILED); \
+ EINA_LOG_ERR("%s", "safety check failed: " # exp " is true"); \
+ return val; \
+ } \
+ } \
+ while (0)
+
+#define EINA_SAFETY_ON_TRUE_GOTO(exp, label) \
+ do \
+ { \
+ if (EINA_UNLIKELY(exp)) \
+ { \
+ eina_error_set(EINA_ERROR_SAFETY_FAILED); \
+ EINA_LOG_ERR("%s", "safety check failed: " # exp " is true"); \
+ goto label; \
+ } \
+ } \
+ while (0)
+
+#define EINA_SAFETY_ON_FALSE_RETURN(exp) \
+ do \
+ { \
+ if (EINA_UNLIKELY(!(exp))) \
+ { \
+ eina_error_set(EINA_ERROR_SAFETY_FAILED); \
+ EINA_LOG_ERR("%s", "safety check failed: " # exp " is false"); \
+ return; \
+ } \
+ } \
+ while (0)
+
+#define EINA_SAFETY_ON_FALSE_RETURN_VAL(exp, val) \
+ do \
+ { \
+ if (EINA_UNLIKELY(!(exp))) \
+ { \
+ eina_error_set(EINA_ERROR_SAFETY_FAILED); \
+ EINA_LOG_ERR("%s", "safety check failed: " # exp " is false"); \
+ return val; \
+ } \
+ } \
+ while (0)
+
+#define EINA_SAFETY_ON_FALSE_GOTO(exp, label) \
+ do \
+ { \
+ if (EINA_UNLIKELY(!(exp))) \
+ { \
+ eina_error_set(EINA_ERROR_SAFETY_FAILED); \
+ EINA_LOG_ERR("%s", "safety check failed: " # exp " is false"); \
+ goto label; \
+ } \
+ } \
+ while (0)
#ifdef EINA_ARG_NONNULL
/* make EINA_ARG_NONNULL void so GCC does not optimize safety checks */
#else /* no safety checks */
-#define EINA_SAFETY_ON_NULL_RETURN(exp) \
- do { (void)((exp) == NULL); } while (0)
+#define EINA_SAFETY_ON_NULL_RETURN(exp) \
+ do { (void)((exp) == NULL); } while (0)
-#define EINA_SAFETY_ON_NULL_RETURN_VAL(exp, val) \
- do { if (0 && (exp) == NULL) (void)val; } while (0)
+#define EINA_SAFETY_ON_NULL_RETURN_VAL(exp, val) \
+ do { if (0 && (exp) == NULL) { (void)val; } } while (0)
-#define EINA_SAFETY_ON_NULL_GOTO(exp, label) \
- do { if (0 && (exp) == NULL) goto label; } while (0)
+#define EINA_SAFETY_ON_NULL_GOTO(exp, label) \
+ do { if (0 && (exp) == NULL) { goto label; } } while (0)
-#define EINA_SAFETY_ON_TRUE_RETURN(exp) \
- do { (void)(exp); } while (0)
+#define EINA_SAFETY_ON_TRUE_RETURN(exp) \
+ do { (void)(exp); } while (0)
-#define EINA_SAFETY_ON_TRUE_RETURN_VAL(exp, val) \
- do { if (0 && (exp)) (void)val; } while (0)
+#define EINA_SAFETY_ON_TRUE_RETURN_VAL(exp, val) \
+ do { if (0 && (exp)) { (void)val; } } while (0)
-#define EINA_SAFETY_ON_TRUE_GOTO(exp, label) \
- do { if (0 && (exp)) goto label; } while (0)
+#define EINA_SAFETY_ON_TRUE_GOTO(exp, label) \
+ do { if (0 && (exp)) { goto label; } } while (0)
-#define EINA_SAFETY_ON_FALSE_RETURN(exp) \
- do { (void)(!(exp)); } while (0)
+#define EINA_SAFETY_ON_FALSE_RETURN(exp) \
+ do { (void)(!(exp)); } while (0)
-#define EINA_SAFETY_ON_FALSE_RETURN_VAL(exp, val) \
- do { if (0 && !(exp)) (void)val; } while (0)
+#define EINA_SAFETY_ON_FALSE_RETURN_VAL(exp, val) \
+ do { if (0 && !(exp)) { (void)val; } } while (0)
-#define EINA_SAFETY_ON_FALSE_GOTO(exp, label) \
- do { if (0 && !(exp)) goto label; } while (0)
+#define EINA_SAFETY_ON_FALSE_GOTO(exp, label) \
+ do { if (0 && !(exp)) { goto label; } } while (0)
#endif /* safety checks macros */
#endif /* EINA_SAFETY_CHECKS_H_ */
*/
/* strlcpy implementation for libc's lacking it */
-EAPI size_t eina_strlcpy(char *dst, const char *src, size_t siz) EINA_ARG_NONNULL(1, 2);
-EAPI size_t eina_strlcat(char *dst, const char *src, size_t siz) EINA_ARG_NONNULL(1, 2);
-
-EAPI Eina_Bool eina_str_has_prefix(const char *str, const char *prefix) EINA_PURE EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_Bool eina_str_has_suffix(const char *str, const char *suffix) EINA_PURE EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_Bool eina_str_has_extension(const char *str, const char *ext) EINA_PURE EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
-
-EAPI char **eina_str_split(const char *string, const char *delimiter, int max_tokens) EINA_ARG_NONNULL(1, 2) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
-EAPI char **eina_str_split_full(const char *string, const char *delimiter, int max_tokens, unsigned int *elements) EINA_ARG_NONNULL(1, 2, 4) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
-
-EAPI size_t eina_str_join_len(char *dst, size_t size, char sep, const char *a, size_t a_len, const char *b, size_t b_len) EINA_ARG_NONNULL(1, 4, 6);
-
-EAPI char *eina_str_convert(const char *enc_from, const char *enc_to, const char *text) EINA_WARN_UNUSED_RESULT EINA_MALLOC EINA_ARG_NONNULL(1, 2, 3);
-
-EAPI char *eina_str_escape(const char *str) EINA_WARN_UNUSED_RESULT EINA_MALLOC EINA_ARG_NONNULL(1);
-
-EAPI void eina_str_tolower(char **str);
-EAPI void eina_str_toupper(char **str);
-
-static inline size_t eina_str_join(char *dst, size_t size, char sep, const char *a, const char *b) EINA_ARG_NONNULL(1, 4, 5);
+EAPI size_t
+ eina_strlcpy(char *dst,
+ const char *src,
+ size_t siz) EINA_ARG_NONNULL(1, 2);
+EAPI size_t
+ eina_strlcat(char *dst,
+ const char *src,
+ size_t siz) EINA_ARG_NONNULL(1, 2);
+
+EAPI Eina_Bool
+ eina_str_has_prefix(
+ const char *str,
+ const char *prefix) EINA_PURE EINA_ARG_NONNULL(1,
+ 2) EINA_WARN_UNUSED_RESULT;
+EAPI Eina_Bool
+ eina_str_has_suffix(
+ const char *str,
+ const char *suffix) EINA_PURE EINA_ARG_NONNULL(1,
+ 2) EINA_WARN_UNUSED_RESULT;
+EAPI Eina_Bool
+ eina_str_has_extension(
+ const char *str,
+ const char *ext) EINA_PURE EINA_ARG_NONNULL(1,
+ 2) EINA_WARN_UNUSED_RESULT;
+
+EAPI char **
+ eina_str_split(
+ const char *string,
+ const char *delimiter,
+ int max_tokens) EINA_ARG_NONNULL(1,
+ 2) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
+EAPI char **
+eina_str_split_full(
+ const char *string,
+ const char *delimiter,
+ int max_tokens,
+ unsigned int *elements) EINA_ARG_NONNULL(1, 2,
+ 4) EINA_MALLOC
+EINA_WARN_UNUSED_RESULT;
+
+EAPI size_t
+eina_str_join_len(char *dst,
+ size_t size,
+ char sep,
+ const char *a,
+ size_t a_len,
+ const char *b,
+ size_t b_len) EINA_ARG_NONNULL(1, 4, 6);
+
+EAPI char *
+eina_str_convert(
+ const char *enc_from,
+ const char *enc_to,
+ const char *text) EINA_WARN_UNUSED_RESULT EINA_MALLOC
+EINA_ARG_NONNULL(1, 2, 3);
+
+EAPI char *
+eina_str_escape(
+ const char *str) EINA_WARN_UNUSED_RESULT EINA_MALLOC
+EINA_ARG_NONNULL(
+ 1);
+
+EAPI void
+eina_str_tolower(
+ char **str);
+EAPI void
+eina_str_toupper(
+ char **str);
+
+static inline size_t
+eina_str_join(
+ char *dst,
+ size_t size,
+ char sep,
+ const char *a,
+ const char *b) EINA_ARG_NONNULL(1, 4, 5);
/**
* @brief Join two strings of known length.
* @see eina_str_join_len()
* @see eina_str_join_static()
*/
-static inline size_t eina_str_join(char *dst, size_t size, char sep, const char *a, const char *b)
+static inline size_t eina_str_join(char *dst,
+ size_t size,
+ char sep,
+ const char *a,
+ const char *b)
{
return eina_str_join_len(dst, size, sep, a, strlen(a), b, strlen(b));
}
* @see eina_str_join()
* @see eina_str_join_static()
*/
-#define eina_str_join_static(dst, sep, a, b) eina_str_join_len(dst, sizeof(dst), sep, a, (sizeof(a) > 0) ? sizeof(a) - 1 : 0, b, (sizeof(b) > 0) ? sizeof(b) - 1 : 0)
-
-static inline size_t eina_strlen_bounded(const char *str, size_t maxlen) EINA_PURE EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
+#define eina_str_join_static(dst, sep, a, b) eina_str_join_len( \
+ dst, \
+ sizeof(dst), \
+ sep, \
+ a, \
+ (sizeof(a) > \
+ 0) ? sizeof(a) \
+ - 1 : 0, \
+ b, \
+ (sizeof(b) > \
+ 0) ? sizeof(b) \
+ - 1 : 0)
+
+static inline size_t
+eina_strlen_bounded(
+ const char *str,
+ size_t maxlen) EINA_PURE EINA_WARN_UNUSED_RESULT
+EINA_ARG_NONNULL(1);
#include "eina_inline_str.x"
* @brief These functions provide string buffers management.
*
* The String Buffer data type is designed to be a mutable string,
- * allowing to append, prepend or insert a string to a buffer.
+ * allowing to append, prepend or insert a string to a buffer.
*
* @{
*/
* This function frees the memory of @p buf. @p buf must have been
* created by eina_strbuf_new().
*/
-EAPI void eina_strbuf_free(Eina_Strbuf *buf) EINA_ARG_NONNULL(1);
+EAPI void eina_strbuf_free(Eina_Strbuf *buf) EINA_ARG_NONNULL(1);
/**
* @brief Reset a string buffer.
*
* This function reset @p buf: the buffer len is set to 0, and the
* string is set to '\\0'. No memory is free'd.
*/
-EAPI void eina_strbuf_reset(Eina_Strbuf *buf) EINA_ARG_NONNULL(1);
+EAPI void eina_strbuf_reset(Eina_Strbuf *buf) EINA_ARG_NONNULL(1);
/**
* @brief Append a string to a buffer, reallocating as necessary.
* @see eina_strbuf_append()
* @see eina_strbuf_append_length()
*/
-EAPI Eina_Bool eina_strbuf_append(Eina_Strbuf *buf, const char *str) EINA_ARG_NONNULL(1, 2);
+EAPI Eina_Bool eina_strbuf_append(Eina_Strbuf *buf,
+ const char *str) EINA_ARG_NONNULL(1, 2);
/**
* @brief Append an escaped string to a buffer, reallocating as necessary.
*
* str can not be appended, #EINA_FALSE is returned, otherwise,
* #EINA_TRUE is returned.
*/
-EAPI Eina_Bool eina_strbuf_append_escaped(Eina_Strbuf *buf, const char *str) EINA_ARG_NONNULL(1, 2);
+EAPI Eina_Bool eina_strbuf_append_escaped(Eina_Strbuf *buf,
+ const char *str) EINA_ARG_NONNULL(
+ 1,
+ 2);
/**
* @brief Append a string to a buffer, reallocating as necessary,
* limited by the given length.
* @see eina_strbuf_append()
* @see eina_strbuf_append_length()
*/
-EAPI Eina_Bool eina_strbuf_append_n(Eina_Strbuf *buf, const char *str, size_t maxlen) EINA_ARG_NONNULL(1, 2);
+EAPI Eina_Bool eina_strbuf_append_n(Eina_Strbuf *buf,
+ const char *str,
+ size_t maxlen) EINA_ARG_NONNULL(1, 2);
/**
* @brief Append a string of exact length to a buffer, reallocating as necessary.
*
* @see eina_strbuf_append()
* @see eina_strbuf_append_n()
*/
-EAPI Eina_Bool eina_strbuf_append_length(Eina_Strbuf *buf, const char *str, size_t length) EINA_ARG_NONNULL(1, 2);
+EAPI Eina_Bool eina_strbuf_append_length(Eina_Strbuf *buf,
+ const char *str,
+ size_t length) EINA_ARG_NONNULL(1,
+ 2);
/**
* @brief Append a character to a string buffer, reallocating as
* necessary.
* This function inserts @p c to @p buf. If it can not insert it,
* #EINA_FALSE is returned, otherwise #EINA_TRUE is returned.
*/
-EAPI Eina_Bool eina_strbuf_append_char(Eina_Strbuf *buf, char c) EINA_ARG_NONNULL(1);
+EAPI Eina_Bool eina_strbuf_append_char(Eina_Strbuf *buf,
+ char c) EINA_ARG_NONNULL(1);
/**
* @brief Append a string to a buffer, reallocating as necessary.
*
*
* @see eina_strbuf_append()
*/
-EAPI Eina_Bool eina_strbuf_append_printf(Eina_Strbuf *buf, const char *fmt, ...) EINA_ARG_NONNULL(1, 2) EINA_PRINTF(2, 3);
+EAPI Eina_Bool eina_strbuf_append_printf(Eina_Strbuf *buf,
+ const char *fmt,
+ ...) EINA_ARG_NONNULL(1,
+ 2)
+EINA_PRINTF(2, 3);
/**
* @brief Append a string to a buffer, reallocating as necessary.
*
*
* @see eina_strbuf_append()
*/
-EAPI Eina_Bool eina_strbuf_append_vprintf(Eina_Strbuf *buf, const char *fmt, va_list args) EINA_ARG_NONNULL(1, 2);
+EAPI Eina_Bool eina_strbuf_append_vprintf(Eina_Strbuf *buf,
+ const char *fmt,
+ va_list args) EINA_ARG_NONNULL(1,
+ 2);
/**
* @brief Insert a string to a buffer, reallocating as necessary.
*
* consider using that variant. If @p buf can't insert it, #EINA_FALSE
* is returned, otherwise #EINA_TRUE is returned.
*/
-EAPI Eina_Bool eina_strbuf_insert(Eina_Strbuf *buf, const char *str, size_t pos) EINA_ARG_NONNULL(1, 2);
+EAPI Eina_Bool eina_strbuf_insert(Eina_Strbuf *buf,
+ const char *str,
+ size_t pos) EINA_ARG_NONNULL(1, 2);
/**
* @brief Insert an escaped string to a buffer, reallocating as
* necessary.
* position @p pos. If @p buf can't insert @p str, #EINA_FALSE is
* returned, otherwise #EINA_TRUE is returned.
*/
-EAPI Eina_Bool eina_strbuf_insert_escaped(Eina_Strbuf *buf, const char *str, size_t pos) EINA_ARG_NONNULL(1, 2);
+EAPI Eina_Bool eina_strbuf_insert_escaped(Eina_Strbuf *buf,
+ const char *str,
+ size_t pos) EINA_ARG_NONNULL(1, 2);
/**
* @brief Insert a string to a buffer, reallocating as necessary. Limited by maxlen.
*
* @p str). If @p str can not be inserted, #EINA_FALSE is returned,
* otherwise, #EINA_TRUE is returned.
*/
-EAPI Eina_Bool eina_strbuf_insert_n(Eina_Strbuf *buf, const char *str, size_t maxlen, size_t pos) EINA_ARG_NONNULL(1, 2);
+EAPI Eina_Bool eina_strbuf_insert_n(Eina_Strbuf *buf,
+ const char *str,
+ size_t maxlen,
+ size_t pos) EINA_ARG_NONNULL(1, 2);
/**
* @brief Insert a string of exact length to a buffer, reallocating as necessary.
*
* @see eina_strbuf_insert()
* @see eina_strbuf_insert_n()
*/
-EAPI Eina_Bool eina_strbuf_insert_length(Eina_Strbuf *buf, const char *str, size_t length, size_t pos) EINA_ARG_NONNULL(1, 2);
+EAPI Eina_Bool eina_strbuf_insert_length(Eina_Strbuf *buf,
+ const char *str,
+ size_t length,
+ size_t pos) EINA_ARG_NONNULL(1, 2);
/**
* @brief Insert a character to a string buffer, reallocating as
* necessary.
* can't append it, #EINA_FALSE is returned, otherwise #EINA_TRUE is
* returned.
*/
-EAPI Eina_Bool eina_strbuf_insert_char(Eina_Strbuf *buf, char c, size_t pos) EINA_ARG_NONNULL(1);
+EAPI Eina_Bool eina_strbuf_insert_char(Eina_Strbuf *buf, char c,
+ size_t pos) EINA_ARG_NONNULL(1);
/**
* @brief Insert a string to a buffer, reallocating as necessary.
*
* @param pos The position to insert the string.
* @return #EINA_TRUE on success, #EINA_FALSE on failure.
*/
-EAPI Eina_Bool eina_strbuf_insert_printf(Eina_Strbuf *buf, const char *fmt, size_t pos, ...) EINA_ARG_NONNULL(1, 2) EINA_PRINTF(2, 4);
+EAPI Eina_Bool eina_strbuf_insert_printf(Eina_Strbuf *buf,
+ const char *fmt,
+ size_t pos,
+ ...) EINA_ARG_NONNULL(1,
+ 2)
+EINA_PRINTF(2, 4);
/**
* @brief Insert a string to a buffer, reallocating as necessary.
*
* @param pos The position to insert the string.
* @return #EINA_TRUE on success, #EINA_FALSE on failure.
*/
-EAPI Eina_Bool eina_strbuf_insert_vprintf(Eina_Strbuf *buf, const char *fmt, size_t pos, va_list args) EINA_ARG_NONNULL(1, 2);
+EAPI Eina_Bool eina_strbuf_insert_vprintf(Eina_Strbuf *buf,
+ const char *fmt,
+ size_t pos,
+ va_list args) EINA_ARG_NONNULL(1,
+ 2);
/**
* @def eina_strbuf_prepend(buf, str)
* @p buf can't prepend it, #EINA_FALSE is returned, otherwise
* #EINA_TRUE is returned.
*/
-#define eina_strbuf_prepend_escaped(buf, str) eina_strbuf_insert_escaped(buf, str, 0)
+#define eina_strbuf_prepend_escaped(buf, str) eina_strbuf_insert_escaped(buf, \
+ str, \
+ 0)
/**
* @def eina_strbuf_prepend_n(buf, str)
* @p buf can't prepend it, #EINA_FALSE is returned, otherwise
* #EINA_TRUE is returned.
*/
-#define eina_strbuf_prepend_n(buf, str, maxlen) eina_strbuf_insert_n(buf, str, maxlen, 0)
+#define eina_strbuf_prepend_n(buf, str, maxlen) eina_strbuf_insert_n(buf, \
+ str, \
+ maxlen, \
+ 0)
/**
* @def eina_strbuf_prepend_length(buf, str)
* @p buf can't prepend it, #EINA_FALSE is returned, otherwise
* #EINA_TRUE is returned.
*/
-#define eina_strbuf_prepend_length(buf, str, length) eina_strbuf_insert_length(buf, str, length, 0)
+#define eina_strbuf_prepend_length(buf, str, length) eina_strbuf_insert_length( \
+ buf, \
+ str, \
+ length, \
+ 0)
/**
* @def eina_strbuf_prepend_char(buf, str)
* can't prepend it, #EINA_FALSE is returned, otherwise #EINA_TRUE is
* returned.
*/
-#define eina_strbuf_prepend_printf(buf, fmt, ...) eina_strbuf_insert_printf(buf, fmt, 0, ##__VA_ARGS__)
+#define eina_strbuf_prepend_printf(buf, fmt, ...) eina_strbuf_insert_printf( \
+ buf, \
+ fmt, \
+ 0, \
+ ## \
+ __VA_ARGS__)
/**
* @def eina_strbuf_prepend_vprintf(buf, fmt, args)
* can't prepend it, #EINA_FALSE is returned, otherwise #EINA_TRUE is
* returned.
*/
-#define eina_strbuf_prepend_vprintf(buf, fmt, args) eina_strbuf_insert_vprintf(buf, fmt, 0, args)
+#define eina_strbuf_prepend_vprintf(buf, fmt, args) eina_strbuf_insert_vprintf( \
+ buf, \
+ fmt, \
+ 0, \
+ args)
/**
* @brief Remove a slice of the given string buffer.
* in bytes. It returns #EINA_FALSE on failure, #EINA_TRUE otherwise.
*/
-EAPI Eina_Bool eina_strbuf_remove(Eina_Strbuf *buf, size_t start, size_t end) EINA_ARG_NONNULL(1);
+EAPI Eina_Bool
+eina_strbuf_remove(Eina_Strbuf *buf, size_t start, size_t end) EINA_ARG_NONNULL(
+ 1);
/**
* @brief Retrieve a pointer to the contents of a string buffer
*
*
* @see eina_strbuf_string_steal()
*/
-EAPI const char *eina_strbuf_string_get(const Eina_Strbuf *buf) EINA_ARG_NONNULL(1);
+EAPI const char *
+eina_strbuf_string_get(const Eina_Strbuf *buf) EINA_ARG_NONNULL(1);
/**
* @brief Steal the contents of a string buffer.
*
* This function returns the string contained in @p buf. @p buf is
* then initialized and does not own the returned string anymore. The
* caller must release the memory of the returned string by calling
- * free().
+ * free().
*
* @see eina_strbuf_string_get()
*/
-EAPI char *eina_strbuf_string_steal(Eina_Strbuf *buf) EINA_MALLOC EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
+EAPI char *
+eina_strbuf_string_steal(Eina_Strbuf *buf) EINA_MALLOC EINA_WARN_UNUSED_RESULT
+EINA_ARG_NONNULL(1);
/**
* @brief Free the contents of a string buffer but not the buffer.
*
* @param buf The string buffer to free the string of.
- *
+ *
* This function frees the string contained in @p buf without freeing
* @p buf.
*/
-EAPI void eina_strbuf_string_free(Eina_Strbuf *buf) EINA_ARG_NONNULL(1);
+EAPI void
+eina_strbuf_string_free(Eina_Strbuf *buf) EINA_ARG_NONNULL(1);
/**
* @brief Retrieve the length of the string buffer content.
*
*
* This function returns the length of @p buf.
*/
-EAPI size_t eina_strbuf_length_get(const Eina_Strbuf *buf) EINA_ARG_NONNULL(1);
-EAPI Eina_Bool eina_strbuf_replace(Eina_Strbuf *buf, const char *str, const char *with, unsigned int n) EINA_ARG_NONNULL(1, 2, 3);
+EAPI size_t
+eina_strbuf_length_get(const Eina_Strbuf *buf) EINA_ARG_NONNULL(1);
+EAPI Eina_Bool
+eina_strbuf_replace(Eina_Strbuf *buf,
+ const char *str,
+ const char *with,
+ unsigned int n) EINA_ARG_NONNULL(1, 2, 3);
/**
* @def eina_strbuf_replace_first(buf, str, with)
* equal to @c 1. If @p buf can't replace it, #EINA_FALSE is returned,
* otherwise #EINA_TRUE is returned.
*/
-#define eina_strbuf_replace_first(buf, str, with) eina_strbuf_replace(buf, str, with, 1)
+#define eina_strbuf_replace_first(buf, str, with) eina_strbuf_replace(buf, \
+ str, \
+ with, \
+ 1)
-EAPI int eina_strbuf_replace_all(Eina_Strbuf *buf, const char *str, const char *with) EINA_ARG_NONNULL(1, 2, 3);
+EAPI int
+eina_strbuf_replace_all(Eina_Strbuf *buf, const char *str,
+ const char *with) EINA_ARG_NONNULL(1, 2, 3);
/**
* @}
* @{
*/
-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_printf(const char *fmt, ...) EINA_WARN_UNUSED_RESULT;
-EAPI const char *eina_stringshare_vprintf(const char *fmt, va_list args) EINA_WARN_UNUSED_RESULT;
-EAPI const char *eina_stringshare_nprintf(unsigned int len, const char *fmt, ...) EINA_WARN_UNUSED_RESULT;
-EAPI const char *eina_stringshare_ref(const char *str);
-EAPI void eina_stringshare_del(const char *str);
-EAPI int eina_stringshare_strlen(const char *str) EINA_CONST EINA_WARN_UNUSED_RESULT;
-EAPI void eina_stringshare_dump(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_printf(const char *fmt,
+ ...) EINA_WARN_UNUSED_RESULT;
+EAPI const char * eina_stringshare_vprintf(const char *fmt,
+ va_list args)
+EINA_WARN_UNUSED_RESULT;
+EAPI const char * eina_stringshare_nprintf(unsigned int len,
+ const char *fmt,
+ ...) EINA_WARN_UNUSED_RESULT;
+EAPI const char * eina_stringshare_ref(const char *str);
+EAPI void eina_stringshare_del(const char *str);
+EAPI int eina_stringshare_strlen(const char *str) EINA_CONST
+EINA_WARN_UNUSED_RESULT;
+EAPI void eina_stringshare_dump(void);
-static inline Eina_Bool eina_stringshare_replace(const char **p_str, const char *news) EINA_ARG_NONNULL(1);
-static inline Eina_Bool eina_stringshare_replace_length(const char **p_str, const char *news, unsigned int slen) EINA_ARG_NONNULL(1);
+static inline Eina_Bool eina_stringshare_replace(const char **p_str,
+ const char *news)
+EINA_ARG_NONNULL(1);
+static inline Eina_Bool eina_stringshare_replace_length(const char **p_str,
+ const char *news,
+ unsigned int slen)
+EINA_ARG_NONNULL(1);
#include "eina_inline_stringshare.x"
*/
struct Eina_Tile_Grid_Info
{
- unsigned long col; /**< column of the tiler grid */
- unsigned long row; /**< row of the tiler grid*/
+ unsigned long col; /**< column of the tiler grid */
+ unsigned long row; /**< row of the tiler grid*/
Eina_Rectangle rect; /**< rectangle of the tiler grid*/
- Eina_Bool full; /**< whether the grid is full or not */
+ Eina_Bool full; /**< whether the grid is full or not */
};
typedef struct _Eina_Tile_Grid_Slicer Eina_Tile_Grid_Slicer;
-EAPI Eina_Tiler *eina_tiler_new(int w, int h);
-EAPI void eina_tiler_free(Eina_Tiler *t);
-EAPI void eina_tiler_tile_size_set(Eina_Tiler *t, int w, int h);
-EAPI Eina_Bool eina_tiler_rect_add(Eina_Tiler *t, const Eina_Rectangle *r);
-EAPI void eina_tiler_rect_del(Eina_Tiler *t, const Eina_Rectangle *r);
-EAPI void eina_tiler_clear(Eina_Tiler *t);
-EAPI Eina_Iterator * eina_tiler_iterator_new(const Eina_Tiler *t);
-EAPI Eina_Iterator * eina_tile_grid_slicer_iterator_new(int x, int y, int w, int h, int tile_w, int tile_h);
-static inline Eina_Bool eina_tile_grid_slicer_next(Eina_Tile_Grid_Slicer *slc, const Eina_Tile_Grid_Info **rect);
-static inline Eina_Bool eina_tile_grid_slicer_setup(Eina_Tile_Grid_Slicer *slc, int x, int y, int w, int h, int tile_w, int tile_h);
+EAPI Eina_Tiler * eina_tiler_new(int w, int h);
+EAPI void eina_tiler_free(Eina_Tiler *t);
+EAPI void eina_tiler_tile_size_set(Eina_Tiler *t, int w, int h);
+EAPI Eina_Bool eina_tiler_rect_add(Eina_Tiler *t,
+ const Eina_Rectangle *r);
+EAPI void eina_tiler_rect_del(Eina_Tiler *t,
+ const Eina_Rectangle *r);
+EAPI void eina_tiler_clear(Eina_Tiler *t);
+EAPI Eina_Iterator *eina_tiler_iterator_new(const Eina_Tiler *t);
+EAPI Eina_Iterator *eina_tile_grid_slicer_iterator_new(int x,
+ int y,
+ int w,
+ int h,
+ int tile_w,
+ int tile_h);
+static inline Eina_Bool eina_tile_grid_slicer_next(
+ Eina_Tile_Grid_Slicer *slc,
+ const Eina_Tile_Grid_Info **
+ rect);
+static inline Eina_Bool eina_tile_grid_slicer_setup(Eina_Tile_Grid_Slicer *slc,
+ int x,
+ int y,
+ int w,
+ int h,
+ int tile_w,
+ int tile_h);
#include "eina_inline_tiler.x"
Eina_Trash *next; /**< next item in trash. */
};
-static inline void eina_trash_init(Eina_Trash **trash) EINA_ARG_NONNULL(1);
-static inline void eina_trash_push(Eina_Trash **trash, void *data) EINA_ARG_NONNULL(1);
-static inline void *eina_trash_pop(Eina_Trash **trash) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
+static inline void eina_trash_init(Eina_Trash **trash) EINA_ARG_NONNULL(1);
+static inline void eina_trash_push(Eina_Trash **trash,
+ void *data) EINA_ARG_NONNULL(1);
+static inline void *eina_trash_pop(Eina_Trash **trash) EINA_ARG_NONNULL(1)
+EINA_WARN_UNUSED_RESULT;
/**
* @def EINA_TRASH_CLEAN
# define EINA_WARN_UNUSED_RESULT
# endif
-# if (!defined(EINA_SAFETY_CHECKS)) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3))
-# define EINA_ARG_NONNULL(idx, ...) __attribute__ ((nonnull(idx, ## __VA_ARGS__)))
+# if (!defined(EINA_SAFETY_CHECKS)) && (__GNUC__ > 3 || (__GNUC__ == 3 && \
+ __GNUC_MINOR__ >= 3))
+# define EINA_ARG_NONNULL(idx, \
+ ...) __attribute__ ((nonnull(idx, ## __VA_ARGS__)))
# else
# define EINA_ARG_NONNULL(idx, ...)
# endif
* if it is 'greater', 1 must be returned, and if they are equal, 0
* must be returned.
*/
-typedef int (*Eina_Compare_Cb) (const void *data1, const void *data2);
+typedef int (*Eina_Compare_Cb)(const void *data1, const void *data2);
/**
* @def EINA_COMPARE_CB
#define EINA_COMPARE_CB(function) ((Eina_Compare_Cb)function)
typedef Eina_Bool (*Eina_Each)(const void *container,
- void *data,
- void *fdata);
+ void *data,
+ void *fdata);
/**
* @def EINA_EACH
*/
#if EINA_SIZEOF_WCHAR_T >= 4
# include <wchar.h>
-typedef wchar_t Eina_Unicode;
+typedef wchar_t Eina_Unicode;
#elif defined(EINA_HAVE_INTTYPES_H)
# include <inttypes.h>
-typedef uint32_t Eina_Unicode;
+typedef uint32_t Eina_Unicode;
#elif defined(EINA_HAVE_STDINT_H)
# include <stdint.h>
-typedef uint32_t Eina_Unicode;
+typedef uint32_t Eina_Unicode;
#else
/* Hope that int is big enough */
-typedef unsigned int Eina_Unicode;
+typedef unsigned int Eina_Unicode;
#endif
#include <stdlib.h>
extern const Eina_Unicode *EINA_UNICODE_EMPTY_STRING;
EAPI size_t
-eina_unicode_strlen(const Eina_Unicode *ustr) EINA_ARG_NONNULL(1);
+ eina_unicode_strlen(
+ const Eina_Unicode *ustr) EINA_ARG_NONNULL(1);
EAPI Eina_Unicode *
-eina_unicode_strdup(const Eina_Unicode *text) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_MALLOC;
+ eina_unicode_strdup(
+ const Eina_Unicode *text) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1)
+EINA_MALLOC;
EAPI int
-eina_unicode_strcmp(const Eina_Unicode *a, const Eina_Unicode *b) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1, 2);
+ eina_unicode_strcmp(
+ const Eina_Unicode *a,
+ const Eina_Unicode *b) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1, 2);
EAPI Eina_Unicode *
-eina_unicode_strcpy(Eina_Unicode *dest, const Eina_Unicode *source);
+ eina_unicode_strcpy(
+ Eina_Unicode *dest,
+ const Eina_Unicode *source);
EAPI Eina_Unicode *
-eina_unicode_strstr(const Eina_Unicode *haystack, const Eina_Unicode *needle) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1, 2);
+ eina_unicode_strstr(
+ const Eina_Unicode *haystack,
+ const Eina_Unicode *needle) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1, 2);
EAPI Eina_Unicode *
-eina_unicode_strncpy(Eina_Unicode *dest, const Eina_Unicode *source, size_t n);
+ eina_unicode_strncpy(
+ Eina_Unicode *dest,
+ const Eina_Unicode *source,
+ size_t n);
EAPI Eina_Unicode *
-eina_unicode_escape(const Eina_Unicode *str);
+eina_unicode_escape(
+ const Eina_Unicode *str);
/**
* @}
* @brief These functions provide unicode string buffers management.
*
* The Unicode String Buffer data type is designed to be a mutable string,
- * allowing to append, prepend or insert a string to a buffer.
+ * allowing to append, prepend or insert a string to a buffer.
*
* @{
*/
* This function frees the memory of @p buf. @p buf must have been
* created by eina_ustrbuf_new().
*/
-EAPI void eina_ustrbuf_free(Eina_UStrbuf *buf) EINA_ARG_NONNULL(1);
+EAPI void eina_ustrbuf_free(Eina_UStrbuf *buf) EINA_ARG_NONNULL(1);
/**
* @brief Reset a string buffer.
*
* This function reset @p buf: the buffer len is set to 0, and the
* string is set to '\\0'. No memory is free'd.
*/
-EAPI void eina_ustrbuf_reset(Eina_UStrbuf *buf) EINA_ARG_NONNULL(1);
+EAPI void eina_ustrbuf_reset(Eina_UStrbuf *buf) EINA_ARG_NONNULL(1);
/**
* @brief Append a string to a buffer, reallocating as necessary.
* @see eina_ustrbuf_append()
* @see eina_ustrbuf_append_length()
*/
-EAPI Eina_Bool eina_ustrbuf_append(Eina_UStrbuf *buf, const Eina_Unicode *str) EINA_ARG_NONNULL(1, 2);
+EAPI Eina_Bool eina_ustrbuf_append(Eina_UStrbuf *buf,
+ const Eina_Unicode *str)
+EINA_ARG_NONNULL(1, 2);
/**
* @brief Append an escaped string to a buffer, reallocating as necessary.
*
* str can not be appended, #EINA_FALSE is returned, otherwise,
* #EINA_TRUE is returned.
*/
-EAPI Eina_Bool eina_ustrbuf_append_escaped(Eina_UStrbuf *buf, const Eina_Unicode *str) EINA_ARG_NONNULL(1, 2);
+EAPI Eina_Bool eina_ustrbuf_append_escaped(Eina_UStrbuf *buf,
+ const Eina_Unicode *str)
+EINA_ARG_NONNULL(1, 2);
/**
* @brief Append a string to a buffer, reallocating as necessary,
* limited by the given length.
* @see eina_ustrbuf_append()
* @see eina_ustrbuf_append_length()
*/
-EAPI Eina_Bool eina_ustrbuf_append_n(Eina_UStrbuf *buf, const Eina_Unicode *str, size_t maxlen) EINA_ARG_NONNULL(1, 2);
+EAPI Eina_Bool eina_ustrbuf_append_n(Eina_UStrbuf *buf,
+ const Eina_Unicode *str,
+ size_t maxlen) EINA_ARG_NONNULL(1, 2);
/**
* @brief Append a string of exact length to a buffer, reallocating as necessary.
*
* @see eina_ustrbuf_append()
* @see eina_ustrbuf_append_n()
*/
-EAPI Eina_Bool eina_ustrbuf_append_length(Eina_UStrbuf *buf, const Eina_Unicode *str, size_t length) EINA_ARG_NONNULL(1, 2);
+EAPI Eina_Bool eina_ustrbuf_append_length(Eina_UStrbuf *buf,
+ const Eina_Unicode *str,
+ size_t length) EINA_ARG_NONNULL(1,
+ 2);
/**
* @brief Append a character to a string buffer, reallocating as
* This function inserts @p c to @p buf. If it can not insert it,
* #EINA_FALSE is returned, otherwise #EINA_TRUE is returned.
*/
-EAPI Eina_Bool eina_ustrbuf_append_char(Eina_UStrbuf *buf, Eina_Unicode c) EINA_ARG_NONNULL(1);
+EAPI Eina_Bool eina_ustrbuf_append_char(Eina_UStrbuf *buf,
+ Eina_Unicode c) EINA_ARG_NONNULL(1);
/**
* @brief Insert a string to a buffer, reallocating as necessary.
* consider using that variant. If @p buf can't insert it, #EINA_FALSE
* is returned, otherwise #EINA_TRUE is returned.
*/
-EAPI Eina_Bool eina_ustrbuf_insert(Eina_UStrbuf *buf, const Eina_Unicode *str, size_t pos) EINA_ARG_NONNULL(1, 2);
+EAPI Eina_Bool eina_ustrbuf_insert(Eina_UStrbuf *buf,
+ const Eina_Unicode *str,
+ size_t pos) EINA_ARG_NONNULL(1, 2);
/**
* @brief Insert an escaped string to a buffer, reallocating as
* necessary.
* position @p pos. If @p buf can't insert @p str, #EINA_FALSE is
* returned, otherwise #EINA_TRUE is returned.
*/
-EAPI Eina_Bool eina_ustrbuf_insert_escaped(Eina_UStrbuf *buf, const Eina_Unicode *str, size_t pos) EINA_ARG_NONNULL(1, 2);
+EAPI Eina_Bool eina_ustrbuf_insert_escaped(Eina_UStrbuf *buf,
+ const Eina_Unicode *str,
+ size_t pos) EINA_ARG_NONNULL(1,
+ 2);
/**
* @brief Insert a string to a buffer, reallocating as necessary. Limited by maxlen.
*
* @p str). If @p str can not be inserted, #EINA_FALSE is returned,
* otherwise, #EINA_TRUE is returned.
*/
-EAPI Eina_Bool eina_ustrbuf_insert_n(Eina_UStrbuf *buf, const Eina_Unicode *str, size_t maxlen, size_t pos) EINA_ARG_NONNULL(1, 2);
+EAPI Eina_Bool eina_ustrbuf_insert_n(Eina_UStrbuf *buf,
+ const Eina_Unicode *str,
+ size_t maxlen,
+ size_t pos) EINA_ARG_NONNULL(1, 2);
/**
* @brief Insert a string of exact length to a buffer, reallocating as necessary.
*
* @see eina_ustrbuf_insert()
* @see eina_ustrbuf_insert_n()
*/
-EAPI Eina_Bool eina_ustrbuf_insert_length(Eina_UStrbuf *buf, const Eina_Unicode *str, size_t length, size_t pos) EINA_ARG_NONNULL(1, 2);
+EAPI Eina_Bool eina_ustrbuf_insert_length(Eina_UStrbuf *buf,
+ const Eina_Unicode *str,
+ size_t length,
+ size_t pos) EINA_ARG_NONNULL(1, 2);
/**
* @brief Insert a character to a string buffer, reallocating as
* necessary.
* can't append it, #EINA_FALSE is returned, otherwise #EINA_TRUE is
* returned.
*/
-EAPI Eina_Bool eina_ustrbuf_insert_char(Eina_UStrbuf *buf, Eina_Unicode c, size_t pos) EINA_ARG_NONNULL(1);
+EAPI Eina_Bool eina_ustrbuf_insert_char(Eina_UStrbuf *buf,
+ Eina_Unicode c,
+ size_t pos) EINA_ARG_NONNULL(1);
/**
* @def eina_ustrbuf_prepend(buf, str)
* @p buf can't prepend it, #EINA_FALSE is returned, otherwise
* #EINA_TRUE is returned.
*/
-#define eina_ustrbuf_prepend_escaped(buf, str) eina_ustrbuf_insert_escaped(buf, str, 0)
+#define eina_ustrbuf_prepend_escaped(buf, str) eina_ustrbuf_insert_escaped(buf, \
+ str, \
+ 0)
/**
* @def eina_ustrbuf_prepend_n(buf, str)
* @p buf can't prepend it, #EINA_FALSE is returned, otherwise
* #EINA_TRUE is returned.
*/
-#define eina_ustrbuf_prepend_n(buf, str, maxlen) eina_ustrbuf_insert_n(buf, str, maxlen, 0)
+#define eina_ustrbuf_prepend_n(buf, str, maxlen) eina_ustrbuf_insert_n(buf, \
+ str, \
+ maxlen, \
+ 0)
/**
* @def eina_ustrbuf_prepend_length(buf, str)
* @p buf can't prepend it, #EINA_FALSE is returned, otherwise
* #EINA_TRUE is returned.
*/
-#define eina_ustrbuf_prepend_length(buf, str, length) eina_ustrbuf_insert_length(buf, str, length, 0)
+#define eina_ustrbuf_prepend_length(buf, str, \
+ length) eina_ustrbuf_insert_length(buf, \
+ str, \
+ length, \
+ 0)
/**
* @def eina_ustrbuf_prepend_Eina_Unicode *(buf, str)
* @p buf can't prepend it, #EINA_FALSE is returned, otherwise
* #EINA_TRUE is returned.
*/
-#define eina_ustrbuf_prepend_Eina_Unicode *(buf, c) eina_ustrbuf_insert_Eina_Unicode *(buf, c, 0)
+#define eina_ustrbuf_prepend_Eina_Unicode *(buf, \
+ c)eina_ustrbuf_insert_Eina_Unicode \
+ * (buf, c, 0)
/**
* @def eina_ustrbuf_prepend_printf(buf, fmt, ...)
* can't prepend it, #EINA_FALSE is returned, otherwise #EINA_TRUE is
* returned.
*/
-#define eina_ustrbuf_prepend_printf(buf, fmt, ...) eina_ustrbuf_insert_printf(buf, fmt, 0, ##__VA_ARGS__)
+#define eina_ustrbuf_prepend_printf(buf, fmt, ...) eina_ustrbuf_insert_printf( \
+ buf, \
+ fmt, \
+ 0, \
+ ## __VA_ARGS__)
/**
* @def eina_ustrbuf_prepend_vprintf(buf, fmt, args)
* can't prepend it, #EINA_FALSE is returned, otherwise #EINA_TRUE is
* returned.
*/
-#define eina_ustrbuf_prepend_vprintf(buf, fmt, args) eina_ustrbuf_insert_vprintf(buf, fmt, 0, args)
+#define eina_ustrbuf_prepend_vprintf(buf, fmt, \
+ args) eina_ustrbuf_insert_vprintf(buf, \
+ fmt, \
+ 0, \
+ args)
/**
* @brief Remove a slice of the given string buffer.
* (inclusive) and ending at @p end (non-inclusive). Both values are
* in bytes. It returns #EINA_FALSE on failure, #EINA_TRUE otherwise.
*/
-EAPI Eina_Bool eina_ustrbuf_remove(Eina_UStrbuf *buf, size_t start, size_t end) EINA_ARG_NONNULL(1);
+EAPI Eina_Bool
+eina_ustrbuf_remove(Eina_UStrbuf *buf, size_t start,
+ size_t end) EINA_ARG_NONNULL(1);
/**
* @brief Retrieve a pointer to the contents of a string buffer
*
*
* @see eina_ustrbuf_string_steal()
*/
-EAPI const Eina_Unicode *eina_ustrbuf_string_get(const Eina_UStrbuf *buf) EINA_ARG_NONNULL(1);
+EAPI const Eina_Unicode *
+eina_ustrbuf_string_get(const Eina_UStrbuf *buf) EINA_ARG_NONNULL(1);
/**
* @brief Steal the contents of a string buffer.
*
* This function returns the string contained in @p buf. @p buf is
* then initialized and does not own the returned string anymore. The
* caller must release the memory of the returned string by calling
- * free().
+ * free().
*
* @see eina_ustrbuf_string_get()
*/
-EAPI Eina_Unicode *eina_ustrbuf_string_steal(Eina_UStrbuf *buf) EINA_MALLOC EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
+EAPI Eina_Unicode *
+eina_ustrbuf_string_steal(Eina_UStrbuf *buf) EINA_MALLOC
+EINA_WARN_UNUSED_RESULT
+EINA_ARG_NONNULL(1);
/**
* @brief Free the contents of a string buffer but not the buffer.
*
* @param buf The string buffer to free the string of.
- *
+ *
* This function frees the string contained in @p buf without freeing
* @p buf.
*/
-EAPI void eina_ustrbuf_string_free(Eina_UStrbuf *buf) EINA_ARG_NONNULL(1);
+EAPI void
+eina_ustrbuf_string_free(Eina_UStrbuf *buf) EINA_ARG_NONNULL(1);
/**
* @brief Retrieve the length of the string buffer content.
*
*
* This function returns the length of @p buf.
*/
-EAPI size_t eina_ustrbuf_length_get(const Eina_UStrbuf *buf) EINA_ARG_NONNULL(1);
+EAPI size_t
+eina_ustrbuf_length_get(const Eina_UStrbuf *buf) EINA_ARG_NONNULL(1);
/**
* @}
*/
* @{
*/
-EAPI const Eina_Unicode *eina_ustringshare_add_length(const Eina_Unicode *str, unsigned int slen) EINA_WARN_UNUSED_RESULT;
-EAPI const Eina_Unicode *eina_ustringshare_add(const Eina_Unicode *str) EINA_WARN_UNUSED_RESULT;
+EAPI const Eina_Unicode *eina_ustringshare_add_length(const Eina_Unicode *str,
+ unsigned int slen)
+EINA_WARN_UNUSED_RESULT;
+EAPI const Eina_Unicode *eina_ustringshare_add(const Eina_Unicode *str)
+EINA_WARN_UNUSED_RESULT;
EAPI const Eina_Unicode *eina_ustringshare_ref(const Eina_Unicode *str);
-EAPI void eina_ustringshare_del(const Eina_Unicode *str);
-EAPI int eina_ustringshare_strlen(const Eina_Unicode *str) EINA_CONST EINA_WARN_UNUSED_RESULT;
-EAPI void eina_ustringshare_dump(void);
+EAPI void eina_ustringshare_del(const Eina_Unicode *str);
+EAPI int eina_ustringshare_strlen(const Eina_Unicode *str)
+EINA_CONST EINA_WARN_UNUSED_RESULT;
+EAPI void eina_ustringshare_dump(void);
-static inline Eina_Bool eina_ustringshare_replace(const Eina_Unicode **p_str, const Eina_Unicode *news) EINA_ARG_NONNULL(1);
-static inline Eina_Bool eina_ustringshare_replace_length(const Eina_Unicode **p_str, const Eina_Unicode *news, unsigned int slen) EINA_ARG_NONNULL(1);
+static inline Eina_Bool eina_ustringshare_replace(const Eina_Unicode **p_str,
+ const Eina_Unicode *news)
+EINA_ARG_NONNULL(1);
+static inline Eina_Bool eina_ustringshare_replace_length(
+ const Eina_Unicode **p_str,
+ const Eina_Unicode *news,
+ unsigned int slen) EINA_ARG_NONNULL(1);
#include "eina_inline_ustringshare.x"
#include "eina_accessor.h"
/*============================================================================*
- * Local *
- *============================================================================*/
+* Local *
+*============================================================================*/
/**
* @cond LOCAL
static const char EINA_MAGIC_ACCESSOR_STR[] = "Eina Accessor";
-#define EINA_MAGIC_CHECK_ACCESSOR(d) \
- do { \
- if (!EINA_MAGIC_CHECK(d, EINA_MAGIC_ACCESSOR)) \
- EINA_MAGIC_FAIL(d, EINA_MAGIC_ACCESSOR); \
- } while(0)
+#define EINA_MAGIC_CHECK_ACCESSOR(d) \
+ do { \
+ if (!EINA_MAGIC_CHECK(d, EINA_MAGIC_ACCESSOR)) { \
+ EINA_MAGIC_FAIL(d, EINA_MAGIC_ACCESSOR); } \
+ } while(0)
/**
* @endcond
*/
/*============================================================================*
- * Global *
- *============================================================================*/
+* Global *
+*============================================================================*/
/**
* @internal
}
/*============================================================================*
- * API *
- *============================================================================*/
+* API *
+*============================================================================*/
/**
* @addtogroup Eina_Accessor_Group Accessor Functions
eina_accessor_container_get(Eina_Accessor *accessor)
{
EINA_MAGIC_CHECK_ACCESSOR(accessor);
- EINA_SAFETY_ON_NULL_RETURN_VAL(accessor, NULL);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(accessor, NULL);
EINA_SAFETY_ON_NULL_RETURN_VAL(accessor->get_container, NULL);
return accessor->get_container(accessor);
}
* #EINA_FALSE is returned, otherwise EINA_TRUE is returned.
*/
EAPI Eina_Bool
-eina_accessor_data_get(Eina_Accessor *accessor, unsigned int position, void **data)
+eina_accessor_data_get(Eina_Accessor *accessor,
+ unsigned int position,
+ void **data)
{
EINA_MAGIC_CHECK_ACCESSOR(accessor);
- EINA_SAFETY_ON_NULL_RETURN_VAL(accessor, EINA_FALSE);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(accessor, EINA_FALSE);
EINA_SAFETY_ON_NULL_RETURN_VAL(accessor->get_at, EINA_FALSE);
- EINA_SAFETY_ON_NULL_RETURN_VAL(data, EINA_FALSE);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(data, EINA_FALSE);
return accessor->get_at(accessor, position, data);
}
*/
EAPI void
eina_accessor_over(Eina_Accessor *accessor,
- Eina_Each cb,
- unsigned int start,
- unsigned int end,
- const void *fdata)
+ Eina_Each cb,
+ unsigned int start,
+ unsigned int end,
+ const void *fdata)
{
const void *container;
void *data;
EINA_SAFETY_ON_FALSE_RETURN(start < end);
container = accessor->get_container(accessor);
- for (i = start; i < end && accessor->get_at(accessor, i, &data) == EINA_TRUE; ++i)
- if (cb(container, data, (void*) fdata) != EINA_TRUE) return ;
+ for (i = start; i < end && accessor->get_at(accessor, i, &data) == EINA_TRUE;
+ ++i)
+ if (cb(container, data, (void *)fdata) != EINA_TRUE)
+ return;
+
}
/**
#include "eina_array.h"
/*============================================================================*
- * Local *
- *============================================================================*/
+* Local *
+*============================================================================*/
/**
* @cond LOCAL
static const char EINA_MAGIC_ARRAY_ITERATOR_STR[] = "Eina Array Iterator";
static const char EINA_MAGIC_ARRAY_ACCESSOR_STR[] = "Eina Array Accessor";
-#define EINA_MAGIC_CHECK_ARRAY(d) \
- do { \
- if (!EINA_MAGIC_CHECK(d, EINA_MAGIC_ARRAY)) \
- EINA_MAGIC_FAIL(d, EINA_MAGIC_ARRAY); \
- } while (0)
-
-#define EINA_MAGIC_CHECK_ARRAY_ITERATOR(d, ...) \
- do { \
- if (!EINA_MAGIC_CHECK(d, EINA_MAGIC_ARRAY_ITERATOR)) \
- { \
- EINA_MAGIC_FAIL(d, EINA_MAGIC_ARRAY_ITERATOR); \
- return __VA_ARGS__; \
- } \
- } while (0)
-
-#define EINA_MAGIC_CHECK_ARRAY_ACCESSOR(d, ...) \
- do { \
- if (!EINA_MAGIC_CHECK(d, EINA_MAGIC_ARRAY_ACCESSOR)) \
- { \
- EINA_MAGIC_FAIL(d, EINA_MAGIC_ACCESSOR); \
- return __VA_ARGS__; \
- } \
- } while (0)
+#define EINA_MAGIC_CHECK_ARRAY(d) \
+ do { \
+ if (!EINA_MAGIC_CHECK(d, EINA_MAGIC_ARRAY)) { \
+ EINA_MAGIC_FAIL(d, EINA_MAGIC_ARRAY); } \
+ } while (0)
+
+#define EINA_MAGIC_CHECK_ARRAY_ITERATOR(d, ...) \
+ do { \
+ if (!EINA_MAGIC_CHECK(d, EINA_MAGIC_ARRAY_ITERATOR)) \
+ { \
+ EINA_MAGIC_FAIL(d, EINA_MAGIC_ARRAY_ITERATOR); \
+ return __VA_ARGS__; \
+ } \
+ } while (0)
+
+#define EINA_MAGIC_CHECK_ARRAY_ACCESSOR(d, ...) \
+ do { \
+ if (!EINA_MAGIC_CHECK(d, EINA_MAGIC_ARRAY_ACCESSOR)) \
+ { \
+ EINA_MAGIC_FAIL(d, EINA_MAGIC_ACCESSOR); \
+ return __VA_ARGS__; \
+ } \
+ } while (0)
typedef struct _Eina_Iterator_Array Eina_Iterator_Array;
#endif
#define DBG(...) EINA_LOG_DOM_DBG(_eina_array_log_dom, __VA_ARGS__)
-static void eina_array_iterator_free(Eina_Iterator_Array *it) EINA_ARG_NONNULL(1);
-static Eina_Array *eina_array_iterator_get_container(Eina_Iterator_Array *it) EINA_ARG_NONNULL(1);
-static Eina_Bool eina_array_iterator_next(Eina_Iterator_Array *it, void **data) EINA_ARG_NONNULL(1);
-
-static Eina_Bool eina_array_accessor_get_at(Eina_Accessor_Array *it, unsigned int idx, void **data) EINA_ARG_NONNULL(1);
-static Eina_Array *eina_array_accessor_get_container(Eina_Accessor_Array *it) EINA_ARG_NONNULL(1);
-static void eina_array_accessor_free(Eina_Accessor_Array *it) EINA_ARG_NONNULL(1);
+static void eina_array_iterator_free(Eina_Iterator_Array *it)
+EINA_ARG_NONNULL(1);
+static Eina_Array *eina_array_iterator_get_container(Eina_Iterator_Array *it)
+EINA_ARG_NONNULL(1);
+static Eina_Bool eina_array_iterator_next(Eina_Iterator_Array *it,
+ void **data) EINA_ARG_NONNULL(1);
+
+static Eina_Bool eina_array_accessor_get_at(Eina_Accessor_Array *it,
+ unsigned int idx,
+ void **data) EINA_ARG_NONNULL(1);
+static Eina_Array *eina_array_accessor_get_container(Eina_Accessor_Array *it)
+EINA_ARG_NONNULL(1);
+static void eina_array_accessor_free(Eina_Accessor_Array *it)
+EINA_ARG_NONNULL(1);
static Eina_Bool
eina_array_iterator_next(Eina_Iterator_Array *it, void **data)
EINA_MAGIC_CHECK_ARRAY_ITERATOR(it, EINA_FALSE);
if (!(it->index < eina_array_count_get(it->array)))
- return EINA_FALSE;
+ return EINA_FALSE;
+
if (data)
- *data = eina_array_data_get(it->array, it->index);
+ *data = eina_array_data_get(it->array, it->index);
+
it->index++;
return EINA_TRUE;
}
eina_array_iterator_get_container(Eina_Iterator_Array *it)
{
EINA_MAGIC_CHECK_ARRAY_ITERATOR(it, NULL);
- return (Eina_Array *) it->array;
+ return (Eina_Array *)it->array;
}
static void
}
static Eina_Bool
-eina_array_accessor_get_at(Eina_Accessor_Array *it, unsigned int idx, void **data)
+eina_array_accessor_get_at(Eina_Accessor_Array *it,
+ unsigned int idx,
+ void **data)
{
EINA_MAGIC_CHECK_ARRAY_ACCESSOR(it, EINA_FALSE);
if (!(idx < eina_array_count_get(it->array)))
- return EINA_FALSE;
+ return EINA_FALSE;
+
if (data)
- *data = eina_array_data_get(it->array, idx);
+ *data = eina_array_data_get(it->array, idx);
+
return EINA_TRUE;
}
eina_array_accessor_get_container(Eina_Accessor_Array *it)
{
EINA_MAGIC_CHECK_ARRAY_ACCESSOR(it, NULL);
- return (Eina_Array *) it->array;
+ return (Eina_Array *)it->array;
}
static void
EINA_SAFETY_ON_NULL_RETURN_VAL(array, EINA_FALSE);
total = array->total + array->step;
- eina_error_set(0);
- tmp = realloc(array->data, sizeof (void*) * total);
- if (EINA_UNLIKELY(!tmp)) {
- eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
- return 0;
- }
+ eina_error_set(0);
+ tmp = realloc(array->data, sizeof (void *) * total);
+ if (EINA_UNLIKELY(!tmp))
+ {
+ eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+ return 0;
+ }
array->total = total;
array->data = tmp;
/*============================================================================*
- * Global *
- *============================================================================*/
+* Global *
+*============================================================================*/
/**
* @internal
Eina_Bool
eina_array_init(void)
{
- _eina_array_log_dom = eina_log_domain_register("eina_array", EINA_LOG_COLOR_DEFAULT);
+ _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");
- return EINA_FALSE;
+ EINA_LOG_ERR("Could not register log domain: eina_array");
+ return EINA_FALSE;
}
-#define EMS(n) eina_magic_string_static_set(n, n##_STR)
+#define EMS(n) eina_magic_string_static_set(n, n ## _STR)
EMS(EINA_MAGIC_ARRAY);
EMS(EINA_MAGIC_ARRAY_ITERATOR);
EMS(EINA_MAGIC_ARRAY_ACCESSOR);
}
/*============================================================================*
- * API *
- *============================================================================*/
+* API *
+*============================================================================*/
/**
* @addtogroup Eina_Array_Group Array
{
Eina_Array *array;
- eina_error_set(0);
+ eina_error_set(0);
array = malloc(sizeof (Eina_Array));
- if (!array) {
- eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
- return NULL;
- }
+ if (!array)
+ {
+ eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+ return NULL;
+ }
EINA_MAGIC_SET(array, EINA_MAGIC_ARRAY);
EAPI void
eina_array_step_set(Eina_Array *array, unsigned int step)
{
- EINA_SAFETY_ON_NULL_RETURN(array);
- array->data = NULL;
- array->total = 0;
- array->count = 0;
- array->step = step;
- EINA_MAGIC_SET(array, EINA_MAGIC_ARRAY);
- DBG("array=%p, step=%u", array, step);
+ EINA_SAFETY_ON_NULL_RETURN(array);
+ array->data = NULL;
+ array->total = 0;
+ array->count = 0;
+ array->step = step;
+ EINA_MAGIC_SET(array, EINA_MAGIC_ARRAY);
+ DBG("array=%p, step=%u", array, step);
}
/**
array->count = 0;
array->total = 0;
- if (!array->data) return;
+ if (!array->data)
+ return;
+
free(array->data);
array->data = NULL;
}
* and the error is set to #EINA_ERROR_OUT_OF_MEMORY.
*/
EAPI Eina_Bool
-eina_array_remove(Eina_Array *array, Eina_Bool (*keep)(void *data, void *gdata), void *gdata)
+eina_array_remove(Eina_Array *array, Eina_Bool (*keep)(void *data,
+ void *gdata),
+ void *gdata)
{
void **tmp;
/* WARNING:
EINA_MAGIC_CHECK_ARRAY(array);
EINA_SAFETY_ON_NULL_RETURN_VAL(array, EINA_FALSE);
- EINA_SAFETY_ON_NULL_RETURN_VAL(keep, EINA_FALSE);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(keep, EINA_FALSE);
DBG("array=%p, keep=%p, gdata=%p", array, keep, gdata);
- if (array->total == 0) return EINA_TRUE;
+ if (array->total == 0)
+ return EINA_TRUE;
for (i = 0; i < array->count; ++i)
{
- data = eina_array_data_get(array, i);
+ data = eina_array_data_get(array, i);
- if (keep(data, gdata) == EINA_FALSE) break;
+ if (keep(data, gdata) == EINA_FALSE)
+ break;
}
limit = i;
- if (i < array->count) ++i;
+ if (i < array->count)
+ ++i;
+
for (; i < array->count; ++i)
{
- data = eina_array_data_get(array, i);
+ data = eina_array_data_get(array, i);
- if (keep(data, gdata) == EINA_TRUE) break;
+ if (keep(data, gdata) == EINA_TRUE)
+ break;
}
/* Special case all objects that need to stay are at the beginning of the array. */
if (i == array->count)
{
- array->count = limit;
- if (array->count == 0)
- {
- free(array->data);
- array->total = 0;
- array->data = NULL;
- }
-
- return EINA_TRUE;
+ array->count = limit;
+ if (array->count == 0)
+ {
+ free(array->data);
+ array->total = 0;
+ array->data = NULL;
+ }
+
+ return EINA_TRUE;
}
- eina_error_set(0);
- tmp = malloc(sizeof (void*) * array->total);
- if (!tmp) {
- eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
- return EINA_FALSE;
- }
+ eina_error_set(0);
+ tmp = malloc(sizeof (void *) * array->total);
+ if (!tmp)
+ {
+ eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+ return EINA_FALSE;
+ }
- memcpy(tmp, array->data, limit * sizeof(void*));
+ memcpy(tmp, array->data, limit * sizeof(void *));
total = limit;
if (i < array->count)
{
- tmp[total] = data;
- total++;
- ++i;
+ tmp[total] = data;
+ total++;
+ ++i;
}
for (; i < array->count; ++i)
{
- data = eina_array_data_get(array, i);
+ data = eina_array_data_get(array, i);
- if (keep(data, gdata))
- {
- tmp[total] = data;
- total++;
- }
+ if (keep(data, gdata))
+ {
+ tmp[total] = data;
+ total++;
+ }
}
free(array->data);
EINA_MAGIC_CHECK_ARRAY(array);
EINA_SAFETY_ON_NULL_RETURN_VAL(array, NULL);
- eina_error_set(0);
+ eina_error_set(0);
it = calloc(1, sizeof (Eina_Iterator_Array));
- if (!it) {
- eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
- return NULL;
- }
+ if (!it)
+ {
+ eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+ return NULL;
+ }
- EINA_MAGIC_SET(it, EINA_MAGIC_ARRAY_ITERATOR);
+ EINA_MAGIC_SET(it, EINA_MAGIC_ARRAY_ITERATOR);
EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_ITERATOR);
it->array = array;
it->iterator.next = FUNC_ITERATOR_NEXT(eina_array_iterator_next);
- it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(eina_array_iterator_get_container);
+ it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(
+ eina_array_iterator_get_container);
it->iterator.free = FUNC_ITERATOR_FREE(eina_array_iterator_free);
DBG("array=%p, iterator=%p", array, it);
EINA_MAGIC_CHECK_ARRAY(array);
EINA_SAFETY_ON_NULL_RETURN_VAL(array, NULL);
- eina_error_set(0);
+ eina_error_set(0);
it = calloc(1, sizeof (Eina_Accessor_Array));
- if (!it) {
- eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
- return NULL;
- }
+ if (!it)
+ {
+ eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+ return NULL;
+ }
- EINA_MAGIC_SET(it, EINA_MAGIC_ARRAY_ACCESSOR);
+ EINA_MAGIC_SET(it, EINA_MAGIC_ARRAY_ACCESSOR);
EINA_MAGIC_SET(&it->accessor, EINA_MAGIC_ACCESSOR);
it->array = array;
it->accessor.get_at = FUNC_ACCESSOR_GET_AT(eina_array_accessor_get_at);
- it->accessor.get_container = FUNC_ACCESSOR_GET_CONTAINER(eina_array_accessor_get_container);
+ it->accessor.get_container = FUNC_ACCESSOR_GET_CONTAINER(
+ eina_array_accessor_get_container);
it->accessor.free = FUNC_ACCESSOR_FREE(eina_array_accessor_free);
DBG("array=%p, accessor=%p", array, it);
*
* @li Create a new bechmark
* @li Write the functions that wraps the the functions you want to
- * bechmark.
+ * bechmark.
* @li Register these wrappers functions.
* @li Run the benchmark.
* @li Free the memory.
* eina_shutdown();
*
* return EXIT_SUCCESS;
- *
+ *
* shutdown_eina:
* eina_shutdown();
*
* test = eina_benchmark_new(benchmarks[i].bench_case, "Benchmark example");
* if (!test)
* continue;
- *
+ *
* benchmarks[i].build(test);
*
* ea = eina_benchmark_run(test);
#include "eina_counter.h"
/*============================================================================*
- * Local *
- *============================================================================*/
+* Local *
+*============================================================================*/
/**
* @cond LOCAL
*/
/*============================================================================*
- * Global *
- *============================================================================*/
+* Global *
+*============================================================================*/
/**
* @internal
Eina_Bool
eina_benchmark_init(void)
{
- _eina_benchmark_log_dom = eina_log_domain_register("eina_benchmark", EINA_LOG_COLOR_DEFAULT);
+ _eina_benchmark_log_dom = eina_log_domain_register("eina_benchmark",
+ EINA_LOG_COLOR_DEFAULT);
if (_eina_benchmark_log_dom < 0)
{
- EINA_LOG_ERR("Could not register log domain: eina_benchmark");
- return EINA_FALSE;
+ EINA_LOG_ERR("Could not register log domain: eina_benchmark");
+ return EINA_FALSE;
}
return EINA_TRUE;
}
/*============================================================================*
- * API *
- *============================================================================*/
+* API *
+*============================================================================*/
/**
* @addtogroup Eina_Benchmark_Group Benchmark
{
Eina_Benchmark *new;
- eina_error_set(0);
+ eina_error_set(0);
new = calloc(1, sizeof (Eina_Benchmark));
if (!new)
{
- eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
- return NULL;
+ eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+ return NULL;
}
new->name = name;
{
Eina_Array *names;
- if (!bench) return ;
+ if (!bench)
+ return;
while (bench->runs)
{
- Eina_Run *run = (Eina_Run *) bench->runs;
+ Eina_Run *run = (Eina_Run *)bench->runs;
- bench->runs = eina_inlist_remove(bench->runs, bench->runs);
- free(run);
+ bench->runs = eina_inlist_remove(bench->runs, bench->runs);
+ free(run);
}
EINA_LIST_FREE(bench->names, names)
- {
- Eina_Array_Iterator it;
- char *tmp;
- unsigned int i;
+ {
+ Eina_Array_Iterator it;
+ char *tmp;
+ unsigned int i;
- EINA_ARRAY_ITER_NEXT(names, i, tmp, it)
- free(tmp);
+ EINA_ARRAY_ITER_NEXT(names, i, tmp, it)
+ free(tmp);
- eina_array_free(names);
- }
+ eina_array_free(names);
+ }
free(bench);
}
* to #EINA_ERROR_OUT_OF_MEMORY.
*/
EAPI Eina_Bool
-eina_benchmark_register(Eina_Benchmark *bench, const char *name, Eina_Benchmark_Specimens bench_cb,
- int count_start, int count_end, int count_step)
+eina_benchmark_register(Eina_Benchmark *bench,
+ const char *name,
+ Eina_Benchmark_Specimens bench_cb,
+ int count_start,
+ int count_end,
+ int count_step)
{
Eina_Run *run;
- if (!bench) return EINA_FALSE;
- if (count_step == 0) return EINA_FALSE;
+ if (!bench)
+ return EINA_FALSE;
- eina_error_set(0);
+ if (count_step == 0)
+ return EINA_FALSE;
+
+ eina_error_set(0);
run = calloc(1, sizeof (Eina_Run));
if (!run)
{
- eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
- return EINA_FALSE;
+ eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+ return EINA_FALSE;
}
run->cb = bench_cb;
Eina_Bool first = EINA_FALSE;
size_t length;
- if (!bench) return NULL;
+ if (!bench)
+ return NULL;
- length = strlen(EINA_BENCHMARK_FILENAME_MASK) + strlen(bench->name) + strlen(bench->run);
+ length = strlen(EINA_BENCHMARK_FILENAME_MASK) + strlen(bench->name) + strlen(
+ bench->run);
buffer = alloca(sizeof (char) * length);
- if (!buffer) return NULL;
+ if (!buffer)
+ return NULL;
- snprintf(buffer, length, EINA_BENCHMARK_FILENAME_MASK, bench->name, bench->run);
+ snprintf(buffer,
+ length,
+ EINA_BENCHMARK_FILENAME_MASK,
+ bench->name,
+ bench->run);
main_script = fopen(buffer, "w");
- if (!main_script) return NULL;
+ if (!main_script)
+ return NULL;
ea = eina_array_new(16);
if (!ea)
{
- fclose(main_script);
- return NULL;
+ fclose(main_script);
+ return NULL;
}
eina_array_push(ea, strdup(buffer));
- fprintf(main_script,
- "set autoscale # scale axes automatically\n"
- "unset log # remove any log-scaling\n"
- "unset label # remove any previous labels\n"
- "set xtic auto # set xtics automatically\n"
- "set ytic auto # set ytics automatically\n"
-/* "set logscale y\n" */
- "set terminal png size 1024,768\n"
- "set output \"output_%s_%s.png\"\n"
- "set title \"%s %s\n"
- "set xlabel \"tests\"\n"
- "set ylabel \"time\"\n"
- "plot ", bench->name, bench->run, bench->name, bench->run);
+ fprintf(
+ main_script,
+ "set autoscale # scale axes automatically\n"
+ "unset log # remove any log-scaling\n"
+ "unset label # remove any previous labels\n"
+ "set xtic auto # set xtics automatically\n"
+ "set ytic auto # set ytics automatically\n"
+/* "set logscale y\n" */
+ "set terminal png size 1024,768\n"
+ "set output \"output_%s_%s.png\"\n"
+ "set title \"%s %s\n"
+ "set xlabel \"tests\"\n"
+ "set ylabel \"time\"\n"
+ "plot ",
+ bench->name,
+ bench->run,
+ bench->name,
+ bench->run);
EINA_INLIST_FOREACH(bench->runs, run)
- {
- Eina_Counter *counter;
- char *result;
- size_t tmp;
- int i;
+ {
+ Eina_Counter *counter;
+ char *result;
+ size_t tmp;
+ int i;
- tmp = strlen(EINA_BENCHMARK_DATA_MASK) + strlen(bench->name) + strlen(bench->run) + strlen(run->name);
- if (tmp > length)
- {
- buffer = alloca(sizeof (char) * tmp);
- length = tmp;
- }
+ tmp = strlen(EINA_BENCHMARK_DATA_MASK) + strlen(bench->name) + strlen(
+ bench->run) + strlen(run->name);
+ if (tmp > length)
+ {
+ buffer = alloca(sizeof (char) * tmp);
+ length = tmp;
+ }
- snprintf(buffer, length, EINA_BENCHMARK_DATA_MASK, bench->name, bench->run, run->name);
+ snprintf(buffer,
+ length,
+ EINA_BENCHMARK_DATA_MASK,
+ bench->name,
+ bench->run,
+ run->name);
- current_data = fopen(buffer, "w");
- if (!current_data) continue ;
+ current_data = fopen(buffer, "w");
+ if (!current_data)
+ continue;
- eina_array_push(ea, strdup(buffer));
+ eina_array_push(ea, strdup(buffer));
- counter = eina_counter_new(run->name);
+ counter = eina_counter_new(run->name);
- for (i = run->start; i < run->end; i += run->step)
- {
- fprintf(stderr, "Run %s: %i\n", run->name, i);
- eina_counter_start(counter);
+ for (i = run->start; i < run->end; i += run->step)
+ {
+ fprintf(stderr, "Run %s: %i\n", run->name, i);
+ eina_counter_start(counter);
- run->cb(i);
+ run->cb(i);
- eina_counter_stop(counter, i);
- }
+ eina_counter_stop(counter, i);
+ }
- result = eina_counter_dump(counter);
- if (result)
- {
- fprintf(current_data, "%s", result);
- free(result);
- }
+ result = eina_counter_dump(counter);
+ if (result)
+ {
+ fprintf(current_data, "%s", result);
+ free(result);
+ }
- eina_counter_free(counter);
+ eina_counter_free(counter);
- fclose(current_data);
+ fclose(current_data);
- if (first == EINA_FALSE) first = EINA_TRUE;
- else fprintf(main_script, ", \\\n");
+ if (first == EINA_FALSE)
+ first = EINA_TRUE;
+ else
+ fprintf(main_script, ", \\\n");
- fprintf(main_script,
- "\"%s\" using 1:2 title \'%s\' with line",
- buffer, run->name);
- }
+ fprintf(main_script,
+ "\"%s\" using 1:2 title \'%s\' with line",
+ buffer, run->name);
+ }
- fprintf(main_script, "\n");
+ fprintf(main_script, "\n");
- fclose(main_script);
+ fclose(main_script);
bench->names = eina_list_append(bench->names, ea);
* if not, see <http://www.gnu.org/licenses/>.
*/
- /**
+/**
* @page tutorial_binshare_page Binary Share Tutorial
*
* Should call eina_binshare_init() before usage and eina_binshare_shutdown() after.
static const char EINA_MAGIC_BINSHARE_NODE_STR[] = "Eina Binshare Node";
/*============================================================================*
- * Global *
- *============================================================================*/
+* Global *
+*============================================================================*/
/**
* @internal
EAPI Eina_Bool
eina_binshare_init(void)
{
- return eina_share_common_init(&binshare_share, EINA_MAGIC_BINSHARE_NODE, EINA_MAGIC_BINSHARE_NODE_STR);
+ return eina_share_common_init(&binshare_share,
+ EINA_MAGIC_BINSHARE_NODE,
+ EINA_MAGIC_BINSHARE_NODE_STR);
}
/**
}
/*============================================================================*
- * API *
- *============================================================================*/
+* API *
+*============================================================================*/
/**
* @addtogroup Eina_Binshare_Group Binary Share
*
{
if (!str)
return;
- eina_share_common_del(binshare_share,(const char *) str);
+
+ eina_share_common_del(binshare_share,(const char *)str);
}
/**
EAPI const char *
eina_binshare_add_length(const char *str, unsigned int slen)
{
- return (const char *) eina_share_common_add_length(binshare_share,(const char *) str, (slen) * sizeof(char), 0);
+ return (const char *)eina_share_common_add_length(binshare_share,
+ (const char *)str,
+ (slen) * sizeof(char),
+ 0);
}
/**
EAPI const char *
eina_binshare_ref(const char *str)
{
- return (const char *) eina_share_common_ref(binshare_share, (const char *) str);
+ return (const char *)eina_share_common_ref(binshare_share, (const char *)str);
}
/**
EAPI int
eina_binshare_length(const char *str)
{
- return eina_share_common_length(binshare_share, (const char *) str);
+ return eina_share_common_length(binshare_share, (const char *)str);
}
/**
#include "eina_fp.h"
/*============================================================================*
- * Local *
- *============================================================================*/
+* Local *
+*============================================================================*/
/**
* @cond LOCAL
*/
static const char look_up_table[] = {'0', '1', '2', '3', '4',
- '5', '6', '7', '8', '9',
- 'a', 'b', 'c', 'd', 'e', 'f'};
+ '5', '6', '7', '8', '9',
+ 'a', 'b', 'c', 'd', 'e', 'f'};
static int _eina_convert_log_dom = -1;
#ifdef ERR
for (i = 0, j = length - 1; i < j; i++, j--)
{
- c = s[i];
- s[i] = s[j];
- s[j] = c;
+ c = s[i];
+ s[i] = s[j];
+ s[j] = c;
}
}
*/
/*============================================================================*
- * Global *
- *============================================================================*/
+* Global *
+*============================================================================*/
/**
* @cond LOCAL
EAPI Eina_Error EINA_ERROR_CONVERT_0X_NOT_FOUND = 0;
EAPI Eina_Error EINA_ERROR_CONVERT_OUTRUN_STRING_LENGTH = 0;
-static const char EINA_ERROR_CONVERT_0X_NOT_FOUND_STR[] = "Error during string convertion to float, First '0x' was not found.";
-static const char EINA_ERROR_CONVERT_P_NOT_FOUND_STR[] = "Error during string convertion to float, First 'p' was not found.";
-static const char EINA_ERROR_CONVERT_OUTRUN_STRING_LENGTH_STR[] = "Error outrun string limit during convertion string convertion to float.";
+static const char EINA_ERROR_CONVERT_0X_NOT_FOUND_STR[] =
+ "Error during string convertion to float, First '0x' was not found.";
+static const char EINA_ERROR_CONVERT_P_NOT_FOUND_STR[] =
+ "Error during string convertion to float, First 'p' was not found.";
+static const char EINA_ERROR_CONVERT_OUTRUN_STRING_LENGTH_STR[] =
+ "Error outrun string limit during convertion string convertion to float.";
/**
* @endcond
Eina_Bool
eina_convert_init(void)
{
- _eina_convert_log_dom = eina_log_domain_register("eina_convert", EINA_LOG_COLOR_DEFAULT);
+ _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");
- return EINA_FALSE;
+ EINA_LOG_ERR("Could not register log domain: eina_convert");
+ return EINA_FALSE;
}
-#define EEMR(n) n = eina_error_msg_static_register(n##_STR)
+#define EEMR(n) n = eina_error_msg_static_register(n ## _STR)
EEMR(EINA_ERROR_CONVERT_0X_NOT_FOUND);
EEMR(EINA_ERROR_CONVERT_P_NOT_FOUND);
EEMR(EINA_ERROR_CONVERT_OUTRUN_STRING_LENGTH);
}
/*============================================================================*
- * API *
- *============================================================================*/
+* API *
+*============================================================================*/
/**
* @addtogroup Eina_Convert_Group Convert
if (n < 0)
{
- n = -n;
- *s++ = '-';
- r = 1;
+ n = -n;
+ *s++ = '-';
+ r = 1;
}
do {
- s[i++] = n % 10 + '0';
- } while ((n /= 10) > 0);
+ s[i++] = n % 10 + '0';
+ } while ((n /= 10) > 0);
s[i] = '\0';
i = 0;
do {
- s[i++] = look_up_table[n & 0xF];
- } while ((n >>= 4) > 0);
+ s[i++] = look_up_table[n & 0xF];
+ } while ((n >>= 4) > 0);
s[i] = '\0';
eina_convert_atod(const char *src, int length, long long *m, long *e)
{
const char *str = src;
- long long mantisse;
- long exponent;
- int nbr_decimals = 0;
- int sign = 1;
+ long long mantisse;
+ long exponent;
+ int nbr_decimals = 0;
+ int sign = 1;
EINA_SAFETY_ON_NULL_RETURN_VAL(src, EINA_FALSE);
- EINA_SAFETY_ON_NULL_RETURN_VAL(m, EINA_FALSE);
- EINA_SAFETY_ON_NULL_RETURN_VAL(e, EINA_FALSE);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(m, EINA_FALSE);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(e, EINA_FALSE);
- if (length <= 0) goto on_length_error;
+ if (length <= 0)
+ goto on_length_error;
/* Compute the mantisse. */
if (*str == '-')
{
sign = -1;
str++;
- length--;
+ length--;
}
- if (length <= 2) goto on_length_error;
+ if (length <= 2)
+ goto on_length_error;
if (strncmp(str, "0x", 2))
{
- eina_error_set(EINA_ERROR_CONVERT_0X_NOT_FOUND);
- DBG("'0x' not found in '%s'", src);
+ eina_error_set(EINA_ERROR_CONVERT_0X_NOT_FOUND);
+ DBG("'0x' not found in '%s'", src);
return EINA_FALSE;
}
mantisse = HEXA_TO_INT(*str);
str++;
- length--; if (length <= 0) goto on_length_error;
+ length--; if (length <= 0)
+ goto on_length_error;
if (*str == '.')
- {
- for (str++, length--;
- length > 0 && *str != 'p';
- ++str, --length, ++nbr_decimals)
- {
- mantisse <<= 4;
- mantisse += HEXA_TO_INT(*str);
- }
- }
- if (sign < 0) mantisse = -mantisse;
+ for (str++, length--;
+ length > 0 && *str != 'p';
+ ++str, --length, ++nbr_decimals)
+ {
+ mantisse <<= 4;
+ mantisse += HEXA_TO_INT(*str);
+ }
+
+ if (sign < 0)
+ mantisse = -mantisse;
/* Compute the exponent. */
if (*str != 'p')
{
- eina_error_set(EINA_ERROR_CONVERT_P_NOT_FOUND);
- DBG("'p' not found in '%s'", src);
+ eina_error_set(EINA_ERROR_CONVERT_P_NOT_FOUND);
+ DBG("'p' not found in '%s'", src);
return EINA_FALSE;
}
+
sign = +1;
str++;
- length--; if (length <= 0) goto on_length_error;
+ length--; if (length <= 0)
+ goto on_length_error;
if (strchr("-+", *str))
{
- sign = (*str == '-') ? -1 : +1;
+ sign = (*str == '-') ? -1 : +1;
str++; length--;
}
exponent += *str - '0';
}
- if (length < 0) goto on_length_error;
+ if (length < 0)
+ goto on_length_error;
if (sign < 0)
- exponent = -exponent;
+ exponent = -exponent;
*m = mantisse;
*e = exponent - (nbr_decimals << 2);
return EINA_TRUE;
- on_length_error:
+on_length_error:
eina_error_set(EINA_ERROR_CONVERT_OUTRUN_STRING_LENGTH);
return EINA_FALSE;
}
{
*(des++) = '-';
d = -d;
- length++;
+ length++;
}
d = frexp(d, &p);
while (*(des - 1) == '0')
{
- des--;
- length--;
+ des--;
+ length--;
}
if (*(des - 1) == '.')
{
- des--;
- length--;
+ des--;
+ length--;
}
*(des++) = 'p';
p = -p;
}
else
- *(des++) = '+';
+ *(des++) = '+';
+
length += 2;
return length + eina_convert_itoa(p, des);
if (fp == 0)
{
- memcpy(des, "0x0p+0", 7);
- return 7;
+ memcpy(des, "0x0p+0", 7);
+ return 7;
}
if (fp < 0)
{
*(des++) = '-';
fp = -fp;
- length++;
+ length++;
}
/* fp >= 1 */
if (fp >= 0x0000000100000000LL)
- {
- while (fp >= 0x0000000100000000LL)
- {
- p++;
- /* fp /= 2 */
- fp >>= 1;
- }
- }
- /* fp < 0.5 */
+ while (fp >= 0x0000000100000000LL)
+ {
+ p++;
+ /* fp /= 2 */
+ fp >>= 1;
+ }
+ /* fp < 0.5 */
else if (fp < 0x80000000)
- {
- while (fp < 0x80000000)
- {
- p--;
- /* fp *= 2 */
- fp <<= 1;
- }
- }
+ while (fp < 0x80000000)
+ {
+ p--;
+ /* fp *= 2 */
+ fp <<= 1;
+ }
if (p)
{
p--;
- /* fp *= 2 */
+ /* fp *= 2 */
fp <<= 1;
}
while (*(des - 1) == '0')
{
- des--;
- length--;
+ des--;
+ length--;
}
if (*(des - 1) == '.')
{
- des--;
- length--;
+ des--;
+ length--;
}
*(des++) = 'p';
p = -p;
}
else
- *(des++) = '+';
+ *(des++) = '+';
+
length += 2;
return length + eina_convert_itoa(p, des);
long e;
if (!eina_convert_atod(src, length, &m, &e))
- return EINA_FALSE;
+ return EINA_FALSE;
- if (!fp) return EINA_TRUE;
+ if (!fp)
+ return EINA_TRUE;
e += 32;
- if (e > 0) *fp = m << e;
- else *fp = m >> -e;
+ if (e > 0)
+ *fp = m << e;
+ else
+ *fp = m >> -e;
return EINA_TRUE;
}
#include "eina_counter.h"
/*============================================================================*
- * Local *
- *============================================================================*/
+* Local *
+*============================================================================*/
/**
* @cond LOCAL
# endif
}
#else
-static const char EINA_ERROR_COUNTER_WINDOWS_STR[] = "Change your OS, you moron !";
+static const char EINA_ERROR_COUNTER_WINDOWS_STR[] =
+ "Change your OS, you moron !";
static int EINA_ERROR_COUNTER_WINDOWS = 0;
static LARGE_INTEGER _eina_counter_frequency;
va_list ap;
tmp = realloc(base, sizeof (char) * (*position + size));
- if (!tmp) return base;
+ if (!tmp)
+ return base;
+
result = tmp;
while (1)
{
- va_start(ap, format);
- n = vsnprintf(result + *position, size, format, ap);
- va_end(ap);
-
- if (n > -1 && n < size)
- {
- /* If we always have glibc > 2.2, we could just return *position += n. */
- *position += strlen(result + *position);
- return result;
- }
-
- if (n > -1) size = n + 1;
- else size <<= 1;
-
- tmp = realloc(result, sizeof (char) * (*position + size));
- if (!tmp) return result;
- result = tmp;
+ va_start(ap, format);
+ n = vsnprintf(result + *position, size, format, ap);
+ va_end(ap);
+
+ if (n > -1 && n < size)
+ {
+ /* If we always have glibc > 2.2, we could just return *position += n. */
+ *position += strlen(result + *position);
+ return result;
+ }
+
+ if (n > -1)
+ size = n + 1;
+ else
+ size <<= 1;
+
+ tmp = realloc(result, sizeof (char) * (*position + size));
+ if (!tmp)
+ return result;
+
+ result = tmp;
}
}
*/
/*============================================================================*
- * Global *
- *============================================================================*/
+* Global *
+*============================================================================*/
/**
* @internal
eina_counter_init(void)
{
#ifdef _WIN32
- EINA_ERROR_COUNTER_WINDOWS = eina_error_msg_static_register(EINA_ERROR_COUNTER_WINDOWS_STR);
+ EINA_ERROR_COUNTER_WINDOWS = eina_error_msg_static_register(
+ EINA_ERROR_COUNTER_WINDOWS_STR);
if (!QueryPerformanceFrequency(&_eina_counter_frequency))
{
- eina_error_set(EINA_ERROR_COUNTER_WINDOWS);
- return EINA_FALSE;
+ eina_error_set(EINA_ERROR_COUNTER_WINDOWS);
+ return EINA_FALSE;
}
+
#endif /* _WIN2 */
return EINA_TRUE;
}
}
/*============================================================================*
- * API *
- *============================================================================*/
+* API *
+*============================================================================*/
/**
* @addtogroup Eina_Counter_Group Counter
length = strlen(name) + 1;
- eina_error_set(0);
+ eina_error_set(0);
counter = calloc(1, sizeof (Eina_Counter) + length);
if (!counter)
{
- eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
- return NULL;
+ eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+ return NULL;
}
- counter->name = (char*) (counter + 1);
- memcpy((char*) counter->name, name, length);
+ counter->name = (char *)(counter + 1);
+ memcpy((char *)counter->name, name, length);
return counter;
}
while (counter->clocks)
{
- Eina_Clock *clk = (Eina_Clock *) counter->clocks;
+ Eina_Clock *clk = (Eina_Clock *)counter->clocks;
- counter->clocks = eina_inlist_remove(counter->clocks, counter->clocks);
- free(clk);
+ counter->clocks = eina_inlist_remove(counter->clocks, counter->clocks);
+ free(clk);
}
- free(counter);
+ free(counter);
}
/**
Eina_Nano_Time tp;
EINA_SAFETY_ON_NULL_RETURN(counter);
- if (_eina_counter_time_get(&tp) != 0) return;
+ if (_eina_counter_time_get(&tp) != 0)
+ return;
- eina_error_set(0);
+ eina_error_set(0);
clk = calloc(1, sizeof (Eina_Clock));
if (!clk)
{
- eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
- return;
+ eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+ return;
}
counter->clocks = eina_inlist_prepend(counter->clocks, EINA_INLIST_GET(clk));
Eina_Nano_Time tp;
EINA_SAFETY_ON_NULL_RETURN(counter);
- if (_eina_counter_time_get(&tp) != 0) return;
+ if (_eina_counter_time_get(&tp) != 0)
+ return;
- clk = (Eina_Clock *) counter->clocks;
+ clk = (Eina_Clock *)counter->clocks;
- if (!clk || clk->valid == EINA_TRUE) return;
+ if (!clk || clk->valid == EINA_TRUE)
+ return;
clk->end = tp;
clk->specimen = specimen;
* @endverbatim
*
* The unit of time is the nanosecond.
-*/
+ */
EAPI char *
eina_counter_dump(Eina_Counter *counter)
{
EINA_SAFETY_ON_NULL_RETURN_VAL(counter, NULL);
- result = _eina_counter_asiprintf(result, &position, "# specimen\texperiment time\tstarting time\tending time\n");
- if (!result) return NULL;
+ result = _eina_counter_asiprintf(
+ result,
+ &position,
+ "# specimen\texperiment time\tstarting time\tending time\n");
+ if (!result)
+ return NULL;
EINA_INLIST_REVERSE_FOREACH(counter->clocks, clk)
- {
- long int start;
- long int end;
- long int diff;
+ {
+ long int start;
+ long int end;
+ long int diff;
- if (clk->valid == EINA_FALSE) continue;
+ if (clk->valid == EINA_FALSE)
+ continue;
#ifndef _WIN32
- start = clk->start.tv_sec * 1000000000 + clk->start.tv_nsec;
- end = clk->end.tv_sec * 1000000000 + clk->end.tv_nsec;
- diff = (clk->end.tv_sec - clk->start.tv_sec) * 1000000000 + clk->end.tv_nsec - clk->start.tv_nsec;
+ start = clk->start.tv_sec * 1000000000 + clk->start.tv_nsec;
+ end = clk->end.tv_sec * 1000000000 + clk->end.tv_nsec;
+ diff =
+ (clk->end.tv_sec -
+ clk->start.tv_sec) * 1000000000 + clk->end.tv_nsec -
+ clk->start.tv_nsec;
#else
- start = (long int)(((long long int)clk->start.QuadPart * 1000000000ll) / (long long int)_eina_counter_frequency.QuadPart);
- end = (long int)(((long long int)clk->end.QuadPart * 1000000000LL) / (long long int)_eina_counter_frequency.QuadPart);
- diff = (long int)(((long long int)(clk->end.QuadPart - clk->start.QuadPart) * 1000000000LL) / (long long int)_eina_counter_frequency.QuadPart);
+ start =
+ (long int)(((long long int)clk->start.QuadPart *
+ 1000000000ll) /
+ (long long int)_eina_counter_frequency.QuadPart);
+ end =
+ (long int)(((long long int)clk->end.QuadPart *
+ 1000000000LL) /
+ (long long int)_eina_counter_frequency.QuadPart);
+ diff =
+ (long int)(((long long int)(clk->end.QuadPart -
+ clk->start.QuadPart) *
+ 1000000000LL) /
+ (long long int)_eina_counter_frequency.QuadPart);
#endif /* _WIN2 */
- result = _eina_counter_asiprintf(result, &position,
- "%i\t%li\t%li\t%li\n",
- clk->specimen,
- diff,
- start,
- end);
- }
+ result = _eina_counter_asiprintf(result, &position,
+ "%i\t%li\t%li\t%li\n",
+ clk->specimen,
+ diff,
+ start,
+ end);
+ }
return result;
}
# include <windows.h>
# elif defined (__SUNPRO_C) || defined(__GNU__)
# include <unistd.h>
-# elif defined (__FreeBSD__) || defined (__OpenBSD__) || defined (__NetBSD__) || defined (__DragonFly__) || defined (__MacOSX__) || ( defined (__MACH__) && defined (__APPLE__))
+# elif defined (__FreeBSD__) || defined (__OpenBSD__) || \
+ defined (__NetBSD__) || defined (__DragonFly__) || defined (__MacOSX__) || \
+ (defined (__MACH__) && defined (__APPLE__))
# include <unistd.h>
# include <sys/param.h>
# include <sys/sysctl.h>
#include "eina_cpu.h"
/*============================================================================*
- * Local *
- *============================================================================*/
+* Local *
+*============================================================================*/
/* FIXME this ifdefs should be replaced */
#if defined(__i386__) || defined(__x86_64__)
/* We save ebx and restore it to be PIC compatible */
static inline void _x86_cpuid(int op, int *a, int *b, int *c, int *d)
{
- asm volatile(
+ asm volatile (
#if defined(__x86_64__)
- "pushq %%rbx \n\t" /* save %ebx */
+ "pushq %%rbx \n\t" /* save %ebx */
#else
- "pushl %%ebx \n\t" /* save %ebx */
+ "pushl %%ebx \n\t" /* save %ebx */
#endif
- "cpuid \n\t"
- "movl %%ebx, %1 \n\t" /* save what cpuid just put in %ebx */
+ "cpuid \n\t"
+ "movl %%ebx, %1 \n\t" /* save what cpuid just put in %ebx */
#if defined(__x86_64__)
- "popq %%rbx \n\t" /* restore the old %ebx */
+ "popq %%rbx \n\t" /* restore the old %ebx */
#else
- "popl %%ebx \n\t" /* restore the old %ebx */
+ "popl %%ebx \n\t" /* restore the old %ebx */
#endif
- : "=a"(*a), "=r"(*b), "=c"(*c), "=d"(*d)
- : "a"(op)
- : "cc");
+ : "=a" (*a), "=r" (*b), "=c" (*c), "=d" (*d)
+ : "a" (op)
+ : "cc");
}
static
void _x86_simd(Eina_Cpu_Features *features)
{
- int a, b, c, d;
-
- _x86_cpuid(1, &a, &b, &c, &d);
- /*
- * edx
- * 18 = PN (Processor Number)
- * 19 = CLFlush (Cache Line Flush)
- * 23 = MMX
- * 25 = SSE
- * 26 = SSE2
- * 28 = HTT (Hyper Threading)
- * ecx
- * 0 = SSE3
- */
- if ((d >> 23) & 1)
- *features |= EINA_CPU_MMX;
- if ((d >> 25) & 1)
- *features |= EINA_CPU_SSE;
- if ((d >> 26) & 1)
- *features |= EINA_CPU_SSE2;
- if (c & 1)
- *features |= EINA_CPU_SSE3;
+ int a, b, c, d;
+
+ _x86_cpuid(1, &a, &b, &c, &d);
+ /*
+ * edx
+ * 18 = PN (Processor Number)
+ * 19 = CLFlush (Cache Line Flush)
+ * 23 = MMX
+ * 25 = SSE
+ * 26 = SSE2
+ * 28 = HTT (Hyper Threading)
+ * ecx
+ * 0 = SSE3
+ */
+ if ((d >> 23) & 1)
+ *features |= EINA_CPU_MMX;
+
+ if ((d >> 25) & 1)
+ *features |= EINA_CPU_SSE;
+
+ if ((d >> 26) & 1)
+ *features |= EINA_CPU_SSE2;
+
+ if (c & 1)
+ *features |= EINA_CPU_SSE3;
}
#endif
/*============================================================================*
- * Global *
- *============================================================================*/
+* Global *
+*============================================================================*/
/*============================================================================*
- * API *
- *============================================================================*/
+* API *
+*============================================================================*/
/* FIXME the features checks should be called when this function is called?
* or make it static by doing eina_cpu_init() and return a local var
*/
EAPI Eina_Cpu_Features eina_cpu_features_get(void)
{
- Eina_Cpu_Features ecf = 0;
+ Eina_Cpu_Features ecf = 0;
#if defined(__i386__) || defined(__x86_64__)
- _x86_simd(&ecf);
+ _x86_simd(&ecf);
#endif
- return ecf;
+ return ecf;
}
EAPI int eina_cpu_count(void)
*/
return sysconf(_SC_NPROCESSORS_ONLN);
-# elif defined (__FreeBSD__) || defined (__OpenBSD__) || defined (__NetBSD__) || defined (__DragonFly__) || defined (__MacOSX__) || ( defined (__MACH__) && defined (__APPLE__))
+# elif defined (__FreeBSD__) || defined (__OpenBSD__) || \
+ defined (__NetBSD__) || defined (__DragonFly__) || defined (__MacOSX__) || \
+ (defined (__MACH__) && defined (__APPLE__))
- int mib[4];
- int cpus;
+ int mib[4];
+ int cpus;
size_t len = sizeof(cpus);
mib[0] = CTL_HW;
#endif
sysctl(mib, 2, &cpus, &len, NULL, 0);
if (cpus < 1)
- cpus = 1;
+ cpus = 1;
return cpus;
int i;
static int cpus = 0;
- if (cpus != 0) return cpus;
+ if (cpus != 0)
+ return cpus;
CPU_ZERO(&cpu);
if (sched_getaffinity(0, sizeof(cpu), &cpu) != 0)
{
- fprintf(stderr, "[Eina] could not get cpu affinity: %s\n", strerror(errno));
- return 1;
+ fprintf(stderr, "[Eina] could not get cpu affinity: %s\n",
+ strerror(errno));
+ return 1;
}
+
for (i = 0; i < TH_MAX; i++)
{
- if (CPU_ISSET(i, &cpu)) cpus = i + 1;
- else break;
+ if (CPU_ISSET(i, &cpu))
+ cpus = i + 1;
+ else
+ break;
}
return cpus;
*/
/*============================================================================*
- * Local *
- *============================================================================*/
+* Local *
+*============================================================================*/
/**
* @cond LOCAL
if (_eina_errors_count == _eina_errors_allocated)
{
- void *tmp;
- size_t size;
-
- if (EINA_UNLIKELY(_eina_errors_allocated == 0))
- size = 24;
- else
- size = _eina_errors_allocated + 8;
-
- tmp = realloc(_eina_errors, sizeof(Eina_Error_Message) * size);
- if (!tmp)
- return NULL;
- _eina_errors = tmp;
- _eina_errors_allocated = size;
+ void *tmp;
+ size_t size;
+
+ if (EINA_UNLIKELY(_eina_errors_allocated == 0))
+ size = 24;
+ else
+ size = _eina_errors_allocated + 8;
+
+ tmp = realloc(_eina_errors, sizeof(Eina_Error_Message) * size);
+ if (!tmp)
+ return NULL;
+
+ _eina_errors = tmp;
+ _eina_errors_allocated = size;
}
idx = _eina_errors_count;
/*============================================================================*
- * Global *
- *============================================================================*/
+* Global *
+*============================================================================*/
/**
* @cond LOCAL
eina_error_init(void)
{
/* TODO register the eina's basic errors */
- EINA_ERROR_OUT_OF_MEMORY = eina_error_msg_static_register(EINA_ERROR_OUT_OF_MEMORY_STR);
+ EINA_ERROR_OUT_OF_MEMORY = eina_error_msg_static_register(
+ EINA_ERROR_OUT_OF_MEMORY_STR);
return EINA_TRUE;
}
eem_end = eem + _eina_errors_count;
for (; eem < eem_end; eem++)
- if (eem->string_allocated)
- free((char *)eem->string);
+ if (eem->string_allocated)
+ free((char *)eem->string);
- free(_eina_errors);
+ free(_eina_errors);
_eina_errors = NULL;
_eina_errors_count = 0;
_eina_errors_allocated = 0;
}
/*============================================================================*
- * API *
- *============================================================================*/
+* API *
+*============================================================================*/
/**
* @addtogroup Eina_Error_Group Error
eem = _eina_error_msg_alloc();
if (!eem)
- return 0;
+ return 0;
eem->string_allocated = EINA_TRUE;
eem->string = strdup(msg);
if (!eem->string)
{
- _eina_errors_count--;
- return 0;
+ _eina_errors_count--;
+ return 0;
}
return _eina_errors_count; /* identifier = index + 1 (== _count). */
eem = _eina_error_msg_alloc();
if (!eem)
- return 0;
+ return 0;
eem->string_allocated = EINA_FALSE;
eem->string = msg;
{
EINA_SAFETY_ON_NULL_RETURN_VAL(msg, EINA_FALSE);
if (error < 1)
- return EINA_FALSE;
+ return EINA_FALSE;
+
if ((size_t)error > _eina_errors_count)
- return EINA_FALSE;
+ return EINA_FALSE;
+
if (_eina_errors[error - 1].string_allocated)
{
const char *tmp;
if (!(tmp = strdup(msg)))
- return EINA_FALSE;
+ return EINA_FALSE;
- free((void*)_eina_errors[error - 1].string);
+ free((void *)_eina_errors[error - 1].string);
_eina_errors[error - 1].string = tmp;
return EINA_TRUE;
}
eina_error_msg_get(Eina_Error error)
{
if (error < 1)
- return NULL;
+ return NULL;
+
if ((size_t)error > _eina_errors_count)
- return NULL;
+ return NULL;
+
return _eina_errors[error - 1].string;
}
do
{
- dp = readdir(it->dirp);
- if (!dp) return EINA_FALSE;
+ dp = readdir(it->dirp);
+ if (!dp)
+ return EINA_FALSE;
}
while ((dp->d_name[0] == '.') &&
- ((dp->d_name[1] == '\0') ||
- ((dp->d_name[1] == '.') && (dp->d_name[2] == '\0'))));
+ ((dp->d_name[1] == '\0') ||
+ ((dp->d_name[1] == '.') && (dp->d_name[2] == '\0'))));
length = strlen(dp->d_name);
name = alloca(length + 2 + it->length);
- memcpy(name, it->dir, it->length);
- memcpy(name + it->length, "/", 1);
+ memcpy(name, it->dir, it->length);
+ memcpy(name + it->length, "/", 1);
memcpy(name + it->length + 1, dp->d_name, length + 1);
- *data = (char*) eina_stringshare_add(name);
+ *data = (char *)eina_stringshare_add(name);
return EINA_TRUE;
}
do
{
- dp = readdir(it->dirp);
- if (!dp) return EINA_FALSE;
+ dp = readdir(it->dirp);
+ if (!dp)
+ return EINA_FALSE;
- length = strlen(dp->d_name);
- if (it->info.name_start + length + 1 >= PATH_MAX)
- continue;
+ length = strlen(dp->d_name);
+ if (it->info.name_start + length + 1 >= PATH_MAX)
+ continue;
}
while ((dp->d_name[0] == '.') &&
- ((dp->d_name[1] == '\0') ||
- ((dp->d_name[1] == '.') && (dp->d_name[2] == '\0'))));
+ ((dp->d_name[1] == '\0') ||
+ ((dp->d_name[1] == '.') && (dp->d_name[2] == '\0'))));
memcpy(it->info.path + it->info.name_start, dp->d_name, length);
it->info.name_length = length;
}
/*============================================================================*
- * Global *
- *============================================================================*/
+* Global *
+*============================================================================*/
/*============================================================================*
- * API *
- *============================================================================*/
+* API *
+*============================================================================*/
/**
* @addtogroup Eina_File_Group File
* immediatly. otherwise, it returns #EINA_TRUE.
*/
EAPI Eina_Bool
-eina_file_dir_list(const char *dir, Eina_Bool recursive, Eina_File_Dir_List_Cb cb, void *data)
+eina_file_dir_list(const char *dir,
+ Eina_Bool recursive,
+ Eina_File_Dir_List_Cb cb,
+ void *data)
{
#ifndef _WIN32
- struct dirent *de;
- DIR *d;
+ struct dirent *de;
+ DIR *d;
- EINA_SAFETY_ON_NULL_RETURN_VAL(cb, EINA_FALSE);
- EINA_SAFETY_ON_NULL_RETURN_VAL(dir, EINA_FALSE);
- EINA_SAFETY_ON_TRUE_RETURN_VAL(dir[0] == '\0', EINA_FALSE);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(cb, EINA_FALSE);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(dir, EINA_FALSE);
+ EINA_SAFETY_ON_TRUE_RETURN_VAL(dir[0] == '\0', EINA_FALSE);
- d = opendir(dir);
- if (!d) return EINA_FALSE;
+ d = opendir(dir);
+ if (!d)
+ return EINA_FALSE;
- while ((de = readdir(d)))
- {
- if (!strcmp(de->d_name, ".") || !strcmp(de->d_name, ".."))
- continue;
+ while ((de = readdir(d)))
+ {
+ if (!strcmp(de->d_name, ".") || !strcmp(de->d_name, ".."))
+ continue;
- cb(de->d_name, dir, data);
- /* d_type is only available on linux and bsd (_BSD_SOURCE) */
+ cb(de->d_name, dir, data);
+ /* d_type is only available on linux and bsd (_BSD_SOURCE) */
- if (recursive == EINA_TRUE) {
- char *path;
+ if (recursive == EINA_TRUE)
+ {
+ char *path;
- path = alloca(strlen(dir) + strlen(de->d_name) + 2);
- strcpy(path, dir);
- strcat(path, "/");
- strcat(path, de->d_name);
+ path = alloca(strlen(dir) + strlen(de->d_name) + 2);
+ strcpy(path, dir);
+ strcat(path, "/");
+ strcat(path, de->d_name);
#ifndef sun
- if (de->d_type == DT_UNKNOWN) {
+ if (de->d_type == DT_UNKNOWN)
+ {
#endif
- struct stat st;
+ struct stat st;
+
+ if (stat(path, &st))
+ continue;
- if (stat(path, &st))
- continue ;
+ if (!S_ISDIR(st.st_mode))
+ continue;
- if (!S_ISDIR(st.st_mode))
- continue ;
#ifndef sun
- } else if (de->d_type != DT_DIR) {
- continue ;
- }
+ }
+ else if (de->d_type != DT_DIR)
+ continue;
+
#endif
- eina_file_dir_list(path, recursive, cb, data);
- }
- }
+ eina_file_dir_list(path, recursive, cb, data);
+ }
+ }
- closedir(d);
+ closedir(d);
#else
- WIN32_FIND_DATA file;
- HANDLE hSearch;
- char *new_dir;
- TCHAR *tdir;
- size_t length_dir;
+ WIN32_FIND_DATA file;
+ HANDLE hSearch;
+ char *new_dir;
+ TCHAR *tdir;
+ size_t length_dir;
- EINA_SAFETY_ON_NULL_RETURN_VAL(cb, EINA_FALSE);
- EINA_SAFETY_ON_NULL_RETURN_VAL(dir, EINA_FALSE);
- EINA_SAFETY_ON_TRUE_RETURN_VAL(dir[0] == '\0', EINA_FALSE);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(cb, EINA_FALSE);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(dir, EINA_FALSE);
+ EINA_SAFETY_ON_TRUE_RETURN_VAL(dir[0] == '\0', EINA_FALSE);
- length_dir = strlen(dir);
- new_dir = (char *)alloca(length_dir + 5);
- if (!new_dir) return EINA_FALSE;
+ length_dir = strlen(dir);
+ new_dir = (char *)alloca(length_dir + 5);
+ if (!new_dir)
+ return EINA_FALSE;
- memcpy(new_dir, dir, length_dir);
- memcpy(new_dir + length_dir, "/*.*", 5);
+ memcpy(new_dir, dir, length_dir);
+ memcpy(new_dir + length_dir, "/*.*", 5);
#ifdef UNICODE
- tdir = evil_char_to_wchar(new_dir);
+ tdir = evil_char_to_wchar(new_dir);
#else
- tdir = new_dir;
+ tdir = new_dir;
#endif /* ! UNICODE */
- hSearch = FindFirstFile(tdir, &file);
+ hSearch = FindFirstFile(tdir, &file);
#ifdef UNICODE
- free(tdir);
+ free(tdir);
#endif /* UNICODE */
- if (hSearch == INVALID_HANDLE_VALUE) return EINA_FALSE;
+ if (hSearch == INVALID_HANDLE_VALUE)
+ return EINA_FALSE;
- do
- {
- char *filename;
+ do
+ {
+ char *filename;
#ifdef UNICODE
- filename = evil_wchar_to_char(file.cFileName);
+ filename = evil_wchar_to_char(file.cFileName);
#else
- filename = file.cFileName;
+ filename = file.cFileName;
#endif /* ! UNICODE */
- if (!strcmp(filename, ".") || !strcmp(filename, ".."))
- continue;
+ if (!strcmp(filename, ".") || !strcmp(filename, ".."))
+ continue;
+
+ cb(filename, dir, data);
- cb(filename, dir, data);
+ if (recursive == EINA_TRUE)
+ {
+ char *path;
- if (recursive == EINA_TRUE) {
- char *path;
+ path = alloca(strlen(dir) + strlen(filename) + 2);
+ strcpy(path, dir);
+ strcat(path, "/");
+ strcat(path, filename);
- path = alloca(strlen(dir) + strlen(filename) + 2);
- strcpy(path, dir);
- strcat(path, "/");
- strcat(path, filename);
+ if (!(file.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
+ continue;
- if (!(file.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
- continue ;
+ eina_file_dir_list(path, recursive, cb, data);
+ }
- eina_file_dir_list(path, recursive, cb, data);
- }
#ifdef UNICODE
- free(filename);
+ free(filename);
#endif /* UNICODE */
- } while (FindNextFile(hSearch, &file));
- FindClose(hSearch);
+ } while (FindNextFile(hSearch, &file));
+ FindClose(hSearch);
#endif /* _WIN32 */
- return EINA_TRUE;
+ return EINA_TRUE;
}
/**
EAPI Eina_Array *
eina_file_split(char *path)
{
- Eina_Array *ea;
- char *current;
- size_t length;
+ Eina_Array *ea;
+ char *current;
+ size_t length;
- EINA_SAFETY_ON_NULL_RETURN_VAL(path, NULL);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(path, NULL);
- ea = eina_array_new(16);
+ ea = eina_array_new(16);
- if (!ea) return NULL;
+ if (!ea)
+ return NULL;
- for (current = strchr(path, PATH_DELIM);
- current != NULL;
- path = current + 1, current = strchr(path, PATH_DELIM))
- {
- length = current - path;
+ for (current = strchr(path, PATH_DELIM);
+ current != NULL;
+ path = current + 1, current = strchr(path, PATH_DELIM))
+ {
+ length = current - path;
- if (length <= 0) continue ;
+ if (length <= 0)
+ continue;
- eina_array_push(ea, path);
- *current = '\0';
- }
+ eina_array_push(ea, path);
+ *current = '\0';
+ }
- if (*path != '\0')
- eina_array_push(ea, path);
+ if (*path != '\0')
+ eina_array_push(ea, path);
- return ea;
+ return ea;
}
/**
Eina_File_Iterator *it;
size_t length;
- if (!dir) return NULL;
+ if (!dir)
+ return NULL;
length = strlen(dir);
- if (length < 1) return NULL;
+ if (length < 1)
+ return NULL;
it = malloc(sizeof (Eina_File_Iterator) + length);
- if (!it) return NULL;
+ if (!it)
+ return NULL;
EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_ITERATOR);
it->dirp = opendir(dir);
if (!it->dirp)
{
- free(it);
- return NULL;
+ free(it);
+ return NULL;
}
memcpy(it->dir, dir, length + 1);
if (dir[length - 1] != '/')
- it->length = length;
+ it->length = length;
else
- it->length = length - 1;
+ it->length = length - 1;
it->iterator.next = FUNC_ITERATOR_NEXT(_eina_file_ls_iterator_next);
- it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(_eina_file_ls_iterator_container);
+ it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(
+ _eina_file_ls_iterator_container);
it->iterator.free = FUNC_ITERATOR_FREE(_eina_file_ls_iterator_free);
return &it->iterator;
Eina_File_Direct_Iterator *it;
size_t length;
- if (!dir) return NULL;
+ if (!dir)
+ return NULL;
length = strlen(dir);
- if (length < 1) return NULL;
- if (length + NAME_MAX + 2 >= PATH_MAX) return NULL;
+ if (length < 1)
+ return NULL;
+
+ if (length + NAME_MAX + 2 >= PATH_MAX)
+ return NULL;
it = malloc(sizeof(Eina_File_Direct_Iterator) + length);
- if (!it) return NULL;
+ if (!it)
+ return NULL;
EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_ITERATOR);
it->dirp = opendir(dir);
if (!it->dirp)
{
- free(it);
- return NULL;
+ free(it);
+ return NULL;
}
- memcpy(it->dir, dir, length + 1);
+ memcpy(it->dir, dir, length + 1);
it->length = length;
memcpy(it->info.path, dir, length);
if (dir[length - 1] == '/')
- it->info.name_start = length;
+ it->info.name_start = length;
else
{
- it->info.path[length] = '/';
- it->info.name_start = length + 1;
+ it->info.path[length] = '/';
+ it->info.name_start = length + 1;
}
it->iterator.next = FUNC_ITERATOR_NEXT(_eina_file_direct_ls_iterator_next);
- it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(_eina_file_direct_ls_iterator_container);
+ it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(
+ _eina_file_direct_ls_iterator_container);
it->iterator.free = FUNC_ITERATOR_FREE(_eina_file_direct_ls_iterator_free);
return &it->iterator;
#define MAX_PREC 1025
static const Eina_F32p32 eina_trigo[MAX_PREC] =
- {
- 0x0000000100000000, 0x00000000ffffec43, 0x00000000ffffb10b, 0x00000000ffff4e5a, 0x00000000fffec42e, 0x00000000fffe1287, 0x00000000fffd3967, 0x00000000fffc38cd, 0x00000000fffb10b9, 0x00000000fff9c12c,
- 0x00000000fff84a25, 0x00000000fff6aba5, 0x00000000fff4e5ac, 0x00000000fff2f83b, 0x00000000fff0e351, 0x00000000ffeea6ef, 0x00000000ffec4316, 0x00000000ffe9b7c5, 0x00000000ffe704fe, 0x00000000ffe42ac0,
- 0x00000000ffe1290b, 0x00000000ffddffe2, 0x00000000ffdaaf43, 0x00000000ffd7372f, 0x00000000ffd397a8, 0x00000000ffcfd0ad, 0x00000000ffcbe23f, 0x00000000ffc7cc5f, 0x00000000ffc38f0d, 0x00000000ffbf2a4b,
- 0x00000000ffba9e17, 0x00000000ffb5ea75, 0x00000000ffb10f63, 0x00000000ffac0ce3, 0x00000000ffa6e2f6, 0x00000000ffa1919c, 0x00000000ff9c18d6, 0x00000000ff9678a6, 0x00000000ff90b10b, 0x00000000ff8ac208,
- 0x00000000ff84ab9c, 0x00000000ff7e6dc8, 0x00000000ff78088f, 0x00000000ff717bf0, 0x00000000ff6ac7ec, 0x00000000ff63ec85, 0x00000000ff5ce9bc, 0x00000000ff55bf92, 0x00000000ff4e6e08, 0x00000000ff46f51f,
- 0x00000000ff3f54d8, 0x00000000ff378d34, 0x00000000ff2f9e35, 0x00000000ff2787dc, 0x00000000ff1f4a2a, 0x00000000ff16e520, 0x00000000ff0e58c0, 0x00000000ff05a50a, 0x00000000fefcca01, 0x00000000fef3c7a6,
- 0x00000000feea9df9, 0x00000000fee14cfe, 0x00000000fed7d4b3, 0x00000000fece351d, 0x00000000fec46e3b, 0x00000000feba800f, 0x00000000feb06a9c, 0x00000000fea62de1, 0x00000000fe9bc9e2, 0x00000000fe913e9f,
- 0x00000000fe868c1b, 0x00000000fe7bb256, 0x00000000fe70b153, 0x00000000fe658913, 0x00000000fe5a3998, 0x00000000fe4ec2e4, 0x00000000fe4324f9, 0x00000000fe375fd7, 0x00000000fe2b7382, 0x00000000fe1f5ffa,
- 0x00000000fe132543, 0x00000000fe06c35d, 0x00000000fdfa3a4b, 0x00000000fded8a0e, 0x00000000fde0b2a8, 0x00000000fdd3b41c, 0x00000000fdc68e6c, 0x00000000fdb94199, 0x00000000fdabcda5, 0x00000000fd9e3294,
- 0x00000000fd907065, 0x00000000fd82871d, 0x00000000fd7476bd, 0x00000000fd663f46, 0x00000000fd57e0bd, 0x00000000fd495b21, 0x00000000fd3aae77, 0x00000000fd2bdabf, 0x00000000fd1cdffd, 0x00000000fd0dbe32,
- 0x00000000fcfe7562, 0x00000000fcef058e, 0x00000000fcdf6eb8, 0x00000000fccfb0e4, 0x00000000fcbfcc13, 0x00000000fcafc048, 0x00000000fc9f8d86, 0x00000000fc8f33ce, 0x00000000fc7eb325, 0x00000000fc6e0b8b,
- 0x00000000fc5d3d03, 0x00000000fc4c4791, 0x00000000fc3b2b37, 0x00000000fc29e7f7, 0x00000000fc187dd5, 0x00000000fc06ecd2, 0x00000000fbf534f2, 0x00000000fbe35637, 0x00000000fbd150a3, 0x00000000fbbf243b,
- 0x00000000fbacd100, 0x00000000fb9a56f6, 0x00000000fb87b61f, 0x00000000fb74ee7e, 0x00000000fb620016, 0x00000000fb4eeaea, 0x00000000fb3baefd, 0x00000000fb284c52, 0x00000000fb14c2eb, 0x00000000fb0112cd,
- 0x00000000faed3bf9, 0x00000000fad93e73, 0x00000000fac51a3f, 0x00000000fab0cf5e, 0x00000000fa9c5dd5, 0x00000000fa87c5a6, 0x00000000fa7306d5, 0x00000000fa5e2164, 0x00000000fa491558, 0x00000000fa33e2b3,
- 0x00000000fa1e8978, 0x00000000fa0909ab, 0x00000000f9f36350, 0x00000000f9dd9668, 0x00000000f9c7a2f9, 0x00000000f9b18905, 0x00000000f99b488f, 0x00000000f984e19c, 0x00000000f96e542e, 0x00000000f957a049,
- 0x00000000f940c5f1, 0x00000000f929c528, 0x00000000f9129df3, 0x00000000f8fb5056, 0x00000000f8e3dc53, 0x00000000f8cc41ee, 0x00000000f8b4812b, 0x00000000f89c9a0e, 0x00000000f8848c9b, 0x00000000f86c58d4,
- 0x00000000f853febe, 0x00000000f83b7e5d, 0x00000000f822d7b4, 0x00000000f80a0ac7, 0x00000000f7f1179a, 0x00000000f7d7fe31, 0x00000000f7bebe90, 0x00000000f7a558ba, 0x00000000f78bccb3, 0x00000000f7721a80,
- 0x00000000f7584225, 0x00000000f73e43a5, 0x00000000f7241f04, 0x00000000f709d446, 0x00000000f6ef6370, 0x00000000f6d4cc85, 0x00000000f6ba0f8a, 0x00000000f69f2c83, 0x00000000f6842374, 0x00000000f668f461,
- 0x00000000f64d9f4e, 0x00000000f632243f, 0x00000000f616833a, 0x00000000f5fabc41, 0x00000000f5decf59, 0x00000000f5c2bc87, 0x00000000f5a683cf, 0x00000000f58a2535, 0x00000000f56da0be, 0x00000000f550f66e,
- 0x00000000f5342649, 0x00000000f5173054, 0x00000000f4fa1494, 0x00000000f4dcd30c, 0x00000000f4bf6bc2, 0x00000000f4a1deb9, 0x00000000f4842bf7, 0x00000000f4665380, 0x00000000f4485559, 0x00000000f42a3186,
- 0x00000000f40be80c, 0x00000000f3ed78ef, 0x00000000f3cee434, 0x00000000f3b029e1, 0x00000000f39149f9, 0x00000000f3724482, 0x00000000f3531980, 0x00000000f333c8f8, 0x00000000f31452ef, 0x00000000f2f4b76a,
- 0x00000000f2d4f66d, 0x00000000f2b50ffe, 0x00000000f2950421, 0x00000000f274d2dc, 0x00000000f2547c33, 0x00000000f234002b, 0x00000000f2135eca, 0x00000000f1f29814, 0x00000000f1d1ac0e, 0x00000000f1b09abe,
- 0x00000000f18f6429, 0x00000000f16e0853, 0x00000000f14c8742, 0x00000000f12ae0fb, 0x00000000f1091583, 0x00000000f0e724e0, 0x00000000f0c50f17, 0x00000000f0a2d42c, 0x00000000f0807426, 0x00000000f05def09,
- 0x00000000f03b44db, 0x00000000f01875a1, 0x00000000eff58161, 0x00000000efd2681f, 0x00000000efaf29e2, 0x00000000ef8bc6af, 0x00000000ef683e8b, 0x00000000ef44917b, 0x00000000ef20bf86, 0x00000000eefcc8b1,
- 0x00000000eed8ad01, 0x00000000eeb46c7b, 0x00000000ee900727, 0x00000000ee6b7d08, 0x00000000ee46ce25, 0x00000000ee21fa83, 0x00000000edfd0228, 0x00000000edd7e51a, 0x00000000edb2a35f, 0x00000000ed8d3cfc,
- 0x00000000ed67b1f6, 0x00000000ed420255, 0x00000000ed1c2e1d, 0x00000000ecf63554, 0x00000000ecd01801, 0x00000000eca9d628, 0x00000000ec836fd1, 0x00000000ec5ce501, 0x00000000ec3635bd, 0x00000000ec0f620d,
- 0x00000000ebe869f5, 0x00000000ebc14d7d, 0x00000000eb9a0ca9, 0x00000000eb72a780, 0x00000000eb4b1e08, 0x00000000eb237047, 0x00000000eafb9e43, 0x00000000ead3a803, 0x00000000eaab8d8d, 0x00000000ea834ee6,
- 0x00000000ea5aec15, 0x00000000ea326520, 0x00000000ea09ba0d, 0x00000000e9e0eae4, 0x00000000e9b7f7a9, 0x00000000e98ee063, 0x00000000e965a51a, 0x00000000e93c45d2, 0x00000000e912c292, 0x00000000e8e91b61,
- 0x00000000e8bf5046, 0x00000000e8956146, 0x00000000e86b4e68, 0x00000000e84117b3, 0x00000000e816bd2d, 0x00000000e7ec3edc, 0x00000000e7c19cc8, 0x00000000e796d6f6, 0x00000000e76bed6e, 0x00000000e740e036,
- 0x00000000e715af54, 0x00000000e6ea5ad0, 0x00000000e6bee2af, 0x00000000e69346f9, 0x00000000e66787b5, 0x00000000e63ba4e9, 0x00000000e60f9e9b, 0x00000000e5e374d4, 0x00000000e5b72798, 0x00000000e58ab6f1,
- 0x00000000e55e22e3, 0x00000000e5316b76, 0x00000000e50490b1, 0x00000000e4d7929c, 0x00000000e4aa713c, 0x00000000e47d2c98, 0x00000000e44fc4b9, 0x00000000e42239a4, 0x00000000e3f48b61, 0x00000000e3c6b9f7,
- 0x00000000e398c56c, 0x00000000e36aadc9, 0x00000000e33c7314, 0x00000000e30e1554, 0x00000000e2df9490, 0x00000000e2b0f0d0, 0x00000000e2822a1a, 0x00000000e2534077, 0x00000000e22433ec, 0x00000000e1f50482,
- 0x00000000e1c5b240, 0x00000000e1963d2d, 0x00000000e166a550, 0x00000000e136eab0, 0x00000000e1070d56, 0x00000000e0d70d48, 0x00000000e0a6ea8e, 0x00000000e076a52f, 0x00000000e0463d33, 0x00000000e015b2a1,
- 0x00000000dfe50580, 0x00000000dfb435d9, 0x00000000df8343b2, 0x00000000df522f13, 0x00000000df20f804, 0x00000000deef9e8d, 0x00000000debe22b5, 0x00000000de8c8483, 0x00000000de5ac3ff, 0x00000000de28e131,
- 0x00000000ddf6dc21, 0x00000000ddc4b4d6, 0x00000000dd926b59, 0x00000000dd5fffb0, 0x00000000dd2d71e3, 0x00000000dcfac1fb, 0x00000000dcc7f000, 0x00000000dc94fbf8, 0x00000000dc61e5ec, 0x00000000dc2eade4,
- 0x00000000dbfb53e8, 0x00000000dbc7d7ff, 0x00000000db943a31, 0x00000000db607a88, 0x00000000db2c9909, 0x00000000daf895bf, 0x00000000dac470af, 0x00000000da9029e3, 0x00000000da5bc163, 0x00000000da273737,
- 0x00000000d9f28b66, 0x00000000d9bdbdf9, 0x00000000d988cef8, 0x00000000d953be6b, 0x00000000d91e8c5b, 0x00000000d8e938d0, 0x00000000d8b3c3d1, 0x00000000d87e2d67, 0x00000000d848759b, 0x00000000d8129c74,
- 0x00000000d7dca1fb, 0x00000000d7a68638, 0x00000000d7704934, 0x00000000d739eaf7, 0x00000000d7036b89, 0x00000000d6cccaf3, 0x00000000d696093d, 0x00000000d65f266f, 0x00000000d6282293, 0x00000000d5f0fdb0,
- 0x00000000d5b9b7d0, 0x00000000d58250fa, 0x00000000d54ac937, 0x00000000d513208f, 0x00000000d4db570c, 0x00000000d4a36cb6, 0x00000000d46b6195, 0x00000000d43335b3, 0x00000000d3fae917, 0x00000000d3c27bcb,
- 0x00000000d389edd7, 0x00000000d3513f43, 0x00000000d318701a, 0x00000000d2df8063, 0x00000000d2a67027, 0x00000000d26d3f6f, 0x00000000d233ee43, 0x00000000d1fa7cae, 0x00000000d1c0eab7, 0x00000000d1873867,
- 0x00000000d14d65c8, 0x00000000d11372e1, 0x00000000d0d95fbd, 0x00000000d09f2c64, 0x00000000d064d8df, 0x00000000d02a6537, 0x00000000cfefd176, 0x00000000cfb51da3, 0x00000000cf7a49c8, 0x00000000cf3f55ef,
- 0x00000000cf044220, 0x00000000cec90e64, 0x00000000ce8dbac5, 0x00000000ce52474c, 0x00000000ce16b401, 0x00000000cddb00ef, 0x00000000cd9f2e1e, 0x00000000cd633b97, 0x00000000cd272964, 0x00000000cceaf78e,
- 0x00000000ccaea61e, 0x00000000cc72351e, 0x00000000cc35a497, 0x00000000cbf8f492, 0x00000000cbbc2519, 0x00000000cb7f3634, 0x00000000cb4227ee, 0x00000000cb04fa50, 0x00000000cac7ad63, 0x00000000ca8a4131,
- 0x00000000ca4cb5c3, 0x00000000ca0f0b22, 0x00000000c9d14159, 0x00000000c9935870, 0x00000000c9555072, 0x00000000c9172967, 0x00000000c8d8e35a, 0x00000000c89a7e53, 0x00000000c85bfa5e, 0x00000000c81d5782,
- 0x00000000c7de95cb, 0x00000000c79fb541, 0x00000000c760b5ee, 0x00000000c72197dc, 0x00000000c6e25b15, 0x00000000c6a2ffa3, 0x00000000c663858f, 0x00000000c623ece2, 0x00000000c5e435a8, 0x00000000c5a45fe9,
- 0x00000000c5646bb0, 0x00000000c5245906, 0x00000000c4e427f6, 0x00000000c4a3d888, 0x00000000c4636ac8, 0x00000000c422debf, 0x00000000c3e23476, 0x00000000c3a16bf9, 0x00000000c3608550, 0x00000000c31f8087,
- 0x00000000c2de5da6, 0x00000000c29d1cb8, 0x00000000c25bbdc8, 0x00000000c21a40de, 0x00000000c1d8a606, 0x00000000c196ed49, 0x00000000c15516b2, 0x00000000c113224a, 0x00000000c0d1101d, 0x00000000c08ee033,
- 0x00000000c04c9297, 0x00000000c00a2754, 0x00000000bfc79e73, 0x00000000bf84f800, 0x00000000bf423404, 0x00000000beff5289, 0x00000000bebc539a, 0x00000000be793741, 0x00000000be35fd89, 0x00000000bdf2a67b,
- 0x00000000bdaf3223, 0x00000000bd6ba08b, 0x00000000bd27f1bc, 0x00000000bce425c2, 0x00000000bca03ca7, 0x00000000bc5c3676, 0x00000000bc181338, 0x00000000bbd3d2f9, 0x00000000bb8f75c3, 0x00000000bb4afba1,
- 0x00000000bb06649c, 0x00000000bac1b0c0, 0x00000000ba7ce018, 0x00000000ba37f2ad, 0x00000000b9f2e88b, 0x00000000b9adc1bc, 0x00000000b9687e4a, 0x00000000b9231e41, 0x00000000b8dda1ac, 0x00000000b8980894,
- 0x00000000b8525305, 0x00000000b80c8109, 0x00000000b7c692ac, 0x00000000b78087f7, 0x00000000b73a60f6, 0x00000000b6f41db4, 0x00000000b6adbe3a, 0x00000000b6674296, 0x00000000b620aad0, 0x00000000b5d9f6f4,
- 0x00000000b593270e, 0x00000000b54c3b27, 0x00000000b505334a, 0x00000000b4be0f84, 0x00000000b476cfde, 0x00000000b42f7464, 0x00000000b3e7fd20, 0x00000000b3a06a1e, 0x00000000b358bb69, 0x00000000b310f10c,
- 0x00000000b2c90b11, 0x00000000b2810985, 0x00000000b238ec71, 0x00000000b1f0b3e2, 0x00000000b1a85fe2, 0x00000000b15ff07c, 0x00000000b11765bc, 0x00000000b0cebfad, 0x00000000b085fe5a, 0x00000000b03d21ce,
- 0x00000000aff42a15, 0x00000000afab1739, 0x00000000af61e946, 0x00000000af18a048, 0x00000000aecf3c49, 0x00000000ae85bd55, 0x00000000ae3c2377, 0x00000000adf26ebb, 0x00000000ada89f2c, 0x00000000ad5eb4d5,
- 0x00000000ad14afc2, 0x00000000acca8ffd, 0x00000000ac805594, 0x00000000ac360090, 0x00000000abeb90fe, 0x00000000aba106e9, 0x00000000ab56625d, 0x00000000ab0ba364, 0x00000000aac0ca0b, 0x00000000aa75d65d,
- 0x00000000aa2ac865, 0x00000000a9dfa030, 0x00000000a9945dc9, 0x00000000a949013a, 0x00000000a8fd8a91, 0x00000000a8b1f9d8, 0x00000000a8664f1c, 0x00000000a81a8a68, 0x00000000a7ceabc7, 0x00000000a782b345,
- 0x00000000a736a0ef, 0x00000000a6ea74cf, 0x00000000a69e2ef2, 0x00000000a651cf63, 0x00000000a605562f, 0x00000000a5b8c360, 0x00000000a56c1702, 0x00000000a51f5123, 0x00000000a4d271cc, 0x00000000a485790b,
- 0x00000000a43866eb, 0x00000000a3eb3b77, 0x00000000a39df6bd, 0x00000000a35098c7, 0x00000000a30321a2, 0x00000000a2b5915a, 0x00000000a267e7fa, 0x00000000a21a258e, 0x00000000a1cc4a24, 0x00000000a17e55c5,
- 0x00000000a1304880, 0x00000000a0e2225f, 0x00000000a093e36f, 0x00000000a0458bbb, 0x000000009ff71b50, 0x000000009fa8923a, 0x000000009f59f086, 0x000000009f0b363e, 0x000000009ebc6370, 0x000000009e6d7827,
- 0x000000009e1e746f, 0x000000009dcf5856, 0x000000009d8023e6, 0x000000009d30d72d, 0x000000009ce17236, 0x000000009c91f50e, 0x000000009c425fc1, 0x000000009bf2b25b, 0x000000009ba2ece8, 0x000000009b530f76,
- 0x000000009b031a0f, 0x000000009ab30cc1, 0x000000009a62e797, 0x000000009a12aa9f, 0x0000000099c255e5, 0x000000009971e974, 0x000000009921655a, 0x0000000098d0c9a2, 0x0000000098801659, 0x00000000982f4b8d,
- 0x0000000097de6948, 0x00000000978d6f97, 0x00000000973c5e88, 0x0000000096eb3626, 0x000000009699f67f, 0x0000000096489f9e, 0x0000000095f73190, 0x0000000095a5ac61, 0x000000009554101f, 0x0000000095025cd6,
- 0x0000000094b09292, 0x00000000945eb161, 0x00000000940cb94e, 0x0000000093baaa66, 0x00000000936884b6, 0x000000009316484b, 0x0000000092c3f531, 0x0000000092718b75, 0x00000000921f0b24, 0x0000000091cc744b,
- 0x000000009179c6f5, 0x0000000091270331, 0x0000000090d4290a, 0x000000009081388e, 0x00000000902e31c8, 0x000000008fdb14c7, 0x000000008f87e197, 0x000000008f349845, 0x000000008ee138dd, 0x000000008e8dc36c,
- 0x000000008e3a3800, 0x000000008de696a5, 0x000000008d92df68, 0x000000008d3f1256, 0x000000008ceb2f7c, 0x000000008c9736e7, 0x000000008c4328a3, 0x000000008bef04bf, 0x000000008b9acb46, 0x000000008b467c45,
- 0x000000008af217cb, 0x000000008a9d9de3, 0x000000008a490e9b, 0x0000000089f469ff, 0x00000000899fb01e, 0x00000000894ae103, 0x0000000088f5fcbc, 0x0000000088a10357, 0x00000000884bf4df, 0x0000000087f6d163,
- 0x0000000087a198f0, 0x00000000874c4b92, 0x0000000086f6e956, 0x0000000086a1724b, 0x00000000864be67c, 0x0000000085f645f8, 0x0000000085a090cc, 0x00000000854ac704, 0x0000000084f4e8ad, 0x00000000849ef5d7,
- 0x000000008448ee8c, 0x0000000083f2d2db, 0x00000000839ca2d1, 0x0000000083465e7c, 0x0000000082f005e8, 0x0000000082999922, 0x0000000082431839, 0x0000000081ec833a, 0x000000008195da31, 0x00000000813f1d2d,
- 0x0000000080e84c3a, 0x0000000080916766, 0x00000000803a6ebf, 0x000000007fe36251, 0x000000007f8c422b, 0x000000007f350e59, 0x000000007eddc6ea, 0x000000007e866bea, 0x000000007e2efd67, 0x000000007dd77b6f,
- 0x000000007d7fe60f, 0x000000007d283d54, 0x000000007cd0814c, 0x000000007c78b205, 0x000000007c20cf8c, 0x000000007bc8d9ef, 0x000000007b70d13b, 0x000000007b18b57e, 0x000000007ac086c5, 0x000000007a68451f,
- 0x000000007a0ff098, 0x0000000079b7893e, 0x00000000795f0f1f, 0x0000000079068248, 0x0000000078ade2c8, 0x00000000785530ab, 0x0000000077fc6c01, 0x0000000077a394d5, 0x00000000774aab36, 0x0000000076f1af32,
- 0x000000007698a0d6, 0x00000000763f8030, 0x0000000075e64d4e, 0x00000000758d083e, 0x000000007533b10d, 0x0000000074da47c9, 0x000000007480cc80, 0x0000000074273f3f, 0x0000000073cda016, 0x000000007373ef10,
- 0x00000000731a2c3d, 0x0000000072c057aa, 0x0000000072667164, 0x00000000720c797a, 0x0000000071b26ffa, 0x00000000715854f2, 0x0000000070fe286e, 0x0000000070a3ea7e, 0x0000000070499b30, 0x000000006fef3a90,
- 0x000000006f94c8ae, 0x000000006f3a4596, 0x000000006edfb157, 0x000000006e850c00, 0x000000006e2a559d, 0x000000006dcf8e3d, 0x000000006d74b5ee, 0x000000006d19ccbe, 0x000000006cbed2bb, 0x000000006c63c7f3,
- 0x000000006c08ac74, 0x000000006bad804c, 0x000000006b524389, 0x000000006af6f639, 0x000000006a9b986b, 0x000000006a402a2c, 0x0000000069e4ab8a, 0x0000000069891c94, 0x00000000692d7d57, 0x0000000068d1cde3,
- 0x0000000068760e44, 0x00000000681a3e89, 0x0000000067be5ec1, 0x0000000067626ef9, 0x0000000067066f40, 0x0000000066aa5fa3, 0x00000000664e4032, 0x0000000065f210f9, 0x000000006595d209, 0x000000006539836d,
- 0x0000000064dd2536, 0x000000006480b770, 0x0000000064243a2b, 0x0000000063c7ad75, 0x00000000636b115c, 0x00000000630e65ed, 0x0000000062b1ab39, 0x000000006254e14c, 0x0000000061f80835, 0x00000000619b2002,
- 0x00000000613e28c2, 0x0000000060e12283, 0x0000000060840d54, 0x000000006026e943, 0x000000005fc9b65d, 0x000000005f6c74b2, 0x000000005f0f2450, 0x000000005eb1c545, 0x000000005e5457a0, 0x000000005df6db6f,
- 0x000000005d9950c0, 0x000000005d3bb7a3, 0x000000005cde1024, 0x000000005c805a54, 0x000000005c22963f, 0x000000005bc4c3f6, 0x000000005b66e385, 0x000000005b08f4fd, 0x000000005aaaf86a, 0x000000005a4ceddc,
- 0x0000000059eed561, 0x000000005990af08, 0x0000000059327adf, 0x0000000058d438f4, 0x000000005875e957, 0x0000000058178c16, 0x0000000057b9213f, 0x00000000575aa8e0, 0x0000000056fc230a, 0x00000000569d8fc9,
- 0x00000000563eef2d, 0x0000000055e04144, 0x000000005581861d, 0x000000005522bdc6, 0x0000000054c3e84e, 0x00000000546505c4, 0x0000000054061636, 0x0000000053a719b3, 0x000000005348104a, 0x0000000052e8fa09,
- 0x000000005289d6ff, 0x00000000522aa73a, 0x0000000051cb6aca, 0x00000000516c21bc, 0x00000000510ccc20, 0x0000000050ad6a05, 0x00000000504dfb78, 0x000000004fee808a, 0x000000004f8ef947, 0x000000004f2f65c0,
- 0x000000004ecfc603, 0x000000004e701a1f, 0x000000004e106222, 0x000000004db09e1b, 0x000000004d50ce19, 0x000000004cf0f22b, 0x000000004c910a5f, 0x000000004c3116c5, 0x000000004bd1176b, 0x000000004b710c5f,
- 0x000000004b10f5b2, 0x000000004ab0d371, 0x000000004a50a5ab, 0x0000000049f06c70, 0x00000000499027cd, 0x00000000492fd7d3, 0x0000000048cf7c8f, 0x00000000486f1611, 0x00000000480ea467, 0x0000000047ae27a1,
- 0x00000000474d9fcd, 0x0000000046ed0cfa, 0x00000000468c6f37, 0x00000000462bc693, 0x0000000045cb131c, 0x00000000456a54e3, 0x0000000045098bf5, 0x0000000044a8b861, 0x000000004447da37, 0x0000000043e6f186,
- 0x000000004385fe5c, 0x00000000432500c8, 0x0000000042c3f8d9, 0x000000004262e69f, 0x000000004201ca28, 0x0000000041a0a383, 0x00000000413f72bf, 0x0000000040de37eb, 0x00000000407cf317, 0x00000000401ba450,
- 0x000000003fba4ba7, 0x000000003f58e92a, 0x000000003ef77ce8, 0x000000003e9606f1, 0x000000003e348752, 0x000000003dd2fe1c, 0x000000003d716b5e, 0x000000003d0fcf25, 0x000000003cae2982, 0x000000003c4c7a83,
- 0x000000003beac238, 0x000000003b8900b0, 0x000000003b2735f9, 0x000000003ac56223, 0x000000003a63853d, 0x000000003a019f56, 0x00000000399fb07d, 0x00000000393db8c1, 0x0000000038dbb831, 0x000000003879aedd,
- 0x0000000038179cd3, 0x0000000037b58222, 0x0000000037535edb, 0x0000000036f1330b, 0x00000000368efec2, 0x00000000362cc20f, 0x0000000035ca7d02, 0x0000000035682fa9, 0x000000003505da14, 0x0000000034a37c51,
- 0x0000000034411671, 0x0000000033dea881, 0x00000000337c3292, 0x000000003319b4b3, 0x0000000032b72ef2, 0x000000003254a15e, 0x0000000031f20c08, 0x00000000318f6efe, 0x00000000312cca50, 0x0000000030ca1e0c,
- 0x0000000030676a43, 0x000000003004af02, 0x000000002fa1ec5a, 0x000000002f3f2259, 0x000000002edc510f, 0x000000002e79788b, 0x000000002e1698dc, 0x000000002db3b212, 0x000000002d50c43c, 0x000000002cedcf68,
- 0x000000002c8ad3a7, 0x000000002c27d108, 0x000000002bc4c799, 0x000000002b61b76b, 0x000000002afea08c, 0x000000002a9b830b, 0x000000002a385ef9, 0x0000000029d53464, 0x000000002972035b, 0x00000000290ecbee,
- 0x0000000028ab8e2c, 0x0000000028484a25, 0x0000000027e4ffe7, 0x000000002781af83, 0x00000000271e5906, 0x0000000026bafc82, 0x0000000026579a04, 0x0000000025f4319d, 0x000000002590c35c, 0x00000000252d4f4f,
- 0x0000000024c9d587, 0x0000000024665613, 0x000000002402d101, 0x00000000239f4662, 0x00000000233bb644, 0x0000000022d820b8, 0x00000000227485cc, 0x000000002210e590, 0x0000000021ad4013, 0x0000000021499565,
- 0x0000000020e5e594, 0x00000000208230b1, 0x00000000201e76ca, 0x000000001fbab7ef, 0x000000001f56f430, 0x000000001ef32b9b, 0x000000001e8f5e41, 0x000000001e2b8c30, 0x000000001dc7b578, 0x000000001d63da29,
- 0x000000001cfffa51, 0x000000001c9c1600, 0x000000001c382d46, 0x000000001bd44032, 0x000000001b704ed3, 0x000000001b0c5939, 0x000000001aa85f74, 0x000000001a446191, 0x0000000019e05fa2, 0x00000000197c59b5,
- 0x0000000019184fdb, 0x0000000018b44221, 0x0000000018503098, 0x0000000017ec1b50, 0x0000000017880257, 0x000000001723e5bd, 0x0000000016bfc591, 0x00000000165ba1e4, 0x0000000015f77ac3, 0x0000000015935040,
- 0x00000000152f2269, 0x0000000014caf14d, 0x000000001466bcfd, 0x0000000014028587, 0x00000000139e4afb, 0x00000000133a0d69, 0x0000000012d5cce0, 0x000000001271896f, 0x00000000120d4326, 0x0000000011a8fa15,
- 0x000000001144ae4a, 0x0000000010e05fd6, 0x00000000107c0ec7, 0x000000001017bb2d, 0x000000000fb36519, 0x000000000f4f0c98, 0x000000000eeab1bb, 0x000000000e865491, 0x000000000e21f52a, 0x000000000dbd9395,
- 0x000000000d592fe1, 0x000000000cf4ca1f, 0x000000000c90625c, 0x000000000c2bf8aa, 0x000000000bc78d18, 0x000000000b631fb4, 0x000000000afeb08f, 0x000000000a9a3fb8, 0x000000000a35cd3e, 0x0000000009d15931,
- 0x00000000096ce3a1, 0x0000000009086c9c, 0x0000000008a3f433, 0x00000000083f7a75, 0x0000000007daff71, 0x0000000007768337, 0x00000000071205d6, 0x0000000006ad875f, 0x00000000064907df, 0x0000000005e48768,
- 0x0000000005800608, 0x00000000051b83cf, 0x0000000004b700cc, 0x0000000004527d0f, 0x0000000003edf8a7, 0x00000000038973a4, 0x000000000324ee16, 0x0000000002c0680b, 0x00000000025be194, 0x0000000001f75ac0,
- 0x000000000192d39e, 0x00000000012e4c3e, 0x0000000000c9c4af, 0x0000000000653d02, 0x0000000000000000
- };
+{
+ 0x0000000100000000, 0x00000000ffffec43, 0x00000000ffffb10b,
+ 0x00000000ffff4e5a, 0x00000000fffec42e, 0x00000000fffe1287,
+ 0x00000000fffd3967, 0x00000000fffc38cd, 0x00000000fffb10b9,
+ 0x00000000fff9c12c,
+ 0x00000000fff84a25, 0x00000000fff6aba5, 0x00000000fff4e5ac,
+ 0x00000000fff2f83b, 0x00000000fff0e351, 0x00000000ffeea6ef,
+ 0x00000000ffec4316, 0x00000000ffe9b7c5, 0x00000000ffe704fe,
+ 0x00000000ffe42ac0,
+ 0x00000000ffe1290b, 0x00000000ffddffe2, 0x00000000ffdaaf43,
+ 0x00000000ffd7372f, 0x00000000ffd397a8, 0x00000000ffcfd0ad,
+ 0x00000000ffcbe23f, 0x00000000ffc7cc5f, 0x00000000ffc38f0d,
+ 0x00000000ffbf2a4b,
+ 0x00000000ffba9e17, 0x00000000ffb5ea75, 0x00000000ffb10f63,
+ 0x00000000ffac0ce3, 0x00000000ffa6e2f6, 0x00000000ffa1919c,
+ 0x00000000ff9c18d6, 0x00000000ff9678a6, 0x00000000ff90b10b,
+ 0x00000000ff8ac208,
+ 0x00000000ff84ab9c, 0x00000000ff7e6dc8, 0x00000000ff78088f,
+ 0x00000000ff717bf0, 0x00000000ff6ac7ec, 0x00000000ff63ec85,
+ 0x00000000ff5ce9bc, 0x00000000ff55bf92, 0x00000000ff4e6e08,
+ 0x00000000ff46f51f,
+ 0x00000000ff3f54d8, 0x00000000ff378d34, 0x00000000ff2f9e35,
+ 0x00000000ff2787dc, 0x00000000ff1f4a2a, 0x00000000ff16e520,
+ 0x00000000ff0e58c0, 0x00000000ff05a50a, 0x00000000fefcca01,
+ 0x00000000fef3c7a6,
+ 0x00000000feea9df9, 0x00000000fee14cfe, 0x00000000fed7d4b3,
+ 0x00000000fece351d, 0x00000000fec46e3b, 0x00000000feba800f,
+ 0x00000000feb06a9c, 0x00000000fea62de1, 0x00000000fe9bc9e2,
+ 0x00000000fe913e9f,
+ 0x00000000fe868c1b, 0x00000000fe7bb256, 0x00000000fe70b153,
+ 0x00000000fe658913, 0x00000000fe5a3998, 0x00000000fe4ec2e4,
+ 0x00000000fe4324f9, 0x00000000fe375fd7, 0x00000000fe2b7382,
+ 0x00000000fe1f5ffa,
+ 0x00000000fe132543, 0x00000000fe06c35d, 0x00000000fdfa3a4b,
+ 0x00000000fded8a0e, 0x00000000fde0b2a8, 0x00000000fdd3b41c,
+ 0x00000000fdc68e6c, 0x00000000fdb94199, 0x00000000fdabcda5,
+ 0x00000000fd9e3294,
+ 0x00000000fd907065, 0x00000000fd82871d, 0x00000000fd7476bd,
+ 0x00000000fd663f46, 0x00000000fd57e0bd, 0x00000000fd495b21,
+ 0x00000000fd3aae77, 0x00000000fd2bdabf, 0x00000000fd1cdffd,
+ 0x00000000fd0dbe32,
+ 0x00000000fcfe7562, 0x00000000fcef058e, 0x00000000fcdf6eb8,
+ 0x00000000fccfb0e4, 0x00000000fcbfcc13, 0x00000000fcafc048,
+ 0x00000000fc9f8d86, 0x00000000fc8f33ce, 0x00000000fc7eb325,
+ 0x00000000fc6e0b8b,
+ 0x00000000fc5d3d03, 0x00000000fc4c4791, 0x00000000fc3b2b37,
+ 0x00000000fc29e7f7, 0x00000000fc187dd5, 0x00000000fc06ecd2,
+ 0x00000000fbf534f2, 0x00000000fbe35637, 0x00000000fbd150a3,
+ 0x00000000fbbf243b,
+ 0x00000000fbacd100, 0x00000000fb9a56f6, 0x00000000fb87b61f,
+ 0x00000000fb74ee7e, 0x00000000fb620016, 0x00000000fb4eeaea,
+ 0x00000000fb3baefd, 0x00000000fb284c52, 0x00000000fb14c2eb,
+ 0x00000000fb0112cd,
+ 0x00000000faed3bf9, 0x00000000fad93e73, 0x00000000fac51a3f,
+ 0x00000000fab0cf5e, 0x00000000fa9c5dd5, 0x00000000fa87c5a6,
+ 0x00000000fa7306d5, 0x00000000fa5e2164, 0x00000000fa491558,
+ 0x00000000fa33e2b3,
+ 0x00000000fa1e8978, 0x00000000fa0909ab, 0x00000000f9f36350,
+ 0x00000000f9dd9668, 0x00000000f9c7a2f9, 0x00000000f9b18905,
+ 0x00000000f99b488f, 0x00000000f984e19c, 0x00000000f96e542e,
+ 0x00000000f957a049,
+ 0x00000000f940c5f1, 0x00000000f929c528, 0x00000000f9129df3,
+ 0x00000000f8fb5056, 0x00000000f8e3dc53, 0x00000000f8cc41ee,
+ 0x00000000f8b4812b, 0x00000000f89c9a0e, 0x00000000f8848c9b,
+ 0x00000000f86c58d4,
+ 0x00000000f853febe, 0x00000000f83b7e5d, 0x00000000f822d7b4,
+ 0x00000000f80a0ac7, 0x00000000f7f1179a, 0x00000000f7d7fe31,
+ 0x00000000f7bebe90, 0x00000000f7a558ba, 0x00000000f78bccb3,
+ 0x00000000f7721a80,
+ 0x00000000f7584225, 0x00000000f73e43a5, 0x00000000f7241f04,
+ 0x00000000f709d446, 0x00000000f6ef6370, 0x00000000f6d4cc85,
+ 0x00000000f6ba0f8a, 0x00000000f69f2c83, 0x00000000f6842374,
+ 0x00000000f668f461,
+ 0x00000000f64d9f4e, 0x00000000f632243f, 0x00000000f616833a,
+ 0x00000000f5fabc41, 0x00000000f5decf59, 0x00000000f5c2bc87,
+ 0x00000000f5a683cf, 0x00000000f58a2535, 0x00000000f56da0be,
+ 0x00000000f550f66e,
+ 0x00000000f5342649, 0x00000000f5173054, 0x00000000f4fa1494,
+ 0x00000000f4dcd30c, 0x00000000f4bf6bc2, 0x00000000f4a1deb9,
+ 0x00000000f4842bf7, 0x00000000f4665380, 0x00000000f4485559,
+ 0x00000000f42a3186,
+ 0x00000000f40be80c, 0x00000000f3ed78ef, 0x00000000f3cee434,
+ 0x00000000f3b029e1, 0x00000000f39149f9, 0x00000000f3724482,
+ 0x00000000f3531980, 0x00000000f333c8f8, 0x00000000f31452ef,
+ 0x00000000f2f4b76a,
+ 0x00000000f2d4f66d, 0x00000000f2b50ffe, 0x00000000f2950421,
+ 0x00000000f274d2dc, 0x00000000f2547c33, 0x00000000f234002b,
+ 0x00000000f2135eca, 0x00000000f1f29814, 0x00000000f1d1ac0e,
+ 0x00000000f1b09abe,
+ 0x00000000f18f6429, 0x00000000f16e0853, 0x00000000f14c8742,
+ 0x00000000f12ae0fb, 0x00000000f1091583, 0x00000000f0e724e0,
+ 0x00000000f0c50f17, 0x00000000f0a2d42c, 0x00000000f0807426,
+ 0x00000000f05def09,
+ 0x00000000f03b44db, 0x00000000f01875a1, 0x00000000eff58161,
+ 0x00000000efd2681f, 0x00000000efaf29e2, 0x00000000ef8bc6af,
+ 0x00000000ef683e8b, 0x00000000ef44917b, 0x00000000ef20bf86,
+ 0x00000000eefcc8b1,
+ 0x00000000eed8ad01, 0x00000000eeb46c7b, 0x00000000ee900727,
+ 0x00000000ee6b7d08, 0x00000000ee46ce25, 0x00000000ee21fa83,
+ 0x00000000edfd0228, 0x00000000edd7e51a, 0x00000000edb2a35f,
+ 0x00000000ed8d3cfc,
+ 0x00000000ed67b1f6, 0x00000000ed420255, 0x00000000ed1c2e1d,
+ 0x00000000ecf63554, 0x00000000ecd01801, 0x00000000eca9d628,
+ 0x00000000ec836fd1, 0x00000000ec5ce501, 0x00000000ec3635bd,
+ 0x00000000ec0f620d,
+ 0x00000000ebe869f5, 0x00000000ebc14d7d, 0x00000000eb9a0ca9,
+ 0x00000000eb72a780, 0x00000000eb4b1e08, 0x00000000eb237047,
+ 0x00000000eafb9e43, 0x00000000ead3a803, 0x00000000eaab8d8d,
+ 0x00000000ea834ee6,
+ 0x00000000ea5aec15, 0x00000000ea326520, 0x00000000ea09ba0d,
+ 0x00000000e9e0eae4, 0x00000000e9b7f7a9, 0x00000000e98ee063,
+ 0x00000000e965a51a, 0x00000000e93c45d2, 0x00000000e912c292,
+ 0x00000000e8e91b61,
+ 0x00000000e8bf5046, 0x00000000e8956146, 0x00000000e86b4e68,
+ 0x00000000e84117b3, 0x00000000e816bd2d, 0x00000000e7ec3edc,
+ 0x00000000e7c19cc8, 0x00000000e796d6f6, 0x00000000e76bed6e,
+ 0x00000000e740e036,
+ 0x00000000e715af54, 0x00000000e6ea5ad0, 0x00000000e6bee2af,
+ 0x00000000e69346f9, 0x00000000e66787b5, 0x00000000e63ba4e9,
+ 0x00000000e60f9e9b, 0x00000000e5e374d4, 0x00000000e5b72798,
+ 0x00000000e58ab6f1,
+ 0x00000000e55e22e3, 0x00000000e5316b76, 0x00000000e50490b1,
+ 0x00000000e4d7929c, 0x00000000e4aa713c, 0x00000000e47d2c98,
+ 0x00000000e44fc4b9, 0x00000000e42239a4, 0x00000000e3f48b61,
+ 0x00000000e3c6b9f7,
+ 0x00000000e398c56c, 0x00000000e36aadc9, 0x00000000e33c7314,
+ 0x00000000e30e1554, 0x00000000e2df9490, 0x00000000e2b0f0d0,
+ 0x00000000e2822a1a, 0x00000000e2534077, 0x00000000e22433ec,
+ 0x00000000e1f50482,
+ 0x00000000e1c5b240, 0x00000000e1963d2d, 0x00000000e166a550,
+ 0x00000000e136eab0, 0x00000000e1070d56, 0x00000000e0d70d48,
+ 0x00000000e0a6ea8e, 0x00000000e076a52f, 0x00000000e0463d33,
+ 0x00000000e015b2a1,
+ 0x00000000dfe50580, 0x00000000dfb435d9, 0x00000000df8343b2,
+ 0x00000000df522f13, 0x00000000df20f804, 0x00000000deef9e8d,
+ 0x00000000debe22b5, 0x00000000de8c8483, 0x00000000de5ac3ff,
+ 0x00000000de28e131,
+ 0x00000000ddf6dc21, 0x00000000ddc4b4d6, 0x00000000dd926b59,
+ 0x00000000dd5fffb0, 0x00000000dd2d71e3, 0x00000000dcfac1fb,
+ 0x00000000dcc7f000, 0x00000000dc94fbf8, 0x00000000dc61e5ec,
+ 0x00000000dc2eade4,
+ 0x00000000dbfb53e8, 0x00000000dbc7d7ff, 0x00000000db943a31,
+ 0x00000000db607a88, 0x00000000db2c9909, 0x00000000daf895bf,
+ 0x00000000dac470af, 0x00000000da9029e3, 0x00000000da5bc163,
+ 0x00000000da273737,
+ 0x00000000d9f28b66, 0x00000000d9bdbdf9, 0x00000000d988cef8,
+ 0x00000000d953be6b, 0x00000000d91e8c5b, 0x00000000d8e938d0,
+ 0x00000000d8b3c3d1, 0x00000000d87e2d67, 0x00000000d848759b,
+ 0x00000000d8129c74,
+ 0x00000000d7dca1fb, 0x00000000d7a68638, 0x00000000d7704934,
+ 0x00000000d739eaf7, 0x00000000d7036b89, 0x00000000d6cccaf3,
+ 0x00000000d696093d, 0x00000000d65f266f, 0x00000000d6282293,
+ 0x00000000d5f0fdb0,
+ 0x00000000d5b9b7d0, 0x00000000d58250fa, 0x00000000d54ac937,
+ 0x00000000d513208f, 0x00000000d4db570c, 0x00000000d4a36cb6,
+ 0x00000000d46b6195, 0x00000000d43335b3, 0x00000000d3fae917,
+ 0x00000000d3c27bcb,
+ 0x00000000d389edd7, 0x00000000d3513f43, 0x00000000d318701a,
+ 0x00000000d2df8063, 0x00000000d2a67027, 0x00000000d26d3f6f,
+ 0x00000000d233ee43, 0x00000000d1fa7cae, 0x00000000d1c0eab7,
+ 0x00000000d1873867,
+ 0x00000000d14d65c8, 0x00000000d11372e1, 0x00000000d0d95fbd,
+ 0x00000000d09f2c64, 0x00000000d064d8df, 0x00000000d02a6537,
+ 0x00000000cfefd176, 0x00000000cfb51da3, 0x00000000cf7a49c8,
+ 0x00000000cf3f55ef,
+ 0x00000000cf044220, 0x00000000cec90e64, 0x00000000ce8dbac5,
+ 0x00000000ce52474c, 0x00000000ce16b401, 0x00000000cddb00ef,
+ 0x00000000cd9f2e1e, 0x00000000cd633b97, 0x00000000cd272964,
+ 0x00000000cceaf78e,
+ 0x00000000ccaea61e, 0x00000000cc72351e, 0x00000000cc35a497,
+ 0x00000000cbf8f492, 0x00000000cbbc2519, 0x00000000cb7f3634,
+ 0x00000000cb4227ee, 0x00000000cb04fa50, 0x00000000cac7ad63,
+ 0x00000000ca8a4131,
+ 0x00000000ca4cb5c3, 0x00000000ca0f0b22, 0x00000000c9d14159,
+ 0x00000000c9935870, 0x00000000c9555072, 0x00000000c9172967,
+ 0x00000000c8d8e35a, 0x00000000c89a7e53, 0x00000000c85bfa5e,
+ 0x00000000c81d5782,
+ 0x00000000c7de95cb, 0x00000000c79fb541, 0x00000000c760b5ee,
+ 0x00000000c72197dc, 0x00000000c6e25b15, 0x00000000c6a2ffa3,
+ 0x00000000c663858f, 0x00000000c623ece2, 0x00000000c5e435a8,
+ 0x00000000c5a45fe9,
+ 0x00000000c5646bb0, 0x00000000c5245906, 0x00000000c4e427f6,
+ 0x00000000c4a3d888, 0x00000000c4636ac8, 0x00000000c422debf,
+ 0x00000000c3e23476, 0x00000000c3a16bf9, 0x00000000c3608550,
+ 0x00000000c31f8087,
+ 0x00000000c2de5da6, 0x00000000c29d1cb8, 0x00000000c25bbdc8,
+ 0x00000000c21a40de, 0x00000000c1d8a606, 0x00000000c196ed49,
+ 0x00000000c15516b2, 0x00000000c113224a, 0x00000000c0d1101d,
+ 0x00000000c08ee033,
+ 0x00000000c04c9297, 0x00000000c00a2754, 0x00000000bfc79e73,
+ 0x00000000bf84f800, 0x00000000bf423404, 0x00000000beff5289,
+ 0x00000000bebc539a, 0x00000000be793741, 0x00000000be35fd89,
+ 0x00000000bdf2a67b,
+ 0x00000000bdaf3223, 0x00000000bd6ba08b, 0x00000000bd27f1bc,
+ 0x00000000bce425c2, 0x00000000bca03ca7, 0x00000000bc5c3676,
+ 0x00000000bc181338, 0x00000000bbd3d2f9, 0x00000000bb8f75c3,
+ 0x00000000bb4afba1,
+ 0x00000000bb06649c, 0x00000000bac1b0c0, 0x00000000ba7ce018,
+ 0x00000000ba37f2ad, 0x00000000b9f2e88b, 0x00000000b9adc1bc,
+ 0x00000000b9687e4a, 0x00000000b9231e41, 0x00000000b8dda1ac,
+ 0x00000000b8980894,
+ 0x00000000b8525305, 0x00000000b80c8109, 0x00000000b7c692ac,
+ 0x00000000b78087f7, 0x00000000b73a60f6, 0x00000000b6f41db4,
+ 0x00000000b6adbe3a, 0x00000000b6674296, 0x00000000b620aad0,
+ 0x00000000b5d9f6f4,
+ 0x00000000b593270e, 0x00000000b54c3b27, 0x00000000b505334a,
+ 0x00000000b4be0f84, 0x00000000b476cfde, 0x00000000b42f7464,
+ 0x00000000b3e7fd20, 0x00000000b3a06a1e, 0x00000000b358bb69,
+ 0x00000000b310f10c,
+ 0x00000000b2c90b11, 0x00000000b2810985, 0x00000000b238ec71,
+ 0x00000000b1f0b3e2, 0x00000000b1a85fe2, 0x00000000b15ff07c,
+ 0x00000000b11765bc, 0x00000000b0cebfad, 0x00000000b085fe5a,
+ 0x00000000b03d21ce,
+ 0x00000000aff42a15, 0x00000000afab1739, 0x00000000af61e946,
+ 0x00000000af18a048, 0x00000000aecf3c49, 0x00000000ae85bd55,
+ 0x00000000ae3c2377, 0x00000000adf26ebb, 0x00000000ada89f2c,
+ 0x00000000ad5eb4d5,
+ 0x00000000ad14afc2, 0x00000000acca8ffd, 0x00000000ac805594,
+ 0x00000000ac360090, 0x00000000abeb90fe, 0x00000000aba106e9,
+ 0x00000000ab56625d, 0x00000000ab0ba364, 0x00000000aac0ca0b,
+ 0x00000000aa75d65d,
+ 0x00000000aa2ac865, 0x00000000a9dfa030, 0x00000000a9945dc9,
+ 0x00000000a949013a, 0x00000000a8fd8a91, 0x00000000a8b1f9d8,
+ 0x00000000a8664f1c, 0x00000000a81a8a68, 0x00000000a7ceabc7,
+ 0x00000000a782b345,
+ 0x00000000a736a0ef, 0x00000000a6ea74cf, 0x00000000a69e2ef2,
+ 0x00000000a651cf63, 0x00000000a605562f, 0x00000000a5b8c360,
+ 0x00000000a56c1702, 0x00000000a51f5123, 0x00000000a4d271cc,
+ 0x00000000a485790b,
+ 0x00000000a43866eb, 0x00000000a3eb3b77, 0x00000000a39df6bd,
+ 0x00000000a35098c7, 0x00000000a30321a2, 0x00000000a2b5915a,
+ 0x00000000a267e7fa, 0x00000000a21a258e, 0x00000000a1cc4a24,
+ 0x00000000a17e55c5,
+ 0x00000000a1304880, 0x00000000a0e2225f, 0x00000000a093e36f,
+ 0x00000000a0458bbb, 0x000000009ff71b50, 0x000000009fa8923a,
+ 0x000000009f59f086, 0x000000009f0b363e, 0x000000009ebc6370,
+ 0x000000009e6d7827,
+ 0x000000009e1e746f, 0x000000009dcf5856, 0x000000009d8023e6,
+ 0x000000009d30d72d, 0x000000009ce17236, 0x000000009c91f50e,
+ 0x000000009c425fc1, 0x000000009bf2b25b, 0x000000009ba2ece8,
+ 0x000000009b530f76,
+ 0x000000009b031a0f, 0x000000009ab30cc1, 0x000000009a62e797,
+ 0x000000009a12aa9f, 0x0000000099c255e5, 0x000000009971e974,
+ 0x000000009921655a, 0x0000000098d0c9a2, 0x0000000098801659,
+ 0x00000000982f4b8d,
+ 0x0000000097de6948, 0x00000000978d6f97, 0x00000000973c5e88,
+ 0x0000000096eb3626, 0x000000009699f67f, 0x0000000096489f9e,
+ 0x0000000095f73190, 0x0000000095a5ac61, 0x000000009554101f,
+ 0x0000000095025cd6,
+ 0x0000000094b09292, 0x00000000945eb161, 0x00000000940cb94e,
+ 0x0000000093baaa66, 0x00000000936884b6, 0x000000009316484b,
+ 0x0000000092c3f531, 0x0000000092718b75, 0x00000000921f0b24,
+ 0x0000000091cc744b,
+ 0x000000009179c6f5, 0x0000000091270331, 0x0000000090d4290a,
+ 0x000000009081388e, 0x00000000902e31c8, 0x000000008fdb14c7,
+ 0x000000008f87e197, 0x000000008f349845, 0x000000008ee138dd,
+ 0x000000008e8dc36c,
+ 0x000000008e3a3800, 0x000000008de696a5, 0x000000008d92df68,
+ 0x000000008d3f1256, 0x000000008ceb2f7c, 0x000000008c9736e7,
+ 0x000000008c4328a3, 0x000000008bef04bf, 0x000000008b9acb46,
+ 0x000000008b467c45,
+ 0x000000008af217cb, 0x000000008a9d9de3, 0x000000008a490e9b,
+ 0x0000000089f469ff, 0x00000000899fb01e, 0x00000000894ae103,
+ 0x0000000088f5fcbc, 0x0000000088a10357, 0x00000000884bf4df,
+ 0x0000000087f6d163,
+ 0x0000000087a198f0, 0x00000000874c4b92, 0x0000000086f6e956,
+ 0x0000000086a1724b, 0x00000000864be67c, 0x0000000085f645f8,
+ 0x0000000085a090cc, 0x00000000854ac704, 0x0000000084f4e8ad,
+ 0x00000000849ef5d7,
+ 0x000000008448ee8c, 0x0000000083f2d2db, 0x00000000839ca2d1,
+ 0x0000000083465e7c, 0x0000000082f005e8, 0x0000000082999922,
+ 0x0000000082431839, 0x0000000081ec833a, 0x000000008195da31,
+ 0x00000000813f1d2d,
+ 0x0000000080e84c3a, 0x0000000080916766, 0x00000000803a6ebf,
+ 0x000000007fe36251, 0x000000007f8c422b, 0x000000007f350e59,
+ 0x000000007eddc6ea, 0x000000007e866bea, 0x000000007e2efd67,
+ 0x000000007dd77b6f,
+ 0x000000007d7fe60f, 0x000000007d283d54, 0x000000007cd0814c,
+ 0x000000007c78b205, 0x000000007c20cf8c, 0x000000007bc8d9ef,
+ 0x000000007b70d13b, 0x000000007b18b57e, 0x000000007ac086c5,
+ 0x000000007a68451f,
+ 0x000000007a0ff098, 0x0000000079b7893e, 0x00000000795f0f1f,
+ 0x0000000079068248, 0x0000000078ade2c8, 0x00000000785530ab,
+ 0x0000000077fc6c01, 0x0000000077a394d5, 0x00000000774aab36,
+ 0x0000000076f1af32,
+ 0x000000007698a0d6, 0x00000000763f8030, 0x0000000075e64d4e,
+ 0x00000000758d083e, 0x000000007533b10d, 0x0000000074da47c9,
+ 0x000000007480cc80, 0x0000000074273f3f, 0x0000000073cda016,
+ 0x000000007373ef10,
+ 0x00000000731a2c3d, 0x0000000072c057aa, 0x0000000072667164,
+ 0x00000000720c797a, 0x0000000071b26ffa, 0x00000000715854f2,
+ 0x0000000070fe286e, 0x0000000070a3ea7e, 0x0000000070499b30,
+ 0x000000006fef3a90,
+ 0x000000006f94c8ae, 0x000000006f3a4596, 0x000000006edfb157,
+ 0x000000006e850c00, 0x000000006e2a559d, 0x000000006dcf8e3d,
+ 0x000000006d74b5ee, 0x000000006d19ccbe, 0x000000006cbed2bb,
+ 0x000000006c63c7f3,
+ 0x000000006c08ac74, 0x000000006bad804c, 0x000000006b524389,
+ 0x000000006af6f639, 0x000000006a9b986b, 0x000000006a402a2c,
+ 0x0000000069e4ab8a, 0x0000000069891c94, 0x00000000692d7d57,
+ 0x0000000068d1cde3,
+ 0x0000000068760e44, 0x00000000681a3e89, 0x0000000067be5ec1,
+ 0x0000000067626ef9, 0x0000000067066f40, 0x0000000066aa5fa3,
+ 0x00000000664e4032, 0x0000000065f210f9, 0x000000006595d209,
+ 0x000000006539836d,
+ 0x0000000064dd2536, 0x000000006480b770, 0x0000000064243a2b,
+ 0x0000000063c7ad75, 0x00000000636b115c, 0x00000000630e65ed,
+ 0x0000000062b1ab39, 0x000000006254e14c, 0x0000000061f80835,
+ 0x00000000619b2002,
+ 0x00000000613e28c2, 0x0000000060e12283, 0x0000000060840d54,
+ 0x000000006026e943, 0x000000005fc9b65d, 0x000000005f6c74b2,
+ 0x000000005f0f2450, 0x000000005eb1c545, 0x000000005e5457a0,
+ 0x000000005df6db6f,
+ 0x000000005d9950c0, 0x000000005d3bb7a3, 0x000000005cde1024,
+ 0x000000005c805a54, 0x000000005c22963f, 0x000000005bc4c3f6,
+ 0x000000005b66e385, 0x000000005b08f4fd, 0x000000005aaaf86a,
+ 0x000000005a4ceddc,
+ 0x0000000059eed561, 0x000000005990af08, 0x0000000059327adf,
+ 0x0000000058d438f4, 0x000000005875e957, 0x0000000058178c16,
+ 0x0000000057b9213f, 0x00000000575aa8e0, 0x0000000056fc230a,
+ 0x00000000569d8fc9,
+ 0x00000000563eef2d, 0x0000000055e04144, 0x000000005581861d,
+ 0x000000005522bdc6, 0x0000000054c3e84e, 0x00000000546505c4,
+ 0x0000000054061636, 0x0000000053a719b3, 0x000000005348104a,
+ 0x0000000052e8fa09,
+ 0x000000005289d6ff, 0x00000000522aa73a, 0x0000000051cb6aca,
+ 0x00000000516c21bc, 0x00000000510ccc20, 0x0000000050ad6a05,
+ 0x00000000504dfb78, 0x000000004fee808a, 0x000000004f8ef947,
+ 0x000000004f2f65c0,
+ 0x000000004ecfc603, 0x000000004e701a1f, 0x000000004e106222,
+ 0x000000004db09e1b, 0x000000004d50ce19, 0x000000004cf0f22b,
+ 0x000000004c910a5f, 0x000000004c3116c5, 0x000000004bd1176b,
+ 0x000000004b710c5f,
+ 0x000000004b10f5b2, 0x000000004ab0d371, 0x000000004a50a5ab,
+ 0x0000000049f06c70, 0x00000000499027cd, 0x00000000492fd7d3,
+ 0x0000000048cf7c8f, 0x00000000486f1611, 0x00000000480ea467,
+ 0x0000000047ae27a1,
+ 0x00000000474d9fcd, 0x0000000046ed0cfa, 0x00000000468c6f37,
+ 0x00000000462bc693, 0x0000000045cb131c, 0x00000000456a54e3,
+ 0x0000000045098bf5, 0x0000000044a8b861, 0x000000004447da37,
+ 0x0000000043e6f186,
+ 0x000000004385fe5c, 0x00000000432500c8, 0x0000000042c3f8d9,
+ 0x000000004262e69f, 0x000000004201ca28, 0x0000000041a0a383,
+ 0x00000000413f72bf, 0x0000000040de37eb, 0x00000000407cf317,
+ 0x00000000401ba450,
+ 0x000000003fba4ba7, 0x000000003f58e92a, 0x000000003ef77ce8,
+ 0x000000003e9606f1, 0x000000003e348752, 0x000000003dd2fe1c,
+ 0x000000003d716b5e, 0x000000003d0fcf25, 0x000000003cae2982,
+ 0x000000003c4c7a83,
+ 0x000000003beac238, 0x000000003b8900b0, 0x000000003b2735f9,
+ 0x000000003ac56223, 0x000000003a63853d, 0x000000003a019f56,
+ 0x00000000399fb07d, 0x00000000393db8c1, 0x0000000038dbb831,
+ 0x000000003879aedd,
+ 0x0000000038179cd3, 0x0000000037b58222, 0x0000000037535edb,
+ 0x0000000036f1330b, 0x00000000368efec2, 0x00000000362cc20f,
+ 0x0000000035ca7d02, 0x0000000035682fa9, 0x000000003505da14,
+ 0x0000000034a37c51,
+ 0x0000000034411671, 0x0000000033dea881, 0x00000000337c3292,
+ 0x000000003319b4b3, 0x0000000032b72ef2, 0x000000003254a15e,
+ 0x0000000031f20c08, 0x00000000318f6efe, 0x00000000312cca50,
+ 0x0000000030ca1e0c,
+ 0x0000000030676a43, 0x000000003004af02, 0x000000002fa1ec5a,
+ 0x000000002f3f2259, 0x000000002edc510f, 0x000000002e79788b,
+ 0x000000002e1698dc, 0x000000002db3b212, 0x000000002d50c43c,
+ 0x000000002cedcf68,
+ 0x000000002c8ad3a7, 0x000000002c27d108, 0x000000002bc4c799,
+ 0x000000002b61b76b, 0x000000002afea08c, 0x000000002a9b830b,
+ 0x000000002a385ef9, 0x0000000029d53464, 0x000000002972035b,
+ 0x00000000290ecbee,
+ 0x0000000028ab8e2c, 0x0000000028484a25, 0x0000000027e4ffe7,
+ 0x000000002781af83, 0x00000000271e5906, 0x0000000026bafc82,
+ 0x0000000026579a04, 0x0000000025f4319d, 0x000000002590c35c,
+ 0x00000000252d4f4f,
+ 0x0000000024c9d587, 0x0000000024665613, 0x000000002402d101,
+ 0x00000000239f4662, 0x00000000233bb644, 0x0000000022d820b8,
+ 0x00000000227485cc, 0x000000002210e590, 0x0000000021ad4013,
+ 0x0000000021499565,
+ 0x0000000020e5e594, 0x00000000208230b1, 0x00000000201e76ca,
+ 0x000000001fbab7ef, 0x000000001f56f430, 0x000000001ef32b9b,
+ 0x000000001e8f5e41, 0x000000001e2b8c30, 0x000000001dc7b578,
+ 0x000000001d63da29,
+ 0x000000001cfffa51, 0x000000001c9c1600, 0x000000001c382d46,
+ 0x000000001bd44032, 0x000000001b704ed3, 0x000000001b0c5939,
+ 0x000000001aa85f74, 0x000000001a446191, 0x0000000019e05fa2,
+ 0x00000000197c59b5,
+ 0x0000000019184fdb, 0x0000000018b44221, 0x0000000018503098,
+ 0x0000000017ec1b50, 0x0000000017880257, 0x000000001723e5bd,
+ 0x0000000016bfc591, 0x00000000165ba1e4, 0x0000000015f77ac3,
+ 0x0000000015935040,
+ 0x00000000152f2269, 0x0000000014caf14d, 0x000000001466bcfd,
+ 0x0000000014028587, 0x00000000139e4afb, 0x00000000133a0d69,
+ 0x0000000012d5cce0, 0x000000001271896f, 0x00000000120d4326,
+ 0x0000000011a8fa15,
+ 0x000000001144ae4a, 0x0000000010e05fd6, 0x00000000107c0ec7,
+ 0x000000001017bb2d, 0x000000000fb36519, 0x000000000f4f0c98,
+ 0x000000000eeab1bb, 0x000000000e865491, 0x000000000e21f52a,
+ 0x000000000dbd9395,
+ 0x000000000d592fe1, 0x000000000cf4ca1f, 0x000000000c90625c,
+ 0x000000000c2bf8aa, 0x000000000bc78d18, 0x000000000b631fb4,
+ 0x000000000afeb08f, 0x000000000a9a3fb8, 0x000000000a35cd3e,
+ 0x0000000009d15931,
+ 0x00000000096ce3a1, 0x0000000009086c9c, 0x0000000008a3f433,
+ 0x00000000083f7a75, 0x0000000007daff71, 0x0000000007768337,
+ 0x00000000071205d6, 0x0000000006ad875f, 0x00000000064907df,
+ 0x0000000005e48768,
+ 0x0000000005800608, 0x00000000051b83cf, 0x0000000004b700cc,
+ 0x0000000004527d0f, 0x0000000003edf8a7, 0x00000000038973a4,
+ 0x000000000324ee16, 0x0000000002c0680b, 0x00000000025be194,
+ 0x0000000001f75ac0,
+ 0x000000000192d39e, 0x00000000012e4c3e, 0x0000000000c9c4af,
+ 0x0000000000653d02, 0x0000000000000000
+};
EAPI Eina_F32p32
eina_f32p32_cos(Eina_F32p32 a)
remainder_2PI = a - (a / F32P32_2PI) * F32P32_2PI;
interpol = eina_f32p32_div(eina_f32p32_scale(remainder_PI, MAX_PREC * 2),
- EINA_F32P32_PI);
+ EINA_F32P32_PI);
idx = eina_f32p32_int_to(interpol);
if (idx >= MAX_PREC)
- idx = 2 * MAX_PREC - (idx - 1);
+ idx = 2 * MAX_PREC - (idx - 1);
index2 = idx + 1;
if (index2 == MAX_PREC)
- index2 = idx - 1;
+ index2 = idx - 1;
result = eina_f32p32_add(eina_trigo[idx],
- eina_f32p32_mul(eina_f32p32_sub(eina_trigo[idx],
- eina_trigo[index2]),
- (Eina_F32p32) eina_f32p32_fracc_get(interpol)));
+ eina_f32p32_mul(eina_f32p32_sub(eina_trigo[idx],
+ eina_trigo[index2]),
+ (Eina_F32p32)eina_f32p32_fracc_get(
+ interpol)));
if (0 <= remainder_2PI && remainder_2PI < F32P32_PI2)
- return result;
+ return result;
else if (F32P32_PI2 <= remainder_2PI && remainder_2PI < EINA_F32P32_PI)
- return -result;
+ return -result;
else if (EINA_F32P32_PI <= remainder_2PI && remainder_2PI < F32P32_3PI2)
- return -result;
- else/* if (F32P32_3PI2 <= remainder_2PI) */
- return result;
+ return -result;
+ else /* if (F32P32_3PI2 <= remainder_2PI) */
+ return result;
}
EAPI Eina_F32p32
remainder_2PI = a - (a / F32P32_2PI) * F32P32_2PI;
interpol = eina_f32p32_div(eina_f32p32_scale(remainder_PI, MAX_PREC * 2),
- EINA_F32P32_PI);
+ EINA_F32P32_PI);
idx = eina_f32p32_int_to(interpol);
if (idx >= MAX_PREC)
- idx = 2 * MAX_PREC - (idx + 1);
+ idx = 2 * MAX_PREC - (idx + 1);
index2 = idx + 1;
if (index2 == MAX_PREC)
- index2 = idx - 1;
+ index2 = idx - 1;
result = eina_f32p32_add(eina_trigo[idx],
- eina_f32p32_mul(eina_f32p32_sub(eina_trigo[idx],
- eina_trigo[index2]),
- (Eina_F32p32) eina_f32p32_fracc_get(interpol)));
+ eina_f32p32_mul(eina_f32p32_sub(eina_trigo[idx],
+ eina_trigo[index2]),
+ (Eina_F32p32)eina_f32p32_fracc_get(
+ interpol)));
if (0 <= remainder_2PI && remainder_2PI < F32P32_PI2)
- return result;
+ return result;
else if (F32P32_PI2 <= remainder_2PI && remainder_2PI < EINA_F32P32_PI)
- return -result;
+ return -result;
else if (EINA_F32P32_PI <= remainder_2PI && remainder_2PI < F32P32_3PI2)
- return -result;
+ return -result;
else /* if (F32P32_3PI2 <= remainder_2PI) */
- return result;
+ return result;
}
#include "eina_hamster.h"
/*============================================================================*
- * Local *
- *============================================================================*/
+* Local *
+*============================================================================*/
/**
* @cond LOCAL
*/
/*============================================================================*
- * Global *
- *============================================================================*/
+* Global *
+*============================================================================*/
/*============================================================================*
- * API *
- *============================================================================*/
+* API *
+*============================================================================*/
/**
* @addtogroup Eina_Hamster_Group Hamster
char mon[8] = "";
int monnum = 0, day = 0, year = 0;
int fields;
-
+
fields = sscanf(_eina_hamster_time, "%02i:%02i:%02i", &hrs, &min, &sec);
if (fields == 3)
{
{
int i;
const char *mons[] =
- {
- "Jan",
- "Feb",
- "Mar",
- "Apr",
- "May",
- "Jun",
- "Jul",
- "Aug",
- "Sep",
- "Oct",
- "Nov",
- "Dec"
- };
-
+ {
+ "Jan",
+ "Feb",
+ "Mar",
+ "Apr",
+ "May",
+ "Jun",
+ "Jul",
+ "Aug",
+ "Sep",
+ "Oct",
+ "Nov",
+ "Dec"
+ };
+
for (i = 0; i < 12; i++)
{
if (!strcmp(mon, mons[i]))
// use year as-is, for 31 bits (signed) this gives us up to
// 3584 years, which is good enough imho. - 1500 years from
// now or so. :)
- _eina_hamsters +=
- (day + (monnum * 32) + (13 * 32 * year)) * (24 * 60);
+ _eina_hamsters +=
+ (day + (monnum * 32) + (13 * 32 * year)) * (24 * 60);
}
}
}
+
// format: [rest - year][0-12 - month][0-31 - day][0-23 - hrs][0-59 - sec]
return _eina_hamsters;
}
#include "eina_hash.h"
/*============================================================================*
- * Local *
- *============================================================================*/
+* Local *
+*============================================================================*/
/**
* @cond LOCAL
*/
-#define EINA_MAGIC_CHECK_HASH(d) \
- do { \
- if (!EINA_MAGIC_CHECK(d, EINA_MAGIC_HASH)) \
- EINA_MAGIC_FAIL(d, EINA_MAGIC_HASH); \
- } while(0)
-
-#define EINA_MAGIC_CHECK_HASH_ITERATOR(d, ...) \
- do { \
- if (!EINA_MAGIC_CHECK(d, EINA_MAGIC_HASH_ITERATOR)) \
- { \
- EINA_MAGIC_FAIL(d, EINA_MAGIC_HASH_ITERATOR); \
- return __VA_ARGS__; \
- } \
- } while(0)
+#define EINA_MAGIC_CHECK_HASH(d) \
+ do { \
+ if (!EINA_MAGIC_CHECK(d, EINA_MAGIC_HASH)) { \
+ EINA_MAGIC_FAIL(d, EINA_MAGIC_HASH); } \
+ } while(0)
+
+#define EINA_MAGIC_CHECK_HASH_ITERATOR(d, ...) \
+ do { \
+ if (!EINA_MAGIC_CHECK(d, EINA_MAGIC_HASH_ITERATOR)) \
+ { \
+ EINA_MAGIC_FAIL(d, EINA_MAGIC_HASH_ITERATOR); \
+ return __VA_ARGS__; \
+ } \
+ } while(0)
#define EINA_HASH_BUCKET_SIZE 8
#define EINA_HASH_SMALL_BUCKET_SIZE 5
};
typedef void *(*Eina_Iterator_Get_Content_Callback)(Eina_Iterator_Hash *it);
-#define FUNC_ITERATOR_GET_CONTENT(Function) ((Eina_Iterator_Get_Content_Callback)Function)
+#define FUNC_ITERATOR_GET_CONTENT(Function) (( \
+ Eina_Iterator_Get_Content_Callback) \
+ Function)
struct _Eina_Iterator_Hash
{
#undef get16bits
#if (defined(__GNUC__) && defined(__i386__)) || defined(__WATCOMC__) \
- || defined(_MSC_VER) || defined (__BORLANDC__) || defined (__TURBOC__)
-# define get16bits(d) (*((const uint16_t *) (d)))
+ || defined(_MSC_VER) || defined (__BORLANDC__) || defined (__TURBOC__)
+# define get16bits(d) (*((const uint16_t *)(d)))
#endif
#if !defined (get16bits)
-# define get16bits(d) ((((uint32_t)(((const uint8_t *)(d))[1])) << 8)\
- +(uint32_t)(((const uint8_t *)(d))[0]) )
+# define get16bits(d) ((((uint32_t)(((const uint8_t *)(d))[1])) << 8) \
+ + (uint32_t)(((const uint8_t *)(d))[0]))
#endif
static inline int
-_eina_hash_hash_rbtree_cmp_hash(const Eina_Hash_Head *eh, const int *hash, __UNUSED__ int key_length, __UNUSED__ void *data)
+_eina_hash_hash_rbtree_cmp_hash(const Eina_Hash_Head *eh,
+ const int *hash,
+ __UNUSED__ int key_length,
+ __UNUSED__ void *data)
{
return eh->hash - *hash;
}
static Eina_Rbtree_Direction
-_eina_hash_hash_rbtree_cmp_node(const Eina_Hash_Head *left, const Eina_Hash_Head *right, __UNUSED__ void *data)
+_eina_hash_hash_rbtree_cmp_node(const Eina_Hash_Head *left,
+ const Eina_Hash_Head *right,
+ __UNUSED__ void *data)
{
if (left->hash - right->hash < 0)
- return EINA_RBTREE_LEFT;
+ return EINA_RBTREE_LEFT;
+
return EINA_RBTREE_RIGHT;
}
static inline int
-_eina_hash_key_rbtree_cmp_key_data(const Eina_Hash_El *el, const Eina_Hash_Tuple *tuple, __UNUSED__ unsigned int key_length, Eina_Key_Cmp cmp)
+_eina_hash_key_rbtree_cmp_key_data(const Eina_Hash_El *el,
+ const Eina_Hash_Tuple *tuple,
+ __UNUSED__ unsigned int key_length,
+ Eina_Key_Cmp cmp)
{
int result;
- result = cmp(el->tuple.key, el->tuple.key_length, tuple->key, tuple->key_length);
+ result = cmp(el->tuple.key,
+ el->tuple.key_length,
+ tuple->key,
+ tuple->key_length);
if (result == 0 && tuple->data && tuple->data != el->tuple.data)
- return 1;
+ return 1;
+
return result;
}
static Eina_Rbtree_Direction
-_eina_hash_key_rbtree_cmp_node(const Eina_Hash_El *left, const Eina_Hash_El *right, Eina_Key_Cmp cmp)
+_eina_hash_key_rbtree_cmp_node(const Eina_Hash_El *left,
+ const Eina_Hash_El *right,
+ Eina_Key_Cmp cmp)
{
int result;
result = cmp(left->tuple.key, left->tuple.key_length,
- right->tuple.key, right->tuple.key_length);
+ right->tuple.key, right->tuple.key_length);
if (result < 0)
- return EINA_RBTREE_LEFT;
+ return EINA_RBTREE_LEFT;
+
return EINA_RBTREE_RIGHT;
}
static inline Eina_Bool
eina_hash_add_alloc_by_hash(Eina_Hash *hash,
- const void *key, int key_length, int alloc_length,
- int key_hash,
- const void *data)
+ const void *key, int key_length, int alloc_length,
+ int key_hash,
+ const void *data)
{
Eina_Hash_El *el = NULL;
Eina_Hash_Head *eh;
EINA_MAGIC_CHECK_HASH(hash);
EINA_SAFETY_ON_NULL_RETURN_VAL(hash, EINA_FALSE);
- EINA_SAFETY_ON_NULL_RETURN_VAL(key, EINA_FALSE);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(key, EINA_FALSE);
EINA_SAFETY_ON_NULL_RETURN_VAL(data, EINA_FALSE);
error = EINA_ERROR_OUT_OF_MEMORY;
if (!hash->buckets)
{
- hash->buckets = malloc(sizeof (Eina_Rbtree*) * hash->size);
- memset(hash->buckets, 0, sizeof (Eina_Rbtree*) * hash->size);
+ hash->buckets = malloc(sizeof (Eina_Rbtree *) * hash->size);
+ memset(hash->buckets, 0, sizeof (Eina_Rbtree *) * hash->size);
- eh = NULL;
+ eh = NULL;
}
else
- {
- /* Look up for head node. */
- eh = (Eina_Hash_Head*) eina_rbtree_inline_lookup(hash->buckets[hash_num],
- &key_hash, 0,
- EINA_RBTREE_CMP_KEY_CB(_eina_hash_hash_rbtree_cmp_hash), NULL);
- }
+ /* Look up for head node. */
+ eh = (Eina_Hash_Head *)eina_rbtree_inline_lookup(hash->buckets[hash_num],
+ &key_hash, 0,
+ EINA_RBTREE_CMP_KEY_CB(
+ _eina_hash_hash_rbtree_cmp_hash),
+ NULL);
if (!eh)
{
- /* If not found allocate it and a element. */
- eh = malloc(sizeof (Eina_Hash_Head) + sizeof (Eina_Hash_El) + alloc_length);
- if (!eh) goto on_error;
- eh->hash = key_hash;
- eh->head = NULL;
-
- hash->buckets[hash_num] = eina_rbtree_inline_insert(hash->buckets[hash_num], EINA_RBTREE_GET(eh),
- EINA_RBTREE_CMP_NODE_CB(_eina_hash_hash_rbtree_cmp_node), NULL);
-
- el = (Eina_Hash_El*) (eh + 1);
- el->begin = EINA_TRUE;
+ /* If not found allocate it and a element. */
+ eh = malloc(
+ sizeof (Eina_Hash_Head) + sizeof (Eina_Hash_El) + alloc_length);
+ if (!eh)
+ goto on_error;
+
+ eh->hash = key_hash;
+ eh->head = NULL;
+
+ hash->buckets[hash_num] =
+ eina_rbtree_inline_insert(hash->buckets[hash_num], EINA_RBTREE_GET(
+ eh),
+ EINA_RBTREE_CMP_NODE_CB(
+ _eina_hash_hash_rbtree_cmp_node), NULL);
+
+ el = (Eina_Hash_El *)(eh + 1);
+ el->begin = EINA_TRUE;
}
if (!el)
{
- /*
- Alloc every needed things
- (No more lookup as we expect to support more than one item for one key).
- */
- el = malloc(sizeof (Eina_Hash_El) + alloc_length);
- if (!el) goto on_error;
- el->begin = EINA_FALSE;
+ /*
+ Alloc every needed things
+ (No more lookup as we expect to support more than one item for one key).
+ */
+ el = malloc(sizeof (Eina_Hash_El) + alloc_length);
+ if (!el)
+ goto on_error;
+
+ el->begin = EINA_FALSE;
}
/* Setup the element */
el->tuple.key_length = key_length;
- el->tuple.data = (void *) data;
+ el->tuple.data = (void *)data;
if (alloc_length > 0)
{
- el->tuple.key = (char *) (el + 1);
- memcpy((char *) el->tuple.key, key, alloc_length);
+ el->tuple.key = (char *)(el + 1);
+ memcpy((char *)el->tuple.key, key, alloc_length);
}
else
- {
- el->tuple.key = key;
- }
+ el->tuple.key = key;
/* add the new element to the hash. */
eh->head = eina_rbtree_inline_insert(eh->head, EINA_RBTREE_GET(el),
- EINA_RBTREE_CMP_NODE_CB(_eina_hash_key_rbtree_cmp_node), (const void *)hash->key_cmp_cb);
+ EINA_RBTREE_CMP_NODE_CB(
+ _eina_hash_key_rbtree_cmp_node),
+ (const void *)hash->key_cmp_cb);
hash->population++;
return EINA_TRUE;
- on_error:
+on_error:
eina_error_set(error);
return EINA_FALSE;
}
static Eina_Bool
-_eina_hash_rbtree_each(__UNUSED__ const Eina_Rbtree *container, const Eina_Hash_Head *eh, Eina_Hash_Each *data)
+_eina_hash_rbtree_each(__UNUSED__ const Eina_Rbtree *container,
+ const Eina_Hash_Head *eh,
+ Eina_Hash_Each *data)
{
Eina_Iterator *it;
Eina_Hash_El *el;
it = eina_rbtree_iterator_prefix(eh->head);
EINA_ITERATOR_FOREACH(it, el)
- {
- if (el->tuple.data == data->data)
- {
- data->el = el;
- data->eh = (Eina_Hash_Head*) eh;
- found = EINA_FALSE;
- break ;
- }
- }
+ {
+ if (el->tuple.data == data->data)
+ {
+ data->el = el;
+ data->eh = (Eina_Hash_Head *)eh;
+ found = EINA_FALSE;
+ break;
+ }
+ }
eina_iterator_free(it);
return found;
}
static inline Eina_Hash_El *
-_eina_hash_find_by_hash(const Eina_Hash *hash, Eina_Hash_Tuple *tuple, int key_hash, Eina_Hash_Head **eh)
+_eina_hash_find_by_hash(const Eina_Hash *hash,
+ Eina_Hash_Tuple *tuple,
+ int key_hash,
+ Eina_Hash_Head **eh)
{
Eina_Hash_El *el;
int rb_hash = key_hash & EINA_HASH_RBTREE_MASK;
key_hash &= hash->mask;
- if (!hash->buckets) return NULL;
+ if (!hash->buckets)
+ return NULL;
- *eh = (Eina_Hash_Head*) eina_rbtree_inline_lookup(hash->buckets[key_hash],
- &rb_hash, 0,
- EINA_RBTREE_CMP_KEY_CB(_eina_hash_hash_rbtree_cmp_hash), NULL);
- if (!*eh) return NULL;
+ *eh = (Eina_Hash_Head *)eina_rbtree_inline_lookup(hash->buckets[key_hash],
+ &rb_hash, 0,
+ EINA_RBTREE_CMP_KEY_CB(
+ _eina_hash_hash_rbtree_cmp_hash),
+ NULL);
+ if (!*eh)
+ return NULL;
- el = (Eina_Hash_El*) eina_rbtree_inline_lookup((*eh)->head,
- tuple, 0,
- EINA_RBTREE_CMP_KEY_CB(_eina_hash_key_rbtree_cmp_key_data), (const void *)hash->key_cmp_cb);
+ el = (Eina_Hash_El *)eina_rbtree_inline_lookup((*eh)->head,
+ tuple, 0,
+ EINA_RBTREE_CMP_KEY_CB(
+ _eina_hash_key_rbtree_cmp_key_data),
+ (const void *)hash->
+ key_cmp_cb);
return el;
}
static inline Eina_Hash_El *
-_eina_hash_find_by_data(const Eina_Hash *hash, const void *data, int *key_hash, Eina_Hash_Head **eh)
+_eina_hash_find_by_data(const Eina_Hash *hash,
+ const void *data,
+ int *key_hash,
+ Eina_Hash_Head **eh)
{
Eina_Hash_Each each;
Eina_Iterator *it;
int hash_num;
- if (!hash->buckets) return NULL;
+ if (!hash->buckets)
+ return NULL;
each.el = NULL;
each.data = data;
for (hash_num = 0; hash_num < hash->size; hash_num++)
{
- if (!hash->buckets[hash_num])
- continue;
- it = eina_rbtree_iterator_prefix(hash->buckets[hash_num]);
- eina_iterator_foreach(it, EINA_EACH(_eina_hash_rbtree_each), &each);
- eina_iterator_free(it);
-
- if (each.el)
- {
- *key_hash = hash_num;
- *eh = each.eh;
- return (Eina_Hash_El*) each.el;
- }
+ if (!hash->buckets[hash_num])
+ continue;
+
+ it = eina_rbtree_iterator_prefix(hash->buckets[hash_num]);
+ eina_iterator_foreach(it, EINA_EACH(_eina_hash_rbtree_each), &each);
+ eina_iterator_free(it);
+
+ if (each.el)
+ {
+ *key_hash = hash_num;
+ *eh = each.eh;
+ return (Eina_Hash_El *)each.el;
+ }
}
return NULL;
_eina_hash_el_free(Eina_Hash_El *el, Eina_Hash *hash)
{
if (hash->data_free_cb)
- hash->data_free_cb(el->tuple.data);
- if (el->begin == EINA_FALSE) free(el);
+ hash->data_free_cb(el->tuple.data);
+
+ if (el->begin == EINA_FALSE)
+ free(el);
}
static void
}
static Eina_Bool
-_eina_hash_del_by_hash_el(Eina_Hash *hash, Eina_Hash_El *el, Eina_Hash_Head *eh, int key_hash)
+_eina_hash_del_by_hash_el(Eina_Hash *hash,
+ Eina_Hash_El *el,
+ Eina_Hash_Head *eh,
+ int key_hash)
{
- eh->head = eina_rbtree_inline_remove(eh->head, EINA_RBTREE_GET(el), EINA_RBTREE_CMP_NODE_CB(_eina_hash_key_rbtree_cmp_node), (const void *)hash->key_cmp_cb);
+ eh->head = eina_rbtree_inline_remove(eh->head, EINA_RBTREE_GET(
+ el), EINA_RBTREE_CMP_NODE_CB(
+ _eina_hash_key_rbtree_cmp_node),
+ (const void *)hash->key_cmp_cb);
_eina_hash_el_free(el, hash);
if (!eh->head)
{
- key_hash &= hash->mask;
-
- hash->buckets[key_hash] = eina_rbtree_inline_remove(hash->buckets[key_hash], EINA_RBTREE_GET(eh), EINA_RBTREE_CMP_NODE_CB(_eina_hash_hash_rbtree_cmp_node), NULL);
- free(eh);
+ key_hash &= hash->mask;
+
+ hash->buckets[key_hash] =
+ eina_rbtree_inline_remove(hash->buckets[key_hash], EINA_RBTREE_GET(
+ eh),
+ EINA_RBTREE_CMP_NODE_CB(
+ _eina_hash_hash_rbtree_cmp_node), NULL);
+ free(eh);
}
hash->population--;
if (hash->population == 0)
{
- free(hash->buckets);
- hash->buckets = NULL;
+ free(hash->buckets);
+ hash->buckets = NULL;
}
return EINA_TRUE;
}
static Eina_Bool
-_eina_hash_del_by_key_hash(Eina_Hash *hash, const void *key, int key_length, int key_hash, const void *data)
+_eina_hash_del_by_key_hash(Eina_Hash *hash,
+ const void *key,
+ int key_length,
+ int key_hash,
+ const void *data)
{
Eina_Hash_El *el;
Eina_Hash_Head *eh;
EINA_MAGIC_CHECK_HASH(hash);
EINA_SAFETY_ON_NULL_RETURN_VAL(hash, EINA_FALSE);
- EINA_SAFETY_ON_NULL_RETURN_VAL(key, EINA_FALSE);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(key, EINA_FALSE);
- if (!hash->buckets) return EINA_FALSE;
+ if (!hash->buckets)
+ return EINA_FALSE;
- tuple.key = (void *) key;
+ tuple.key = (void *)key;
tuple.key_length = key_length;
- tuple.data = (void *) data;
+ tuple.data = (void *)data;
el = _eina_hash_find_by_hash(hash, &tuple, key_hash, &eh);
- if (!el) return EINA_FALSE;
+ if (!el)
+ return EINA_FALSE;
+
return _eina_hash_del_by_hash_el(hash, el, eh, key_hash);
}
int key_length, key_hash;
EINA_MAGIC_CHECK_HASH(hash);
- if (!hash) return EINA_FALSE;
- if (!key) return EINA_FALSE;
- if (!hash->buckets) return EINA_FALSE;
+ if (!hash)
+ return EINA_FALSE;
+
+ if (!key)
+ return EINA_FALSE;
+
+ if (!hash->buckets)
+ return EINA_FALSE;
key_length = hash->key_length_cb ? hash->key_length_cb(key) : 0;
key_hash = hash->key_hash_cb(key, key_length);
static unsigned int
_eina_string_key_length(const char *key)
{
- if (!key) return 0;
+ if (!key)
+ return 0;
+
return (int)strlen(key) + 1;
}
static int
_eina_string_key_cmp(const char *key1, __UNUSED__ int key1_length,
- const char *key2, __UNUSED__ int key2_length)
+ const char *key2, __UNUSED__ int key2_length)
{
return strcmp(key1, key2);
}
static int
_eina_stringshared_key_cmp(const char *key1, __UNUSED__ int key1_length,
- const char *key2, __UNUSED__ int key2_length)
+ const char *key2, __UNUSED__ int key2_length)
{
return key1 - key2;
}
static unsigned int
_eina_int32_key_length(__UNUSED__ const uint32_t *key)
{
- return 4;
+ return 4;
}
static int
_eina_int32_key_cmp(const uint32_t *key1, __UNUSED__ int key1_length,
- const uint32_t *key2, __UNUSED__ int key2_length)
+ const uint32_t *key2, __UNUSED__ int key2_length)
{
return *key1 - *key2;
}
static unsigned int
_eina_int64_key_length(__UNUSED__ const uint32_t *key)
{
- return 8;
+ return 8;
}
static int
_eina_int64_key_cmp(const uint64_t *key1, __UNUSED__ int key1_length,
- const uint64_t *key2, __UNUSED__ int key2_length)
+ const uint64_t *key2, __UNUSED__ int key2_length)
{
return *key1 - *key2;
}
static Eina_Bool
-_eina_foreach_cb(const Eina_Hash *hash, Eina_Hash_Tuple *data, Eina_Hash_Foreach_Data *fdata)
+_eina_foreach_cb(const Eina_Hash *hash,
+ Eina_Hash_Tuple *data,
+ Eina_Hash_Foreach_Data *fdata)
{
- return fdata->cb((Eina_Hash *) hash, data->key, data->data, (void*) fdata->fdata);
+ return fdata->cb((Eina_Hash *)hash,
+ data->key,
+ data->data,
+ (void *)fdata->fdata);
}
static void *
stuff = it->el;
- if (!stuff) return NULL;
+ if (!stuff)
+ return NULL;
+
return stuff->tuple.data;
}
stuff = it->el;
- if (!stuff) return NULL;
- return (void *) stuff->tuple.key;
+ if (!stuff)
+ return NULL;
+
+ return (void *)stuff->tuple.key;
}
static Eina_Hash_Tuple *
stuff = it->el;
- if (!stuff) return NULL;
+ if (!stuff)
+ return NULL;
+
return &stuff->tuple;
}
Eina_Bool ok;
int bucket;
- if (!(it->index < it->hash->population)) return EINA_FALSE;
+ if (!(it->index < it->hash->population))
+ return EINA_FALSE;
+
if (it->current == NULL)
{
- ok = EINA_FALSE;
- bucket = 0;
- it->index = -1;
+ ok = EINA_FALSE;
+ bucket = 0;
+ it->index = -1;
}
else
{
- ok = eina_iterator_next(it->list, (void**) &it->el);
- if (!ok)
- {
- eina_iterator_free(it->list);
- it->list = NULL;
-
- ok = eina_iterator_next(it->current, (void**) &it->eh);
- if (!ok)
- {
- eina_iterator_free(it->current);
- it->current = NULL;
- it->bucket++;
- }
- else
- {
- it->list = eina_rbtree_iterator_prefix(it->eh->head);
- ok = eina_iterator_next(it->list, (void**) &it->el);
- }
- }
-
- bucket = it->bucket;
+ ok = eina_iterator_next(it->list, (void **)&it->el);
+ if (!ok)
+ {
+ eina_iterator_free(it->list);
+ it->list = NULL;
+
+ ok = eina_iterator_next(it->current, (void **)&it->eh);
+ if (!ok)
+ {
+ eina_iterator_free(it->current);
+ it->current = NULL;
+ it->bucket++;
+ }
+ else
+ {
+ it->list = eina_rbtree_iterator_prefix(it->eh->head);
+ ok = eina_iterator_next(it->list, (void **)&it->el);
+ }
+ }
+
+ bucket = it->bucket;
}
if (ok == EINA_FALSE)
{
- while (bucket < it->hash->size)
- {
- if (it->hash->buckets[bucket] != NULL)
- {
- it->current = eina_rbtree_iterator_prefix(it->hash->buckets[bucket]);
- ok = eina_iterator_next(it->current, (void**) &it->eh);
- if (ok) break ;
- eina_iterator_free(it->current);
- it->current = NULL;
- }
- ++bucket;
- }
- if (it->list) eina_iterator_free(it->list);
- it->list = eina_rbtree_iterator_prefix(it->eh->head);
- ok = eina_iterator_next(it->list, (void**) &it->el);
- if (bucket == it->hash->size) ok = EINA_FALSE;
+ while (bucket < it->hash->size)
+ {
+ if (it->hash->buckets[bucket] != NULL)
+ {
+ it->current =
+ eina_rbtree_iterator_prefix(it->hash->buckets[bucket]);
+ ok = eina_iterator_next(it->current, (void **)&it->eh);
+ if (ok)
+ break;
+
+ eina_iterator_free(it->current);
+ it->current = NULL;
+ }
+
+ ++bucket;
+ }
+ if (it->list)
+ eina_iterator_free(it->list);
+
+ it->list = eina_rbtree_iterator_prefix(it->eh->head);
+ ok = eina_iterator_next(it->list, (void **)&it->el);
+ if (bucket == it->hash->size)
+ ok = EINA_FALSE;
}
it->index++;
it->bucket = bucket;
if (ok)
- *data = it->get_content(it);
+ *data = it->get_content(it);
return ok;
}
static void *
_eina_hash_iterator_get_container(Eina_Iterator_Hash *it)
{
- EINA_MAGIC_CHECK_HASH_ITERATOR(it, NULL);
- return (void *) it->hash;
+ EINA_MAGIC_CHECK_HASH_ITERATOR(it, NULL);
+ return (void *)it->hash;
}
static void
_eina_hash_iterator_free(Eina_Iterator_Hash *it)
{
- EINA_MAGIC_CHECK_HASH_ITERATOR(it);
- if (it->current) eina_iterator_free(it->current);
- if (it->list) eina_iterator_free(it->list);
- free(it);
+ EINA_MAGIC_CHECK_HASH_ITERATOR(it);
+ if (it->current)
+ eina_iterator_free(it->current);
+
+ if (it->list)
+ eina_iterator_free(it->list);
+
+ free(it);
}
/**
*/
/*============================================================================*
- * Global *
- *============================================================================*/
+* Global *
+*============================================================================*/
/*============================================================================*
- * API *
- *============================================================================*/
+* API *
+*============================================================================*/
/**
* @addtogroup Eina_Hash_Group Hash Table
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_Free_Cb data_free_cb,
- int buckets_power_size)
+ Eina_Key_Cmp key_cmp_cb,
+ Eina_Key_Hash key_hash_cb,
+ Eina_Free_Cb data_free_cb,
+ int buckets_power_size)
{
/* FIXME: Use mempool. */
Eina_Hash *new;
eina_error_set(0);
- EINA_SAFETY_ON_NULL_RETURN_VAL(key_cmp_cb, NULL);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(key_cmp_cb, NULL);
EINA_SAFETY_ON_NULL_RETURN_VAL(key_hash_cb, NULL);
- EINA_SAFETY_ON_TRUE_RETURN_VAL(buckets_power_size < 3, NULL);
+ EINA_SAFETY_ON_TRUE_RETURN_VAL(buckets_power_size < 3, NULL);
EINA_SAFETY_ON_TRUE_RETURN_VAL(buckets_power_size > 16, NULL);
new = malloc(sizeof (Eina_Hash));
- if (!new) goto on_error;
+ if (!new)
+ goto on_error;
new->key_length_cb = key_length_cb;
new->key_cmp_cb = key_cmp_cb;
return new;
- on_error:
+on_error:
eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
return NULL;
}
eina_hash_string_djb2_new(Eina_Free_Cb data_free_cb)
{
return eina_hash_new(EINA_KEY_LENGTH(_eina_string_key_length),
- EINA_KEY_CMP(_eina_string_key_cmp),
- EINA_KEY_HASH(eina_hash_djb2),
- data_free_cb,
- EINA_HASH_BUCKET_SIZE);
+ EINA_KEY_CMP(_eina_string_key_cmp),
+ EINA_KEY_HASH(eina_hash_djb2),
+ data_free_cb,
+ EINA_HASH_BUCKET_SIZE);
}
/**
eina_hash_string_superfast_new(Eina_Free_Cb data_free_cb)
{
return eina_hash_new(EINA_KEY_LENGTH(_eina_string_key_length),
- EINA_KEY_CMP(_eina_string_key_cmp),
- EINA_KEY_HASH(eina_hash_superfast),
- data_free_cb,
- EINA_HASH_BUCKET_SIZE);
+ EINA_KEY_CMP(_eina_string_key_cmp),
+ EINA_KEY_HASH(eina_hash_superfast),
+ data_free_cb,
+ EINA_HASH_BUCKET_SIZE);
}
/**
eina_hash_string_small_new(Eina_Free_Cb data_free_cb)
{
return eina_hash_new(EINA_KEY_LENGTH(_eina_string_key_length),
- EINA_KEY_CMP(_eina_string_key_cmp),
- EINA_KEY_HASH(eina_hash_superfast),
- data_free_cb,
- EINA_HASH_SMALL_BUCKET_SIZE);
+ EINA_KEY_CMP(_eina_string_key_cmp),
+ EINA_KEY_HASH(eina_hash_superfast),
+ data_free_cb,
+ EINA_HASH_SMALL_BUCKET_SIZE);
}
/**
* @brief Create a new hash for use with 32bit ints
* @param data_free_cb The function to call on values when the hash table is freed
* @return The @ref Eina_Hash object, or @c NULL on error
- * Use to create a new hash using the int32 algorithm for table management and dereferenced
+ * Use to create a new hash using the int32 algorithm for table management and dereferenced
* pointers to compare keys.
* NOTE: If your hash is created by this, you CAN look up values with pointers other
- * than the original key pointer that was used to add a value. Also note that while this method may
+ * than the original key pointer that was used to add a value. Also note that while this method may
* appear to be able to match string keys, it is really only matching the first character.
*/
EAPI Eina_Hash *
eina_hash_int32_new(Eina_Free_Cb data_free_cb)
{
return eina_hash_new(EINA_KEY_LENGTH(_eina_int32_key_length),
- EINA_KEY_CMP(_eina_int32_key_cmp),
- EINA_KEY_HASH(eina_hash_int32),
- data_free_cb,
- EINA_HASH_BUCKET_SIZE);
+ EINA_KEY_CMP(_eina_int32_key_cmp),
+ EINA_KEY_HASH(eina_hash_int32),
+ data_free_cb,
+ EINA_HASH_BUCKET_SIZE);
}
/**
* @brief Create a new hash for use with 64bit ints
* @param data_free_cb The function to call on values when the hash table is freed
* @return The @ref Eina_Hash object, or @c NULL on error
- * Use to create a new hash using the int64 algorithm for table management and dereferenced
+ * Use to create a new hash using the int64 algorithm for table management and dereferenced
* pointers to compare keys.
* NOTE: If your hash is created by this, you CAN look up values with pointers other
- * than the original key pointer that was used to add a value. Also note that while this method may
+ * than the original key pointer that was used to add a value. Also note that while this method may
* appear to be able to match string keys, it is really only matching the first character.
*/
EAPI Eina_Hash *
eina_hash_int64_new(Eina_Free_Cb data_free_cb)
{
return eina_hash_new(EINA_KEY_LENGTH(_eina_int64_key_length),
- EINA_KEY_CMP(_eina_int64_key_cmp),
- EINA_KEY_HASH(eina_hash_int64),
- data_free_cb,
- EINA_HASH_BUCKET_SIZE);
+ EINA_KEY_CMP(_eina_int64_key_cmp),
+ EINA_KEY_HASH(eina_hash_int64),
+ data_free_cb,
+ EINA_HASH_BUCKET_SIZE);
}
/**
* @brief Create a new hash for use with pointers
* @param data_free_cb The function to call on values when the hash table is freed
* @return The @ref Eina_Hash object, or @c NULL on error
- * Use to create a new hash using the int64 algorithm for table management and dereferenced
+ * Use to create a new hash using the int64 algorithm for table management and dereferenced
* pointers to compare keys.
* NOTE: If your hash is created by this, you CAN look up values with pointers other
- * than the original key pointer that was used to add a value. Also note that while this method may
+ * than the original key pointer that was used to add a value. Also note that while this method may
* appear to be able to match string keys, it is really only matching the first character.
*/
EAPI Eina_Hash *
{
#ifdef __LP64__
return eina_hash_new(EINA_KEY_LENGTH(_eina_int64_key_length),
- EINA_KEY_CMP(_eina_int64_key_cmp),
- EINA_KEY_HASH(eina_hash_int64),
- data_free_cb,
- EINA_HASH_BUCKET_SIZE);
+ EINA_KEY_CMP(_eina_int64_key_cmp),
+ EINA_KEY_HASH(eina_hash_int64),
+ data_free_cb,
+ EINA_HASH_BUCKET_SIZE);
#else
return eina_hash_new(EINA_KEY_LENGTH(_eina_int32_key_length),
- EINA_KEY_CMP(_eina_int32_key_cmp),
- EINA_KEY_HASH(eina_hash_int32),
- data_free_cb,
- EINA_HASH_BUCKET_SIZE);
+ EINA_KEY_CMP(_eina_int32_key_cmp),
+ EINA_KEY_HASH(eina_hash_int32),
+ data_free_cb,
+ EINA_HASH_BUCKET_SIZE);
#endif
}
/**
eina_hash_stringshared_new(Eina_Free_Cb data_free_cb)
{
return eina_hash_new(NULL,
- EINA_KEY_CMP(_eina_stringshared_key_cmp),
- EINA_KEY_HASH(eina_hash_superfast),
- data_free_cb,
- EINA_HASH_BUCKET_SIZE);
+ EINA_KEY_CMP(_eina_stringshared_key_cmp),
+ EINA_KEY_HASH(eina_hash_superfast),
+ data_free_cb,
+ EINA_HASH_BUCKET_SIZE);
}
/**
EAPI int
eina_hash_population(const Eina_Hash *hash)
{
- if (!hash) return 0;
+ if (!hash)
+ return 0;
EINA_MAGIC_CHECK_HASH(hash);
return hash->population;
if (hash->buckets)
{
- for (i = 0; i < hash->size; i++)
- eina_rbtree_delete(hash->buckets[i], EINA_RBTREE_FREE_CB(_eina_hash_head_free), hash);
- free(hash->buckets);
+ for (i = 0; i < hash->size; i++)
+ eina_rbtree_delete(hash->buckets[i],
+ EINA_RBTREE_FREE_CB(_eina_hash_head_free), hash);
+ free(hash->buckets);
}
- free(hash);
+
+ free(hash);
}
/**
if (hash->buckets)
{
- for (i = 0; i < hash->size; i++)
- eina_rbtree_delete(hash->buckets[i], EINA_RBTREE_FREE_CB(_eina_hash_head_free), hash);
- free(hash->buckets);
- hash->buckets = NULL;
- hash->population = 0;
+ for (i = 0; i < hash->size; i++)
+ eina_rbtree_delete(hash->buckets[i],
+ EINA_RBTREE_FREE_CB(_eina_hash_head_free), hash);
+ free(hash->buckets);
+ hash->buckets = NULL;
+ hash->population = 0;
}
}
*/
EAPI Eina_Bool
eina_hash_add_by_hash(Eina_Hash *hash,
- const void *key, int key_length, int key_hash,
- const void *data)
+ const void *key, int key_length, int key_hash,
+ const void *data)
{
- return eina_hash_add_alloc_by_hash(hash, key, key_length, key_length, key_hash, data);
+ return eina_hash_add_alloc_by_hash(hash,
+ key,
+ key_length,
+ key_length,
+ key_hash,
+ data);
}
/**
*/
EAPI Eina_Bool
eina_hash_direct_add_by_hash(Eina_Hash *hash,
- const void *key, int key_length, int key_hash,
- const void *data)
+ const void *key, int key_length, int key_hash,
+ const void *data)
{
return eina_hash_add_alloc_by_hash(hash, key, key_length, 0, key_hash, data);
}
int key_hash;
EINA_MAGIC_CHECK_HASH(hash);
- EINA_SAFETY_ON_NULL_RETURN_VAL(hash, EINA_FALSE);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(hash, EINA_FALSE);
EINA_SAFETY_ON_NULL_RETURN_VAL(hash->key_hash_cb, EINA_FALSE);
- EINA_SAFETY_ON_NULL_RETURN_VAL(key, EINA_FALSE);
- EINA_SAFETY_ON_NULL_RETURN_VAL(data, EINA_FALSE);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(key, EINA_FALSE);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(data, EINA_FALSE);
key_length = hash->key_length_cb ? hash->key_length_cb(key) : 0;
key_hash = hash->key_hash_cb(key, key_length);
int key_hash;
EINA_MAGIC_CHECK_HASH(hash);
- EINA_SAFETY_ON_NULL_RETURN_VAL(hash, EINA_FALSE);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(hash, EINA_FALSE);
EINA_SAFETY_ON_NULL_RETURN_VAL(hash->key_hash_cb, EINA_FALSE);
- EINA_SAFETY_ON_NULL_RETURN_VAL(key, EINA_FALSE);
- EINA_SAFETY_ON_NULL_RETURN_VAL(data, EINA_FALSE);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(key, EINA_FALSE);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(data, EINA_FALSE);
key_length = hash->key_length_cb ? hash->key_length_cb(key) : 0;
key_hash = hash->key_hash_cb(key, key_length);
* @note if you don't have the key, use eina_hash_del_by_data() instead.
*/
EAPI Eina_Bool
-eina_hash_del_by_key_hash(Eina_Hash *hash, const void *key, int key_length, int key_hash)
+eina_hash_del_by_key_hash(Eina_Hash *hash,
+ const void *key,
+ int key_length,
+ int key_hash)
{
EINA_SAFETY_ON_NULL_RETURN_VAL(hash, EINA_FALSE);
- EINA_SAFETY_ON_NULL_RETURN_VAL(key, EINA_FALSE);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(key, EINA_FALSE);
return _eina_hash_del_by_key_hash(hash, key, key_length, key_hash, NULL);
}
eina_hash_del_by_key(Eina_Hash *hash, const void *key)
{
EINA_SAFETY_ON_NULL_RETURN_VAL(hash, EINA_FALSE);
- EINA_SAFETY_ON_NULL_RETURN_VAL(key, EINA_FALSE);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(key, EINA_FALSE);
return _eina_hash_del_by_key(hash, key, NULL);
}
EINA_SAFETY_ON_NULL_RETURN_VAL(data, EINA_FALSE);
el = _eina_hash_find_by_data(hash, data, &key_hash, &eh);
- if (!el) return EINA_FALSE;
- if (el->tuple.data != data) return EINA_FALSE;
+ if (!el)
+ return EINA_FALSE;
+
+ if (el->tuple.data != data)
+ return EINA_FALSE;
+
return _eina_hash_del_by_hash_el(hash, el, eh, key_hash);
}
* directly.
*/
EAPI Eina_Bool
-eina_hash_del_by_hash(Eina_Hash *hash, const void *key, int key_length, int key_hash, const void *data)
+eina_hash_del_by_hash(Eina_Hash *hash,
+ const void *key,
+ int key_length,
+ int key_hash,
+ const void *data)
{
EINA_MAGIC_CHECK_HASH(hash);
EINA_SAFETY_ON_NULL_RETURN_VAL(hash, EINA_FALSE);
- if (key) return _eina_hash_del_by_key_hash(hash, key, key_length, key_hash, data);
- else return eina_hash_del_by_data(hash, data);
+ if (key)
+ return _eina_hash_del_by_key_hash(hash, key, key_length, key_hash, data);
+ else
+ return eina_hash_del_by_data(hash, data);
}
/**
{
EINA_MAGIC_CHECK_HASH(hash);
EINA_SAFETY_ON_NULL_RETURN_VAL(hash, EINA_FALSE);
- if (key) return _eina_hash_del_by_key(hash, key, data);
- else return eina_hash_del_by_data(hash, data);
+ if (key)
+ return _eina_hash_del_by_key(hash, key, data);
+ else
+ return eina_hash_del_by_data(hash, data);
}
/**
* found.
*/
EAPI void *
-eina_hash_find_by_hash(const Eina_Hash *hash, const void *key, int key_length, int key_hash)
+eina_hash_find_by_hash(const Eina_Hash *hash,
+ const void *key,
+ int key_length,
+ int key_hash)
{
Eina_Hash_Head *eh;
Eina_Hash_El *el;
Eina_Hash_Tuple tuple;
- if (!hash) return NULL;
+ if (!hash)
+ return NULL;
EINA_MAGIC_CHECK_HASH(hash);
EINA_SAFETY_ON_NULL_RETURN_VAL(key, NULL);
tuple.data = NULL;
el = _eina_hash_find_by_hash(hash, &tuple, key_hash, &eh);
- if (el) return el->tuple.data;
+ if (el)
+ return el->tuple.data;
+
return NULL;
}
int key_length;
int hash_num;
- if (!hash) return NULL;
+ if (!hash)
+ return NULL;
EINA_MAGIC_CHECK_HASH(hash);
EINA_SAFETY_ON_NULL_RETURN_VAL(hash->key_hash_cb, NULL);
- EINA_SAFETY_ON_NULL_RETURN_VAL(key, NULL);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(key, NULL);
key_length = hash->key_length_cb ? hash->key_length_cb(key) : 0;
hash_num = hash->key_hash_cb(key, key_length);
* hash.
*/
EAPI void *
-eina_hash_modify_by_hash(Eina_Hash *hash, const void *key, int key_length, int key_hash, const void *data)
+eina_hash_modify_by_hash(Eina_Hash *hash,
+ const void *key,
+ int key_length,
+ int key_hash,
+ const void *data)
{
Eina_Hash_Head *eh;
Eina_Hash_El *el;
EINA_MAGIC_CHECK_HASH(hash);
EINA_SAFETY_ON_NULL_RETURN_VAL(hash, NULL);
- EINA_SAFETY_ON_NULL_RETURN_VAL(key, NULL);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(key, NULL);
EINA_SAFETY_ON_NULL_RETURN_VAL(data, NULL);
tuple.key = key;
if (el)
{
old_data = el->tuple.data;
- el->tuple.data = (void *) data;
+ el->tuple.data = (void *)data;
}
return old_data;
int key_hash;
EINA_MAGIC_CHECK_HASH(hash);
- EINA_SAFETY_ON_NULL_RETURN_VAL(hash, NULL);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(hash, NULL);
EINA_SAFETY_ON_NULL_RETURN_VAL(hash->key_hash_cb, NULL);
- EINA_SAFETY_ON_NULL_RETURN_VAL(key, NULL);
- EINA_SAFETY_ON_NULL_RETURN_VAL(data, NULL);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(key, NULL);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(data, NULL);
key_length = hash->key_length_cb ? hash->key_length_cb(key) : 0;
key_hash = hash->key_hash_cb(key, key_length);
void *old_data = NULL;
old_data = el->tuple.data;
- el->tuple.data = (void *) data;
+ el->tuple.data = (void *)data;
return old_data;
}
- eina_hash_add_alloc_by_hash(hash, key, key_length, key_length, key_hash, data);
+ eina_hash_add_alloc_by_hash(hash,
+ key,
+ key_length,
+ key_length,
+ key_hash,
+ data);
return NULL;
}
int hash_num;
EINA_MAGIC_CHECK_HASH(hash);
- EINA_SAFETY_ON_NULL_RETURN_VAL(hash, NULL);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(hash, NULL);
EINA_SAFETY_ON_NULL_RETURN_VAL(hash->key_hash_cb, NULL);
- EINA_SAFETY_ON_NULL_RETURN_VAL(key, NULL);
- EINA_SAFETY_ON_NULL_RETURN_VAL(data, NULL);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(key, NULL);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(data, NULL);
key_length = hash->key_length_cb ? hash->key_length_cb(key) : 0;
hash_num = hash->key_hash_cb(key, key_length);
}
/*============================================================================*
- * Iterator *
- *============================================================================*/
+* Iterator *
+*============================================================================*/
/**
* Call a function on every member stored in the hash table
*/
EAPI void
eina_hash_foreach(const Eina_Hash *hash,
- Eina_Hash_Foreach func,
- const void *fdata)
+ Eina_Hash_Foreach func,
+ const void *fdata)
{
Eina_Iterator *it;
Eina_Hash_Foreach_Data foreach;
foreach.fdata = fdata;
it = eina_hash_iterator_tuple_new(hash);
- if (!it) return;
+ if (!it)
+ return;
eina_iterator_foreach(it, EINA_EACH(_eina_foreach_cb), &foreach);
eina_iterator_free(it);
EINA_MAGIC_CHECK_HASH(hash);
EINA_SAFETY_ON_NULL_RETURN_VAL(hash, NULL);
- eina_error_set(0);
+ eina_error_set(0);
it = calloc(1, sizeof (Eina_Iterator_Hash));
- if (!it) {
- eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
- return NULL;
- }
+ if (!it)
+ {
+ eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+ return NULL;
+ }
it->hash = hash;
- it->get_content = FUNC_ITERATOR_GET_CONTENT(_eina_hash_iterator_data_get_content);
+ it->get_content = FUNC_ITERATOR_GET_CONTENT(
+ _eina_hash_iterator_data_get_content);
it->iterator.next = FUNC_ITERATOR_NEXT(_eina_hash_iterator_next);
- it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(_eina_hash_iterator_get_container);
+ it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(
+ _eina_hash_iterator_get_container);
it->iterator.free = FUNC_ITERATOR_FREE(_eina_hash_iterator_free);
EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_ITERATOR);
- EINA_MAGIC_SET(it, EINA_MAGIC_HASH_ITERATOR);
+ EINA_MAGIC_SET(it, EINA_MAGIC_HASH_ITERATOR);
return &it->iterator;
}
EINA_MAGIC_CHECK_HASH(hash);
EINA_SAFETY_ON_NULL_RETURN_VAL(hash, NULL);
- eina_error_set(0);
+ eina_error_set(0);
it = calloc(1, sizeof (Eina_Iterator_Hash));
- if (!it) {
- eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
- return NULL;
- }
+ if (!it)
+ {
+ eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+ return NULL;
+ }
it->hash = hash;
- it->get_content = FUNC_ITERATOR_GET_CONTENT(_eina_hash_iterator_key_get_content);
+ it->get_content = FUNC_ITERATOR_GET_CONTENT(
+ _eina_hash_iterator_key_get_content);
it->iterator.next = FUNC_ITERATOR_NEXT(_eina_hash_iterator_next);
- it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(_eina_hash_iterator_get_container);
+ it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(
+ _eina_hash_iterator_get_container);
it->iterator.free = FUNC_ITERATOR_FREE(_eina_hash_iterator_free);
EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_ITERATOR);
- EINA_MAGIC_SET(it, EINA_MAGIC_HASH_ITERATOR);
+ EINA_MAGIC_SET(it, EINA_MAGIC_HASH_ITERATOR);
return &it->iterator;
}
EINA_MAGIC_CHECK_HASH(hash);
EINA_SAFETY_ON_NULL_RETURN_VAL(hash, NULL);
- eina_error_set(0);
+ eina_error_set(0);
it = calloc(1, sizeof (Eina_Iterator_Hash));
- if (!it) {
- eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
- return NULL;
- }
+ if (!it)
+ {
+ eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+ return NULL;
+ }
it->hash = hash;
- it->get_content = FUNC_ITERATOR_GET_CONTENT(_eina_hash_iterator_tuple_get_content);
+ it->get_content = FUNC_ITERATOR_GET_CONTENT(
+ _eina_hash_iterator_tuple_get_content);
it->iterator.next = FUNC_ITERATOR_NEXT(_eina_hash_iterator_next);
- it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(_eina_hash_iterator_get_container);
+ it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(
+ _eina_hash_iterator_get_container);
it->iterator.free = FUNC_ITERATOR_FREE(_eina_hash_iterator_free);
EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_ITERATOR);
- EINA_MAGIC_SET(it, EINA_MAGIC_HASH_ITERATOR);
+ EINA_MAGIC_SET(it, EINA_MAGIC_HASH_ITERATOR);
return &it->iterator;
}
len >>= 2;
/* Main loop */
- for ( ;len > 0; len--)
+ for (; len > 0; len--)
{
- hash += get16bits(key);
- tmp = (get16bits(key + 2) << 11) ^ hash;
- hash = (hash << 16) ^ tmp;
- key += 2 * sizeof (uint16_t);
- hash += hash >> 11;
+ hash += get16bits(key);
+ tmp = (get16bits(key + 2) << 11) ^ hash;
+ hash = (hash << 16) ^ tmp;
+ key += 2 * sizeof (uint16_t);
+ hash += hash >> 11;
}
/* Handle end cases */
switch (rem)
{
case 3:
- hash += get16bits(key);
- hash ^= hash << 16;
- hash ^= key[sizeof (uint16_t)] << 18;
- hash += hash >> 11;
- break;
+ hash += get16bits(key);
+ hash ^= hash << 16;
+ hash ^= key[sizeof (uint16_t)] << 18;
+ hash += hash >> 11;
+ break;
+
case 2:
- hash += get16bits(key);
- hash ^= hash << 11;
- hash += hash >> 17;
- break;
+ hash += get16bits(key);
+ hash ^= hash << 11;
+ hash += hash >> 17;
+ break;
+
case 1:
- hash += *key;
- hash ^= hash << 10;
- hash += hash >> 1;
+ hash += *key;
+ hash ^= hash << 10;
+ hash += hash >> 1;
}
/* Force "avalanching" of final 127 bits */
/* FIXME: TODO please, refactor this :) */
/*============================================================================*
- * Local *
- *============================================================================*/
+* Local *
+*============================================================================*/
/**
* @cond LOCAL
struct _Eina_Iterator_Inlist
{
- Eina_Iterator iterator;
- const Eina_Inlist *head;
- const Eina_Inlist *current;
+ Eina_Iterator iterator;
+ const Eina_Inlist *head;
+ const Eina_Inlist *current;
};
struct _Eina_Accessor_Inlist
{
- Eina_Accessor accessor;
+ Eina_Accessor accessor;
- const Eina_Inlist *head;
- const Eina_Inlist *current;
+ const Eina_Inlist *head;
+ const Eina_Inlist *current;
- unsigned int index;
+ unsigned int index;
};
static Eina_Bool
eina_inlist_iterator_next(Eina_Iterator_Inlist *it, void **data) {
- if (it->current == NULL) return EINA_FALSE;
- if (data) *data = (void*) it->current;
+ if (it->current == NULL)
+ return EINA_FALSE;
- it->current = it->current->next;
+ if (data)
+ *data = (void *)it->current;
- return EINA_TRUE;
+ it->current = it->current->next;
+
+ return EINA_TRUE;
}
static Eina_Inlist *
eina_inlist_iterator_get_container(Eina_Iterator_Inlist *it) {
- return (Eina_Inlist*) it->head;
+ return (Eina_Inlist *)it->head;
}
static void
eina_inlist_iterator_free(Eina_Iterator_Inlist *it) {
- free(it);
+ free(it);
}
static Eina_Bool
-eina_inlist_accessor_get_at(Eina_Accessor_Inlist *it, unsigned int idx, void **data) {
- const Eina_Inlist *over;
- unsigned int middle;
- unsigned int i;
-
- if (it->index == idx) {
- over = it->current;
- } else if (idx > it->index) {
- /* Looking after current. */
- for (i = it->index, over = it->current;
- i < idx && over != NULL;
- ++i, over = over->next)
- ;
-
- } else {
- middle = it->index >> 1;
-
- if (idx > middle) {
- /* Looking backward from current. */
- for (i = it->index, over = it->current;
- i > idx && over != NULL;
- --i, over = over->prev)
- ;
- } else {
- /* Looking from the start. */
- for (i = 0, over = it->head;
- i < idx && over != NULL;
- ++i, over = over->next)
- ;
- }
- }
-
- if (over == NULL) return EINA_FALSE;
-
- it->current = over;
- it->index = idx;
-
- if (data) *data = (void*) over;
- return EINA_TRUE;
+eina_inlist_accessor_get_at(Eina_Accessor_Inlist *it,
+ unsigned int idx,
+ void **data) {
+ const Eina_Inlist *over;
+ unsigned int middle;
+ unsigned int i;
+
+ if (it->index == idx)
+ over = it->current;
+ else if (idx > it->index)
+ /* Looking after current. */
+ for (i = it->index, over = it->current;
+ i < idx && over != NULL;
+ ++i, over = over->next)
+ ;
+
+ else
+ {
+ middle = it->index >> 1;
+
+ if (idx > middle)
+ /* Looking backward from current. */
+ for (i = it->index, over = it->current;
+ i > idx && over != NULL;
+ --i, over = over->prev)
+ ;
+ else
+ /* Looking from the start. */
+ for (i = 0, over = it->head;
+ i < idx && over != NULL;
+ ++i, over = over->next)
+ ;
+ }
+
+ if (over == NULL)
+ return EINA_FALSE;
+
+ it->current = over;
+ it->index = idx;
+
+ if (data)
+ *data = (void *)over;
+
+ return EINA_TRUE;
}
static Eina_Inlist *
eina_inlist_accessor_get_container(Eina_Accessor_Inlist *it) {
- return (Eina_Inlist *) it->head;
+ return (Eina_Inlist *)it->head;
}
static void
eina_inlist_accessor_free(Eina_Accessor_Inlist *it) {
- free(it);
+ free(it);
}
/**
/*============================================================================*
- * Global *
- *============================================================================*/
+* Global *
+*============================================================================*/
/*============================================================================*
- * API *
- *============================================================================*/
+* API *
+*============================================================================*/
/**
* @addtogroup Eina_Inline_List_Group Inline List
* printf("list=%p\n", list);
* for (itr = list; itr != NULL; itr = itr->next)
* {
- * cur = EINA_INLIST_CONTAINER_GET(itr, struct my_struct);
- * printf("\ta=%d, b=%d\n", cur->a, cur->b);
+ * cur = EINA_INLIST_CONTAINER_GET(itr, struct my_struct);
+ * printf("\ta=%d, b=%d\n", cur->a, cur->b);
* }
*
* while (list)
* {
- * Eina_Inlist *aux = list;
- * list = eina_inlist_remove(list, list);
- * free(aux);
+ * Eina_Inlist *aux = list;
+ * list = eina_inlist_remove(list, list);
+ * free(aux);
* }
*
* eina_shutdown();
EINA_SAFETY_ON_NULL_RETURN_VAL(new_l, list);
new_l->next = NULL;
- if (!list) {
- new_l->prev = NULL;
- new_l->last = new_l;
- return new_l;
- }
+ if (!list)
+ {
+ new_l->prev = NULL;
+ new_l->last = new_l;
+ return new_l;
+ }
+
if (list->last)
- l = list->last;
+ l = list->last;
else
- for (l = list; (l) && (l->next); l = l->next)
- ;
+ for (l = list; (l) && (l->next); l = l->next)
+ ;
+
l->next = new_l;
new_l->prev = l;
list->last = new_l;
EINA_SAFETY_ON_NULL_RETURN_VAL(new_l, list);
new_l->prev = NULL;
- if (!list) {
- new_l->next = NULL;
- new_l->last = new_l;
- return new_l;
- }
+ if (!list)
+ {
+ new_l->next = NULL;
+ new_l->last = new_l;
+ return new_l;
+ }
+
new_l->next = list;
list->prev = new_l;
new_l->last = list->last;
*/
EAPI Eina_Inlist *
eina_inlist_append_relative(Eina_Inlist *list,
- Eina_Inlist *new_l,
- Eina_Inlist *relative)
+ Eina_Inlist *new_l,
+ Eina_Inlist *relative)
{
EINA_SAFETY_ON_NULL_RETURN_VAL(new_l, list);
- if (relative) {
- if (relative->next) {
- new_l->next = relative->next;
- relative->next->prev = new_l;
- } else
- new_l->next = NULL;
- relative->next = new_l;
- new_l->prev = relative;
- if (!new_l->next)
- list->last = new_l;
- return list;
- }
+ if (relative)
+ {
+ if (relative->next)
+ {
+ new_l->next = relative->next;
+ relative->next->prev = new_l;
+ }
+ else
+ new_l->next = NULL;
+
+ relative->next = new_l;
+ new_l->prev = relative;
+ if (!new_l->next)
+ list->last = new_l;
+
+ return list;
+ }
+
return eina_inlist_append(list, new_l);
}
*/
EAPI Eina_Inlist *
eina_inlist_prepend_relative(Eina_Inlist *list,
- Eina_Inlist *new_l,
- Eina_Inlist *relative)
+ Eina_Inlist *new_l,
+ Eina_Inlist *relative)
{
EINA_SAFETY_ON_NULL_RETURN_VAL(new_l, list);
- if (relative) {
- new_l->prev = relative->prev;
- new_l->next = relative;
- relative->prev = new_l;
- if (new_l->prev) {
- new_l->prev->next = new_l;
- /* new_l->next could not be NULL, as it was set to 'relative' */
- assert(new_l->next);
- return list;
- } else {
- /* new_l->next could not be NULL, as it was set to 'relative' */
- assert(new_l->next);
-
- new_l->last = list->last;
- list->last = NULL;
- return new_l;
- }
- }
+ if (relative)
+ {
+ new_l->prev = relative->prev;
+ new_l->next = relative;
+ relative->prev = new_l;
+ if (new_l->prev)
+ {
+ new_l->prev->next = new_l;
+ /* new_l->next could not be NULL, as it was set to 'relative' */
+ assert(new_l->next);
+ return list;
+ }
+ else
+ {
+ /* new_l->next could not be NULL, as it was set to 'relative' */
+ assert(new_l->next);
+
+ new_l->last = list->last;
+ list->last = NULL;
+ return new_l;
+ }
+ }
+
return eina_inlist_prepend(list, new_l);
}
EINA_SAFETY_ON_NULL_RETURN_VAL(list, NULL);
EINA_SAFETY_ON_NULL_RETURN_VAL(item, list);
EINA_SAFETY_ON_TRUE_RETURN_VAL
- ((item != list) && (item->prev == NULL) && (item->next == NULL), list);
+ ((item != list) && (item->prev == NULL) && (item->next == NULL), list);
if (item->next)
- item->next->prev = item->prev;
+ item->next->prev = item->prev;
+
+ if (item->prev)
+ {
+ item->prev->next = item->next;
+ return_l = list;
+ }
+ else
+ {
+ return_l = item->next;
+ if (return_l)
+ return_l->last = list->last;
+ }
- if (item->prev) {
- item->prev->next = item->next;
- return_l = list;
- } else {
- return_l = item->next;
- if (return_l)
- return_l->last = list->last;
- }
if (item == list->last)
- list->last = item->prev;
+ list->last = item->prev;
+
item->next = NULL;
item->prev = NULL;
return return_l;
EINA_SAFETY_ON_NULL_RETURN_VAL(list, NULL);
EINA_SAFETY_ON_NULL_RETURN_VAL(item, list);
- if (item == list) return list;
+ if (item == list)
+ return list;
if (item->next)
- item->next->prev = item->prev;
+ item->next->prev = item->prev;
+
item->prev->next = item->next;
if (list->last == item)
- list->last = item->prev;
+ list->last = item->prev;
item->next = list;
item->prev = NULL;
EINA_SAFETY_ON_NULL_RETURN_VAL(list, NULL);
EINA_SAFETY_ON_NULL_RETURN_VAL(item, list);
- if (list->last == item) return list;
+ if (list->last == item)
+ return list;
if (!list->last)
{
- for (l = list; l->next; l = l->next)
- ;
- list->last = l;
+ for (l = list; l->next; l = l->next)
+ ;
+ list->last = l;
}
l = list;
if (item->prev)
- item->prev->next = item->next;
+ item->prev->next = item->next;
else
- l = item->next;
+ l = item->next;
+
item->next->prev = item->prev;
list->last->next = item;
Eina_Inlist *l;
for (l = list; l; l = l->next) {
- if (l == item)
- return item;
- }
+ if (l == item)
+ return item;
+ }
return NULL;
}
unsigned int i = 0;
for (l = list; l; l = l->next)
- i++;
+ i++;
return i;
}
{
Eina_Iterator_Inlist *it;
- eina_error_set(0);
+ eina_error_set(0);
it = calloc(1, sizeof (Eina_Iterator_Inlist));
- if (!it) {
- eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
- return NULL;
- }
+ if (!it)
+ {
+ eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+ return NULL;
+ }
it->head = list;
it->current = list;
it->iterator.next = FUNC_ITERATOR_NEXT(eina_inlist_iterator_next);
- it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(eina_inlist_iterator_get_container);
+ it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(
+ eina_inlist_iterator_get_container);
it->iterator.free = FUNC_ITERATOR_FREE(eina_inlist_iterator_free);
EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_ITERATOR);
{
Eina_Accessor_Inlist *it;
- eina_error_set(0);
+ eina_error_set(0);
it = calloc(1, sizeof (Eina_Accessor_Inlist));
- if (!it) {
- eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
- return NULL;
- }
+ if (!it)
+ {
+ eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+ return NULL;
+ }
it->head = list;
it->current = list;
it->index = 0;
it->accessor.get_at = FUNC_ACCESSOR_GET_AT(eina_inlist_accessor_get_at);
- it->accessor.get_container = FUNC_ACCESSOR_GET_CONTAINER(eina_inlist_accessor_get_container);
+ it->accessor.get_container = FUNC_ACCESSOR_GET_CONTAINER(
+ eina_inlist_accessor_get_container);
it->accessor.free = FUNC_ACCESSOR_FREE(eina_inlist_accessor_free);
EINA_MAGIC_SET(&it->accessor, EINA_MAGIC_ACCESSOR);
#include "eina_iterator.h"
/*============================================================================*
- * Local *
- *============================================================================*/
+* Local *
+*============================================================================*/
/**
* @cond LOCAL
static const char EINA_MAGIC_ITERATOR_STR[] = "Eina Iterator";
-#define EINA_MAGIC_CHECK_ITERATOR(d) \
- do { \
- if (!EINA_MAGIC_CHECK(d, EINA_MAGIC_ITERATOR)) \
- EINA_MAGIC_FAIL(d, EINA_MAGIC_ITERATOR); \
- } while(0)
+#define EINA_MAGIC_CHECK_ITERATOR(d) \
+ do { \
+ if (!EINA_MAGIC_CHECK(d, EINA_MAGIC_ITERATOR)) { \
+ EINA_MAGIC_FAIL(d, EINA_MAGIC_ITERATOR); } \
+ } while(0)
/**
* @endcond
/*============================================================================*
- * Global *
- *============================================================================*/
+* Global *
+*============================================================================*/
/**
* @internal
}
/*============================================================================*
- * API *
- *============================================================================*/
+* API *
+*============================================================================*/
/**
* @addtogroup Eina_Iterator_Group Iterator Functions
eina_iterator_container_get(Eina_Iterator *iterator)
{
EINA_MAGIC_CHECK_ITERATOR(iterator);
- EINA_SAFETY_ON_NULL_RETURN_VAL(iterator, NULL);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(iterator, NULL);
EINA_SAFETY_ON_NULL_RETURN_VAL(iterator->get_container, NULL);
return iterator->get_container(iterator);
}
EAPI Eina_Bool
eina_iterator_next(Eina_Iterator *iterator, void **data)
{
- if (!iterator) return EINA_FALSE;
+ if (!iterator)
+ return EINA_FALSE;
+
EINA_MAGIC_CHECK_ITERATOR(iterator);
- EINA_SAFETY_ON_NULL_RETURN_VAL(iterator, EINA_FALSE);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(iterator, EINA_FALSE);
EINA_SAFETY_ON_NULL_RETURN_VAL(iterator->next, EINA_FALSE);
- EINA_SAFETY_ON_NULL_RETURN_VAL(data, EINA_FALSE);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(data, EINA_FALSE);
return iterator->next(iterator, data);
}
*/
EAPI void
eina_iterator_foreach(Eina_Iterator *iterator,
- Eina_Each cb,
- const void *fdata)
+ Eina_Each cb,
+ const void *fdata)
{
const void *container;
void *data;
container = iterator->get_container(iterator);
while (iterator->next(iterator, &data) == EINA_TRUE) {
- if (cb(container, data, (void*) fdata) != EINA_TRUE) return ;
- }
+ if (cb(container, data, (void *)fdata) != EINA_TRUE)
+ return;
+ }
}
/**
#include "eina_lalloc.h"
/*============================================================================*
- * Local *
- *============================================================================*/
+* Local *
+*============================================================================*/
/**
* @cond LOCAL
struct _Eina_Lalloc
{
- void *data;
- int num_allocated;
- int num_elements;
- int acc;
- Eina_Lalloc_Alloc alloc_cb;
- Eina_Lalloc_Free free_cb;
+ void *data;
+ int num_allocated;
+ int num_elements;
+ int acc;
+ Eina_Lalloc_Alloc alloc_cb;
+ Eina_Lalloc_Free free_cb;
};
/**
*/
/*============================================================================*
- * Global *
- *============================================================================*/
+* Global *
+*============================================================================*/
/*============================================================================*
- * API *
- *============================================================================*/
+* API *
+*============================================================================*/
/**
* @addtogroup Eina_Lalloc_Group Lazy allocator
* @{
*/
-EAPI Eina_Lalloc * eina_lalloc_new(void *data, Eina_Lalloc_Alloc alloc_cb, Eina_Lalloc_Free free_cb, int num_init)
+EAPI Eina_Lalloc *eina_lalloc_new(void *data,
+ Eina_Lalloc_Alloc alloc_cb,
+ Eina_Lalloc_Free free_cb,
+ int num_init)
{
- Eina_Lalloc *a;
-
- EINA_SAFETY_ON_NULL_RETURN_VAL(alloc_cb, NULL);
- EINA_SAFETY_ON_NULL_RETURN_VAL(free_cb, NULL);
-
- a = calloc(1, sizeof(Eina_Lalloc));
- a->data = data;
- a->alloc_cb = alloc_cb;
- a->free_cb = free_cb;
- if (num_init > 0)
- {
- a->num_allocated = num_init;
- a->alloc_cb(a->data, a->num_allocated);
- }
- return a;
+ Eina_Lalloc *a;
+
+ EINA_SAFETY_ON_NULL_RETURN_VAL(alloc_cb, NULL);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(free_cb, NULL);
+
+ a = calloc(1, sizeof(Eina_Lalloc));
+ a->data = data;
+ a->alloc_cb = alloc_cb;
+ a->free_cb = free_cb;
+ if (num_init > 0)
+ {
+ a->num_allocated = num_init;
+ a->alloc_cb(a->data, a->num_allocated);
+ }
+
+ return a;
}
EAPI void eina_lalloc_free(Eina_Lalloc *a)
{
- EINA_SAFETY_ON_NULL_RETURN(a);
- EINA_SAFETY_ON_NULL_RETURN(a->free_cb);
- a->free_cb(a->data);
- free(a);
+ EINA_SAFETY_ON_NULL_RETURN(a);
+ EINA_SAFETY_ON_NULL_RETURN(a->free_cb);
+ a->free_cb(a->data);
+ free(a);
}
EAPI Eina_Bool eina_lalloc_element_add(Eina_Lalloc *a)
{
- EINA_SAFETY_ON_NULL_RETURN_VAL(a, EINA_FALSE);
- EINA_SAFETY_ON_NULL_RETURN_VAL(a->alloc_cb, EINA_FALSE);
-
- if (a->num_elements == a->num_allocated)
- {
- if (a->alloc_cb(a->data, (1 << a->acc)) == EINA_TRUE)
- {
- a->num_allocated = (1 << a->acc);
- a->acc++;
- } else {
- return EINA_FALSE;
- }
- }
- a->num_elements++;
-
- return EINA_TRUE;
+ EINA_SAFETY_ON_NULL_RETURN_VAL(a, EINA_FALSE);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(a->alloc_cb, EINA_FALSE);
+
+ if (a->num_elements == a->num_allocated)
+ {
+ if (a->alloc_cb(a->data, (1 << a->acc)) == EINA_TRUE)
+ {
+ a->num_allocated = (1 << a->acc);
+ a->acc++;
+ }
+ else
+ return EINA_FALSE;
+ }
+
+ a->num_elements++;
+
+ return EINA_TRUE;
}
EAPI Eina_Bool eina_lalloc_elements_add(Eina_Lalloc *a, int num)
{
- int tmp;
-
- EINA_SAFETY_ON_NULL_RETURN_VAL(a, EINA_FALSE);
- EINA_SAFETY_ON_NULL_RETURN_VAL(a->alloc_cb, EINA_FALSE);
-
- tmp = a->num_elements + num;
- if (tmp > a->num_allocated)
- {
- int allocated;
- int acc;
-
- allocated = a->num_allocated;
- acc = a->acc;
-
- while (tmp > allocated)
- {
- allocated = (1 << acc);
- acc++;
- }
-
- if (a->alloc_cb(a->data, allocated) == EINA_TRUE)
- {
- a->num_allocated = allocated;
- a->acc = acc;
- } else {
- return EINA_FALSE;
- }
- }
- a->num_elements += num;
-
- return EINA_TRUE;
+ int tmp;
+
+ EINA_SAFETY_ON_NULL_RETURN_VAL(a, EINA_FALSE);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(a->alloc_cb, EINA_FALSE);
+
+ tmp = a->num_elements + num;
+ if (tmp > a->num_allocated)
+ {
+ int allocated;
+ int acc;
+
+ allocated = a->num_allocated;
+ acc = a->acc;
+
+ while (tmp > allocated)
+ {
+ allocated = (1 << acc);
+ acc++;
+ }
+
+ if (a->alloc_cb(a->data, allocated) == EINA_TRUE)
+ {
+ a->num_allocated = allocated;
+ a->acc = acc;
+ }
+ else
+ return EINA_FALSE;
+ }
+
+ a->num_elements += num;
+
+ return EINA_TRUE;
}
/**
/*============================================================================*
- * Local *
- *============================================================================*/
+* Local *
+*============================================================================*/
/**
* @cond LOCAL
static const char EINA_MAGIC_LIST_ACCOUNTING_STR[] = "Eina List Accounting";
-#define EINA_MAGIC_CHECK_LIST(d, ...) \
- do { \
- if (!EINA_MAGIC_CHECK(d, EINA_MAGIC_LIST)) \
- { \
- EINA_MAGIC_FAIL(d, EINA_MAGIC_LIST); \
- return __VA_ARGS__; \
- } \
- } while(0)
-
-#define EINA_MAGIC_CHECK_LIST_ITERATOR(d, ...) \
- do { \
- if (!EINA_MAGIC_CHECK(d, EINA_MAGIC_LIST_ITERATOR)) \
- { \
- EINA_MAGIC_FAIL(d, EINA_MAGIC_LIST_ITERATOR); \
- return __VA_ARGS__; \
- } \
- } while(0)
-
-#define EINA_MAGIC_CHECK_LIST_ACCESSOR(d, ...) \
- do { \
- if (!EINA_MAGIC_CHECK(d, EINA_MAGIC_LIST_ACCESSOR)) \
- { \
- EINA_MAGIC_FAIL(d, EINA_MAGIC_LIST_ACCESSOR); \
- return __VA_ARGS__; \
- } \
- } while(0)
-
-#define EINA_MAGIC_CHECK_LIST_ACCOUNTING(d) \
- do { \
- if (!EINA_MAGIC_CHECK(d, EINA_MAGIC_LIST_ACCOUNTING)) \
- { \
- EINA_MAGIC_FAIL(d, EINA_MAGIC_LIST_ACCOUNTING); \
- return; \
- } \
- } while(0)
+#define EINA_MAGIC_CHECK_LIST(d, ...) \
+ do { \
+ if (!EINA_MAGIC_CHECK(d, EINA_MAGIC_LIST)) \
+ { \
+ EINA_MAGIC_FAIL(d, EINA_MAGIC_LIST); \
+ return __VA_ARGS__; \
+ } \
+ } while(0)
+
+#define EINA_MAGIC_CHECK_LIST_ITERATOR(d, ...) \
+ do { \
+ if (!EINA_MAGIC_CHECK(d, EINA_MAGIC_LIST_ITERATOR)) \
+ { \
+ EINA_MAGIC_FAIL(d, EINA_MAGIC_LIST_ITERATOR); \
+ return __VA_ARGS__; \
+ } \
+ } while(0)
+
+#define EINA_MAGIC_CHECK_LIST_ACCESSOR(d, ...) \
+ do { \
+ if (!EINA_MAGIC_CHECK(d, EINA_MAGIC_LIST_ACCESSOR)) \
+ { \
+ EINA_MAGIC_FAIL(d, EINA_MAGIC_LIST_ACCESSOR); \
+ return __VA_ARGS__; \
+ } \
+ } while(0)
+
+#define EINA_MAGIC_CHECK_LIST_ACCOUNTING(d) \
+ do { \
+ if (!EINA_MAGIC_CHECK(d, EINA_MAGIC_LIST_ACCOUNTING)) \
+ { \
+ EINA_MAGIC_FAIL(d, EINA_MAGIC_LIST_ACCOUNTING); \
+ return; \
+ } \
+ } while(0)
#define EINA_LIST_SORT_STACK_SIZE 32
#endif
#define DBG(...) EINA_LOG_DOM_DBG(_eina_list_log_dom, __VA_ARGS__)
-static inline Eina_List_Accounting*
+static inline Eina_List_Accounting *
_eina_list_mempool_accounting_new(__UNUSED__ Eina_List *list)
{
Eina_List_Accounting *tmp;
- tmp = eina_mempool_malloc(_eina_list_accounting_mp, sizeof (Eina_List_Accounting));
- if (!tmp) return NULL;
+ tmp =
+ eina_mempool_malloc(_eina_list_accounting_mp,
+ sizeof (Eina_List_Accounting));
+ if (!tmp)
+ return NULL;
EINA_MAGIC_SET(tmp, EINA_MAGIC_LIST_ACCOUNTING);
eina_mempool_free(_eina_list_accounting_mp, accounting);
}
-static inline Eina_List*
+static inline Eina_List *
_eina_list_mempool_list_new(__UNUSED__ Eina_List *list)
{
Eina_List *tmp;
tmp = eina_mempool_malloc(_eina_list_mp, sizeof (Eina_List));
- if (!tmp) return NULL;
+ if (!tmp)
+ return NULL;
EINA_MAGIC_SET(tmp, EINA_MAGIC_LIST);
list->accounting->count--;
if (list->accounting->count == 0)
- _eina_list_mempool_accounting_free(list->accounting);
+ _eina_list_mempool_accounting_free(list->accounting);
EINA_MAGIC_SET(list, EINA_MAGIC_NONE);
eina_mempool_free(_eina_list_mp, list);
EINA_MAGIC_CHECK_LIST(list, NULL);
list->accounting = _eina_list_mempool_accounting_new(list);
- if (!list->accounting) goto on_error;
+ if (!list->accounting)
+ goto on_error;
list->accounting->last = list;
list->accounting->count = 1;
return list;
- on_error:
+on_error:
_eina_list_mempool_list_free(list);
return NULL;
}
{
EINA_MAGIC_CHECK_LIST_ITERATOR(it, EINA_FALSE);
- if (it->current == NULL) return EINA_FALSE;
+ if (it->current == NULL)
+ return EINA_FALSE;
+
*data = eina_list_data_get(it->current);
it->current = eina_list_next(it->current);
{
EINA_MAGIC_CHECK_LIST_ITERATOR(it, EINA_FALSE);
- if (it->current == NULL) return EINA_FALSE;
+ if (it->current == NULL)
+ return EINA_FALSE;
+
*data = eina_list_data_get(it->current);
it->current = eina_list_prev(it->current);
{
EINA_MAGIC_CHECK_LIST_ITERATOR(it, NULL);
- return (Eina_List *) it->head;
+ return (Eina_List *)it->head;
}
static void
EINA_MAGIC_CHECK_LIST_ACCESSOR(it, EINA_FALSE);
- if (idx >= eina_list_count(it->head)) return EINA_FALSE;
+ if (idx >= eina_list_count(it->head))
+ return EINA_FALSE;
if (it->index == idx)
- {
- over = it->current;
- }
+ over = it->current;
else if (idx > it->index)
{
- /* After current position. */
- middle = ((eina_list_count(it->head) - it->index) >> 1) + it->index;
-
- if (idx > middle)
- {
- /* Go backward from the end. */
- for (i = eina_list_count(it->head) - 1, over = eina_list_last(it->head);
- i > idx && over != NULL;
- --i, over = eina_list_prev(over))
- ;
- }
- else
- {
- /* Go forward from current. */
- for (i = it->index, over = it->current;
- i < idx && over != NULL;
- ++i, over = eina_list_next(over))
- ;
- }
+ /* After current position. */
+ middle = ((eina_list_count(it->head) - it->index) >> 1) + it->index;
+
+ if (idx > middle)
+ /* Go backward from the end. */
+ for (i = eina_list_count(it->head) - 1,
+ over = eina_list_last(it->head);
+ i > idx && over != NULL;
+ --i, over = eina_list_prev(over))
+ ;
+ else
+ /* Go forward from current. */
+ for (i = it->index, over = it->current;
+ i < idx && over != NULL;
+ ++i, over = eina_list_next(over))
+ ;
}
else
{
- /* Before current position. */
- middle = it->index >> 1;
-
- if (idx > middle)
- {
- /* Go backward from current. */
- for (i = it->index, over = it->current;
- i > idx && over != NULL;
- --i, over = eina_list_prev(over))
- ;
- }
- else
- {
- /* Go forward from start. */
- for (i = 0, over = it->head;
- i < idx && over != NULL;
- ++i, over = eina_list_next(over))
- ;
- }
+ /* Before current position. */
+ middle = it->index >> 1;
+
+ if (idx > middle)
+ /* Go backward from current. */
+ for (i = it->index, over = it->current;
+ i > idx && over != NULL;
+ --i, over = eina_list_prev(over))
+ ;
+ else
+ /* Go forward from start. */
+ for (i = 0, over = it->head;
+ i < idx && over != NULL;
+ ++i, over = eina_list_next(over))
+ ;
}
- if (over == NULL) return EINA_FALSE;
+ if (over == NULL)
+ return EINA_FALSE;
it->current = over;
it->index = idx;
{
EINA_MAGIC_CHECK_LIST_ACCESSOR(it, NULL);
- return (Eina_List *) it->head;
+ return (Eina_List *)it->head;
}
static void
for (; list; list = list->next)
{
- list->prev = prev;
- prev = list;
+ list->prev = prev;
+ prev = list;
}
return prev;
Eina_List *first, *last;
if (func(a->data, b->data) < 0)
- a = (last = first = a)->next;
+ a = (last = first = a)->next;
else
- b = (last = first = b)->next;
+ b = (last = first = b)->next;
while (a && b)
- if (func(a->data, b->data) < 0)
- a = (last = last->next = a)->next;
- else
- b = (last = last->next = b)->next;
+ if (func(a->data, b->data) < 0)
+ a = (last = last->next = a)->next;
+ else
+ b = (last = last->next = b)->next;
last->next = a ? a : b;
*/
/*============================================================================*
- * Global *
- *============================================================================*/
+* Global *
+*============================================================================*/
/**
* @internal
{
const char *choice, *tmp;
- _eina_list_log_dom = eina_log_domain_register("eina_list", EINA_LOG_COLOR_DEFAULT);
+ _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");
- return EINA_FALSE;
+ EINA_LOG_ERR("Could not register log domain: eina_list");
+ return EINA_FALSE;
}
#ifdef EINA_DEFAULT_MEMPOOL
#endif
tmp = getenv("EINA_MEMPOOL");
if (tmp && tmp[0])
- choice = tmp;
+ choice = tmp;
_eina_list_mp = eina_mempool_add
- (choice, "list", NULL, sizeof(Eina_List), 320);
+ (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;
+ 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);
+ (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;
+ ERR(
+ "ERROR: Mempool for list accounting cannot be allocated in list init.");
+ eina_mempool_del(_eina_list_mp);
+ goto on_init_fail;
}
-#define EMS(n) eina_magic_string_static_set(n, n##_STR)
+#define EMS(n) eina_magic_string_static_set(n, n ## _STR)
EMS(EINA_MAGIC_LIST);
EMS(EINA_MAGIC_LIST_ITERATOR);
EMS(EINA_MAGIC_LIST_ACCESSOR);
return EINA_TRUE;
- on_init_fail:
+on_init_fail:
eina_log_domain_unregister(_eina_list_log_dom);
_eina_list_log_dom = -1;
return EINA_FALSE;
}
/*============================================================================*
- * API *
- *============================================================================*/
+* API *
+*============================================================================*/
/**
* @addtogroup Eina_List_Group List
eina_error_set(0);
new_l = _eina_list_mempool_list_new(list);
- if (!new_l) return list;
+ if (!new_l)
+ return list;
+
new_l->next = NULL;
new_l->data = (void *)data;
if (!list)
{
- new_l->prev = NULL;
- return _eina_list_setup_accounting(new_l);
+ new_l->prev = NULL;
+ return _eina_list_setup_accounting(new_l);
}
EINA_MAGIC_CHECK_LIST(list, NULL);
eina_error_set(0);
new_l = _eina_list_mempool_list_new(list);
- if (!new_l) return list;
+ if (!new_l)
+ return list;
new_l->prev = NULL;
new_l->next = list;
new_l->data = (void *)data;
- if (!list) return _eina_list_setup_accounting(new_l);
+ if (!list)
+ return _eina_list_setup_accounting(new_l);
EINA_MAGIC_CHECK_LIST(list, NULL);
* @endcode
*/
EAPI Eina_List *
-eina_list_append_relative(Eina_List *list, const void *data, const void *relative)
+eina_list_append_relative(Eina_List *list,
+ const void *data,
+ const void *relative)
{
Eina_List *l;
void *list_data;
- if (list) EINA_MAGIC_CHECK_LIST(list, NULL);
+ if (list)
+ EINA_MAGIC_CHECK_LIST(list, NULL);
EINA_LIST_FOREACH(list, l, list_data)
- {
- if (list_data == relative)
- return eina_list_append_relative_list(list, data, l);
- }
+ {
+ if (list_data == relative)
+ return eina_list_append_relative_list(list, data, l);
+ }
return eina_list_append(list, data);
}
* old pointer is returned.
*/
EAPI Eina_List *
-eina_list_append_relative_list(Eina_List *list, const void *data, Eina_List *relative)
+eina_list_append_relative_list(Eina_List *list,
+ const void *data,
+ Eina_List *relative)
{
Eina_List *new_l;
- if ((!list) || (!relative)) return eina_list_append(list, data);
+ if ((!list) || (!relative))
+ return eina_list_append(list, data);
+
eina_error_set(0);
new_l = _eina_list_mempool_list_new(list);
- if (!new_l) return list;
+ if (!new_l)
+ return list;
EINA_MAGIC_CHECK_LIST(relative, NULL);
new_l->next = relative->next;
new_l->data = (void *)data;
if (relative->next)
- relative->next->prev = new_l;
+ relative->next->prev = new_l;
relative->next = new_l;
new_l->prev = relative;
_eina_list_update_accounting(list, new_l);
if (!new_l->next)
- new_l->accounting->last = new_l;
+ new_l->accounting->last = new_l;
return list;
}
* @endcode
*/
EAPI Eina_List *
-eina_list_prepend_relative(Eina_List *list, const void *data, const void *relative)
+eina_list_prepend_relative(Eina_List *list,
+ const void *data,
+ const void *relative)
{
Eina_List *l;
void *list_data;
- if (list) EINA_MAGIC_CHECK_LIST(list, NULL);
+ if (list)
+ EINA_MAGIC_CHECK_LIST(list, NULL);
EINA_LIST_FOREACH(list, l, list_data)
- {
- if (list_data == relative)
- return eina_list_prepend_relative_list(list, data, l);
- }
+ {
+ if (list_data == relative)
+ return eina_list_prepend_relative_list(list, data, l);
+ }
return eina_list_prepend(list, data);
}
* old pointer is returned.
*/
EAPI Eina_List *
-eina_list_prepend_relative_list(Eina_List *list, const void *data, Eina_List *relative)
+eina_list_prepend_relative_list(Eina_List *list,
+ const void *data,
+ Eina_List *relative)
{
Eina_List *new_l;
- if ((!list) || (!relative)) return eina_list_prepend(list, data);
+ if ((!list) || (!relative))
+ return eina_list_prepend(list, data);
+
eina_error_set(0);
new_l = _eina_list_mempool_list_new(list);
- if (!new_l) return list;
+ if (!new_l)
+ return list;
EINA_MAGIC_CHECK_LIST(relative, NULL);
new_l->next = relative;
new_l->data = (void *)data;
- if (relative->prev) relative->prev->next = new_l;
+ if (relative->prev)
+ relative->prev->next = new_l;
+
relative->prev = new_l;
_eina_list_update_accounting(list, new_l);
if (new_l->prev)
- return list;
+ return list;
return new_l;
}
Eina_List *lnear;
int cmp;
- if (!list) return eina_list_append(NULL, data);
+ if (!list)
+ return eina_list_append(NULL, data);
lnear = eina_list_search_sorted_near_list(list, func, data, &cmp);
if (cmp < 0)
- return eina_list_append_relative_list(list, data, lnear);
+ return eina_list_append_relative_list(list, data, lnear);
else
- return eina_list_prepend_relative_list(list, data, lnear);
+ return eina_list_prepend_relative_list(list, data, lnear);
}
/**
{
Eina_List *l;
- if (list) EINA_MAGIC_CHECK_LIST(list, NULL);
+ if (list)
+ EINA_MAGIC_CHECK_LIST(list, NULL);
l = eina_list_data_find_list(list, data);
return eina_list_remove_list(list, l);
{
Eina_List *return_l;
- if (!list) return NULL;
- if (!remove_list) return list;
+ if (!list)
+ return NULL;
+
+ if (!remove_list)
+ return list;
+
+ EINA_MAGIC_CHECK_LIST(remove_list, NULL);
- EINA_MAGIC_CHECK_LIST(remove_list, NULL);
+ if (remove_list->next)
+ remove_list->next->prev = remove_list->prev;
- if (remove_list->next) remove_list->next->prev = remove_list->prev;
if (remove_list->prev)
{
- remove_list->prev->next = remove_list->next;
- return_l = list;
+ remove_list->prev->next = remove_list->next;
+ return_l = list;
}
else
- return_l = remove_list->next;
+ return_l = remove_list->next;
+
if (remove_list == remove_list->accounting->last)
{
- EINA_MAGIC_CHECK_LIST(list, NULL);
- list->accounting->last = remove_list->prev;
+ EINA_MAGIC_CHECK_LIST(list, NULL);
+ list->accounting->last = remove_list->prev;
}
+
_eina_list_mempool_list_free(remove_list);
return return_l;
}
{
Eina_List *l, *free_l;
- if (!list) return NULL;
+ if (!list)
+ return NULL;
EINA_MAGIC_CHECK_LIST(list, NULL);
- for (l = list; l;)
+ for (l = list; l; )
{
- free_l = l;
- l = l->next;
+ free_l = l;
+ l = l->next;
- _eina_list_mempool_list_free(free_l);
+ _eina_list_mempool_list_free(free_l);
}
return NULL;
EAPI Eina_List *
eina_list_promote_list(Eina_List *list, Eina_List *move_list)
{
- if (!list) return NULL;
- if (!move_list) return list;
- /* Promoting head to be head. */
- if (move_list == list) return list;
- if (move_list->next == list) return move_list;
+ if (!list)
+ return NULL;
- EINA_MAGIC_CHECK_LIST(list, NULL);
- EINA_MAGIC_CHECK_LIST(move_list, NULL);
+ if (!move_list)
+ return list; /* Promoting head to be head. */
+
+ if (move_list == list)
+ return list;
+
+ if (move_list->next == list)
+ return move_list;
+
+ EINA_MAGIC_CHECK_LIST(list, NULL);
+ EINA_MAGIC_CHECK_LIST(move_list, NULL);
/* Remove the promoted item from the list. */
if (!move_list->prev)
move_list->next->prev = NULL;
else
{
- move_list->prev->next = move_list->next;
- if (move_list == list->accounting->last)
- list->accounting->last = move_list->prev;
- else
- move_list->next->prev = move_list->prev;
+ move_list->prev->next = move_list->next;
+ if (move_list == list->accounting->last)
+ list->accounting->last = move_list->prev;
+ else
+ move_list->next->prev = move_list->prev;
}
/* Add the promoted item in the list. */
EAPI Eina_List *
eina_list_demote_list(Eina_List *list, Eina_List *move_list)
{
- if (!list) return NULL;
- if (!move_list) return list;
- /* Demoting tail to be tail. */
- if (move_list == list->accounting->last) return list;
+ if (!list)
+ return NULL;
- EINA_MAGIC_CHECK_LIST(list, NULL);
- EINA_MAGIC_CHECK_LIST(move_list, NULL);
+ if (!move_list)
+ return list; /* Demoting tail to be tail. */
+
+ if (move_list == list->accounting->last)
+ return list;
+
+ EINA_MAGIC_CHECK_LIST(list, NULL);
+ EINA_MAGIC_CHECK_LIST(move_list, NULL);
/* Update pointer list if necessary. */
if (list == move_list)
- list = move_list->next;
- /* Remove the demoted item from the list. */
+ list = move_list->next; /* Remove the demoted item from the list. */
+
if (move_list->prev)
move_list->prev->next = move_list->next;
+
move_list->next->prev = move_list->prev;
/* Add the demoted item in the list. */
move_list->prev = list->accounting->last;
EAPI void *
eina_list_data_find(const Eina_List *list, const void *data)
{
- if (eina_list_data_find_list(list, data)) return (void*) data;
+ if (eina_list_data_find_list(list, data))
+ return (void *)data;
+
return NULL;
}
const Eina_List *l;
void *list_data;
- if (list) EINA_MAGIC_CHECK_LIST(list, NULL);
+ if (list)
+ EINA_MAGIC_CHECK_LIST(list, NULL);
- EINA_LIST_FOREACH(list, l, list_data)
- {
- if (list_data == data) return (Eina_List *)l;
- }
+ EINA_LIST_FOREACH(list, l, list_data)
+ {
+ if (list_data == data)
+ return (Eina_List *)l;
+ }
return NULL;
}
const Eina_List *l;
unsigned int i;
- if (list) EINA_MAGIC_CHECK_LIST(list, NULL);
+ if (list)
+ EINA_MAGIC_CHECK_LIST(list, NULL);
/* check for non-existing nodes */
if ((!list) || (n > (list->accounting->count - 1)))
- return NULL;
+ return NULL;
/* if the node is in the 2nd half of the list, search from the end
* else, search from the beginning.
*/
if (n > (list->accounting->count / 2))
- {
- for (i = list->accounting->count - 1,
- l = list->accounting->last;
- l;
- l = l->prev, i--)
- {
- if (i == n) return (Eina_List *)l;
- }
- }
+ for (i = list->accounting->count - 1,
+ l = list->accounting->last;
+ l;
+ l = l->prev, i--)
+ {
+ if (i == n)
+ return (Eina_List *)l;
+ }
else
- {
- for (i = 0, l = list; l; l = l->next, i++)
- {
- if (i == n) return (Eina_List *)l;
- }
- }
+ for (i = 0, l = list; l; l = l->next, i++)
+ {
+ if (i == n)
+ return (Eina_List *)l;
+ }
+
abort();
}
{
Eina_List *l1, *l2;
- if (!list) return NULL;
+ if (!list)
+ return NULL;
EINA_MAGIC_CHECK_LIST(list, NULL);
l2 = list->accounting->last;
while (l1 != l2)
{
- void *data;
-
- data = l1->data;
- l1->data = l2->data;
- l2->data = data;
- l1 = l1->next;
- if (l1 == l2) break;
- l2 = l2->prev;
+ void *data;
+
+ data = l1->data;
+ l1->data = l2->data;
+ l2->data = data;
+ l1 = l1->next;
+ if (l1 == l2)
+ break;
+
+ l2 = l2->prev;
}
return list;
Eina_List *lclone;
void *data;
- if (!list) return NULL;
+ if (!list)
+ return NULL;
EINA_MAGIC_CHECK_LIST(list, NULL);
lclone = NULL;
EINA_LIST_FOREACH(list, l, data)
- lclone = eina_list_prepend(lclone, data);
+ lclone = eina_list_prepend(lclone, data);
return lclone;
}
Eina_List *lclone;
void *data;
- if (!list) return NULL;
+ if (!list)
+ return NULL;
EINA_MAGIC_CHECK_LIST(list, NULL);
lclone = NULL;
EINA_LIST_FOREACH(list, l, data)
- lclone = eina_list_append(lclone, data);
+ lclone = eina_list_append(lclone, data);
return lclone;
}
Eina_List *stack[EINA_LIST_SORT_STACK_SIZE];
EINA_SAFETY_ON_NULL_RETURN_VAL(func, list);
- if (!list) return NULL;
+ if (!list)
+ return NULL;
+
EINA_MAGIC_CHECK_LIST(list, NULL);
/* if the caller specified an invalid size, sort the whole list */
if ((size == 0) ||
(size > list->accounting->count))
- size = list->accounting->count;
+ size = list->accounting->count;
if (size != list->accounting->count)
{
- unsort = eina_list_nth_list(list, size);
- if (unsort)
- unsort->prev->next = NULL;
+ unsort = eina_list_nth_list(list, size);
+ if (unsort)
+ unsort->prev->next = NULL;
}
while (tail)
{
- unsigned int idx, tmp;
+ unsigned int idx, tmp;
- Eina_List *a = tail;
- Eina_List *b = tail->next;
+ Eina_List *a = tail;
+ Eina_List *b = tail->next;
- if (!b)
- {
- stack[i++] = a;
- break;
- }
+ if (!b)
+ {
+ stack[i++] = a;
+ break;
+ }
- tail = b->next;
+ tail = b->next;
- if (func(a->data, b->data) < 0)
- ((stack[i++] = a)->next = b)->next = 0;
- else
- ((stack[i++] = b)->next = a)->next = 0;
+ if (func(a->data, b->data) < 0)
+ ((stack[i++] = a)->next = b)->next = 0;
+ else
+ ((stack[i++] = b)->next = a)->next = 0;
- tmp = n++;
- for (idx = n ^ tmp; idx &= idx - 1; i--)
- stack[i-2] = eina_list_sort_merge(stack[i-2], stack[i-1], func);
+ tmp = n++;
+ for (idx = n ^ tmp; idx &= idx - 1; i--)
+ stack[i - 2] = eina_list_sort_merge(stack[i - 2], stack[i - 1], func);
}
while (i-- > 1)
- stack[i-1] = eina_list_sort_merge(stack[i-1], stack[i], func);
+ stack[i - 1] = eina_list_sort_merge(stack[i - 1], stack[i], func);
list = stack[0];
tail = eina_list_sort_rebuild_prev(list);
if (unsort)
{
- tail->next = unsort;
- unsort->prev = tail;
+ tail->next = unsort;
+ unsort->prev = tail;
}
else
- list->accounting->last = tail;
+ list->accounting->last = tail;
return list;
}
{
unsigned int n_left, n_right;
- if (!left) return right;
- if (!right) return left;
+ if (!left)
+ return right;
+
+ if (!right)
+ return left;
left->accounting->last->next = right;
right->prev = left->accounting->last;
if (n_left >= n_right)
{
- Eina_List *itr = right;
- left->accounting->last = right->accounting->last;
- left->accounting->count += n_right;
-
- _eina_list_mempool_accounting_free(right->accounting);
-
- do
- {
- itr->accounting = left->accounting;
- itr = itr->next;
- }
- while (itr);
+ Eina_List *itr = right;
+ left->accounting->last = right->accounting->last;
+ left->accounting->count += n_right;
+
+ _eina_list_mempool_accounting_free(right->accounting);
+
+ do
+ {
+ itr->accounting = left->accounting;
+ itr = itr->next;
+ }
+ while (itr);
}
else
{
- Eina_List *itr = left->accounting->last;
- right->accounting->count += n_left;
+ Eina_List *itr = left->accounting->last;
+ right->accounting->count += n_left;
- _eina_list_mempool_accounting_free(left->accounting);
+ _eina_list_mempool_accounting_free(left->accounting);
- do
- {
- itr->accounting = right->accounting;
- itr = itr->prev;
- }
- while (itr);
+ do
+ {
+ itr->accounting = right->accounting;
+ itr = itr->prev;
+ }
+ while (itr);
}
return left;
* list does not exist anymore after the split.
*
*/
- EAPI Eina_List *
+EAPI Eina_List *
eina_list_split_list(Eina_List *list, Eina_List *relative, Eina_List **right)
{
Eina_List *next;
Eina_List *itr;
- if(!right) return list;
+ if(!right)
+ return list;
+
*right = NULL;
- if (!list) return NULL;
+ if (!list)
+ return NULL;
+
if (!relative)
{
- *right = list;
- return NULL;
+ *right = list;
+ return NULL;
}
- if (relative == eina_list_last(list)) return list;
+
+ if (relative == eina_list_last(list))
+ return list;
next = eina_list_next(relative);
next->prev = NULL;
itr = next;
do
{
- itr->accounting = next->accounting;
- next->accounting->count++;
- itr = itr->next;
+ itr->accounting = next->accounting;
+ next->accounting->count++;
+ itr = itr->next;
}
while (itr);
EINA_SAFETY_ON_NULL_RETURN_VAL(func, NULL);
- if (!left) return right;
- if (!right) return left;
+ if (!left)
+ return right;
+
+ if (!right)
+ return left;
if (func(left->data, right->data) < 0)
{
- ret = left;
- current = left;
- left = left->next;
- ret->accounting->count += right->accounting->count;
+ ret = left;
+ current = left;
+ left = left->next;
+ ret->accounting->count += right->accounting->count;
- _eina_list_mempool_accounting_free(right->accounting);
+ _eina_list_mempool_accounting_free(right->accounting);
}
else
{
- ret = right;
- current = right;
- right = right->next;
- ret->accounting->count += left->accounting->count;
+ ret = right;
+ current = right;
+ right = right->next;
+ ret->accounting->count += left->accounting->count;
- _eina_list_mempool_accounting_free(left->accounting);
+ _eina_list_mempool_accounting_free(left->accounting);
}
while (left && right)
{
- if (func(left->data, right->data) < 0)
- {
- current->next = left;
- left->prev = current;
- left = left->next;
- }
- else
- {
- current->next = right;
- right->prev = current;
- right = right->next;
- }
-
- current = current->next;
- current->accounting = ret->accounting;
+ if (func(left->data, right->data) < 0)
+ {
+ current->next = left;
+ left->prev = current;
+ left = left->next;
+ }
+ else
+ {
+ current->next = right;
+ right->prev = current;
+ right = right->next;
+ }
+
+ current = current->next;
+ current->accounting = ret->accounting;
}
if (left)
{
- current->next = left;
- left->prev = current;
- current->accounting = ret->accounting;
+ current->next = left;
+ left->prev = current;
+ current->accounting = ret->accounting;
}
if (right)
{
- current->next = right;
- right->prev = current;
- current->accounting = ret->accounting;
+ current->next = right;
+ right->prev = current;
+ current->accounting = ret->accounting;
}
while (current->next)
{
- current = current->next;
- current->accounting = ret->accounting;
+ current = current->next;
+ current->accounting = ret->accounting;
}
ret->accounting->last = current;
* @see eina_list_sorted_merge()
*/
EAPI Eina_List *
-eina_list_search_sorted_near_list(const Eina_List *list, Eina_Compare_Cb func, const void *data, int *result_cmp)
+eina_list_search_sorted_near_list(const Eina_List *list,
+ Eina_Compare_Cb func,
+ const void *data,
+ int *result_cmp)
{
const Eina_List *ct;
unsigned int inf, sup, cur;
if (!list)
{
- if (result_cmp) *result_cmp = 0;
- return NULL;
+ if (result_cmp)
+ *result_cmp = 0;
+
+ return NULL;
}
if (list->accounting->count == 1)
{
- if (result_cmp) *result_cmp = func(list->data, data);
- return (Eina_List *)list;
+ if (result_cmp)
+ *result_cmp = func(list->data, data);
+
+ return (Eina_List *)list;
}
/* list walk is expensive, do quick check: tail */
ct = list->accounting->last;
cmp = func(ct->data, data);
if (cmp <= 0)
- goto end;
+ goto end;
/* list walk is expensive, do quick check: head */
ct = list;
cmp = func(ct->data, data);
if (cmp >= 0)
- goto end;
+ goto end;
/* inclusive bounds */
inf = 1;
/* no loop, just compare if comparison value is important to caller */
if (inf > sup)
{
- if (result_cmp) cmp = func(ct->data, data);
- goto end;
+ if (result_cmp)
+ cmp = func(ct->data, data);
+
+ goto end;
}
while (inf <= sup)
{
- unsigned int tmp = cur;
- cur = inf + ((sup - inf) >> 1);
- if (tmp < cur) for (; tmp != cur; tmp++, ct = ct->next);
- else if (tmp > cur) for (; tmp != cur; tmp--, ct = ct->prev);
-
- cmp = func(ct->data, data);
- if (cmp == 0)
- break;
- else if (cmp < 0)
- inf = cur + 1;
- else if (cmp > 0)
- {
- if (cur > 0)
- sup = cur - 1;
- else break;
- }
- else break;
+ unsigned int tmp = cur;
+ cur = inf + ((sup - inf) >> 1);
+ if (tmp < cur)
+ for (; tmp != cur; tmp++, ct = ct->next) ;
+ else if (tmp > cur)
+ for (; tmp != cur; tmp--, ct = ct->prev) ;
+
+ cmp = func(ct->data, data);
+ if (cmp == 0)
+ break;
+ else if (cmp < 0)
+ inf = cur + 1;
+ else if (cmp > 0)
+ {
+ if (cur > 0)
+ sup = cur - 1;
+ else
+ break;
+ }
+ else
+ break;
}
- end:
- if (result_cmp) *result_cmp = cmp;
+end:
+ if (result_cmp)
+ *result_cmp = cmp;
+
return (Eina_List *)ct;
}
* @see eina_list_search_sorted_near_list()
*/
EAPI Eina_List *
-eina_list_search_sorted_list(const Eina_List *list, Eina_Compare_Cb func, const void *data)
+eina_list_search_sorted_list(const Eina_List *list,
+ Eina_Compare_Cb func,
+ const void *data)
{
Eina_List *lnear;
int cmp;
lnear = eina_list_search_sorted_near_list(list, func, data, &cmp);
- if (!lnear) return NULL;
+ if (!lnear)
+ return NULL;
+
if (cmp == 0)
- return lnear;
+ return lnear;
+
return NULL;
}
* @see eina_list_search_unsorted_list()
*/
EAPI void *
-eina_list_search_sorted(const Eina_List *list, Eina_Compare_Cb func, const void *data)
+eina_list_search_sorted(const Eina_List *list,
+ Eina_Compare_Cb func,
+ const void *data)
{
return eina_list_data_get(eina_list_search_sorted_list(list, func, data));
}
* @see eina_list_search_unsorted()
*/
EAPI Eina_List *
-eina_list_search_unsorted_list(const Eina_List *list, Eina_Compare_Cb func, const void *data)
+eina_list_search_unsorted_list(const Eina_List *list,
+ Eina_Compare_Cb func,
+ const void *data)
{
const Eina_List *l;
void *d;
EINA_LIST_FOREACH(list, l, d)
- {
- if (!func(d, data))
- return (Eina_List*) l;
- }
+ {
+ if (!func(d, data))
+ return (Eina_List *)l;
+ }
return NULL;
}
* @see eina_list_search_unsorted_list()
*/
EAPI void *
-eina_list_search_unsorted(const Eina_List *list, Eina_Compare_Cb func, const void *data)
+eina_list_search_unsorted(const Eina_List *list,
+ Eina_Compare_Cb func,
+ const void *data)
{
return eina_list_data_get(eina_list_search_unsorted_list(list, func, data));
}
{
Eina_Iterator_List *it;
- eina_error_set(0);
+ eina_error_set(0);
it = calloc(1, sizeof (Eina_Iterator_List));
- if (!it) {
- eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
- return NULL;
- }
+ if (!it)
+ {
+ eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+ return NULL;
+ }
- EINA_MAGIC_SET(it, EINA_MAGIC_LIST_ITERATOR);
+ EINA_MAGIC_SET(it, EINA_MAGIC_LIST_ITERATOR);
EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_ITERATOR);
it->head = list;
it->current = list;
it->iterator.next = FUNC_ITERATOR_NEXT(eina_list_iterator_next);
- it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(eina_list_iterator_get_container);
+ it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(
+ eina_list_iterator_get_container);
it->iterator.free = FUNC_ITERATOR_FREE(eina_list_iterator_free);
return &it->iterator;
{
Eina_Iterator_List *it;
- eina_error_set(0);
+ eina_error_set(0);
it = calloc(1, sizeof (Eina_Iterator_List));
- if (!it) {
- eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
- return NULL;
- }
+ if (!it)
+ {
+ eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+ return NULL;
+ }
- EINA_MAGIC_SET(it, EINA_MAGIC_LIST_ITERATOR);
+ EINA_MAGIC_SET(it, EINA_MAGIC_LIST_ITERATOR);
EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_ITERATOR);
it->head = eina_list_last(list);
it->current = it->head;
it->iterator.next = FUNC_ITERATOR_NEXT(eina_list_iterator_prev);
- it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(eina_list_iterator_get_container);
+ it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(
+ eina_list_iterator_get_container);
it->iterator.free = FUNC_ITERATOR_FREE(eina_list_iterator_free);
return &it->iterator;
{
Eina_Accessor_List *it;
- eina_error_set(0);
+ eina_error_set(0);
it = calloc(1, sizeof (Eina_Accessor_List));
- if (!it) {
- eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
- return NULL;
- }
+ if (!it)
+ {
+ eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+ return NULL;
+ }
- EINA_MAGIC_SET(it, EINA_MAGIC_LIST_ACCESSOR);
+ EINA_MAGIC_SET(it, EINA_MAGIC_LIST_ACCESSOR);
EINA_MAGIC_SET(&it->accessor, EINA_MAGIC_ACCESSOR);
it->head = list;
it->index = 0;
it->accessor.get_at = FUNC_ACCESSOR_GET_AT(eina_list_accessor_get_at);
- it->accessor.get_container = FUNC_ACCESSOR_GET_CONTAINER(eina_list_accessor_get_container);
+ it->accessor.get_container = FUNC_ACCESSOR_GET_CONTAINER(
+ eina_list_accessor_get_container);
it->accessor.free = FUNC_ACCESSOR_FREE(eina_list_accessor_free);
return &it->accessor;
*/
/*============================================================================*
- * Local *
- *============================================================================*/
+* Local *
+*============================================================================*/
/**
* @cond LOCAL
# define SELF() pthread_self()
# define IS_MAIN(t) pthread_equal(t, _main_thread)
# define IS_OTHER(t) EINA_UNLIKELY(!IS_MAIN(t))
-# define CHECK_MAIN(...) \
- do { \
- if (!IS_MAIN(pthread_self())) { \
- fprintf(stderr, \
- "ERR: not main thread! current=%lu, main=%lu\n", \
- pthread_self(), _main_thread); \
- return __VA_ARGS__; \
- } \
- } while (0)
+# define CHECK_MAIN(...) \
+ do { \
+ if (!IS_MAIN(pthread_self())) { \
+ fprintf(stderr, \
+ "ERR: not main thread! current=%lu, main=%lu\n", \
+ pthread_self(), _main_thread); \
+ return __VA_ARGS__; \
+ } \
+ } while (0)
# ifdef EFL_HAVE_POSIX_THREADS_SPINLOCK
static pthread_spinlock_t _log_lock;
-# define LOG_LOCK() \
- if(_threads_enabled) \
- do { \
- if (0) \
- fprintf(stderr, "+++LOG LOG_LOCKED! [%s, %lu]\n", \
- __FUNCTION__, pthread_self()); \
- if (EINA_UNLIKELY(_threads_enabled)) \
- pthread_spin_lock(&_log_lock); \
- } while (0)
-# define LOG_UNLOCK() \
- if(_threads_enabled) \
- do { \
- if (EINA_UNLIKELY(_threads_enabled)) \
- pthread_spin_unlock(&_log_lock); \
- if (0) \
- fprintf(stderr, \
- "---LOG LOG_UNLOCKED! [%s, %lu]\n", \
- __FUNCTION__, pthread_self()); \
- } while (0)
+# define LOG_LOCK() \
+ if(_threads_enabled) \
+ do { \
+ if (0) { \
+ fprintf(stderr, "+++LOG LOG_LOCKED! [%s, %lu]\n", \
+ __FUNCTION__, pthread_self()); } \
+ if (EINA_UNLIKELY(_threads_enabled)) { \
+ pthread_spin_lock(&_log_lock); } \
+ } while (0)
+# define LOG_UNLOCK() \
+ if(_threads_enabled) \
+ do { \
+ if (EINA_UNLIKELY(_threads_enabled)) { \
+ pthread_spin_unlock(&_log_lock); } \
+ if (0) { \
+ fprintf(stderr, \
+ "---LOG LOG_UNLOCKED! [%s, %lu]\n", \
+ __FUNCTION__, pthread_self()); } \
+ } while (0)
# define INIT() pthread_spin_init(&_log_lock, PTHREAD_PROCESS_PRIVATE)
# define SHUTDOWN() pthread_spin_destroy(&_log_lock)
# else /* ! EFL_HAVE_POSIX_THREADS_SPINLOCK */
static pthread_mutex_t _log_mutex = PTHREAD_MUTEX_INITIALIZER;
-# define LOG_LOCK() if(_threads_enabled) pthread_mutex_lock(&_log_mutex);
-# define LOG_UNLOCK() if(_threads_enabled) pthread_mutex_unlock(&_log_mutex);
+# define LOG_LOCK() if(_threads_enabled) {pthread_mutex_lock(&_log_mutex); }
+# define LOG_UNLOCK() if(_threads_enabled) {pthread_mutex_unlock(&_log_mutex); }
# define INIT() (1)
# define SHUTDOWN() do {} while (0)
# define SELF() GetCurrentThreadId()
# define IS_MAIN(t) (t == _main_thread)
# define IS_OTHER(t) EINA_UNLIKELY(!IS_MAIN(t))
-# define CHECK_MAIN(...) \
- do { \
- if (!IS_MAIN(GetCurrentThreadId())) { \
- fprintf(stderr, \
- "ERR: not main thread! current=%lu, main=%lu\n", \
- GetCurrentThreadId(), _main_thread); \
- return __VA_ARGS__; \
- } \
- } while (0)
+# define CHECK_MAIN(...) \
+ do { \
+ if (!IS_MAIN(GetCurrentThreadId())) { \
+ fprintf(stderr, \
+ "ERR: not main thread! current=%lu, main=%lu\n", \
+ GetCurrentThreadId(), _main_thread); \
+ return __VA_ARGS__; \
+ } \
+ } while (0)
static HANDLE _log_mutex = NULL;
-# define LOG_LOCK() if(_threads_enabled) WaitForSingleObject(_log_mutex, INFINITE)
+# define LOG_LOCK() if(_threads_enabled) WaitForSingleObject(_log_mutex, \
+ INFINITE)
# define LOG_UNLOCK() if(_threads_enabled) ReleaseMutex(_log_mutex)
# define INIT() ((_log_mutex = CreateMutex(NULL, FALSE, NULL)) ? 1 : 0)
# define SHUTDOWN() if (_log_mutex) CloseHandle(_log_mutex)
* eina_log_print_level_name_color_get()
*/
static const char *_names[] = {
- "CRI",
- "ERR",
- "WRN",
- "INF",
- "DBG",
+ "CRI",
+ "ERR",
+ "WRN",
+ "INF",
+ "DBG",
};
#ifdef _WIN32
str = strdup(domain_str);
if (!str)
- return 0;
+ return 0;
/* this should not append */
if (str[0] != '\033')
- return 0;
+ return 0;
/* we skip the first char and the [ */
tmp = tmp2 = str + 2;
while (*tmp != 'm')
{
- if (*tmp == ';')
- {
- *tmp = '\0';
- code = atol(tmp2);
- tmp++;
- tmp2 = tmp;
- }
- tmp++;
+ if (*tmp == ';')
+ {
+ *tmp = '\0';
+ code = atol(tmp2);
+ tmp++;
+ tmp2 = tmp;
+ }
+
+ tmp++;
}
*tmp = '\0';
if (code < 0)
- code = atol(tmp2);
+ code = atol(tmp2);
else
- lighted = atol(tmp2);
+ lighted = atol(tmp2);
free(str);
if (code < lighted)
{
- int c;
+ int c;
- c = code;
- code = lighted;
- lighted = c;
+ c = code;
+ code = lighted;
+ lighted = c;
}
- if (lighted) ret = FOREGROUND_INTENSITY;
+ if (lighted)
+ ret = FOREGROUND_INTENSITY;
+
if (code == 31)
- ret |= FOREGROUND_RED;
+ ret |= FOREGROUND_RED;
else if (code == 32)
- ret |= FOREGROUND_GREEN;
+ ret |= FOREGROUND_GREEN;
else if (code == 33)
- ret |= FOREGROUND_RED | FOREGROUND_GREEN;
+ ret |= FOREGROUND_RED | FOREGROUND_GREEN;
else if (code == 34)
- ret |= FOREGROUND_BLUE;
+ ret |= FOREGROUND_BLUE;
else if (code == 36)
- ret |= FOREGROUND_GREEN | FOREGROUND_BLUE;
+ ret |= FOREGROUND_GREEN | FOREGROUND_BLUE;
else if (code == 37)
- ret |= FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE;
+ ret |= FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE;
return ret;
}
*/
if (EINA_UNLIKELY(level < 0))
{
- snprintf(buf, sizeof(buf), "%03d", level);
- *p_name = buf;
+ snprintf(buf, sizeof(buf), "%03d", level);
+ *p_name = buf;
}
else if (EINA_UNLIKELY(level >= EINA_LOG_LEVELS))
{
- snprintf(buf, sizeof(buf), "%03d", level);
- *p_name = buf;
+ snprintf(buf, sizeof(buf), "%03d", level);
+ *p_name = buf;
}
else
- *p_name = _names[level];
+ *p_name = _names[level];
}
#ifdef _WIN32
static inline void
-eina_log_print_level_name_color_get(int level, const char **p_name, int *p_color)
+eina_log_print_level_name_color_get(int level,
+ const char **p_name,
+ int *p_color)
{
static char buf[4];
/* NOTE: if you change this, also change:
*/
if (EINA_UNLIKELY(level < 0))
{
- snprintf(buf, sizeof(buf), "%03d", level);
- *p_name = buf;
+ snprintf(buf, sizeof(buf), "%03d", level);
+ *p_name = buf;
}
else if (EINA_UNLIKELY(level >= EINA_LOG_LEVELS))
{
- snprintf(buf, sizeof(buf), "%03d", level);
- *p_name = buf;
+ snprintf(buf, sizeof(buf), "%03d", level);
+ *p_name = buf;
}
else
- {
- *p_name = _names[level];
- }
+ *p_name = _names[level];
*p_color = eina_log_win32_color_get(eina_log_level_color_get(level));
}
#else
static inline void
-eina_log_print_level_name_color_get(int level, const char **p_name, const char **p_color)
+eina_log_print_level_name_color_get(int level,
+ const char **p_name,
+ const char **p_color)
{
static char buf[4];
/* NOTE: if you change this, also change:
*/
if (EINA_UNLIKELY(level < 0))
{
- snprintf(buf, sizeof(buf), "%03d", level);
- *p_name = buf;
+ snprintf(buf, sizeof(buf), "%03d", level);
+ *p_name = buf;
}
else if (EINA_UNLIKELY(level >= EINA_LOG_LEVELS))
{
- snprintf(buf, sizeof(buf), "%03d", level);
- *p_name = buf;
+ snprintf(buf, sizeof(buf), "%03d", level);
+ *p_name = buf;
}
else
- {
- *p_name = _names[level];
- }
+ *p_name = _names[level];
+
*p_color = eina_log_level_color_get(level);
}
#endif
-#define DECLARE_LEVEL_NAME(level) const char *name; eina_log_print_level_name_get(level, &name)
+#define DECLARE_LEVEL_NAME(level) const char *name; \
+ eina_log_print_level_name_get(level, &name)
#ifdef _WIN32
-# define DECLARE_LEVEL_NAME_COLOR(level) const char *name; int color; eina_log_print_level_name_color_get(level, &name, &color)
+# define DECLARE_LEVEL_NAME_COLOR(level) const char *name; int color; \
+ eina_log_print_level_name_color_get(level, &name, &color)
#else
-# define DECLARE_LEVEL_NAME_COLOR(level) const char *name, *color; eina_log_print_level_name_color_get(level, &name, &color)
+# define DECLARE_LEVEL_NAME_COLOR(level) const char *name, *color; \
+ eina_log_print_level_name_color_get(level, &name, &color)
#endif
/** No threads, No color */
static void
-eina_log_print_prefix_NOthreads_NOcolor_file_func(FILE *fp, const Eina_Log_Domain *d, Eina_Log_Level level, const char *file, const char *fnc, int line)
+eina_log_print_prefix_NOthreads_NOcolor_file_func(FILE *fp,
+ const Eina_Log_Domain *d,
+ Eina_Log_Level level,
+ const char *file,
+ const char *fnc,
+ int line)
{
DECLARE_LEVEL_NAME(level);
fprintf(fp, "%s:%s %s:%d %s() ", name, d->domain_str, file, line, fnc);
}
static void
-eina_log_print_prefix_NOthreads_NOcolor_NOfile_func(FILE *fp, const Eina_Log_Domain *d, Eina_Log_Level level, const char *file __UNUSED__, const char *fnc, int line __UNUSED__)
+eina_log_print_prefix_NOthreads_NOcolor_NOfile_func(FILE *fp,
+ const Eina_Log_Domain *d,
+ Eina_Log_Level level,
+ const char *file __UNUSED__,
+ const char *fnc,
+ int line __UNUSED__)
{
DECLARE_LEVEL_NAME(level);
fprintf(fp, "%s:%s %s() ", name, d->domain_str, fnc);
}
static void
-eina_log_print_prefix_NOthreads_NOcolor_file_NOfunc(FILE *fp, const Eina_Log_Domain *d, Eina_Log_Level level, const char *file, const char *fnc __UNUSED__, int line)
+eina_log_print_prefix_NOthreads_NOcolor_file_NOfunc(FILE *fp,
+ const Eina_Log_Domain *d,
+ Eina_Log_Level level,
+ const char *file,
+ const char *fnc __UNUSED__,
+ int line)
{
DECLARE_LEVEL_NAME(level);
fprintf(fp, "%s:%s %s:%d ", name, d->domain_str, file, line);
/* No threads, color */
static void
-eina_log_print_prefix_NOthreads_color_file_func(FILE *fp, const Eina_Log_Domain *d, Eina_Log_Level level, const char *file, const char *fnc, int line)
+eina_log_print_prefix_NOthreads_color_file_func(FILE *fp,
+ const Eina_Log_Domain *d,
+ Eina_Log_Level level,
+ const char *file,
+ const char *fnc,
+ int line)
{
DECLARE_LEVEL_NAME_COLOR(level);
#ifdef _WIN32
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
- color);
+ color);
fprintf(fp, "%s", name);
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
- FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
+ FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
fprintf(fp, ":");
- SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), eina_log_win32_color_get(d->domain_str));
+ SetConsoleTextAttribute(GetStdHandle(
+ STD_OUTPUT_HANDLE),
+ eina_log_win32_color_get(d->domain_str));
fprintf(fp, "%s", d->name);
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
- FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
+ FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
fprintf(fp, " %s:%d ", file, line);
- SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
- FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
+ SetConsoleTextAttribute(GetStdHandle(
+ STD_OUTPUT_HANDLE),
+ FOREGROUND_INTENSITY | FOREGROUND_RED |
+ FOREGROUND_GREEN | FOREGROUND_BLUE);
fprintf(fp, "%s()", fnc);
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
- FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
+ FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
fprintf(fp, " ");
#else
fprintf(fp, "%s%s" EINA_COLOR_RESET ":%s %s:%d "
- EINA_COLOR_HIGH "%s()" EINA_COLOR_RESET " ",
- color, name, d->domain_str, file, line, fnc);
+ EINA_COLOR_HIGH "%s()" EINA_COLOR_RESET " ",
+ color, name, d->domain_str, file, line, fnc);
#endif
}
static void
-eina_log_print_prefix_NOthreads_color_NOfile_func(FILE *fp, const Eina_Log_Domain *d, Eina_Log_Level level, const char *file __UNUSED__, const char *fnc, int line __UNUSED__)
+eina_log_print_prefix_NOthreads_color_NOfile_func(FILE *fp,
+ const Eina_Log_Domain *d,
+ Eina_Log_Level level,
+ const char *file __UNUSED__,
+ const char *fnc,
+ int line __UNUSED__)
{
DECLARE_LEVEL_NAME_COLOR(level);
#ifdef _WIN32
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
- color);
+ color);
fprintf(fp, "%s", name);
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
- FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
+ FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
fprintf(fp, ":");
- SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), eina_log_win32_color_get(d->domain_str));
+ SetConsoleTextAttribute(GetStdHandle(
+ STD_OUTPUT_HANDLE),
+ eina_log_win32_color_get(d->domain_str));
fprintf(fp, "%s", d->name);
- SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
- FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
+ SetConsoleTextAttribute(GetStdHandle(
+ STD_OUTPUT_HANDLE),
+ FOREGROUND_INTENSITY | FOREGROUND_RED |
+ FOREGROUND_GREEN | FOREGROUND_BLUE);
fprintf(fp, "%s()", fnc);
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
- FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
+ FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
fprintf(fp, " ");
#else
fprintf(fp, "%s%s" EINA_COLOR_RESET ":%s "
- EINA_COLOR_HIGH "%s()" EINA_COLOR_RESET " ",
- color, name, d->domain_str, fnc);
+ EINA_COLOR_HIGH "%s()" EINA_COLOR_RESET " ",
+ color, name, d->domain_str, fnc);
#endif
}
static void
-eina_log_print_prefix_NOthreads_color_file_NOfunc(FILE *fp, const Eina_Log_Domain *d, Eina_Log_Level level, const char *file, const char *fnc __UNUSED__, int line)
+eina_log_print_prefix_NOthreads_color_file_NOfunc(FILE *fp,
+ const Eina_Log_Domain *d,
+ Eina_Log_Level level,
+ const char *file,
+ const char *fnc __UNUSED__,
+ int line)
{
DECLARE_LEVEL_NAME_COLOR(level);
#ifdef _WIN32
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
- color);
+ color);
fprintf(fp, "%s", name);
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
- FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
+ FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
fprintf(fp, ":");
- SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), eina_log_win32_color_get(d->domain_str));
+ SetConsoleTextAttribute(GetStdHandle(
+ STD_OUTPUT_HANDLE),
+ eina_log_win32_color_get(d->domain_str));
fprintf(fp, "%s", d->name);
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
- FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
+ FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
fprintf(fp, " %s:%d ", file, line);
#else
fprintf(fp, "%s%s" EINA_COLOR_RESET ":%s %s:%d ",
- color, name, d->domain_str, file, line);
+ color, name, d->domain_str, file, line);
#endif
}
/** threads, No color */
#ifdef EFL_HAVE_THREADS
static void
-eina_log_print_prefix_threads_NOcolor_file_func(FILE *fp, const Eina_Log_Domain *d, Eina_Log_Level level, const char *file, const char *fnc, int line)
+eina_log_print_prefix_threads_NOcolor_file_func(FILE *fp,
+ const Eina_Log_Domain *d,
+ Eina_Log_Level level,
+ const char *file,
+ const char *fnc,
+ int line)
{
Thread cur;
cur = SELF();
if (IS_OTHER(cur))
{
- fprintf(fp, "%s:%s[T:%lu] %s:%d %s() ",
- name, d->domain_str, cur, file, line, fnc);
- return;
+ fprintf(fp, "%s:%s[T:%lu] %s:%d %s() ",
+ name, d->domain_str, cur, file, line, fnc);
+ return;
}
- fprintf(fp, "%s:%s %s:%d %s() ", name, d->domain_str, file, line, fnc);
+
+ fprintf(fp, "%s:%s %s:%d %s() ", name, d->domain_str, file, line, fnc);
}
static void
-eina_log_print_prefix_threads_NOcolor_NOfile_func(FILE *fp, const Eina_Log_Domain *d, Eina_Log_Level level, const char *file __UNUSED__, const char *fnc, int line __UNUSED__)
+eina_log_print_prefix_threads_NOcolor_NOfile_func(FILE *fp,
+ const Eina_Log_Domain *d,
+ Eina_Log_Level level,
+ const char *file __UNUSED__,
+ const char *fnc,
+ int line __UNUSED__)
{
Thread cur;
cur = SELF();
if (IS_OTHER(cur))
{
- fprintf(fp, "%s:%s[T:%lu] %s() ",
- name, d->domain_str, cur, fnc);
- return;
+ fprintf(fp, "%s:%s[T:%lu] %s() ",
+ name, d->domain_str, cur, fnc);
+ return;
}
- fprintf(fp, "%s:%s %s() ", name, d->domain_str, fnc);
+
+ fprintf(fp, "%s:%s %s() ", name, d->domain_str, fnc);
}
static void
-eina_log_print_prefix_threads_NOcolor_file_NOfunc(FILE *fp, const Eina_Log_Domain *d, Eina_Log_Level level, const char *file, const char *fnc __UNUSED__, int line)
+eina_log_print_prefix_threads_NOcolor_file_NOfunc(FILE *fp,
+ const Eina_Log_Domain *d,
+ Eina_Log_Level level,
+ const char *file,
+ const char *fnc __UNUSED__,
+ int line)
{
Thread cur;
cur = SELF();
if (IS_OTHER(cur))
{
- fprintf(fp, "%s:%s[T:%lu] %s:%d ",
- name, d->domain_str, cur, file, line);
- return;
+ fprintf(fp, "%s:%s[T:%lu] %s:%d ",
+ name, d->domain_str, cur, file, line);
+ return;
}
- fprintf(fp, "%s:%s %s:%d ", name, d->domain_str, file, line);
+
+ fprintf(fp, "%s:%s %s:%d ", name, d->domain_str, file, line);
}
/* threads, color */
static void
-eina_log_print_prefix_threads_color_file_func(FILE *fp, const Eina_Log_Domain *d, Eina_Log_Level level, const char *file, const char *fnc, int line)
+eina_log_print_prefix_threads_color_file_func(FILE *fp,
+ const Eina_Log_Domain *d,
+ Eina_Log_Level level,
+ const char *file,
+ const char *fnc,
+ int line)
{
Thread cur;
-
+
DECLARE_LEVEL_NAME_COLOR(level);
cur = SELF();
if (IS_OTHER(cur))
{
# ifdef _WIN32
- SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
- color);
- fprintf(fp, "%s", name);
- SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
- FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
- fprintf(fp, ":");
- SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), eina_log_win32_color_get(d->domain_str));
- fprintf(fp, "%s[T:", d->name);
- SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
- FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
- fprintf(fp, "[T:");
- SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
- FOREGROUND_GREEN | FOREGROUND_BLUE);
- fprintf(fp, "%lu", (unsigned long)cur);
- SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
- FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
- fprintf(fp, "] %s:%d ", file, line);
- SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
- FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
- fprintf(fp, "%s()", fnc);
- SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
- FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
- fprintf(fp, " ");
+ SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
+ color);
+ fprintf(fp, "%s", name);
+ SetConsoleTextAttribute(GetStdHandle(
+ STD_OUTPUT_HANDLE),
+ FOREGROUND_RED | FOREGROUND_GREEN |
+ FOREGROUND_BLUE);
+ fprintf(fp, ":");
+ SetConsoleTextAttribute(GetStdHandle(
+ STD_OUTPUT_HANDLE),
+ eina_log_win32_color_get(d->domain_str));
+ fprintf(fp, "%s[T:", d->name);
+ SetConsoleTextAttribute(GetStdHandle(
+ STD_OUTPUT_HANDLE),
+ FOREGROUND_RED | FOREGROUND_GREEN |
+ FOREGROUND_BLUE);
+ fprintf(fp, "[T:");
+ SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
+ FOREGROUND_GREEN | FOREGROUND_BLUE);
+ fprintf(fp, "%lu", (unsigned long)cur);
+ SetConsoleTextAttribute(GetStdHandle(
+ STD_OUTPUT_HANDLE),
+ FOREGROUND_RED | FOREGROUND_GREEN |
+ FOREGROUND_BLUE);
+ fprintf(fp, "] %s:%d ", file, line);
+ SetConsoleTextAttribute(GetStdHandle(
+ STD_OUTPUT_HANDLE),
+ FOREGROUND_INTENSITY | FOREGROUND_RED |
+ FOREGROUND_GREEN | FOREGROUND_BLUE);
+ fprintf(fp, "%s()", fnc);
+ SetConsoleTextAttribute(GetStdHandle(
+ STD_OUTPUT_HANDLE),
+ FOREGROUND_RED | FOREGROUND_GREEN |
+ FOREGROUND_BLUE);
+ fprintf(fp, " ");
# else
- fprintf(fp, "%s%s" EINA_COLOR_RESET ":%s[T:"
- EINA_COLOR_ORANGE "%lu" EINA_COLOR_RESET "] %s:%d "
- EINA_COLOR_HIGH "%s()" EINA_COLOR_RESET " ",
- color, name, d->domain_str, cur, file, line, fnc);
+ fprintf(fp, "%s%s" EINA_COLOR_RESET ":%s[T:"
+ EINA_COLOR_ORANGE "%lu" EINA_COLOR_RESET "] %s:%d "
+ EINA_COLOR_HIGH "%s()" EINA_COLOR_RESET " ",
+ color, name, d->domain_str, cur, file, line, fnc);
# endif
- return;
+ return;
}
+
# ifdef _WIN32
- eina_log_print_prefix_NOthreads_color_file_func(fp, d, level, file, fnc, line);
+ eina_log_print_prefix_NOthreads_color_file_func(fp,
+ d,
+ level,
+ file,
+ fnc,
+ line);
# else
fprintf(fp, "%s%s" EINA_COLOR_RESET ":%s %s:%d "
- EINA_COLOR_HIGH "%s()" EINA_COLOR_RESET " ",
- color, name, d->domain_str, file, line, fnc);
+ EINA_COLOR_HIGH "%s()" EINA_COLOR_RESET " ",
+ color, name, d->domain_str, file, line, fnc);
# endif
}
static void
-eina_log_print_prefix_threads_color_NOfile_func(FILE *fp, const Eina_Log_Domain *d, Eina_Log_Level level, const char *file __UNUSED__, const char *fnc, int line __UNUSED__)
+eina_log_print_prefix_threads_color_NOfile_func(FILE *fp,
+ const Eina_Log_Domain *d,
+ Eina_Log_Level level,
+ const char *file __UNUSED__,
+ const char *fnc,
+ int line __UNUSED__)
{
Thread cur;
if (IS_OTHER(cur))
{
# ifdef _WIN32
- SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
- color);
- fprintf(fp, "%s", name);
- SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
- FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
- fprintf(fp, ":");
- SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), eina_log_win32_color_get(d->domain_str));
- fprintf(fp, "%s[T:", d->name);
- SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
- FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
- fprintf(fp, "[T:");
- SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
- FOREGROUND_GREEN | FOREGROUND_BLUE);
- fprintf(fp, "%lu", (unsigned long)cur);
- SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
- FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
- fprintf(fp, "%s()", fnc);
- SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
- FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
- fprintf(fp, " ");
+ SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
+ color);
+ fprintf(fp, "%s", name);
+ SetConsoleTextAttribute(GetStdHandle(
+ STD_OUTPUT_HANDLE),
+ FOREGROUND_RED | FOREGROUND_GREEN |
+ FOREGROUND_BLUE);
+ fprintf(fp, ":");
+ SetConsoleTextAttribute(GetStdHandle(
+ STD_OUTPUT_HANDLE),
+ eina_log_win32_color_get(d->domain_str));
+ fprintf(fp, "%s[T:", d->name);
+ SetConsoleTextAttribute(GetStdHandle(
+ STD_OUTPUT_HANDLE),
+ FOREGROUND_RED | FOREGROUND_GREEN |
+ FOREGROUND_BLUE);
+ fprintf(fp, "[T:");
+ SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
+ FOREGROUND_GREEN | FOREGROUND_BLUE);
+ fprintf(fp, "%lu", (unsigned long)cur);
+ SetConsoleTextAttribute(GetStdHandle(
+ STD_OUTPUT_HANDLE),
+ FOREGROUND_INTENSITY | FOREGROUND_RED |
+ FOREGROUND_GREEN | FOREGROUND_BLUE);
+ fprintf(fp, "%s()", fnc);
+ SetConsoleTextAttribute(GetStdHandle(
+ STD_OUTPUT_HANDLE),
+ FOREGROUND_RED | FOREGROUND_GREEN |
+ FOREGROUND_BLUE);
+ fprintf(fp, " ");
# else
- fprintf(fp, "%s%s" EINA_COLOR_RESET ":%s[T:"
- EINA_COLOR_ORANGE "%lu" EINA_COLOR_RESET "] "
- EINA_COLOR_HIGH "%s()" EINA_COLOR_RESET " ",
- color, name, d->domain_str, cur, fnc);
+ fprintf(fp, "%s%s" EINA_COLOR_RESET ":%s[T:"
+ EINA_COLOR_ORANGE "%lu" EINA_COLOR_RESET "] "
+ EINA_COLOR_HIGH "%s()" EINA_COLOR_RESET " ",
+ color, name, d->domain_str, cur, fnc);
# endif
- return;
+ return;
}
+
# ifdef _WIN32
- eina_log_print_prefix_NOthreads_color_NOfile_func(fp, d, level, file, fnc, line);
+ eina_log_print_prefix_NOthreads_color_NOfile_func(fp,
+ d,
+ level,
+ file,
+ fnc,
+ line);
# else
fprintf(fp, "%s%s" EINA_COLOR_RESET ":%s "
- EINA_COLOR_HIGH "%s()" EINA_COLOR_RESET " ",
- color, name, d->domain_str, fnc);
+ EINA_COLOR_HIGH "%s()" EINA_COLOR_RESET " ",
+ color, name, d->domain_str, fnc);
# endif
}
static void
-eina_log_print_prefix_threads_color_file_NOfunc(FILE *fp, const Eina_Log_Domain *d, Eina_Log_Level level, const char *file, const char *fnc __UNUSED__, int line)
+eina_log_print_prefix_threads_color_file_NOfunc(FILE *fp,
+ const Eina_Log_Domain *d,
+ Eina_Log_Level level,
+ const char *file,
+ const char *fnc __UNUSED__,
+ int line)
{
Thread cur;
if (IS_OTHER(cur))
{
# ifdef _WIN32
- SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
- color);
- fprintf(fp, "%s", name);
- SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
- FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
- fprintf(fp, ":");
- SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), eina_log_win32_color_get(d->domain_str));
- fprintf(fp, "%s[T:", d->name);
- SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
- FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
- fprintf(fp, "[T:");
- SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
- FOREGROUND_GREEN | FOREGROUND_BLUE);
- fprintf(fp, "%lu", (unsigned long)cur);
- SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
- FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
- fprintf(fp, "] %s:%d ", file, line);
+ SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
+ color);
+ fprintf(fp, "%s", name);
+ SetConsoleTextAttribute(GetStdHandle(
+ STD_OUTPUT_HANDLE),
+ FOREGROUND_RED | FOREGROUND_GREEN |
+ FOREGROUND_BLUE);
+ fprintf(fp, ":");
+ SetConsoleTextAttribute(GetStdHandle(
+ STD_OUTPUT_HANDLE),
+ eina_log_win32_color_get(d->domain_str));
+ fprintf(fp, "%s[T:", d->name);
+ SetConsoleTextAttribute(GetStdHandle(
+ STD_OUTPUT_HANDLE),
+ FOREGROUND_RED | FOREGROUND_GREEN |
+ FOREGROUND_BLUE);
+ fprintf(fp, "[T:");
+ SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
+ FOREGROUND_GREEN | FOREGROUND_BLUE);
+ fprintf(fp, "%lu", (unsigned long)cur);
+ SetConsoleTextAttribute(GetStdHandle(
+ STD_OUTPUT_HANDLE),
+ FOREGROUND_RED | FOREGROUND_GREEN |
+ FOREGROUND_BLUE);
+ fprintf(fp, "] %s:%d ", file, line);
# else
- fprintf(fp, "%s%s" EINA_COLOR_RESET ":%s[T:"
- EINA_COLOR_ORANGE "%lu" EINA_COLOR_RESET "] %s:%d ",
- color, name, d->domain_str, cur, file, line);
+ fprintf(fp, "%s%s" EINA_COLOR_RESET ":%s[T:"
+ EINA_COLOR_ORANGE "%lu" EINA_COLOR_RESET "] %s:%d ",
+ color, name, d->domain_str, cur, file, line);
# endif
- return;
+ return;
}
+
# ifdef _WIN32
- eina_log_print_prefix_NOthreads_color_file_NOfunc(fp, d, level, file, fnc, line);
+ eina_log_print_prefix_NOthreads_color_file_NOfunc(fp,
+ d,
+ level,
+ file,
+ fnc,
+ line);
# else
- fprintf(fp, "%s%s" EINA_COLOR_RESET ":%s %s:%d ",
- color, name, d->domain_str, file, line);
+ fprintf(fp, "%s%s" EINA_COLOR_RESET ":%s %s:%d ",
+ color, name, d->domain_str, file, line);
# endif
}
#endif /* EFL_HAVE_THREADS */
-static void (*_eina_log_print_prefix)(FILE *fp, const Eina_Log_Domain *d, Eina_Log_Level level, const char *file, const char *fnc, int line) = eina_log_print_prefix_NOthreads_color_file_func;
+static void (*_eina_log_print_prefix)(FILE *fp, const Eina_Log_Domain *d,
+ Eina_Log_Level level, const char *file,
+ const char *fnc,
+ int line) =
+ eina_log_print_prefix_NOthreads_color_file_func;
static inline void
eina_log_print_prefix_update(void)
{
if (_disable_file && _disable_function)
{
- fprintf(stderr, "ERROR: cannot have " EINA_LOG_ENV_FILE_DISABLE " and "
- EINA_LOG_ENV_FUNCTION_DISABLE " set at the same time, will "
- "just disable function.\n");
- _disable_file = 0;
+ fprintf(stderr, "ERROR: cannot have " EINA_LOG_ENV_FILE_DISABLE " and "
+ EINA_LOG_ENV_FUNCTION_DISABLE " set at the same time, will "
+ "just disable function.\n");
+ _disable_file = 0;
}
#define S(NOthread, NOcolor, NOfile, NOfunc) \
- _eina_log_print_prefix = eina_log_print_prefix_##NOthread##threads_##NOcolor##color_##NOfile##file_##NOfunc##func
+ _eina_log_print_prefix = \
+ eina_log_print_prefix_ ## NOthread ## threads_ ## NOcolor ## color_ ## \
+ NOfile \
+ ## file_ ## NOfunc ## func
#ifdef EFL_HAVE_THREADS
if (_threads_enabled)
{
- if (_disable_color)
- {
- if (_disable_file)
- S(,NO,NO,);
- else if (_disable_function)
- S(,NO,,NO);
- else
- S(,NO,,);
- }
- else
- {
- if (_disable_file)
- S(,,NO,);
- else if (_disable_function)
- S(,,,NO);
- else
- S(,,,);
- }
- return;
+ if (_disable_color)
+ {
+ if (_disable_file)
+ S(,NO,NO,);
+ else if (_disable_function)
+ S(,NO,,NO);
+ else
+ S(,NO,,);
+ }
+ else
+ {
+ if (_disable_file)
+ S(,,NO,);
+ else if (_disable_function)
+ S(,,,NO);
+ else
+ S(,,,);
+ }
+
+ return;
}
+
#endif
if (_disable_color)
{
- if (_disable_file)
- S(NO,NO,NO,);
- else if (_disable_function)
- S(NO,NO,,NO);
- else
- S(NO,NO,,);
+ if (_disable_file)
+ S(NO,NO,NO,);
+ else if (_disable_function)
+ S(NO,NO,,NO);
+ else
+ S(NO,NO,,);
}
else
{
- if (_disable_file)
- S(NO,,NO,);
- else if (_disable_function)
- S(NO,,,NO);
- else
- S(NO,,,);
+ if (_disable_file)
+ S(NO,,NO,);
+ else if (_disable_function)
+ S(NO,,,NO);
+ else
+ S(NO,,,);
}
+
#undef S
}
if (color)
{
- size_t name_len;
- size_t color_len;
-
- name_len = strlen(name);
- color_len = strlen(color);
- d = malloc(sizeof(char) * (color_len + name_len + strlen(EINA_COLOR_RESET) + 1));
- if (!d) return NULL;
- memcpy((char *)d, color, color_len);
- memcpy((char *)(d + color_len), name, name_len);
- memcpy((char *)(d + color_len + name_len), EINA_COLOR_RESET, strlen(EINA_COLOR_RESET));
- ((char *)d)[color_len + name_len + strlen(EINA_COLOR_RESET)] = '\0';
+ size_t name_len;
+ size_t color_len;
+
+ name_len = strlen(name);
+ color_len = strlen(color);
+ d =
+ malloc(sizeof(char) *
+ (color_len + name_len + strlen(EINA_COLOR_RESET) + 1));
+ if (!d)
+ return NULL;
+
+ memcpy((char *)d, color, color_len);
+ memcpy((char *)(d + color_len), name, name_len);
+ memcpy((char *)(d + color_len + name_len), EINA_COLOR_RESET,
+ strlen(EINA_COLOR_RESET));
+ ((char *)d)[color_len + name_len + strlen(EINA_COLOR_RESET)] = '\0';
}
else
- d = strdup(name);
+ d = strdup(name);
return d;
}
static Eina_Log_Domain *
eina_log_domain_new(Eina_Log_Domain *d, const char *name, const char *color)
{
- EINA_SAFETY_ON_NULL_RETURN_VAL(d, NULL);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(d, NULL);
EINA_SAFETY_ON_NULL_RETURN_VAL(name, NULL);
d->level = EINA_LOG_LEVEL_UNKNOWN;
if (name)
{
- if ((color) && (!_disable_color))
- d->domain_str = eina_log_domain_str_get(name, color);
- else
- d->domain_str = eina_log_domain_str_get(name, NULL);
+ if ((color) && (!_disable_color))
+ d->domain_str = eina_log_domain_str_get(name, color);
+ else
+ d->domain_str = eina_log_domain_str_get(name, NULL);
- d->name = strdup(name);
- d->namelen = strlen(name);
+ d->name = strdup(name);
+ d->namelen = strlen(name);
}
else
{
- d->domain_str = NULL;
- d->name = NULL;
- d->namelen = 0;
+ d->domain_str = NULL;
+ d->name = NULL;
+ d->namelen = 0;
}
return d;
if (d->domain_str)
free((char *)d->domain_str);
+
if (d->name)
free((char *)d->name);
}
{
const char *start;
- if (!(start = getenv(EINA_LOG_ENV_LEVELS))) return;
+ if (!(start = getenv(EINA_LOG_ENV_LEVELS)))
+ return;
// name1:level1,name2:level2,name3:level3,...
while (1)
{
- Eina_Log_Domain_Level_Pending *p;
- char *end = NULL;
- char *tmp = NULL;
- long int level;
-
- end = strchr(start, ':');
- if (!end) break;
-
- // Parse level, keep going if failed
- level = strtol((char *)(end + 1), &tmp, 10);
- if (tmp == (end + 1)) goto parse_end;
-
- // Parse name
- p = malloc(sizeof(Eina_Log_Domain_Level_Pending) + end - start + 1);
- if (!p) break;
- p->namelen = end - start;
- memcpy((char *)p->name, start, end - start);
- ((char *)p->name)[end - start] = '\0';
- p->level = level;
-
- _pending_list = eina_inlist_append(_pending_list, EINA_INLIST_GET(p));
-
- parse_end:
- start = strchr(tmp, ',');
- if (start) start++;
- else break;
+ Eina_Log_Domain_Level_Pending *p;
+ char *end = NULL;
+ char *tmp = NULL;
+ long int level;
+
+ end = strchr(start, ':');
+ if (!end)
+ break;
+
+ // Parse level, keep going if failed
+ level = strtol((char *)(end + 1), &tmp, 10);
+ if (tmp == (end + 1))
+ goto parse_end;
+
+ // Parse name
+ p = malloc(sizeof(Eina_Log_Domain_Level_Pending) + end - start + 1);
+ if (!p)
+ break;
+
+ p->namelen = end - start;
+ memcpy((char *)p->name, start, end - start);
+ ((char *)p->name)[end - start] = '\0';
+ p->level = level;
+
+ _pending_list = eina_inlist_append(_pending_list, EINA_INLIST_GET(p));
+
+parse_end:
+ start = strchr(tmp, ',');
+ if (start)
+ start++;
+ else
+ break;
}
}
{
const char *start;
- if (!(start = getenv(EINA_LOG_ENV_LEVELS_GLOB))) return;
+ if (!(start = getenv(EINA_LOG_ENV_LEVELS_GLOB)))
+ return;
// name1:level1,name2:level2,name3:level3,...
while (1)
{
- Eina_Log_Domain_Level_Pending *p;
- char *end = NULL;
- char *tmp = NULL;
- long int level;
-
- end = strchr(start, ':');
- if (!end) break;
-
- // Parse level, keep going if failed
- level = strtol((char *)(end + 1), &tmp, 10);
- if (tmp == (end + 1)) goto parse_end;
-
- // Parse name
- p = malloc(sizeof(Eina_Log_Domain_Level_Pending) + end - start + 1);
- if (!p) break;
- p->namelen = 0; /* not that useful */
- memcpy((char *)p->name, start, end - start);
- ((char *)p->name)[end - start] = '\0';
- p->level = level;
-
- _glob_list = eina_inlist_append(_glob_list, EINA_INLIST_GET(p));
-
- parse_end:
- start = strchr(tmp, ',');
- if (start) start++;
- else break;
+ Eina_Log_Domain_Level_Pending *p;
+ char *end = NULL;
+ char *tmp = NULL;
+ long int level;
+
+ end = strchr(start, ':');
+ if (!end)
+ break;
+
+ // Parse level, keep going if failed
+ level = strtol((char *)(end + 1), &tmp, 10);
+ if (tmp == (end + 1))
+ goto parse_end;
+
+ // Parse name
+ p = malloc(sizeof(Eina_Log_Domain_Level_Pending) + end - start + 1);
+ if (!p)
+ break;
+
+ p->namelen = 0; /* not that useful */
+ memcpy((char *)p->name, start, end - start);
+ ((char *)p->name)[end - start] = '\0';
+ p->level = level;
+
+ _glob_list = eina_inlist_append(_glob_list, EINA_INLIST_GET(p));
+
+parse_end:
+ start = strchr(tmp, ',');
+ if (start)
+ start++;
+ else
+ break;
}
}
for (i = 0; i < _log_domains_count; i++)
{
- if (_log_domains[i].deleted)
- {
- // Found a flagged slot, free domain_str and replace slot
- eina_log_domain_new(&_log_domains[i], name, color);
- goto finish_register;
- }
+ if (_log_domains[i].deleted)
+ {
+ // Found a flagged slot, free domain_str and replace slot
+ eina_log_domain_new(&_log_domains[i], name, color);
+ goto finish_register;
+ }
}
if (_log_domains_count >= _log_domains_allocated)
{
- Eina_Log_Domain *tmp;
- size_t size;
-
- if (!_log_domains)
- // special case for init, eina itself will allocate a dozen of domains
- size = 24;
- else
- // grow 8 buckets to minimize reallocs
- size = _log_domains_allocated + 8;
-
- tmp = realloc(_log_domains, sizeof(Eina_Log_Domain) * size);
-
- if (tmp)
- {
- // Success!
- _log_domains = tmp;
- _log_domains_allocated = size;
- }
- else
- return -1;
+ Eina_Log_Domain *tmp;
+ size_t size;
+
+ if (!_log_domains)
+ // special case for init, eina itself will allocate a dozen of domains
+ size = 24;
+ else
+ // grow 8 buckets to minimize reallocs
+ size = _log_domains_allocated + 8;
+
+ tmp = realloc(_log_domains, sizeof(Eina_Log_Domain) * size);
+
+ if (tmp)
+ {
+ // Success!
+ _log_domains = tmp;
+ _log_domains_allocated = size;
+ }
+ else
+ return -1;
}
// Use an allocated slot
- eina_log_domain_new(&_log_domains[i], name, color);
+ eina_log_domain_new(&_log_domains[i], name, color);
_log_domains_count++;
finish_register:
namelen = _log_domains[i].namelen;
EINA_INLIST_FOREACH(_pending_list, pending)
- {
- if ((namelen == pending->namelen) && (strcmp(pending->name, name) == 0))
- {
- _log_domains[i].level = pending->level;
- _pending_list = eina_inlist_remove(_pending_list, EINA_INLIST_GET(pending));
- free(pending);
- break;
- }
- }
+ {
+ if ((namelen == pending->namelen) && (strcmp(pending->name, name) == 0))
+ {
+ _log_domains[i].level = pending->level;
+ _pending_list =
+ eina_inlist_remove(_pending_list, EINA_INLIST_GET(pending));
+ free(pending);
+ break;
+ }
+ }
if (_log_domains[i].level == EINA_LOG_LEVEL_UNKNOWN)
{
- EINA_INLIST_FOREACH(_glob_list, pending)
- {
- if (!fnmatch(pending->name, name, 0))
- {
- _log_domains[i].level = pending->level;
- break;
- }
- }
+ EINA_INLIST_FOREACH(_glob_list, pending)
+ {
+ if (!fnmatch(pending->name, name, 0))
+ {
+ _log_domains[i].level = pending->level;
+ break;
+ }
+ }
}
// Check if level is still UNKNOWN, set it to global
const char *tail;
if (!term)
- return EINA_FALSE;
+ return EINA_FALSE;
tail = term + 1;
switch (term[0])
{
- /* list of known to support color terminals,
- * take from gentoo's portage.
- */
+ /* list of known to support color terminals,
+ * take from gentoo's portage.
+ */
case 'x': /* xterm and xterm-color */
- return ((strncmp(tail, "term", sizeof("term") - 1) == 0) &&
- ((tail[sizeof("term") - 1] == '\0') ||
- (strcmp(tail + sizeof("term") - 1, "-color") == 0)));
+ return ((strncmp(tail, "term", sizeof("term") - 1) == 0) &&
+ ((tail[sizeof("term") - 1] == '\0') ||
+ (strcmp(tail + sizeof("term") - 1, "-color") == 0)));
+
case 'E': /* Eterm */
case 'a': /* aterm */
case 'k': /* kterm */
- return (strcmp(tail, "term") == 0);
+ return (strcmp(tail, "term") == 0);
+
case 'r': /* xrvt or rxvt-unicode */
- return ((strncmp(tail, "xvt", sizeof("xvt") - 1) == 0) &&
- ((tail[sizeof("xvt") - 1] == '\0') ||
- (strcmp(tail + sizeof("xvt") - 1, "-unicode") == 0)));
+ return ((strncmp(tail, "xvt", sizeof("xvt") - 1) == 0) &&
+ ((tail[sizeof("xvt") - 1] == '\0') ||
+ (strcmp(tail + sizeof("xvt") - 1, "-unicode") == 0)));
+
case 's': /* screen */
- return (strcmp(tail, "creen") == 0);
+ return (strcmp(tail, "creen") == 0);
+
case 'g': /* gnome */
- return (strcmp(tail, "nome") == 0);
+ return (strcmp(tail, "nome") == 0);
+
case 'i': /* interix */
- return (strcmp(tail, "nterix") == 0);
+ return (strcmp(tail, "nterix") == 0);
+
default:
- return EINA_FALSE;
+ return EINA_FALSE;
}
}
/*============================================================================*
- * Global *
- *============================================================================*/
+* Global *
+*============================================================================*/
/**
* @internal
const char *level, *tmp;
int color_disable;
- assert((sizeof(_names)/sizeof(_names[0])) == EINA_LOG_LEVELS);
+ assert((sizeof(_names) / sizeof(_names[0])) == EINA_LOG_LEVELS);
if ((tmp = getenv(EINA_LOG_ENV_COLOR_DISABLE)))
- color_disable = atoi(tmp);
+ color_disable = atoi(tmp);
else
- color_disable = -1;
+ color_disable = -1;
/* Check if color is explicitly disabled */
if (color_disable == 1)
- _disable_color = EINA_TRUE;
+ _disable_color = EINA_TRUE;
#ifndef _WIN32
/* color was not explicitly disabled or enabled, guess it */
else if (color_disable == -1)
{
- if (!eina_log_term_color_supported(getenv("TERM")))
- _disable_color = EINA_TRUE;
- else {
- /* if not a terminal, but redirected to a file, disable color */
- int fd;
-
- if (_print_cb == eina_log_print_cb_stderr)
- fd = STDERR_FILENO;
- else if (_print_cb == eina_log_print_cb_stdout)
- fd = STDOUT_FILENO;
- else
- fd = -1;
-
- if ((fd >= 0) && (!isatty(fd)))
- _disable_color = EINA_TRUE;
- }
+ if (!eina_log_term_color_supported(getenv("TERM")))
+ _disable_color = EINA_TRUE;
+ else
+ {
+ /* if not a terminal, but redirected to a file, disable color */
+ int fd;
+
+ if (_print_cb == eina_log_print_cb_stderr)
+ fd = STDERR_FILENO;
+ else if (_print_cb == eina_log_print_cb_stdout)
+ fd = STDOUT_FILENO;
+ else
+ fd = -1;
+
+ if ((fd >= 0) && (!isatty(fd)))
+ _disable_color = EINA_TRUE;
+ }
}
#endif
if ((tmp = getenv(EINA_LOG_ENV_FILE_DISABLE)) && (atoi(tmp) == 1))
- _disable_file = EINA_TRUE;
+ _disable_file = EINA_TRUE;
if ((tmp = getenv(EINA_LOG_ENV_FUNCTION_DISABLE)) && (atoi(tmp) == 1))
- _disable_function = EINA_TRUE;
+ _disable_function = EINA_TRUE;
if ((tmp = getenv(EINA_LOG_ENV_ABORT)) && (atoi(tmp) == 1))
- _abort_on_critical = EINA_TRUE;
+ _abort_on_critical = EINA_TRUE;
if ((tmp = getenv(EINA_LOG_ENV_ABORT_LEVEL)))
- _abort_level_on_critical = atoi(tmp);
+ _abort_level_on_critical = atoi(tmp);
eina_log_print_prefix_update();
if (EINA_LOG_DOMAIN_GLOBAL < 0)
{
- fprintf(stderr, "Failed to create global logging domain.\n");
- return EINA_FALSE;
+ fprintf(stderr, "Failed to create global logging domain.\n");
+ return EINA_FALSE;
}
// Parse pending domains passed through EINA_LOG_LEVELS_GLOB
while (_log_domains_count--)
{
- if (_log_domains[_log_domains_count].deleted)
- continue;
- eina_log_domain_free(&_log_domains[_log_domains_count]);
+ if (_log_domains[_log_domains_count].deleted)
+ continue;
+
+ eina_log_domain_free(&_log_domains[_log_domains_count]);
}
- free(_log_domains);
+ free(_log_domains);
_log_domains = NULL;
_log_domains_count = 0;
while (_pending_list)
{
- tmp = _pending_list;
- _pending_list = _pending_list->next;
- free(tmp);
+ tmp = _pending_list;
+ _pending_list = _pending_list->next;
+ free(tmp);
}
return EINA_TRUE;
{
_main_thread = SELF();
if (INIT())
- _threads_enabled = EINA_TRUE;
+ _threads_enabled = EINA_TRUE;
}
/**
void
eina_log_threads_shutdown(void)
{
- CHECK_MAIN();
- SHUTDOWN();
- _threads_enabled = EINA_FALSE;
+ CHECK_MAIN();
+ SHUTDOWN();
+ _threads_enabled = EINA_FALSE;
}
#endif
/*============================================================================*
- * API *
- *============================================================================*/
+* API *
+*============================================================================*/
/**
* @addtogroup Eina_Log_Group Log
{
_log_level = level;
if (EINA_LIKELY((EINA_LOG_DOMAIN_GLOBAL >= 0) &&
- ((unsigned int)EINA_LOG_DOMAIN_GLOBAL < _log_domains_count)))
- _log_domains[EINA_LOG_DOMAIN_GLOBAL].level = level;
+ ((unsigned int)EINA_LOG_DOMAIN_GLOBAL < _log_domains_count)))
+ _log_domains[EINA_LOG_DOMAIN_GLOBAL].level = level;
}
/**
eina_log_main_thread_check(void)
{
#ifdef EFL_HAVE_THREADS
- return ((!_threads_enabled) || IS_MAIN(SELF()));
+ return ((!_threads_enabled) || IS_MAIN(SELF()));
#else
return EINA_TRUE;
#endif
{
Eina_Log_Domain *d;
- if ((unsigned int)domain >= _log_domains_count) return;
+ if ((unsigned int)domain >= _log_domains_count)
+ return;
d = &_log_domains[domain];
eina_log_domain_free(d);
for (i = 0; i < _log_domains_count; i++)
{
- if (_log_domains[i].deleted)
- continue;
- if ((namelen != _log_domains[i].namelen) ||
- (strcmp(_log_domains[i].name, domain_name) != 0))
- continue;
-
- _log_domains[i].level = level;
- return;
+ if (_log_domains[i].deleted)
+ continue;
+
+ if ((namelen != _log_domains[i].namelen) ||
+ (strcmp(_log_domains[i].name, domain_name) != 0))
+ continue;
+
+ _log_domains[i].level = level;
+ return;
}
EINA_INLIST_FOREACH(_pending_list, pending)
- {
- if ((namelen == pending->namelen) &&
- (strcmp(pending->name, domain_name) == 0))
- {
- pending->level = level;
- return;
- }
- }
+ {
+ if ((namelen == pending->namelen) &&
+ (strcmp(pending->name, domain_name) == 0))
+ {
+ pending->level = level;
+ return;
+ }
+ }
pending = malloc(sizeof(Eina_Log_Domain_Level_Pending) + namelen + 1);
if (!pending)
- return;
+ return;
+
pending->level = level;
pending->namelen = namelen;
memcpy(pending->name, domain_name, namelen + 1);
for (i = 0; i < _log_domains_count; i++)
{
- if (_log_domains[i].deleted)
- continue;
- if ((namelen != _log_domains[i].namelen) ||
- (strcmp(_log_domains[i].name, domain_name) != 0))
- continue;
+ if (_log_domains[i].deleted)
+ continue;
+
+ if ((namelen != _log_domains[i].namelen) ||
+ (strcmp(_log_domains[i].name, domain_name) != 0))
+ continue;
- return _log_domains[i].level;
+ return _log_domains[i].level;
}
EINA_INLIST_FOREACH(_pending_list, pending)
- {
- if ((namelen == pending->namelen) &&
- (strcmp(pending->name, domain_name) == 0))
- {
- return pending->level;
- }
- }
+ {
+ if ((namelen == pending->namelen) &&
+ (strcmp(pending->name, domain_name) == 0))
+ return pending->level;
+ }
EINA_INLIST_FOREACH(_glob_list, pending)
- {
- if (!fnmatch(pending->name, domain_name, 0))
- {
- return pending->level;
- }
- }
+ {
+ if (!fnmatch(pending->name, domain_name, 0))
+ return pending->level;
+ }
return _log_level;
}
{
EINA_SAFETY_ON_FALSE_RETURN_VAL(domain >= 0, EINA_LOG_LEVEL_UNKNOWN);
EINA_SAFETY_ON_FALSE_RETURN_VAL((unsigned int)domain < _log_domains_count,
- EINA_LOG_LEVEL_UNKNOWN);
+ EINA_LOG_LEVEL_UNKNOWN);
EINA_SAFETY_ON_TRUE_RETURN_VAL(_log_domains[domain].deleted,
- EINA_LOG_LEVEL_UNKNOWN);
+ EINA_LOG_LEVEL_UNKNOWN);
return _log_domains[domain].level;
}
* -1), then Eina will disable color if terminal ($TERM) is
* unsupported or if redirecting to a file.
-. Similarly, to disable file and line
+ . Similarly, to disable file and line
* information, set EINA_LOG_FILE_DISABLE=1 or
* EINA_LOG_FUNCTION_DISABLE=1 to avoid function name in output. It is
* not acceptable to have both EINA_LOG_FILE_DISABLE and
* appended to domain name.
*/
EAPI void
-eina_log_print_cb_stderr(const Eina_Log_Domain *d, Eina_Log_Level level,
- const char *file, const char *fnc, int line, const char *fmt,
- __UNUSED__ void *data, va_list args)
+eina_log_print_cb_stderr(const Eina_Log_Domain *d,
+ Eina_Log_Level level,
+ const char *file,
+ const char *fnc,
+ int line,
+ const char *fmt,
+ __UNUSED__ void *data,
+ va_list args)
{
_eina_log_print_prefix(stderr, d, level, file, fnc, line);
vfprintf(stderr, fmt, args);
* appended to domain name.
*/
EAPI void
-eina_log_print_cb_stdout(const Eina_Log_Domain *d, Eina_Log_Level level,
- const char *file, const char *fnc, int line, const char *fmt,
- __UNUSED__ void *data, va_list args)
+eina_log_print_cb_stdout(const Eina_Log_Domain *d,
+ Eina_Log_Level level,
+ const char *file,
+ const char *fnc,
+ int line,
+ const char *fmt,
+ __UNUSED__ void *data,
+ va_list args)
{
_eina_log_print_prefix(stdout, d, level, file, fnc, line);
vprintf(fmt, args);
* appended to domain name.
*/
EAPI void
-eina_log_print_cb_file(const Eina_Log_Domain *d, __UNUSED__ Eina_Log_Level level,
- const char *file, const char *fnc, int line, const char *fmt,
- void *data, va_list args)
+eina_log_print_cb_file(const Eina_Log_Domain *d,
+ __UNUSED__ Eina_Log_Level level,
+ const char *file,
+ const char *fnc,
+ int line,
+ const char *fmt,
+ void *data,
+ va_list args)
{
FILE *f = data;
#ifdef EFL_HAVE_THREADS
Thread cur;
cur = SELF();
- if (IS_OTHER(cur))
- {
- fprintf(f, "%s[T:%lu] %s:%d %s() ", d->name, cur, file, line, fnc);
- goto end;
- }
+ if (IS_OTHER(cur))
+ {
+ fprintf(f, "%s[T:%lu] %s:%d %s() ", d->name, cur, file, line, fnc);
+ goto end;
+ }
}
+
#endif
- fprintf(f, "%s %s:%d %s() ", d->name, file, line, fnc);
+ fprintf(f, "%s %s:%d %s() ", d->name, file, line, fnc);
#ifdef EFL_HAVE_THREADS
- end:
+end:
#endif
vfprintf(f, fmt, args);
putc('\n', f);
}
static inline void
-eina_log_print_unlocked(int domain, Eina_Log_Level level, const char *file, const char *fnc, int line, const char *fmt, va_list args)
+eina_log_print_unlocked(int domain,
+ Eina_Log_Level level,
+ const char *file,
+ const char *fnc,
+ int line,
+ const char *fmt,
+ va_list args)
{
Eina_Log_Domain *d;
if (EINA_UNLIKELY((unsigned int)domain >= _log_domains_count) ||
EINA_UNLIKELY(domain < 0))
{
- if (file && fnc && fmt)
- fprintf(stderr, "CRI: %s:%d %s() eina_log_print() unknown domain %d, original message format '%s'\n", file, line, fnc, domain, fmt);
- else
- fprintf(stderr, "CRI: eina_log_print() unknown domain %d, original message format '%s'\n", domain, fmt ? fmt : "");
- if (_abort_on_critical) abort();
- return;
+ if (file && fnc && fmt)
+ fprintf(
+ stderr,
+ "CRI: %s:%d %s() eina_log_print() unknown domain %d, original message format '%s'\n",
+ file,
+ line,
+ fnc,
+ domain,
+ fmt);
+ else
+ fprintf(
+ stderr,
+ "CRI: eina_log_print() unknown domain %d, original message format '%s'\n",
+ domain,
+ fmt ? fmt : "");
+
+ if (_abort_on_critical)
+ abort();
+
+ return;
}
+
#endif
d = _log_domains + domain;
#ifdef EINA_SAFETY_CHECKS
if (EINA_UNLIKELY(d->deleted))
{
- fprintf(stderr, "ERR: eina_log_print() domain %d is deleted\n", domain);
- return;
+ fprintf(stderr,
+ "ERR: eina_log_print() domain %d is deleted\n",
+ domain);
+ return;
}
+
#endif
- if (level > d->level) return;
+ if (level > d->level)
+ return;
#ifdef _WIN32
{
fprintf(stderr, "ERR: %s: can not allocate memory\n", __FUNCTION__);
return;
}
+
tmp = wfmt;
while (strchr(tmp, "%"))
{
- tmp++;
- if (*tmp == 'z')
- *tmp = 'I';
+ tmp++;
+ if (*tmp == 'z')
+ *tmp = 'I';
}
_print_cb(d, level, file, fnc, line, wfmt, _print_cb_data, args);
free(wfmt);
if (EINA_UNLIKELY(_abort_on_critical) &&
EINA_UNLIKELY(level <= _abort_level_on_critical))
- abort();
+ abort();
}
/**
*/
EAPI void
eina_log_print(int domain, Eina_Log_Level level, const char *file,
- const char *fnc, int line, const char *fmt, ...)
+ const char *fnc, int line, const char *fmt, ...)
{
va_list args;
#ifdef EINA_SAFETY_CHECKS
if (EINA_UNLIKELY(file == NULL))
{
- fputs("ERR: eina_log_print() file == NULL\n", stderr);
- return;
+ fputs("ERR: eina_log_print() file == NULL\n", stderr);
+ return;
}
+
if (EINA_UNLIKELY(fnc == NULL))
{
- fputs("ERR: eina_log_print() fnc == NULL\n", stderr);
- return;
+ fputs("ERR: eina_log_print() fnc == NULL\n", stderr);
+ return;
}
+
if (EINA_UNLIKELY(fmt == NULL))
{
- fputs("ERR: eina_log_print() fmt == NULL\n", stderr);
- return;
+ fputs("ERR: eina_log_print() fmt == NULL\n", stderr);
+ return;
}
+
#endif
va_start(args, fmt);
LOG_LOCK();
*/
EAPI void
eina_log_vprint(int domain, Eina_Log_Level level, const char *file,
- const char *fnc, int line, const char *fmt, va_list args)
+ const char *fnc, int line, const char *fmt, va_list args)
{
#ifdef EINA_SAFETY_CHECKS
if (EINA_UNLIKELY(file == NULL))
{
- fputs("ERR: eina_log_print() file == NULL\n", stderr);
- return;
+ fputs("ERR: eina_log_print() file == NULL\n", stderr);
+ return;
}
+
if (EINA_UNLIKELY(fnc == NULL))
{
- fputs("ERR: eina_log_print() fnc == NULL\n", stderr);
- return;
+ fputs("ERR: eina_log_print() fnc == NULL\n", stderr);
+ return;
}
+
if (EINA_UNLIKELY(fmt == NULL))
{
- fputs("ERR: eina_log_print() fmt == NULL\n", stderr);
- return;
+ fputs("ERR: eina_log_print() fmt == NULL\n", stderr);
+ return;
}
+
#endif
LOG_LOCK();
eina_log_print_unlocked(domain, level, file, fnc, line, fmt, args);
#include "eina_magic.h"
/*============================================================================*
- * Local *
- *============================================================================*/
+* Local *
+*============================================================================*/
/**
* @cond LOCAL
if (_eina_magic_strings_count == _eina_magic_strings_allocated)
{
- void *tmp;
- size_t size;
+ void *tmp;
+ size_t size;
- if (EINA_UNLIKELY(_eina_magic_strings_allocated == 0))
- size = 48;
- else
- size = _eina_magic_strings_allocated + 16;
+ if (EINA_UNLIKELY(_eina_magic_strings_allocated == 0))
+ size = 48;
+ else
+ size = _eina_magic_strings_allocated + 16;
- tmp = realloc(_eina_magic_strings, sizeof(Eina_Magic_String) * size);
- if (!tmp)
- {
+ tmp = realloc(_eina_magic_strings, sizeof(Eina_Magic_String) * size);
+ if (!tmp)
+ {
#ifdef _WIN32
- ERR("could not realloc magic_strings from %Iu to %Iu buckets.",
+ ERR("could not realloc magic_strings from %Iu to %Iu buckets.",
#else
- ERR("could not realloc magic_strings from %zu to %zu buckets.",
+ ERR("could not realloc magic_strings from %zu to %zu buckets.",
#endif
- _eina_magic_strings_allocated, size);
- return NULL;
- }
- _eina_magic_strings = tmp;
- _eina_magic_strings_allocated = size;
+ _eina_magic_strings_allocated, size);
+ return NULL;
+ }
+
+ _eina_magic_strings = tmp;
+ _eina_magic_strings_allocated = size;
}
idx = _eina_magic_strings_count;
*/
/*============================================================================*
- * Global *
- *============================================================================*/
+* Global *
+*============================================================================*/
/**
* @internal
eina_magic_string_init(void)
{
_eina_magic_string_log_dom = eina_log_domain_register
- ("eina_magic_string", EINA_LOG_COLOR_DEFAULT);
+ ("eina_magic_string", EINA_LOG_COLOR_DEFAULT);
if (_eina_magic_string_log_dom < 0)
{
- EINA_LOG_ERR("Could not register log domain: eina_magic_string");
- return EINA_FALSE;
+ EINA_LOG_ERR("Could not register log domain: eina_magic_string");
+ return EINA_FALSE;
}
return EINA_TRUE;
ems_end = ems + _eina_magic_strings_count;
for (; ems < ems_end; ems++)
- if (ems->string_allocated)
- free((char *)ems->string);
+ if (ems->string_allocated)
+ free((char *)ems->string);
- free(_eina_magic_strings);
+ free(_eina_magic_strings);
_eina_magic_strings = NULL;
_eina_magic_strings_count = 0;
_eina_magic_strings_allocated = 0;
}
/*============================================================================*
- * API *
- *============================================================================*/
+* API *
+*============================================================================*/
/**
* @addtogroup Eina_Magic_Group Magic
* - (undefined): magic was registered and found, but no string associated.
* - (unknown): magic was not found in the registry.
*/
-EAPI const char*
+EAPI const char *
eina_magic_string_get(Eina_Magic magic)
{
Eina_Magic_String *ems;
if (!_eina_magic_strings)
- return "(none)";
+ return "(none)";
if (_eina_magic_strings_dirty)
{
- qsort(_eina_magic_strings, _eina_magic_strings_count,
- sizeof(Eina_Magic_String), _eina_magic_strings_sort_cmp);
- _eina_magic_strings_dirty = 0;
+ qsort(_eina_magic_strings, _eina_magic_strings_count,
+ sizeof(Eina_Magic_String), _eina_magic_strings_sort_cmp);
+ _eina_magic_strings_dirty = 0;
}
ems = bsearch((void *)(long)magic, _eina_magic_strings,
- _eina_magic_strings_count, sizeof(Eina_Magic_String),
- _eina_magic_strings_find_cmp);
+ _eina_magic_strings_count, sizeof(Eina_Magic_String),
+ _eina_magic_strings_find_cmp);
if (ems)
- return ems->string ? ems->string : "(undefined)";
+ return ems->string ? ems->string : "(undefined)";
+
return "(unknown)";
}
ems = _eina_magic_strings_alloc();
if (!ems)
- return EINA_FALSE;
+ return EINA_FALSE;
ems->magic = magic;
ems->string_allocated = EINA_TRUE;
ems->string = strdup(magic_name);
if (!ems->string)
- {
- ERR("could not allocate string '%s'", magic_name);
- _eina_magic_strings_count--;
- return EINA_FALSE;
- }
+ {
+ ERR("could not allocate string '%s'", magic_name);
+ _eina_magic_strings_count--;
+ return EINA_FALSE;
+ }
_eina_magic_strings_dirty = 1;
return EINA_TRUE;
ems = _eina_magic_strings_alloc();
if (!ems)
- return EINA_FALSE;
+ return EINA_FALSE;
ems->magic = magic;
ems->string_allocated = EINA_FALSE;
* with gdb.
*/
EAPI void
-eina_magic_fail(void *d, Eina_Magic m, Eina_Magic req_m, const char *file, const char *fnc, int line)
+eina_magic_fail(void *d,
+ Eina_Magic m,
+ Eina_Magic req_m,
+ const char *file,
+ const char *fnc,
+ int line)
{
if (!d)
- eina_log_print(EINA_LOG_DOMAIN_GLOBAL, EINA_LOG_LEVEL_CRITICAL,
- file, fnc, line,
- "*** Eina Magic Check Failed !!!\n"
- " Input handle pointer is NULL !\n"
- "*** NAUGHTY PROGRAMMER!!!\n"
- "*** SPANK SPANK SPANK!!!\n"
- "*** Now go fix your code. Tut tut tut!\n"
- "\n");
+ eina_log_print(EINA_LOG_DOMAIN_GLOBAL, EINA_LOG_LEVEL_CRITICAL,
+ file, fnc, line,
+ "*** Eina Magic Check Failed !!!\n"
+ " Input handle pointer is NULL !\n"
+ "*** NAUGHTY PROGRAMMER!!!\n"
+ "*** SPANK SPANK SPANK!!!\n"
+ "*** Now go fix your code. Tut tut tut!\n"
+ "\n");
+ else
+ if (m == EINA_MAGIC_NONE)
+ eina_log_print(EINA_LOG_DOMAIN_GLOBAL, EINA_LOG_LEVEL_CRITICAL,
+ file, fnc, line,
+ "*** Eina Magic Check Failed !!!\n"
+ " Input handle has already been freed!\n"
+ "*** NAUGHTY PROGRAMMER!!!\n"
+ "*** SPANK SPANK SPANK!!!\n"
+ "*** Now go fix your code. Tut tut tut!\n"
+ "\n");
+ else
+ if (m != req_m)
+ eina_log_print(EINA_LOG_DOMAIN_GLOBAL, EINA_LOG_LEVEL_CRITICAL,
+ file, fnc, line,
+ "*** Eina Magic Check Failed !!!\n"
+ " Input handle is wrong type\n"
+ " Expected: %08x - %s\n"
+ " Supplied: %08x - %s\n"
+ "*** NAUGHTY PROGRAMMER!!!\n"
+ "*** SPANK SPANK SPANK!!!\n"
+ "*** Now go fix your code. Tut tut tut!\n"
+ "\n",
+ req_m, eina_magic_string_get(req_m),
+ m, eina_magic_string_get(m));
else
- if (m == EINA_MAGIC_NONE)
- eina_log_print(EINA_LOG_DOMAIN_GLOBAL, EINA_LOG_LEVEL_CRITICAL,
- file, fnc, line,
- "*** Eina Magic Check Failed !!!\n"
- " Input handle has already been freed!\n"
- "*** NAUGHTY PROGRAMMER!!!\n"
- "*** SPANK SPANK SPANK!!!\n"
- "*** Now go fix your code. Tut tut tut!\n"
- "\n");
- else
- if (m != req_m)
- eina_log_print(EINA_LOG_DOMAIN_GLOBAL, EINA_LOG_LEVEL_CRITICAL,
- file, fnc, line,
- "*** Eina Magic Check Failed !!!\n"
- " Input handle is wrong type\n"
- " Expected: %08x - %s\n"
- " Supplied: %08x - %s\n"
- "*** NAUGHTY PROGRAMMER!!!\n"
- "*** SPANK SPANK SPANK!!!\n"
- "*** Now go fix your code. Tut tut tut!\n"
- "\n",
- req_m, eina_magic_string_get(req_m),
- m, eina_magic_string_get(m));
- else
- eina_log_print(EINA_LOG_DOMAIN_GLOBAL, EINA_LOG_LEVEL_CRITICAL,
- file, fnc, line,
- "*** Eina Magic Check Failed !!!\n"
- " Why did you call me !\n"
- "*** NAUGHTY PROGRAMMER!!!\n"
- "*** SPANK SPANK SPANK!!!\n"
- "*** Now go fix your code. Tut tut tut!\n"
- "\n");
+ eina_log_print(EINA_LOG_DOMAIN_GLOBAL, EINA_LOG_LEVEL_CRITICAL,
+ file, fnc, line,
+ "*** Eina Magic Check Failed !!!\n"
+ " Why did you call me !\n"
+ "*** NAUGHTY PROGRAMMER!!!\n"
+ "*** SPANK SPANK SPANK!!!\n"
+ "*** Now go fix your code. Tut tut tut!\n"
+ "\n");
}
/**
EAPI Eina_Version *eina_version = &_version;
/*============================================================================*
- * Local *
- *============================================================================*/
+* Local *
+*============================================================================*/
/**
* @cond LOCAL
/* 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(iterator);
-S(accessor);
-S(array);
-S(module);
-S(mempool);
-S(list);
-S(stringshare);
-S(ustringshare);
-S(matrixsparse);
-S(convert);
-S(counter);
-S(benchmark);
-S(rectangle);
-S(strbuf);
-S(ustrbuf);
-S(quadtree);
+#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(iterator);
+ S(accessor);
+ S(array);
+ S(module);
+ S(mempool);
+ S(list);
+ S(stringshare);
+ S(ustringshare);
+ S(matrixsparse);
+ S(convert);
+ S(counter);
+ S(benchmark);
+ S(rectangle);
+ S(strbuf);
+ S(ustrbuf);
+ S(quadtree);
#undef S
struct eina_desc_setup
};
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(iterator),
- S(accessor),
- S(array),
- S(module),
- S(mempool),
- S(list),
- S(stringshare),
- S(ustringshare),
- S(matrixsparse),
- S(convert),
- S(counter),
- S(benchmark),
- S(rectangle),
- S(strbuf),
- S(ustrbuf),
- S(quadtree)
+#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(iterator),
+ S(accessor),
+ S(array),
+ S(module),
+ S(mempool),
+ S(list),
+ S(stringshare),
+ S(ustringshare),
+ S(matrixsparse),
+ S(convert),
+ S(counter),
+ S(benchmark),
+ S(rectangle),
+ S(strbuf),
+ S(ustrbuf),
+ S(quadtree)
#undef S
};
-static const size_t _eina_desc_setup_len = sizeof(_eina_desc_setup) / sizeof(_eina_desc_setup[0]);
+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);
+ if (!itr->shutdown())
+ ERR("Problems shutting down eina module '%s', ignored.", itr->name);
}
eina_log_domain_unregister(_eina_log_dom);
*/
/*============================================================================*
- * Global *
- *============================================================================*/
+* Global *
+*============================================================================*/
/*============================================================================*
- * API *
- *============================================================================*/
+* API *
+*============================================================================*/
/**
* @addtogroup Eina_Main_Group Main
const struct eina_desc_setup *itr, *itr_end;
if (EINA_LIKELY(_eina_main_count > 0))
- return ++_eina_main_count;
+ return ++_eina_main_count;
if (!eina_log_init())
{
- fprintf(stderr, "Could not initialize eina logging system.\n");
- return 0;
+ 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)
{
- EINA_LOG_ERR("Could not register log domain: eina");
- eina_log_shutdown();
- return 0;
+ EINA_LOG_ERR("Could not register log domain: eina");
+ eina_log_shutdown();
+ return 0;
}
itr = _eina_desc_setup;
itr_end = itr + _eina_desc_setup_len;
for (; itr < itr_end; itr++)
{
- if (!itr->init())
- {
- ERR("Could not initialize eina module '%s'.", itr->name);
- _eina_shutdown_from_desc(itr);
- return 0;
- }
+ if (!itr->init())
+ {
+ ERR("Could not initialize eina module '%s'.", itr->name);
+ _eina_shutdown_from_desc(itr);
+ return 0;
+ }
}
_eina_main_count = 1;
{
_eina_main_count--;
if (EINA_UNLIKELY(_eina_main_count == 0))
- _eina_shutdown_from_desc(_eina_desc_setup + _eina_desc_setup_len);
+ _eina_shutdown_from_desc(_eina_desc_setup + _eina_desc_setup_len);
+
return _eina_main_count;
}
eina_threads_init(void)
{
#ifdef EFL_HAVE_THREADS
- int ret;
+ int ret;
# ifdef EFL_HAVE_WIN32_THREADS
- if (!_mutex)
+ if (!_mutex)
_mutex = CreateMutex(NULL, FALSE, NULL);
- if (!_mutex) return 0;
+
+ if (!_mutex)
+ return 0;
+
# endif
-
- LOCK();
- ++_eina_main_thread_count;
- ret = _eina_main_thread_count;
- if(_eina_main_thread_count > 1)
- {
+ LOCK();
+ ++_eina_main_thread_count;
+ ret = _eina_main_thread_count;
+
+ if(_eina_main_thread_count > 1)
+ {
UNLOCK();
return ret;
- }
+ }
- eina_share_common_threads_init();
- eina_log_threads_init();
- _threads_activated = EINA_TRUE;
+ eina_share_common_threads_init();
+ eina_log_threads_init();
+ _threads_activated = EINA_TRUE;
- return ret;
+ return ret;
#else
- return 0;
+ return 0;
#endif
}
eina_threads_shutdown(void)
{
#ifdef EFL_HAVE_THREADS
- int ret;
+ int ret;
- LOCK();
- ret = --_eina_main_thread_count;
- if(_eina_main_thread_count > 0)
- {
+ LOCK();
+ ret = --_eina_main_thread_count;
+ if(_eina_main_thread_count > 0)
+ {
UNLOCK();
- return ret;
- }
+ return ret;
+ }
- eina_share_common_threads_shutdown();
- eina_log_threads_shutdown();
+ eina_share_common_threads_shutdown();
+ eina_log_threads_shutdown();
- _threads_activated = EINA_FALSE;
+ _threads_activated = EINA_FALSE;
- UNLOCK_FORCE();
+ UNLOCK_FORCE();
# ifdef EFL_HAVE_WIN32_THREADS
- if (_mutex) CloseHandle(_mutex);
+ if (_mutex)
+ CloseHandle(_mutex);
+
# endif
- return ret;
+ return ret;
#else
- return 0;
+ return 0;
#endif
}
/*============================================================================*
- * Local *
- *============================================================================*/
+* Local *
+*============================================================================*/
/**
* @cond LOCAL
static const char EINA_MAGIC_MATRIXSPARSE_STR[] = "Eina Matrixsparse";
static const char EINA_MAGIC_MATRIXSPARSE_ROW_STR[] = "Eina Matrixsparse Row";
static const char EINA_MAGIC_MATRIXSPARSE_CELL_STR[] = "Eina Matrixsparse Cell";
-static const char EINA_MAGIC_MATRIXSPARSE_ITERATOR_STR[] = "Eina Matrixsparse Iterator";
-static const char EINA_MAGIC_MATRIXSPARSE_ROW_ACCESSOR_STR[] = "Eina Matrixsparse Row Accessor";
-static const char EINA_MAGIC_MATRIXSPARSE_ROW_ITERATOR_STR[] = "Eina Matrixsparse Row Iterator";
-static const char EINA_MAGIC_MATRIXSPARSE_CELL_ACCESSOR_STR[] = "Eina Matrixsparse Cell Accessor";
-static const char EINA_MAGIC_MATRIXSPARSE_CELL_ITERATOR_STR[] = "Eina Matrixsparse Cell Iterator";
-
-
-#define EINA_MAGIC_CHECK_MATRIXSPARSE(d, ...) \
- do { \
- if (!EINA_MAGIC_CHECK(d, EINA_MAGIC_MATRIXSPARSE)) \
- { \
- EINA_MAGIC_FAIL(d, EINA_MAGIC_MATRIXSPARSE); \
- return __VA_ARGS__; \
- } \
- } while(0)
-
-#define EINA_MAGIC_CHECK_MATRIXSPARSE_ROW(d, ...) \
- do { \
- if (!EINA_MAGIC_CHECK(d, EINA_MAGIC_MATRIXSPARSE_ROW)) \
- { \
- EINA_MAGIC_FAIL(d, EINA_MAGIC_MATRIXSPARSE_ROW); \
- return __VA_ARGS__; \
- } \
- } while(0)
-
-#define EINA_MAGIC_CHECK_MATRIXSPARSE_CELL(d, ...) \
- do { \
- if (!EINA_MAGIC_CHECK(d, EINA_MAGIC_MATRIXSPARSE_CELL)) \
- { \
- EINA_MAGIC_FAIL(d, EINA_MAGIC_MATRIXSPARSE_CELL); \
- return __VA_ARGS__; \
- } \
- } while(0)
-
-#define EINA_MAGIC_CHECK_MATRIXSPARSE_ITERATOR(d, ...) \
- do { \
- if (!EINA_MAGIC_CHECK(d, EINA_MAGIC_MATRIXSPARSE_ITERATOR)) \
- { \
- EINA_MAGIC_FAIL(d, EINA_MAGIC_MATRIXSPARSE_ITERATOR); \
- return __VA_ARGS__; \
- } \
- } while(0)
+static const char EINA_MAGIC_MATRIXSPARSE_ITERATOR_STR[] =
+ "Eina Matrixsparse Iterator";
+static const char EINA_MAGIC_MATRIXSPARSE_ROW_ACCESSOR_STR[] =
+ "Eina Matrixsparse Row Accessor";
+static const char EINA_MAGIC_MATRIXSPARSE_ROW_ITERATOR_STR[] =
+ "Eina Matrixsparse Row Iterator";
+static const char EINA_MAGIC_MATRIXSPARSE_CELL_ACCESSOR_STR[] =
+ "Eina Matrixsparse Cell Accessor";
+static const char EINA_MAGIC_MATRIXSPARSE_CELL_ITERATOR_STR[] =
+ "Eina Matrixsparse Cell Iterator";
+
+
+#define EINA_MAGIC_CHECK_MATRIXSPARSE(d, ...) \
+ do { \
+ if (!EINA_MAGIC_CHECK(d, EINA_MAGIC_MATRIXSPARSE)) \
+ { \
+ EINA_MAGIC_FAIL(d, EINA_MAGIC_MATRIXSPARSE); \
+ return __VA_ARGS__; \
+ } \
+ } while(0)
+
+#define EINA_MAGIC_CHECK_MATRIXSPARSE_ROW(d, ...) \
+ do { \
+ if (!EINA_MAGIC_CHECK(d, EINA_MAGIC_MATRIXSPARSE_ROW)) \
+ { \
+ EINA_MAGIC_FAIL(d, EINA_MAGIC_MATRIXSPARSE_ROW); \
+ return __VA_ARGS__; \
+ } \
+ } while(0)
+
+#define EINA_MAGIC_CHECK_MATRIXSPARSE_CELL(d, ...) \
+ do { \
+ if (!EINA_MAGIC_CHECK(d, EINA_MAGIC_MATRIXSPARSE_CELL)) \
+ { \
+ EINA_MAGIC_FAIL(d, EINA_MAGIC_MATRIXSPARSE_CELL); \
+ return __VA_ARGS__; \
+ } \
+ } while(0)
+
+#define EINA_MAGIC_CHECK_MATRIXSPARSE_ITERATOR(d, ...) \
+ do { \
+ if (!EINA_MAGIC_CHECK(d, EINA_MAGIC_MATRIXSPARSE_ITERATOR)) \
+ { \
+ EINA_MAGIC_FAIL(d, EINA_MAGIC_MATRIXSPARSE_ITERATOR); \
+ return __VA_ARGS__; \
+ } \
+ } while(0)
struct _Eina_Matrixsparse_Cell
{
};
typedef struct _Eina_Matrixsparse_Iterator Eina_Matrixsparse_Iterator;
-typedef struct _Eina_Matrixsparse_Iterator_Complete Eina_Matrixsparse_Iterator_Complete;
+typedef struct _Eina_Matrixsparse_Iterator_Complete
+Eina_Matrixsparse_Iterator_Complete;
struct _Eina_Matrixsparse_Iterator
{
Eina_Iterator iterator;
const Eina_Matrixsparse *m;
- struct {
+ struct
+ {
const Eina_Matrixsparse_Row *row;
const Eina_Matrixsparse_Cell *col;
} ref;
Eina_Iterator iterator;
const Eina_Matrixsparse *m;
- struct {
+ struct
+ {
const Eina_Matrixsparse_Row *row;
const Eina_Matrixsparse_Cell *col;
} ref;
- struct {
+ struct
+ {
unsigned long row, col;
} idx;
- struct {
+ struct
+ {
Eina_Matrixsparse_Row row;
Eina_Matrixsparse_Cell col;
} dummy;
static Eina_Mempool *_eina_matrixsparse_row_mp = NULL;
static inline void
-_eina_matrixsparse_cell_free(Eina_Matrixsparse_Cell *c, void (*free_func)(void *, void *), void *user_data)
+_eina_matrixsparse_cell_free(Eina_Matrixsparse_Cell *c, void (*free_func)(
+ void *,
+ void *), void *user_data)
{
if (free_func)
- free_func(user_data, c->data);
+ free_func(user_data, c->data);
EINA_MAGIC_SET(c, EINA_MAGIC_NONE);
eina_mempool_free(_eina_matrixsparse_cell_mp, c);
if (r->last_used == c)
{
- if (c->next)
- r->last_used = c->next;
- else
- r->last_used = c->prev;
+ if (c->next)
+ r->last_used = c->next;
+ else
+ r->last_used = c->prev;
}
if (r->last_col == c)
- r->last_col = c->prev;
+ r->last_col = c->prev;
if (r->cols == c)
- r->cols = c->next;
+ r->cols = c->next;
if (c->next && c->prev)
{
- c->next->prev = c->prev;
- c->prev->next = c->next;
+ c->next->prev = c->prev;
+ c->prev->next = c->next;
}
else if (c->next)
- c->next->prev = NULL;
+ c->next->prev = NULL;
else if (c->prev)
- c->prev->next = NULL;
+ c->prev->next = NULL;
}
static inline void
-_eina_matrixsparse_row_cells_free(Eina_Matrixsparse_Row *r, void (*free_func)(void *, void *), void *user_data)
+_eina_matrixsparse_row_cells_free(Eina_Matrixsparse_Row *r, void (*free_func)(
+ void *,
+ void *), void *user_data)
{
Eina_Matrixsparse_Cell *c = r->cols;
while (c)
{
- Eina_Matrixsparse_Cell *c_aux = c;
- c = c->next;
- _eina_matrixsparse_cell_free(c_aux, free_func, user_data);
+ Eina_Matrixsparse_Cell *c_aux = c;
+ c = c->next;
+ _eina_matrixsparse_cell_free(c_aux, free_func, user_data);
}
}
static inline void
-_eina_matrixsparse_row_free(Eina_Matrixsparse_Row *r, void (*free_func)(void *, void *), void *user_data)
+_eina_matrixsparse_row_free(Eina_Matrixsparse_Row *r, void (*free_func)(void *,
+ void *),
+ void *user_data)
{
_eina_matrixsparse_row_cells_free(r, free_func, user_data);
EINA_MAGIC_SET(r, EINA_MAGIC_NONE);
if (m->last_used == r)
{
- if (r->next)
- m->last_used = r->next;
- else
- m->last_used = r->prev;
+ if (r->next)
+ m->last_used = r->next;
+ else
+ m->last_used = r->prev;
}
if (m->last_row == r)
- m->last_row = r->prev;
+ m->last_row = r->prev;
if (m->rows == r)
- m->rows = r->next;
+ m->rows = r->next;
if (r->next && r->prev)
{
- r->next->prev = r->prev;
- r->prev->next = r->next;
+ r->next->prev = r->prev;
+ r->prev->next = r->next;
}
else if (r->next)
- r->next->prev = NULL;
+ r->next->prev = NULL;
else if (r->prev)
- r->prev->next = NULL;
+ r->prev->next = NULL;
}
static inline void
-_eina_matrixsparse_row_find_parms_get(const Eina_Matrixsparse *m, unsigned long row, Eina_Matrixsparse_Row **p_r, int *p_dir)
+_eina_matrixsparse_row_find_parms_get(const Eina_Matrixsparse *m,
+ unsigned long row,
+ Eina_Matrixsparse_Row **p_r,
+ int *p_dir)
{
Eina_Matrixsparse_Row *r;
unsigned long dist;
dir = 1;
if (dist > m->last_row->row - row)
{
- dist = m->last_row->row - row;
- r = m->last_row;
- dir = -1;
+ dist = m->last_row->row - row;
+ r = m->last_row;
+ dir = -1;
}
if (m->last_used)
{
- if (m->last_used->row < row)
- {
- if (dist > row - m->last_used->row)
- {
-/* dist = row = m->last_used->row; */
- r = m->last_used;
- dir = 1;
- }
- }
- else
- {
- if (dist > m->last_used->row - row)
- {
-/* dist = m->last_used->row - row; */
- r = m->last_used;
- dir = -1;
- }
- }
+ if (m->last_used->row < row)
+ {
+ if (dist > row - m->last_used->row)
+ {
+/* dist = row = m->last_used->row; */
+ r = m->last_used;
+ dir = 1;
+ }
+ }
+ else if (dist > m->last_used->row - row)
+ {
+/* dist = m->last_used->row - row; */
+ r = m->last_used;
+ dir = -1;
+ }
}
*p_r = r;
}
static inline void
-_eina_matrixsparse_row_cell_find_parms_get(const Eina_Matrixsparse_Row *r, unsigned long col, Eina_Matrixsparse_Cell **p_c, int *p_dir)
+_eina_matrixsparse_row_cell_find_parms_get(const Eina_Matrixsparse_Row *r,
+ unsigned long col,
+ Eina_Matrixsparse_Cell **p_c,
+ int *p_dir)
{
Eina_Matrixsparse_Cell *c;
unsigned long dist;
dir = 1;
if (dist > r->last_col->col - col)
{
- dist = r->last_col->col - col;
- c = r->last_col;
- dir = -1;
+ dist = r->last_col->col - col;
+ c = r->last_col;
+ dir = -1;
}
if (r->last_used)
{
- if (r->last_used->col < col)
- {
- if (dist > col - r->last_used->col)
- {
-/* dist = col = r->last_used->col; */
- c = r->last_used;
- dir = 1;
- }
- }
- else
- {
- if (dist > r->last_used->col - col)
- {
-/* dist = r->last_used->col - col; */
- c = r->last_used;
- dir = -1;
- }
- }
+ if (r->last_used->col < col)
+ {
+ if (dist > col - r->last_used->col)
+ {
+/* dist = col = r->last_used->col; */
+ c = r->last_used;
+ dir = 1;
+ }
+ }
+ else if (dist > r->last_used->col - col)
+ {
+/* dist = r->last_used->col - col; */
+ c = r->last_used;
+ dir = -1;
+ }
}
*p_c = c;
Eina_Matrixsparse_Row *r;
int dir;
- if (!m->rows) return NULL;
+ if (!m->rows)
+ return NULL;
- if (m->rows->row == row) return m->rows;
- else if (m->rows->row > row) return NULL;
+ if (m->rows->row == row)
+ return m->rows;
+ else if (m->rows->row > row)
+ return NULL;
- if (m->last_row->row == row) return m->last_row;
- else if (m->last_row->row < row) return NULL;
+ if (m->last_row->row == row)
+ return m->last_row;
+ else if (m->last_row->row < row)
+ return NULL;
- if ((m->last_used) && (m->last_used->row == row)) return m->last_used;
+ if ((m->last_used) && (m->last_used->row == row))
+ return m->last_used;
_eina_matrixsparse_row_find_parms_get(m, row, &r, &dir);
assert(dir != 0);
if (dir > 0)
{
- for (; r != NULL; r = r->next)
- if (r->row == row)
- {
- ((Eina_Matrixsparse *)m)->last_used = r;
- return r;
- }
- else if (r->row > row)
- return NULL;
+ for (; r != NULL; r = r->next)
+ if (r->row == row)
+ {
+ ((Eina_Matrixsparse *)m)->last_used = r;
+ return r;
+ }
+ else if (r->row > row)
+ return NULL;
+
}
else if (dir < 0)
- {
- for (; r != NULL; r = r->prev)
- if (r->row == row)
- {
- ((Eina_Matrixsparse *)m)->last_used = r;
- return r;
- }
- else if (r->row < row)
- return NULL;
- }
+ for (; r != NULL; r = r->prev)
+ if (r->row == row)
+ {
+ ((Eina_Matrixsparse *)m)->last_used = r;
+ return r;
+ }
+ else if (r->row < row)
+ return NULL;
return NULL;
}
static inline Eina_Matrixsparse_Cell *
-_eina_matrixsparse_row_cell_idx_get(const Eina_Matrixsparse_Row *r, unsigned long col)
+_eina_matrixsparse_row_cell_idx_get(const Eina_Matrixsparse_Row *r,
+ unsigned long col)
{
Eina_Matrixsparse_Cell *c;
int dir;
- if (!r->cols) return NULL;
-
- if (r->cols->col == col) return r->cols;
- else if (r->cols->col > col) return NULL;
+ if (!r->cols)
+ return NULL;
- if (r->last_col->col == col) return r->last_col;
- else if (r->last_col->col < col) return NULL;
+ if (r->cols->col == col)
+ return r->cols;
+ else if (r->cols->col > col)
+ return NULL;
- if ((r->last_used) && (r->last_used->col == col)) return r->last_used;
+ if (r->last_col->col == col)
+ return r->last_col;
+ else if (r->last_col->col < col)
+ return NULL;
+ if ((r->last_used) && (r->last_used->col == col))
+ return r->last_used;
_eina_matrixsparse_row_cell_find_parms_get(r, col, &c, &dir);
assert(dir != 0);
if (dir > 0)
{
- for (; r != NULL; c = c->next)
- if (c->col == col)
- {
- ((Eina_Matrixsparse_Row *)r)->last_used = c;
- return c;
- }
- else if (c->col > col)
- return NULL;
+ for (; r != NULL; c = c->next)
+ if (c->col == col)
+ {
+ ((Eina_Matrixsparse_Row *)r)->last_used = c;
+ return c;
+ }
+ else if (c->col > col)
+ return NULL;
+
}
else if (dir < 0)
- {
- for (; r != NULL; c = c->prev)
- if (c->col == col)
- {
- ((Eina_Matrixsparse_Row *)r)->last_used = c;
- return c;
- }
- else if (c->col < col)
- return NULL;
- }
+ for (; r != NULL; c = c->prev)
+ if (c->col == col)
+ {
+ ((Eina_Matrixsparse_Row *)r)->last_used = c;
+ return c;
+ }
+ else if (c->col < col)
+ return NULL;
return NULL;
}
static inline Eina_Matrixsparse_Cell *
-_eina_matrixsparse_cell_idx_get(const Eina_Matrixsparse *m, unsigned long row, unsigned long col)
+_eina_matrixsparse_cell_idx_get(const Eina_Matrixsparse *m,
+ unsigned long row,
+ unsigned long col)
{
Eina_Matrixsparse_Row *r = _eina_matrixsparse_row_idx_get(m, row);
- if (!r) return NULL;
+ if (!r)
+ return NULL;
+
return _eina_matrixsparse_row_cell_idx_get(r, col);
}
static inline void
-_eina_matrixsparse_row_idx_siblings_find(const Eina_Matrixsparse *m, unsigned long row, Eina_Matrixsparse_Row **p_prev, Eina_Matrixsparse_Row **p_next)
+_eina_matrixsparse_row_idx_siblings_find(const Eina_Matrixsparse *m,
+ unsigned long row,
+ Eina_Matrixsparse_Row **p_prev,
+ Eina_Matrixsparse_Row **p_next)
{
Eina_Matrixsparse_Row *r;
int dir;
_eina_matrixsparse_row_find_parms_get(m, row, &r, &dir);
- assert(dir != 0);
+ assert(dir != 0);
if (dir > 0)
{
- for (; r != NULL; r = r->next)
- if (r->row > row)
- break;
- assert(r != NULL);
- *p_prev = r->prev;
- *p_next = r;
+ for (; r != NULL; r = r->next)
+ if (r->row > row)
+ break;
+
+ assert(r != NULL);
+ *p_prev = r->prev;
+ *p_next = r;
}
else if (dir < 0)
{
- for (; r != NULL; r = r->prev)
- if (r->row < row)
- break;
- assert(r != NULL);
- *p_prev = r;
- *p_next = r->next;
+ for (; r != NULL; r = r->prev)
+ if (r->row < row)
+ break;
+
+ assert(r != NULL);
+ *p_prev = r;
+ *p_next = r->next;
}
}
static inline void
-_eina_matrixsparse_row_cell_idx_siblings_find(const Eina_Matrixsparse_Row *r, unsigned long col, Eina_Matrixsparse_Cell **p_prev, Eina_Matrixsparse_Cell **p_next)
+_eina_matrixsparse_row_cell_idx_siblings_find(const Eina_Matrixsparse_Row *r,
+ unsigned long col,
+ Eina_Matrixsparse_Cell **p_prev,
+ Eina_Matrixsparse_Cell **p_next)
{
Eina_Matrixsparse_Cell *c;
int dir;
_eina_matrixsparse_row_cell_find_parms_get(r, col, &c, &dir);
- assert(dir != 0);
+ assert(dir != 0);
if (dir > 0)
{
- for (; c != NULL; c = c->next)
- if (c->col > col)
- break;
- assert(c != NULL);
- *p_prev = c->prev;
- *p_next = c;
+ for (; c != NULL; c = c->next)
+ if (c->col > col)
+ break;
+
+ assert(c != NULL);
+ *p_prev = c->prev;
+ *p_next = c;
}
else if (dir < 0)
{
- for (; c != NULL; c = c->prev)
- if (c->col < col)
- break;
- assert(c != NULL);
- *p_prev = c;
- *p_next = c->next;
+ for (; c != NULL; c = c->prev)
+ if (c->col < col)
+ break;
+
+ assert(c != NULL);
+ *p_prev = c;
+ *p_next = c->next;
}
}
_eina_matrixsparse_row_idx_add(Eina_Matrixsparse *m, unsigned long row)
{
Eina_Matrixsparse_Row *r = eina_mempool_malloc
- (_eina_matrixsparse_row_mp, sizeof(Eina_Matrixsparse_Row));
- if (!r) return NULL;
+ (_eina_matrixsparse_row_mp, sizeof(Eina_Matrixsparse_Row));
+ if (!r)
+ return NULL;
if (!m->rows)
{
- r->prev = NULL;
- r->next = NULL;
- m->rows = r;
- m->last_row = r;
+ r->prev = NULL;
+ r->next = NULL;
+ m->rows = r;
+ m->last_row = r;
}
else if (row < m->rows->row)
{
- r->prev = NULL;
- r->next = m->rows;
- m->rows->prev = r;
- m->rows = r;
+ r->prev = NULL;
+ r->next = m->rows;
+ m->rows->prev = r;
+ m->rows = r;
}
else if (row > m->last_row->row)
{
- r->prev = m->last_row;
- m->last_row->next = r;
- r->next = NULL;
- m->last_row = r;
+ r->prev = m->last_row;
+ m->last_row->next = r;
+ r->next = NULL;
+ m->last_row = r;
}
else
{
- Eina_Matrixsparse_Row *prev = NULL, *next = NULL;
- _eina_matrixsparse_row_idx_siblings_find(m, row, &prev, &next);
- assert(prev != NULL);
- assert(next != NULL);
- r->prev = prev;
- r->next = next;
- prev->next = r;
- next->prev = r;
+ Eina_Matrixsparse_Row *prev = NULL, *next = NULL;
+ _eina_matrixsparse_row_idx_siblings_find(m, row, &prev, &next);
+ assert(prev != NULL);
+ assert(next != NULL);
+ r->prev = prev;
+ r->next = next;
+ prev->next = r;
+ next->prev = r;
}
r->cols = NULL;
}
static inline Eina_Matrixsparse_Cell *
-_eina_matrixsparse_row_cell_idx_add(Eina_Matrixsparse_Row *r, unsigned long col, const void *data)
+_eina_matrixsparse_row_cell_idx_add(Eina_Matrixsparse_Row *r,
+ unsigned long col,
+ const void *data)
{
Eina_Matrixsparse_Cell *c = eina_mempool_malloc
- (_eina_matrixsparse_cell_mp, sizeof(Eina_Matrixsparse_Cell));
- if (!c) return NULL;
+ (_eina_matrixsparse_cell_mp, sizeof(Eina_Matrixsparse_Cell));
+ if (!c)
+ return NULL;
if (!r->cols)
{
- c->prev = NULL;
- c->next = NULL;
- r->cols = c;
- r->last_col = c;
+ c->prev = NULL;
+ c->next = NULL;
+ r->cols = c;
+ r->last_col = c;
}
else if (col < r->cols->col)
{
- c->prev = NULL;
- c->next = r->cols;
- r->cols->prev = c;
- r->cols = c;
+ c->prev = NULL;
+ c->next = r->cols;
+ r->cols->prev = c;
+ r->cols = c;
}
else if (col > r->last_col->col)
{
- c->prev = r->last_col;
- r->last_col->next = c;
- c->next = NULL;
- r->last_col = c;
+ c->prev = r->last_col;
+ r->last_col->next = c;
+ c->next = NULL;
+ r->last_col = c;
}
else
{
- Eina_Matrixsparse_Cell *prev = NULL, *next = NULL;
- _eina_matrixsparse_row_cell_idx_siblings_find(r, col, &prev, &next);
- assert(prev != NULL);
- assert(next != NULL);
- c->prev = prev;
- c->next = next;
- prev->next = c;
- next->prev = c;
+ Eina_Matrixsparse_Cell *prev = NULL, *next = NULL;
+ _eina_matrixsparse_row_cell_idx_siblings_find(r, col, &prev, &next);
+ assert(prev != NULL);
+ assert(next != NULL);
+ c->prev = prev;
+ c->next = next;
+ prev->next = c;
+ next->prev = c;
}
c->data = (void *)data;
}
static inline Eina_Bool
-_eina_matrixsparse_cell_idx_add(Eina_Matrixsparse *m, unsigned long row, unsigned long col, const void *data)
+_eina_matrixsparse_cell_idx_add(Eina_Matrixsparse *m,
+ unsigned long row,
+ unsigned long col,
+ const void *data)
{
Eina_Matrixsparse_Row *r = _eina_matrixsparse_row_idx_get(m, row);
if (!r)
- r = _eina_matrixsparse_row_idx_add(m, row);
+ r = _eina_matrixsparse_row_idx_add(m, row);
+
if (!r)
- return 0;
+ return 0;
if (_eina_matrixsparse_row_cell_idx_add(r, col, data))
- return 1;
+ return 1;
if (r->cols)
- return 0;
+ return 0;
+
_eina_matrixsparse_row_unlink(r);
_eina_matrixsparse_row_free(r, m->free.func, m->free.user_data);
return 0;
}
/*============================================================================*
- * Iterators *
- *============================================================================*/
+* Iterators *
+*============================================================================*/
static Eina_Bool
_eina_matrixsparse_iterator_next(Eina_Matrixsparse_Iterator *it, void **data)
{
/* do not touch it->idx */
- if (!it->ref.col) return 0;
+ if (!it->ref.col)
+ return 0;
+
*data = (Eina_Matrixsparse_Cell *)it->ref.col;
it->ref.col = it->ref.col->next;
if (!it->ref.col)
{
- it->ref.row = it->ref.row->next;
- if (it->ref.row)
- it->ref.col = it->ref.row->cols;
+ it->ref.row = it->ref.row->next;
+ if (it->ref.row)
+ it->ref.col = it->ref.row->cols;
}
+
return 1;
}
_eina_matrixsparse_iterator_free(Eina_Matrixsparse_Iterator *it)
{
EINA_MAGIC_CHECK_MATRIXSPARSE_ITERATOR(it);
- EINA_MAGIC_SET(it, EINA_MAGIC_NONE);
+ EINA_MAGIC_SET(it, EINA_MAGIC_NONE);
EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_NONE);
free(it);
}
static Eina_Bool
-_eina_matrixsparse_iterator_complete_next(Eina_Matrixsparse_Iterator_Complete *it, void **data)
+_eina_matrixsparse_iterator_complete_next(
+ Eina_Matrixsparse_Iterator_Complete *it,
+ void **data)
{
EINA_MAGIC_CHECK_MATRIXSPARSE_ITERATOR(it, EINA_FALSE);
if (it->idx.row >= it->m->size.rows)
- return 0;
+ return 0;
if (it->dummy.col.data != NULL)
- ERR("Last iterator call changed dummy cell!");
+ ERR("Last iterator call changed dummy cell!");
if ((it->ref.col) &&
(it->ref.col->col == it->idx.col) &&
(it->ref.row->row == it->idx.row))
{
- *data = (Eina_Matrixsparse_Cell *)it->ref.col;
- it->ref.col = it->ref.col->next;
- if (!it->ref.col)
- {
- it->ref.row = it->ref.row->next;
- if (it->ref.row)
- it->ref.col = it->ref.row->cols;
- }
+ *data = (Eina_Matrixsparse_Cell *)it->ref.col;
+ it->ref.col = it->ref.col->next;
+ if (!it->ref.col)
+ {
+ it->ref.row = it->ref.row->next;
+ if (it->ref.row)
+ it->ref.col = it->ref.row->cols;
+ }
}
else
{
- it->dummy.col.data = NULL;
- it->dummy.col.col = it->idx.col;
- it->dummy.row.row = it->idx.row;
- *data = &it->dummy.col;
+ it->dummy.col.data = NULL;
+ it->dummy.col.col = it->idx.col;
+ it->dummy.row.row = it->idx.row;
+ *data = &it->dummy.col;
}
it->idx.col++;
if (it->idx.col == it->m->size.cols)
{
- it->idx.col = 0;
- it->idx.row++;
+ it->idx.col = 0;
+ it->idx.row++;
}
+
return 1;
}
static Eina_Matrixsparse *
-_eina_matrixsparse_iterator_complete_get_container(Eina_Matrixsparse_Iterator_Complete *it)
+_eina_matrixsparse_iterator_complete_get_container(
+ Eina_Matrixsparse_Iterator_Complete *it)
{
- EINA_MAGIC_CHECK_MATRIXSPARSE_ITERATOR(it, NULL);
+ EINA_MAGIC_CHECK_MATRIXSPARSE_ITERATOR(it, NULL);
return (Eina_Matrixsparse *)it->m;
}
static void
-_eina_matrixsparse_iterator_complete_free(Eina_Matrixsparse_Iterator_Complete *it)
+_eina_matrixsparse_iterator_complete_free(
+ Eina_Matrixsparse_Iterator_Complete *it)
{
- EINA_MAGIC_CHECK_MATRIXSPARSE_ITERATOR(it);
+ EINA_MAGIC_CHECK_MATRIXSPARSE_ITERATOR(it);
if (it->dummy.col.data != NULL)
- ERR("Last iterator call changed dummy cell!");
+ ERR("Last iterator call changed dummy cell!");
- EINA_MAGIC_SET(it, EINA_MAGIC_NONE);
+ EINA_MAGIC_SET(it, EINA_MAGIC_NONE);
EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_NONE);
free(it);
}
*/
/*============================================================================*
- * Global *
- *============================================================================*/
+* Global *
+*============================================================================*/
/**
* @internal
{
const char *choice, *tmp;
- _eina_matrixsparse_log_dom = eina_log_domain_register("eina_matrixsparse", EINA_LOG_COLOR_DEFAULT);
+ _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");
- return EINA_FALSE;
+ EINA_LOG_ERR("Could not register log domain: eina_matrixsparse");
+ return EINA_FALSE;
}
#ifdef EINA_DEFAULT_MEMPOOL
#endif
tmp = getenv("EINA_MEMPOOL");
if (tmp && tmp[0])
- choice = tmp;
+ choice = tmp;
_eina_matrixsparse_cell_mp = eina_mempool_add
- (choice, "matrixsparse_cell", NULL, sizeof (Eina_Matrixsparse_Cell), 120);
+ (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;
+ 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);
+ (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;
+ ERR(
+ "Mempool for matrixsparse_row cannot be allocated in matrixsparse init.");
+ goto on_init_fail;
}
-#define EMS(n) eina_magic_string_static_set(n, n##_STR)
+#define EMS(n) eina_magic_string_static_set(n, n ## _STR)
EMS(EINA_MAGIC_MATRIXSPARSE);
EMS(EINA_MAGIC_MATRIXSPARSE_ROW);
EMS(EINA_MAGIC_MATRIXSPARSE_CELL);
return EINA_TRUE;
- on_init_fail:
+on_init_fail:
eina_log_domain_unregister(_eina_matrixsparse_log_dom);
_eina_matrixsparse_log_dom = -1;
return EINA_FALSE;
}
/*============================================================================*
- * API *
- *============================================================================*/
+* API *
+*============================================================================*/
/**
* @addtogroup Eina_Matrixsparse_Group Sparse Matrix
* is set.
*/
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)
+eina_matrixsparse_new(unsigned long rows, unsigned long cols, void (*free_func)(
+ void *user_data,
+ void *cell_data), const void *user_data)
{
Eina_Matrixsparse *m;
m = malloc(sizeof(Eina_Matrixsparse));
if (!m)
{
- eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
- return NULL;
+ eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+ return NULL;
}
m->rows = NULL;
r = m->rows;
while (r)
{
- Eina_Matrixsparse_Row *r_aux = r;
- r = r->next;
- _eina_matrixsparse_row_free(r_aux, free_func, user_data);
+ Eina_Matrixsparse_Row *r_aux = r;
+ r = r->next;
+ _eina_matrixsparse_row_free(r_aux, free_func, user_data);
}
EINA_MAGIC_SET(m, EINA_MAGIC_NONE);
* invalid, returned value is zero, otherwise it's a positive integer.
*/
EAPI void
-eina_matrixsparse_size_get(const Eina_Matrixsparse *m, unsigned long *rows, unsigned long *cols)
+eina_matrixsparse_size_get(const Eina_Matrixsparse *m,
+ unsigned long *rows,
+ unsigned long *cols)
{
- if (rows) *rows = 0;
- if (cols) *cols = 0;
+ if (rows)
+ *rows = 0;
+
+ if (cols)
+ *cols = 0;
+
EINA_MAGIC_CHECK_MATRIXSPARSE(m);
- if (rows) *rows = m->size.rows;
- if (cols) *cols = m->size.cols;
+ if (rows)
+ *rows = m->size.rows;
+
+ if (cols)
+ *cols = m->size.cols;
}
/**
* freed.
*/
EAPI Eina_Bool
-eina_matrixsparse_size_set(Eina_Matrixsparse *m, unsigned long rows, unsigned long cols)
+eina_matrixsparse_size_set(Eina_Matrixsparse *m,
+ unsigned long rows,
+ unsigned long cols)
{
Eina_Bool update_last_used_row;
Eina_Matrixsparse_Row *r;
EINA_SAFETY_ON_FALSE_RETURN_VAL(rows > 0, 0);
EINA_SAFETY_ON_FALSE_RETURN_VAL(cols > 0, 0);
- if ((rows == m->size.rows) && (cols == m->size.cols)) return 1;
+ if ((rows == m->size.rows) && (cols == m->size.cols))
+ return 1;
update_last_used_row = ((m->last_used) && (m->last_used->row >= rows));
free_func = m->free.func;
r = m->last_row;
while (r && r->row >= rows)
{
- Eina_Matrixsparse_Row *r_aux = r;
- r = r->prev;
- _eina_matrixsparse_row_free(r_aux, free_func, user_data);
+ Eina_Matrixsparse_Row *r_aux = r;
+ r = r->prev;
+ _eina_matrixsparse_row_free(r_aux, free_func, user_data);
}
if (!r)
{
- m->last_row = NULL;
- m->rows = NULL;
+ m->last_row = NULL;
+ m->rows = NULL;
}
else if (r != m->last_row)
{
- r->next = NULL;
- m->last_row = r;
+ r->next = NULL;
+ m->last_row = r;
}
if (update_last_used_row)
- m->last_used = m->last_row;
+ m->last_used = m->last_row;
r = m->rows;
while (r)
{
- Eina_Matrixsparse_Cell *c = r->last_col;
- Eina_Bool update_last_used_col;
- update_last_used_col = ((r->last_used) && (r->last_used->col >= cols));
- while (c && c->col >= cols)
- {
- Eina_Matrixsparse_Cell *c_aux = c;
- c = c->prev;
- _eina_matrixsparse_cell_free(c_aux, free_func, user_data);
- }
- if (!c)
- {
- Eina_Matrixsparse_Row *r_aux = r;
- r->cols = NULL;
- r->last_col = NULL;
- if (r->next)
- r->next->prev = r->prev;
- else
- m->last_row = r->prev;
- if (r->prev)
- r->prev->next = r->next;
- else
- m->rows = r->next;
- r = r->next;
- _eina_matrixsparse_row_free(r_aux, free_func, user_data);
- }
- else
- {
- if (c != r->last_col)
- {
- c->next = NULL;
- r->last_col = c;
- }
- if (update_last_used_col)
- r->last_used = r->last_col;
-
- r = r->next;
- }
+ Eina_Matrixsparse_Cell *c = r->last_col;
+ Eina_Bool update_last_used_col;
+ update_last_used_col = ((r->last_used) && (r->last_used->col >= cols));
+ while (c && c->col >= cols)
+ {
+ Eina_Matrixsparse_Cell *c_aux = c;
+ c = c->prev;
+ _eina_matrixsparse_cell_free(c_aux, free_func, user_data);
+ }
+ if (!c)
+ {
+ Eina_Matrixsparse_Row *r_aux = r;
+ r->cols = NULL;
+ r->last_col = NULL;
+ if (r->next)
+ r->next->prev = r->prev;
+ else
+ m->last_row = r->prev;
+
+ if (r->prev)
+ r->prev->next = r->next;
+ else
+ m->rows = r->next;
+
+ r = r->next;
+ _eina_matrixsparse_row_free(r_aux, free_func, user_data);
+ }
+ else
+ {
+ if (c != r->last_col)
+ {
+ c->next = NULL;
+ r->last_col = c;
+ }
+
+ if (update_last_used_col)
+ r->last_used = r->last_col;
+
+ r = r->next;
+ }
}
update_last_used_row = 0;
if (m->last_used)
{
- if (m->last_row)
- update_last_used_row = m->last_used->row > m->last_row->row;
- else
- update_last_used_row = 1;
+ if (m->last_row)
+ update_last_used_row = m->last_used->row > m->last_row->row;
+ else
+ update_last_used_row = 1;
}
if (update_last_used_row)
- m->last_used = m->last_row;
+ m->last_used = m->last_row;
m->size.rows = rows;
m->size.cols = cols;
* @see eina_matrixsparse_data_idx_get()
*/
EAPI Eina_Bool
-eina_matrixsparse_cell_idx_get(const Eina_Matrixsparse *m, unsigned long row, unsigned long col, Eina_Matrixsparse_Cell **cell)
+eina_matrixsparse_cell_idx_get(const Eina_Matrixsparse *m,
+ unsigned long row,
+ unsigned long col,
+ Eina_Matrixsparse_Cell **cell)
{
EINA_MAGIC_CHECK_MATRIXSPARSE(m, 0);
EINA_SAFETY_ON_NULL_RETURN_VAL(cell, 0);
* @see eina_matrixsparse_cell_data_get()
*/
EAPI void *
-eina_matrixsparse_data_idx_get(const Eina_Matrixsparse *m, unsigned long row, unsigned long col)
+eina_matrixsparse_data_idx_get(const Eina_Matrixsparse *m,
+ unsigned long row,
+ unsigned long col)
{
Eina_Matrixsparse_Cell *c;
EINA_MAGIC_CHECK_MATRIXSPARSE(m, NULL);
c = _eina_matrixsparse_cell_idx_get(m, row, col);
- if (c) return c->data;
- else return NULL;
+ if (c)
+ return c->data;
+ else
+ return NULL;
}
/**
* @return 1 on success, 0 otherwise (@c cell is @c NULL).
*/
EAPI Eina_Bool
-eina_matrixsparse_cell_position_get(const Eina_Matrixsparse_Cell *cell, unsigned long *row, unsigned long *col)
+eina_matrixsparse_cell_position_get(const Eina_Matrixsparse_Cell *cell,
+ unsigned long *row,
+ unsigned long *col)
{
- if (row) *row = 0;
- if (col) *col = 0;
+ if (row)
+ *row = 0;
+
+ if (col)
+ *col = 0;
+
EINA_MAGIC_CHECK_MATRIXSPARSE_CELL(cell, 0);
EINA_MAGIC_CHECK_MATRIXSPARSE_ROW(cell->parent, 0);
- if (row) *row = cell->parent->row;
- if (col) *col = cell->col;
+ if (row)
+ *row = cell->parent->row;
+
+ if (col)
+ *col = cell->col;
+
return 1;
}
* @see eina_matrixsparse_data_idx_replace()
*/
EAPI Eina_Bool
-eina_matrixsparse_cell_data_replace(Eina_Matrixsparse_Cell *cell, const void *data, void **p_old)
+eina_matrixsparse_cell_data_replace(Eina_Matrixsparse_Cell *cell,
+ const void *data,
+ void **p_old)
{
- if (p_old) *p_old = NULL;
+ if (p_old)
+ *p_old = NULL;
+
EINA_MAGIC_CHECK_MATRIXSPARSE_CELL(cell, 0);
- if (p_old) *p_old = cell->data;
+ if (p_old)
+ *p_old = cell->data;
+
cell->data = (void *)data;
return 1;
}
m = cell->parent->parent;
if (m->free.func)
- m->free.func(m->free.user_data, cell->data);
+ m->free.func(m->free.user_data, cell->data);
cell->data = (void *)data;
return 1;
* @see eina_matrixsparse_data_idx_set()
*/
EAPI Eina_Bool
-eina_matrixsparse_data_idx_replace(Eina_Matrixsparse *m, unsigned long row, unsigned long col, const void *data, void **p_old)
+eina_matrixsparse_data_idx_replace(Eina_Matrixsparse *m,
+ unsigned long row,
+ unsigned long col,
+ const void *data,
+ void **p_old)
{
Eina_Matrixsparse_Cell *cell;
- if (p_old) *p_old = NULL;
+ if (p_old)
+ *p_old = NULL;
+
EINA_MAGIC_CHECK_MATRIXSPARSE(m, 0);
EINA_SAFETY_ON_FALSE_RETURN_VAL(row < m->size.rows, 0);
EINA_SAFETY_ON_FALSE_RETURN_VAL(col < m->size.cols, 0);
cell = _eina_matrixsparse_cell_idx_get(m, row, col);
if (cell)
{
- if (p_old) *p_old = cell->data;
- cell->data = (void *)data;
- return 1;
+ if (p_old)
+ *p_old = cell->data;
+
+ cell->data = (void *)data;
+ return 1;
}
return _eina_matrixsparse_cell_idx_add(m, row, col, data);
* @see eina_matrixsparse_cell_data_replace()
*/
EAPI Eina_Bool
-eina_matrixsparse_data_idx_set(Eina_Matrixsparse *m, unsigned long row, unsigned long col, const void *data)
+eina_matrixsparse_data_idx_set(Eina_Matrixsparse *m,
+ unsigned long row,
+ unsigned long col,
+ const void *data)
{
Eina_Matrixsparse_Cell *cell;
cell = _eina_matrixsparse_cell_idx_get(m, row, col);
if (cell)
{
- if (m->free.func)
- m->free.func(m->free.user_data, cell->data);
- cell->data = (void *)data;
- return 1;
+ if (m->free.func)
+ m->free.func(m->free.user_data, cell->data);
+
+ cell->data = (void *)data;
+ return 1;
}
return _eina_matrixsparse_cell_idx_add(m, row, col, data);
EINA_SAFETY_ON_FALSE_RETURN_VAL(row < m->size.rows, 0);
r = _eina_matrixsparse_row_idx_get(m, row);
- if (!r) return 1;
+ if (!r)
+ return 1;
_eina_matrixsparse_row_unlink(r);
_eina_matrixsparse_row_free(r, m->free.func, m->free.user_data);
free_func = m->free.func;
user_data = m->free.user_data;
- for (r = m->rows; r != NULL;)
+ for (r = m->rows; r != NULL; )
{
- Eina_Matrixsparse_Row *r_aux = r;
- Eina_Matrixsparse_Cell *c;
-
- c = _eina_matrixsparse_row_cell_idx_get(r, col);
- r = r->next;
-
- if (!c)
- continue;
-
- if ((r_aux->cols != c) || (r_aux->last_col != c))
- {
- _eina_matrixsparse_cell_unlink(c);
- _eina_matrixsparse_cell_free(c, free_func, user_data);
- }
- else
- {
- _eina_matrixsparse_row_unlink(r_aux);
- _eina_matrixsparse_row_free(r_aux, free_func, user_data);
- }
+ Eina_Matrixsparse_Row *r_aux = r;
+ Eina_Matrixsparse_Cell *c;
+
+ c = _eina_matrixsparse_row_cell_idx_get(r, col);
+ r = r->next;
+
+ if (!c)
+ continue;
+
+ if ((r_aux->cols != c) || (r_aux->last_col != c))
+ {
+ _eina_matrixsparse_cell_unlink(c);
+ _eina_matrixsparse_cell_free(c, free_func, user_data);
+ }
+ else
+ {
+ _eina_matrixsparse_row_unlink(r_aux);
+ _eina_matrixsparse_row_free(r_aux, free_func, user_data);
+ }
}
return 1;
* row if this cell was the last remainder.
*/
EAPI Eina_Bool
-eina_matrixsparse_cell_idx_clear(Eina_Matrixsparse *m, unsigned long row, unsigned long col)
+eina_matrixsparse_cell_idx_clear(Eina_Matrixsparse *m,
+ unsigned long row,
+ unsigned long col)
{
Eina_Matrixsparse_Cell *c;
EINA_SAFETY_ON_FALSE_RETURN_VAL(col < m->size.cols, 0);
c = _eina_matrixsparse_cell_idx_get(m, row, col);
- if (!c) return 1;
+ if (!c)
+ return 1;
_eina_matrixsparse_cell_unlink(c);
_eina_matrixsparse_cell_free(c, m->free.func, m->free.user_data);
it = calloc(1, sizeof(*it));
if (!it)
{
- eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
- return NULL;
+ eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+ return NULL;
}
- EINA_MAGIC_SET(it, EINA_MAGIC_MATRIXSPARSE_ITERATOR);
+ EINA_MAGIC_SET(it, EINA_MAGIC_MATRIXSPARSE_ITERATOR);
EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_ITERATOR);
it->m = m;
it->ref.col = m->rows ? m->rows->cols : NULL;
it->iterator.next = FUNC_ITERATOR_NEXT(_eina_matrixsparse_iterator_next);
- it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(_eina_matrixsparse_iterator_get_container);
+ it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(
+ _eina_matrixsparse_iterator_get_container);
it->iterator.free = FUNC_ITERATOR_FREE(_eina_matrixsparse_iterator_free);
return &it->iterator;
}
it = calloc(1, sizeof(*it));
if (!it)
{
- eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
- return NULL;
+ eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+ return NULL;
}
- EINA_MAGIC_SET(it, EINA_MAGIC_MATRIXSPARSE_ITERATOR);
+ EINA_MAGIC_SET(it, EINA_MAGIC_MATRIXSPARSE_ITERATOR);
EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_ITERATOR);
it->m = m;
it->dummy.col.parent = &it->dummy.row;
EINA_MAGIC_SET(&it->dummy.col, EINA_MAGIC_MATRIXSPARSE_CELL);
- it->iterator.next = FUNC_ITERATOR_NEXT(_eina_matrixsparse_iterator_complete_next);
- it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(_eina_matrixsparse_iterator_complete_get_container);
- it->iterator.free = FUNC_ITERATOR_FREE(_eina_matrixsparse_iterator_complete_free);
+ it->iterator.next = FUNC_ITERATOR_NEXT(
+ _eina_matrixsparse_iterator_complete_next);
+ it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(
+ _eina_matrixsparse_iterator_complete_get_container);
+ it->iterator.free = FUNC_ITERATOR_FREE(
+ _eina_matrixsparse_iterator_complete_free);
return &it->iterator;
}
#include "eina_mempool.h"
/*============================================================================*
- * Local *
- *============================================================================*/
+* Local *
+*============================================================================*/
/**
* @cond LOCAL
static Eina_Mempool *
-_new_va(const char *name, const char *context, const char *options, va_list args)
+_new_va(const char *name,
+ const char *context,
+ const char *options,
+ va_list args)
{
- Eina_Mempool_Backend *be;
- Eina_Mempool *mp;
+ Eina_Mempool_Backend *be;
+ Eina_Mempool *mp;
- Eina_Error err = EINA_ERROR_NOT_MEMPOOL_MODULE;
+ Eina_Error err = EINA_ERROR_NOT_MEMPOOL_MODULE;
- eina_error_set(0);
- be = eina_hash_find(_backends, name);
- if (!be)
- goto on_error;
+ eina_error_set(0);
+ be = eina_hash_find(_backends, name);
+ if (!be)
+ goto on_error;
- err = EINA_ERROR_OUT_OF_MEMORY;
- mp = malloc(sizeof(Eina_Mempool));
- if (!mp) goto on_error;
+ err = EINA_ERROR_OUT_OF_MEMORY;
+ mp = malloc(sizeof(Eina_Mempool));
+ if (!mp)
+ goto on_error;
- /* FIXME why backend is not a pointer? */
- mp->backend = *be;
- mp->backend_data = mp->backend.init(context, options, args);
+ /* FIXME why backend is not a pointer? */
+ mp->backend = *be;
+ mp->backend_data = mp->backend.init(context, options, args);
- return mp;
+ return mp;
- on_error:
- eina_error_set(err);
- return NULL;
+on_error:
+ eina_error_set(err);
+ return NULL;
}
/* Built-in backend's prototypes */
#ifdef EINA_STATIC_BUILD_CHAINED_POOL
Eina_Bool chained_init(void);
-void chained_shutdown(void);
+void chained_shutdown(void);
#endif
#ifdef EINA_STATIC_BUILD_PASS_THROUGH
Eina_Bool pass_through_init(void);
-void pass_through_shutdown(void);
+void pass_through_shutdown(void);
#endif
#ifdef EINA_STATIC_BUILD_EMEMOA_UNKNOWN
Eina_Bool ememoa_unknown_init(void);
-void ememoa_unknown_shutdown(void);
+void ememoa_unknown_shutdown(void);
#endif
#ifdef EINA_STATIC_BUILD_EMEMOA_FIXED
Eina_Bool ememoa_fixed_init(void);
-void ememoa_fixed_shutdown(void);
+void ememoa_fixed_shutdown(void);
#endif
#ifdef EINA_STATIC_BUILD_FIXED_BITMAP
Eina_Bool fixed_bitmap_init(void);
-void fixed_bitmap_shutdown(void);
+void fixed_bitmap_shutdown(void);
#endif
#ifdef EINA_STATIC_BUILD_BUDDY
Eina_Bool buddy_init(void);
-void buddy_shutdown(void);
+void buddy_shutdown(void);
#endif
#ifdef EINA_STATIC_BUILD_ONE_BIG
Eina_Bool one_big_init(void);
-void one_big_shutdown(void);
+void one_big_shutdown(void);
#endif
/**
*/
/*============================================================================*
- * Global *
- *============================================================================*/
+* Global *
+*============================================================================*/
/**
* @cond LOCAL
EAPI Eina_Error EINA_ERROR_NOT_MEMPOOL_MODULE = 0;
-static const char EINA_ERROR_NOT_MEMPOOL_MODULE_STR[] = "Not a memory pool module.";
+static const char EINA_ERROR_NOT_MEMPOOL_MODULE_STR[] =
+ "Not a memory pool module.";
/**
* @endcond
{
char *path;
- _eina_mempool_log_dom = eina_log_domain_register("eina_mempool", EINA_LOG_COLOR_DEFAULT);
+ _eina_mempool_log_dom = eina_log_domain_register("eina_mempool",
+ EINA_LOG_COLOR_DEFAULT);
if (_eina_mempool_log_dom < 0)
{
- EINA_LOG_ERR("Could not register log domain: eina_mempool");
- return 0;
+ EINA_LOG_ERR("Could not register log domain: eina_mempool");
+ return 0;
}
- EINA_ERROR_NOT_MEMPOOL_MODULE = eina_error_msg_static_register(EINA_ERROR_NOT_MEMPOOL_MODULE_STR);
+ EINA_ERROR_NOT_MEMPOOL_MODULE = eina_error_msg_static_register(
+ EINA_ERROR_NOT_MEMPOOL_MODULE_STR);
_backends = eina_hash_string_superfast_new(NULL);
/* dynamic backends */
- _modules = eina_module_arch_list_get(NULL, PACKAGE_LIB_DIR "/eina/modules/mp", MODULE_ARCH);
+ _modules = eina_module_arch_list_get(NULL,
+ PACKAGE_LIB_DIR "/eina/modules/mp",
+ MODULE_ARCH);
path = eina_module_environment_path_get("HOME", "/.eina/mp/modules/mp");
_modules = eina_module_arch_list_get(_modules, path, MODULE_ARCH);
- if (path) free(path);
+ if (path)
+ free(path);
- path = eina_module_environment_path_get("EINA_MODULES_MEMPOOL_DIR", "/eina/modules/mp");
+ path = eina_module_environment_path_get("EINA_MODULES_MEMPOOL_DIR",
+ "/eina/modules/mp");
_modules = eina_module_arch_list_get(_modules, path, MODULE_ARCH);
- if (path) free(path);
+ if (path)
+ free(path);
- path = eina_module_symbol_path_get((const void *)eina_init, "/eina/modules/mp");
+ path = eina_module_symbol_path_get((const void *)eina_init,
+ "/eina/modules/mp");
_modules = eina_module_arch_list_get(_modules, path, MODULE_ARCH);
- if (path) free(path);
+ if (path)
+ free(path);
if (!_modules)
{
- ERR("no mempool modules able to be loaded.");
- eina_hash_free(_backends);
- goto mempool_init_error;
+ 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();
return EINA_TRUE;
- mempool_init_error:
+mempool_init_error:
eina_log_domain_unregister(_eina_mempool_log_dom);
_eina_mempool_log_dom = -1;
/* dynamic backends */
eina_module_list_free(_modules);
if (_modules)
- eina_array_free(_modules);
+ eina_array_free(_modules);
if (_backends)
- eina_hash_free(_backends);
+ eina_hash_free(_backends);
eina_log_domain_unregister(_eina_mempool_log_dom);
_eina_mempool_log_dom = -1;
}
/*============================================================================*
- * API *
- *============================================================================*/
+* API *
+*============================================================================*/
/**
* @addtogroup Eina_Memory_Pool_Group Memory Pool
*/
EAPI Eina_Mempool *
-eina_mempool_add(const char *name, const char *context, const char *options, ...)
+eina_mempool_add(const char *name,
+ const char *context,
+ const char *options,
+ ...)
{
- Eina_Mempool *mp;
- va_list args;
+ Eina_Mempool *mp;
+ va_list args;
- EINA_SAFETY_ON_NULL_RETURN_VAL(name, NULL);
- DBG("name=%s, context=%s, options=%s",
- name, context ? context : "", options ? options : "");
+ EINA_SAFETY_ON_NULL_RETURN_VAL(name, NULL);
+ DBG("name=%s, context=%s, options=%s",
+ name, context ? context : "", options ? options : "");
- va_start(args, options);
- mp = _new_va(name, context, options, args);
- va_end(args);
+ va_start(args, options);
+ mp = _new_va(name, context, options, args);
+ va_end(args);
- DBG("name=%s, context=%s, options=%s, mp=%p",
- name, context ? context : "", options ? options : "", mp);
+ DBG("name=%s, context=%s, options=%s, mp=%p",
+ name, context ? context : "", options ? options : "", mp);
- return mp;
+ return mp;
}
EAPI void eina_mempool_del(Eina_Mempool *mp)
{
- EINA_SAFETY_ON_NULL_RETURN(mp);
- EINA_SAFETY_ON_NULL_RETURN(mp->backend.shutdown);
- DBG("mp=%p", mp);
- mp->backend.shutdown(mp->backend_data);
- free(mp);
+ EINA_SAFETY_ON_NULL_RETURN(mp);
+ EINA_SAFETY_ON_NULL_RETURN(mp->backend.shutdown);
+ DBG("mp=%p", mp);
+ mp->backend.shutdown(mp->backend_data);
+ free(mp);
}
EAPI void eina_mempool_gc(Eina_Mempool *mp)
{
- EINA_SAFETY_ON_NULL_RETURN(mp);
- EINA_SAFETY_ON_NULL_RETURN(mp->backend.garbage_collect);
- DBG("mp=%p", mp);
- mp->backend.garbage_collect(mp->backend_data);
+ EINA_SAFETY_ON_NULL_RETURN(mp);
+ EINA_SAFETY_ON_NULL_RETURN(mp->backend.garbage_collect);
+ DBG("mp=%p", mp);
+ mp->backend.garbage_collect(mp->backend_data);
}
EAPI void eina_mempool_statistics(Eina_Mempool *mp)
{
- EINA_SAFETY_ON_NULL_RETURN(mp);
- EINA_SAFETY_ON_NULL_RETURN(mp->backend.statistics);
- DBG("mp=%p", mp);
- mp->backend.statistics(mp->backend_data);
+ EINA_SAFETY_ON_NULL_RETURN(mp);
+ EINA_SAFETY_ON_NULL_RETURN(mp->backend.statistics);
+ DBG("mp=%p", mp);
+ mp->backend.statistics(mp->backend_data);
}
EAPI unsigned int
int align;
if (size <= 2)
- align = 2;
+ align = 2;
else if (size < 8)
- align = 4;
+ align = 4;
else
#if __WORDSIZE == 32
- align = 8;
+ align = 8;
+
#else
if (size < 16)
- align = 8;
+ align = 8;
else
- align = 16;
+ align = 16;
#endif
return ((size / align) + 1) * align;
#include "eina_module.h"
/*============================================================================*
- * Local *
- *============================================================================*/
+* Local *
+*============================================================================*/
/**
* @cond LOCAL
Eina_Bool ret = EINA_TRUE;
if (cb_data->cb)
- {
- ret = cb_data->cb(m, cb_data->data);
- }
+ ret = cb_data->cb(m, cb_data->data);
+
if (ret)
- {
- eina_array_push(cb_data->array, m);
- }
+ eina_array_push(cb_data->array, m);
+
return ret;
}
length = strlen(name);
if (length < sizeof(SHARED_LIB_SUFFIX)) /* x.so */
- return;
+ return;
+
if (!strcmp(name + length - sizeof(SHARED_LIB_SUFFIX) + 1,
- SHARED_LIB_SUFFIX))
+ SHARED_LIB_SUFFIX))
{
- char *file;
- Eina_Module *m;
+ char *file;
+ Eina_Module *m;
+
+ length = strlen(path) + strlen(name) + 2;
- length = strlen(path) + strlen(name) + 2;
+ file = alloca(sizeof (char) * length);
+ if (!file)
+ return;
- file = alloca(sizeof (char) * length);
- if (!file) return ;
+ snprintf(file, length, "%s/%s", path, name);
+ m = eina_module_new(file);
+ if (!m)
+ return; /* call the user provided cb on this module */
- snprintf(file, length, "%s/%s", path, name);
- m = eina_module_new(file);
- if (!m)
- return;
- /* call the user provided cb on this module */
- if (!cb_data->cb(m, cb_data->data))
- eina_module_free(m);
+ if (!cb_data->cb(m, cb_data->data))
+ eina_module_free(m);
}
}
/*============================================================================*
- * Global *
- *============================================================================*/
+* Global *
+*============================================================================*/
/**
* @cond LOCAL
*/
-static const char EINA_ERROR_WRONG_MODULE_STR[] = "Wrong file format or no file module found";
-static const char EINA_ERROR_MODULE_INIT_FAILED_STR[] = "Module initialisation function failed";
+static const char EINA_ERROR_WRONG_MODULE_STR[] =
+ "Wrong file format or no file module found";
+static const char EINA_ERROR_MODULE_INIT_FAILED_STR[] =
+ "Module initialisation function failed";
EAPI Eina_Error EINA_ERROR_WRONG_MODULE = 0;
EAPI Eina_Error EINA_ERROR_MODULE_INIT_FAILED = 0;
eina_module_init(void)
{
EINA_MODULE_LOG_DOM = eina_log_domain_register
- ("eina_module", EINA_LOG_COLOR_DEFAULT);
+ ("eina_module", EINA_LOG_COLOR_DEFAULT);
if (EINA_MODULE_LOG_DOM < 0)
{
- EINA_LOG_ERR("Could not register log domain: eina_module");
- return EINA_FALSE;
+ EINA_LOG_ERR("Could not register log domain: eina_module");
+ return EINA_FALSE;
}
-#define EEMR(n) n = eina_error_msg_static_register(n##_STR)
+#define EEMR(n) n = eina_error_msg_static_register(n ## _STR)
EEMR(EINA_ERROR_WRONG_MODULE);
EEMR(EINA_ERROR_MODULE_INIT_FAILED);
#undef EEMR
}
/*============================================================================*
- * API *
- *============================================================================*/
+* API *
+*============================================================================*/
/**
* @addtogroup Eina_Module_Group Module
EINA_SAFETY_ON_FALSE_RETURN_VAL(len > 0, NULL);
m = malloc(sizeof(Eina_Module) + len + 1);
- if (!m) {
- ERR("could not malloc(%lu)", (unsigned long)(sizeof(Eina_Module) + len + 1));
- return NULL;
- }
+ if (!m)
+ {
+ ERR("could not malloc(%lu)",
+ (unsigned long)(sizeof(Eina_Module) + len + 1));
+ return NULL;
+ }
+
memcpy((char *)m->file, file, len + 1);
m->ref = 0;
m->handle = NULL;
DBG("m=%p, handle=%p, file=%s, refs=%d", m, m->handle, m->file, m->ref);
if (m->handle)
- {
- if (eina_module_unload(m) == EINA_FALSE)
- return EINA_FALSE;
- }
+ if (eina_module_unload(m) == EINA_FALSE)
+ return EINA_FALSE;
+
free(m);
return EINA_TRUE;
}
DBG("m=%p, handle=%p, file=%s, refs=%d", m, m->handle, m->file, m->ref);
- if (m->handle) goto loaded;
+ if (m->handle)
+ goto loaded;
dl_handle = dlopen(m->file, RTLD_NOW);
if (!dl_handle)
{
- WRN("could not dlopen(\"%s\", RTLD_NOW): %s", m->file, dlerror());
- eina_error_set(EINA_ERROR_WRONG_MODULE);
- return EINA_FALSE;
+ WRN("could not dlopen(\"%s\", RTLD_NOW): %s", m->file, dlerror());
+ eina_error_set(EINA_ERROR_WRONG_MODULE);
+ return EINA_FALSE;
}
initcall = dlsym(dl_handle, EINA_MODULE_SYMBOL_INIT);
if ((!initcall) || (!(*initcall)))
- goto ok;
+ goto ok;
+
if ((*initcall)() == EINA_TRUE)
- goto ok;
+ goto ok;
WRN("could not find eina's entry symbol %s inside module %s",
EINA_MODULE_SYMBOL_INIT, m->file);
eina_error_set(EINA_ERROR_MODULE_INIT_FAILED);
dlclose(dl_handle);
return EINA_FALSE;
- ok:
+ok:
DBG("successfully loaded %s", m->file);
m->handle = dl_handle;
- loaded:
+loaded:
m->ref++;
DBG("ref %d", m->ref);
m->ref--;
if (!m->ref)
{
- shut = dlsym(m->handle, EINA_MODULE_SYMBOL_SHUTDOWN);
- if ((shut) && (*shut))
- (*shut)();
- dlclose(m->handle);
- m->handle = NULL;
- DBG("unloaded module %s", m->file);
- return EINA_TRUE;
+ shut = dlsym(m->handle, EINA_MODULE_SYMBOL_SHUTDOWN);
+ if ((shut) && (*shut))
+ (*shut)();
+
+ dlclose(m->handle);
+ m->handle = NULL;
+ DBG("unloaded module %s", m->file);
+ return EINA_TRUE;
}
+
return EINA_FALSE;
}
* is @c NULL, or if it has not been correctly loaded before, the
* function returns immediatly @c NULL.
*/
-EAPI void * eina_module_symbol_get(const Eina_Module *m, const char *symbol)
+EAPI void *eina_module_symbol_get(const Eina_Module *m, const char *symbol)
{
- EINA_SAFETY_ON_NULL_RETURN_VAL(m, NULL);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(m, NULL);
EINA_SAFETY_ON_NULL_RETURN_VAL(m->handle, NULL);
return dlsym(m->handle, symbol);
}
* @c NULL, the function returns immediatly @c NULL. The returned
* value must no be freed.
*/
-EAPI const char * eina_module_file_get(const Eina_Module *m)
+EAPI const char *eina_module_file_get(const Eina_Module *m)
{
EINA_SAFETY_ON_NULL_RETURN_VAL(m, NULL);
return m->file;
EINA_SAFETY_ON_NULL_RETURN_VAL(symbol, NULL);
if (dladdr(symbol, &eina_dl))
- {
- if (strrchr(eina_dl.dli_fname, '/'))
- {
- char *path;
- int l0;
- int l1;
- int l2 = 0;
-
- l0 = strlen(eina_dl.dli_fname);
- l1 = strlen(strrchr(eina_dl.dli_fname, '/'));
- if (sub_dir && (*sub_dir != '\0'))
- l2 = strlen(sub_dir);
- path = malloc(l0 - l1 + l2 + 1);
- if (path)
- {
- memcpy(path, eina_dl.dli_fname, l0 - l1);
- if (sub_dir && (*sub_dir != '\0'))
- memcpy(path + l0 - l1, sub_dir, l2);
- path[l0 - l1 + l2] = '\0';
- return path;
- }
- }
- }
+ if (strrchr(eina_dl.dli_fname, '/'))
+ {
+ char *path;
+ int l0;
+ int l1;
+ int l2 = 0;
+
+ l0 = strlen(eina_dl.dli_fname);
+ l1 = strlen(strrchr(eina_dl.dli_fname, '/'));
+ if (sub_dir && (*sub_dir != '\0'))
+ l2 = strlen(sub_dir);
+
+ path = malloc(l0 - l1 + l2 + 1);
+ if (path)
+ {
+ memcpy(path, eina_dl.dli_fname, l0 - l1);
+ if (sub_dir && (*sub_dir != '\0'))
+ memcpy(path + l0 - l1, sub_dir, l2);
+
+ path[l0 - l1 + l2] = '\0';
+ return path;
+ }
+ }
+
+
#endif /* ! HAVE_DLADDR */
return NULL;
}
-EAPI char *eina_module_environment_path_get(const char *env, const char *sub_dir)
+EAPI char *eina_module_environment_path_get(const char *env,
+ const char *sub_dir)
{
const char *env_dir;
env_dir = getenv(env);
if (env_dir)
{
- char *path;
- size_t l1;
- size_t l2 = 0;
-
- l1 = strlen(env_dir);
- if (sub_dir && (*sub_dir != '\0'))
- l2 = strlen(sub_dir);
-
- path = (char *)malloc(l1 + l2 + 1);
- if (path)
- {
- memcpy(path, env_dir, l1);
- if (sub_dir && (*sub_dir != '\0'))
- memcpy(path + l1, sub_dir, l2);
- path[l1 + l2] = '\0';
-
- return path;
- }
+ char *path;
+ size_t l1;
+ size_t l2 = 0;
+
+ l1 = strlen(env_dir);
+ if (sub_dir && (*sub_dir != '\0'))
+ l2 = strlen(sub_dir);
+
+ path = (char *)malloc(l1 + l2 + 1);
+ if (path)
+ {
+ memcpy(path, env_dir, l1);
+ if (sub_dir && (*sub_dir != '\0'))
+ memcpy(path + l1, sub_dir, l2);
+
+ path[l1 + l2] = '\0';
+
+ return path;
+ }
}
return NULL;
size_t length;
length = strlen(path) + 1 + strlen(name) + 1 +
- strlen((char *)(cb_data->data)) + 1 + sizeof("module") +
- sizeof(SHARED_LIB_SUFFIX) + 1;
+ strlen((char *)(cb_data->data)) + 1 + sizeof("module") +
+ sizeof(SHARED_LIB_SUFFIX) + 1;
file = alloca(length);
snprintf(file, length, "%s/%s/%s/module" SHARED_LIB_SUFFIX,
path, name, (char *)(cb_data->data));
m = eina_module_new(file);
if (!m)
- return;
+ return;
+
eina_array_push(cb_data->array, m);
}
* it won't be added to the list, if it is one, it will.
* @param data Data passed to the callback function
*/
-EAPI Eina_Array * eina_module_arch_list_get(Eina_Array *array, const char *path, const char *arch)
+EAPI Eina_Array *eina_module_arch_list_get(Eina_Array *array,
+ const char *path,
+ const char *arch)
{
Dir_List_Get_Cb_Data list_get_cb_data;
- if ((!path) || (!arch)) return array;
+ if ((!path) || (!arch))
+ return array;
list_get_cb_data.array = array ? array : eina_array_new(4);
list_get_cb_data.cb = NULL;
* it won't be added to the list, if it is one, it will.
* @param data Data passed to the callback function
*/
-EAPI Eina_Array * eina_module_list_get(Eina_Array *array, const char *path, unsigned int recursive, Eina_Module_Cb cb, void *data)
+EAPI Eina_Array *eina_module_list_get(Eina_Array *array,
+ const char *path,
+ unsigned int recursive,
+ Eina_Module_Cb cb,
+ void *data)
{
Dir_List_Get_Cb_Data list_get_cb_data;
Dir_List_Cb_Data list_cb_data;
- if (!path) return array;
+ if (!path)
+ return array;
list_get_cb_data.array = array ? array : eina_array_new(4);
list_get_cb_data.cb = cb;
file_m = basename(tmp);
len = strlen(file_m);
len -= sizeof(SHARED_LIB_SUFFIX) - 1;
- if (len <= 0) continue;
- if (!strncmp(module, file_m, len)) return m;
+ if (len <= 0)
+ continue;
+
+ if (!strncmp(module, file_m, len))
+ return m;
}
return NULL;
EINA_SAFETY_ON_NULL_RETURN(array);
DBG("array %p, count %u", array, array->count);
EINA_ARRAY_ITER_NEXT(array, i, m, iterator)
- eina_module_load(m);
+ eina_module_load(m);
}
/**
EINA_SAFETY_ON_NULL_RETURN(array);
DBG("array %p, count %u", array, array->count);
EINA_ARRAY_ITER_NEXT(array, i, m, iterator)
- eina_module_unload(m);
+ eina_module_unload(m);
}
/**
EINA_SAFETY_ON_NULL_RETURN(array);
DBG("array %p, count %u", array, array->count);
EINA_ARRAY_ITER_NEXT(array, i, m, iterator)
- eina_module_free(m);
+ eina_module_free(m);
eina_array_flush(array);
}
static const char EINA_MAGIC_QUADTREE_ROOT_STR[] = "Eina QuadTree Root";
static const char EINA_MAGIC_QUADTREE_ITEM_STR[] = "Eina QuadTree Item";
-#define EINA_MAGIC_CHECK_QUADTREE(d, ...) \
- do { \
- if (!EINA_MAGIC_CHECK(d, EINA_MAGIC_QUADTREE)) \
- { \
- EINA_MAGIC_FAIL(d, EINA_MAGIC_QUADTREE); \
- return __VA_ARGS__; \
- } \
- } while(0);
-
-#define EINA_MAGIC_CHECK_QUADTREE_ROOT(d, ...) \
- do { \
- if (!EINA_MAGIC_CHECK(d, EINA_MAGIC_QUADTREE_ROOT)) \
- { \
- EINA_MAGIC_FAIL(d, EINA_MAGIC_QUADTREE_ROOT); \
- return __VA_ARGS__; \
- } \
- } while(0);
-
-#define EINA_MAGIC_CHECK_QUADTREE_ITEM(d, ...) \
- do { \
- if (!EINA_MAGIC_CHECK(d, EINA_MAGIC_QUADTREE_ITEM)) \
- { \
- EINA_MAGIC_FAIL(d, EINA_MAGIC_QUADTREE_ITEM); \
- return __VA_ARGS__; \
- } \
- } while(0);
+#define EINA_MAGIC_CHECK_QUADTREE(d, ...) \
+ do { \
+ if (!EINA_MAGIC_CHECK(d, EINA_MAGIC_QUADTREE)) \
+ { \
+ EINA_MAGIC_FAIL(d, EINA_MAGIC_QUADTREE); \
+ return __VA_ARGS__; \
+ } \
+ } while(0);
+
+#define EINA_MAGIC_CHECK_QUADTREE_ROOT(d, ...) \
+ do { \
+ if (!EINA_MAGIC_CHECK(d, EINA_MAGIC_QUADTREE_ROOT)) \
+ { \
+ EINA_MAGIC_FAIL(d, EINA_MAGIC_QUADTREE_ROOT); \
+ return __VA_ARGS__; \
+ } \
+ } while(0);
+
+#define EINA_MAGIC_CHECK_QUADTREE_ITEM(d, ...) \
+ do { \
+ if (!EINA_MAGIC_CHECK(d, EINA_MAGIC_QUADTREE_ITEM)) \
+ { \
+ EINA_MAGIC_FAIL(d, EINA_MAGIC_QUADTREE_ITEM); \
+ return __VA_ARGS__; \
+ } \
+ } while(0);
struct _Eina_QuadTree
{
size_t index;
- struct {
+ struct
+ {
Eina_Quad_Callback v;
Eina_Quad_Callback h;
} func;
- struct {
+ struct
+ {
size_t w;
size_t h;
} geom;
{
Eina_QuadTree_Item *item;
- if (!root) return NULL;
+ if (!root)
+ return NULL;
EINA_MAGIC_CHECK_QUADTREE_ROOT(root, NULL);
EINA_LIST_FREE(root->both, item)
- eina_mempool_free(items_mp, item);
+ eina_mempool_free(items_mp, item);
root->left = eina_quadtree_root_free(q, root->left);
root->right = eina_quadtree_root_free(q, root->right);
static Eina_QuadTree_Root *
eina_quadtree_root_rebuild_pre(Eina_QuadTree *q,
- Eina_Inlist **change,
- Eina_QuadTree_Root *root)
+ Eina_Inlist **change,
+ Eina_QuadTree_Root *root)
{
Eina_QuadTree_Item *item;
- if (!root) return NULL;
+ if (!root)
+ return NULL;
EINA_LIST_FREE(root->both, item)
- {
- if (item->visible)
- {
- *change = eina_inlist_append(*change, EINA_INLIST_GET(item));
- }
- else if (!item->hidden)
- {
- q->hidden = eina_list_append(q->hidden, item);
- item->hidden = EINA_TRUE;
- item->root = NULL;
- }
- }
+ {
+ if (item->visible)
+ *change = eina_inlist_append(*change, EINA_INLIST_GET(item));
+ else if (!item->hidden)
+ {
+ q->hidden = eina_list_append(q->hidden, item);
+ item->hidden = EINA_TRUE;
+ item->root = NULL;
+ }
+ }
root->left = eina_quadtree_root_rebuild_pre(q, change, root->left);
root->right = eina_quadtree_root_rebuild_pre(q, change, root->right);
EINA_MAGIC_SET(root, 0);
if (q->root_count > 50)
- {
- eina_mempool_free(root_mp, root);
- }
+ eina_mempool_free(root_mp, root);
else
{
- eina_trash_push(&q->root_trash, root);
- q->root_count++;
+ eina_trash_push(&q->root_trash, root);
+ q->root_count++;
}
return NULL;
static size_t
_eina_quadtree_split(Eina_Inlist *objects,
- Eina_QuadTree_Root *root,
- Eina_Inlist **left,
- Eina_Inlist **right,
- Eina_Quad_Callback func,
- int border,
- int middle)
+ Eina_QuadTree_Root *root,
+ Eina_Inlist **left,
+ Eina_Inlist **right,
+ Eina_Quad_Callback func,
+ int border,
+ int middle)
{
Eina_QuadTree_Item *object;
middle /= 2;
if (middle <= 4)
- {
- while (objects)
- {
- object = EINA_INLIST_CONTAINER_GET(objects, Eina_QuadTree_Item);
- objects = objects->next;
-
- object->change = EINA_FALSE;
- if (!object->visible)
- {
- if (!object->hidden)
- {
- object->hidden = EINA_TRUE;
- object->quad->hidden = eina_list_append(object->quad->hidden,
- object);
- }
- continue;
- }
- if (object->hidden)
- {
- object->hidden = EINA_FALSE;
- object->quad->hidden = eina_list_remove(object->quad->hidden, object);
- }
- if (!object->delete_me)
- {
- if (root->sorted)
- {
- root->both = eina_list_sorted_insert(root->both,
- _eina_quadtree_item_cmp,
- object);
- }
- else
- {
- root->both = eina_list_append(root->both, object);
- }
- object->root = root;
- }
- else
- {
- eina_quadtree_del(object);
- }
- }
- }
+ while (objects)
+ {
+ object = EINA_INLIST_CONTAINER_GET(objects, Eina_QuadTree_Item);
+ objects = objects->next;
+
+ object->change = EINA_FALSE;
+ if (!object->visible)
+ {
+ if (!object->hidden)
+ {
+ object->hidden = EINA_TRUE;
+ object->quad->hidden = eina_list_append(
+ object->quad->hidden,
+ object);
+ }
+
+ continue;
+ }
+
+ if (object->hidden)
+ {
+ object->hidden = EINA_FALSE;
+ object->quad->hidden = eina_list_remove(object->quad->hidden,
+ object);
+ }
+
+ if (!object->delete_me)
+ {
+ if (root->sorted)
+ root->both = eina_list_sorted_insert(root->both,
+ _eina_quadtree_item_cmp,
+ object);
+ else
+ root->both = eina_list_append(root->both, object);
+
+ object->root = root;
+ }
+ else
+ eina_quadtree_del(object);
+ }
else
- {
- while (objects)
- {
- object = EINA_INLIST_CONTAINER_GET(objects, Eina_QuadTree_Item);
- objects = objects->next;
-
- object->change = EINA_FALSE;
- if (!object->visible)
- {
- if (!object->hidden)
- {
- object->hidden = EINA_TRUE;
- object->quad->hidden = eina_list_append(object->quad->hidden,
- object);
- }
- continue;
- }
- if (object->hidden)
- {
- object->hidden = EINA_FALSE;
- object->quad->hidden = eina_list_remove(object->quad->hidden, object);
- }
- if (!object->delete_me)
- {
- switch (func(object->object, border + middle))
- {
- case EINA_QUAD_LEFT:
- *left = eina_inlist_append(*left, EINA_INLIST_GET(object));
- break;
- case EINA_QUAD_RIGHT:
- *right = eina_inlist_append(*right, EINA_INLIST_GET(object));
- break;
- case EINA_QUAD_BOTH:
- root->both = eina_list_append(root->both, object);
- object->root = root;
- break;
- default:
- abort();
- }
- }
- else
- {
- eina_quadtree_del(object);
- }
- }
- }
+ while (objects)
+ {
+ object = EINA_INLIST_CONTAINER_GET(objects, Eina_QuadTree_Item);
+ objects = objects->next;
+
+ object->change = EINA_FALSE;
+ if (!object->visible)
+ {
+ if (!object->hidden)
+ {
+ object->hidden = EINA_TRUE;
+ object->quad->hidden = eina_list_append(
+ object->quad->hidden,
+ object);
+ }
+
+ continue;
+ }
+
+ if (object->hidden)
+ {
+ object->hidden = EINA_FALSE;
+ object->quad->hidden = eina_list_remove(object->quad->hidden,
+ object);
+ }
+
+ if (!object->delete_me)
+ {
+ switch (func(object->object, border + middle))
+ {
+ case EINA_QUAD_LEFT:
+ *left = eina_inlist_append(*left, EINA_INLIST_GET(object));
+ break;
+
+ case EINA_QUAD_RIGHT:
+ *right =
+ eina_inlist_append(*right, EINA_INLIST_GET(object));
+ break;
+
+ case EINA_QUAD_BOTH:
+ root->both = eina_list_append(root->both, object);
+ object->root = root;
+ break;
+
+ default:
+ abort();
+ }
+ }
+ else
+ eina_quadtree_del(object);
+ }
return middle;
}
static Eina_QuadTree_Root *
_eina_quadtree_update(Eina_QuadTree *q, Eina_QuadTree_Root *parent,
- Eina_QuadTree_Root *root, Eina_Inlist *objects,
- Eina_Bool direction, Eina_Rectangle *size)
+ Eina_QuadTree_Root *root, Eina_Inlist *objects,
+ Eina_Bool direction, Eina_Rectangle *size)
{
Eina_Inlist *right = NULL;
Eina_Inlist *left = NULL;
size_t h2;
if (!objects)
- return root;
+ return root;
if (!root)
{
- root = eina_trash_pop(&q->root_trash);
- if (!root) root = eina_mempool_malloc(root_mp, sizeof (Eina_QuadTree_Root));
- else q->root_count--;
- if (!root)
- {
- /* FIXME: NOT GOOD TIMING, WE ARE GOING TO LEAK MORE MEMORY */
- return NULL;
- }
-
- root->parent = parent;
- root->both = NULL;
- root->left = NULL;
- root->right = NULL;
- root->sorted = EINA_TRUE;
-
- EINA_MAGIC_SET(root, EINA_MAGIC_QUADTREE_ROOT);
+ root = eina_trash_pop(&q->root_trash);
+ if (!root)
+ root = eina_mempool_malloc(root_mp, sizeof (Eina_QuadTree_Root));
+ else
+ q->root_count--;
+
+ if (!root)
+ /* FIXME: NOT GOOD TIMING, WE ARE GOING TO LEAK MORE MEMORY */
+ return NULL;
+
+ root->parent = parent;
+ root->both = NULL;
+ root->left = NULL;
+ root->right = NULL;
+ root->sorted = EINA_TRUE;
+
+ EINA_MAGIC_SET(root, EINA_MAGIC_QUADTREE_ROOT);
}
w2 = 0;
h2 = 0;
if (direction)
- w2 = _eina_quadtree_split(objects, root,
- &left, &right,
- q->func.h, size->x, size->w);
+ w2 = _eina_quadtree_split(objects, root,
+ &left, &right,
+ q->func.h, size->x, size->w);
else
- h2 = _eina_quadtree_split(objects, root,
- &left, &right,
- q->func.v, size->y, size->h);
+ h2 = _eina_quadtree_split(objects, root,
+ &left, &right,
+ q->func.v, size->y, size->h);
size->w -= w2; size->h -= h2;
root->left = _eina_quadtree_update(q, root,
- root->left, left,
- !direction, size);
+ root->left, left,
+ !direction, size);
size->x += w2; size->y += h2;
root->right = _eina_quadtree_update(q, root,
- root->right, right,
- !direction, size);
+ root->right, right,
+ !direction, size);
size->x -= w2; size->y -= h2;
size->w += w2; size->h += h2;
static Eina_Inlist *
_eina_quadtree_merge(Eina_Inlist *result,
- Eina_List *both)
+ Eina_List *both)
{
Eina_QuadTree_Item *item;
Eina_QuadTree_Item *b;
Eina_Inlist *moving;
- if (!both) return result;
+ if (!both)
+ return result;
+
if (!result)
{
- Eina_List *l;
+ Eina_List *l;
- EINA_LIST_FOREACH(both, l, item)
- if (item->visible)
- result = eina_inlist_append(result, EINA_INLIST_GET(item));
+ EINA_LIST_FOREACH(both, l, item)
+ if (item->visible)
+ result = eina_inlist_append(result, EINA_INLIST_GET(item));
- return result;
+ return result;
}
moving = result;
while (both && moving)
{
- if (!b->visible)
- {
- both = eina_list_next(both);
- b = eina_list_data_get(both);
- continue ;
- }
- if (_eina_quadtree_item_cmp(item, b) < 0)
- {
- /* moving is still lower than item, so we can continue to the next one. */
- moving = moving->next;
- item = EINA_INLIST_CONTAINER_GET(moving, Eina_QuadTree_Item);
- }
- else
- {
- /* we just get above the limit of both, so insert it */
- result = eina_inlist_prepend_relative(result,
- EINA_INLIST_GET(b),
- moving);
- both = eina_list_next(both);
- b = eina_list_data_get(both);
- }
+ if (!b->visible)
+ {
+ both = eina_list_next(both);
+ b = eina_list_data_get(both);
+ continue;
+ }
+
+ if (_eina_quadtree_item_cmp(item, b) < 0)
+ {
+ /* moving is still lower than item, so we can continue to the next one. */
+ moving = moving->next;
+ item = EINA_INLIST_CONTAINER_GET(moving, Eina_QuadTree_Item);
+ }
+ else
+ {
+ /* we just get above the limit of both, so insert it */
+ result = eina_inlist_prepend_relative(result,
+ EINA_INLIST_GET(b),
+ moving);
+ both = eina_list_next(both);
+ b = eina_list_data_get(both);
+ }
}
item = EINA_INLIST_CONTAINER_GET(result->last, Eina_QuadTree_Item);
while (both)
{
- b = eina_list_data_get(both);
- if (b->visible)
- {
- if (_eina_quadtree_item_cmp(item, b) < 0)
- break;
-
- result = eina_inlist_prepend_relative(result,
- EINA_INLIST_GET(b),
- result->last);
- }
- both = eina_list_next(both);
+ b = eina_list_data_get(both);
+ if (b->visible)
+ {
+ if (_eina_quadtree_item_cmp(item, b) < 0)
+ break;
+
+ result = eina_inlist_prepend_relative(result,
+ EINA_INLIST_GET(b),
+ result->last);
+ }
+
+ both = eina_list_next(both);
}
while (both)
{
- b = eina_list_data_get(both);
- if (b->visible)
- result = eina_inlist_append(result, EINA_INLIST_GET(b));
- both = eina_list_next(both);
+ b = eina_list_data_get(both);
+ if (b->visible)
+ result = eina_inlist_append(result, EINA_INLIST_GET(b));
+
+ both = eina_list_next(both);
}
return result;
static Eina_Inlist *
_eina_quadtree_collide(Eina_Inlist *result,
- Eina_QuadTree_Root *root,
- Eina_Bool direction, Eina_Rectangle *size,
- Eina_Rectangle *target)
+ Eina_QuadTree_Root *root,
+ Eina_Bool direction, Eina_Rectangle *size,
+ Eina_Rectangle *target)
{
- if (!root) return result;
+ if (!root)
+ return result;
if (!root->sorted)
{
- root->both = eina_list_sort(root->both, -1, _eina_quadtree_item_cmp);
- root->sorted = EINA_TRUE;
+ root->both = eina_list_sort(root->both, -1, _eina_quadtree_item_cmp);
+ root->sorted = EINA_TRUE;
}
result = _eina_quadtree_merge(result, root->both);
if (direction)
{
- int middle = size->w / 2;
-
- size->w -= middle;
- if (eina_spans_intersect(size->x, size->w, target->x, target->w))
- result = _eina_quadtree_collide(result, root->left,
- !direction, size,
- target);
-
- size->x += middle;
- if (eina_spans_intersect(size->x, size->w, target->x, target->w))
- result = _eina_quadtree_collide(result, root->right,
- !direction, size,
- target);
- size->x -= middle;
- size->w += middle;
+ int middle = size->w / 2;
+
+ size->w -= middle;
+ if (eina_spans_intersect(size->x, size->w, target->x, target->w))
+ result = _eina_quadtree_collide(result, root->left,
+ !direction, size,
+ target);
+
+ size->x += middle;
+ if (eina_spans_intersect(size->x, size->w, target->x, target->w))
+ result = _eina_quadtree_collide(result, root->right,
+ !direction, size,
+ target);
+
+ size->x -= middle;
+ size->w += middle;
}
else
{
- int middle = size->h / 2;
-
- size->h -= middle;
- if (eina_spans_intersect(size->y, size->h, target->y, target->h))
- result = _eina_quadtree_collide(result, root->left,
- !direction, size,
- target);
- size->y += middle;
- if (eina_spans_intersect(size->y, size->h, target->y, target->h))
- result = _eina_quadtree_collide(result, root->right,
- !direction, size,
- target);
- size->y -= middle;
- size->h += middle;
+ int middle = size->h / 2;
+
+ size->h -= middle;
+ if (eina_spans_intersect(size->y, size->h, target->y, target->h))
+ result = _eina_quadtree_collide(result, root->left,
+ !direction, size,
+ target);
+
+ size->y += middle;
+ if (eina_spans_intersect(size->y, size->h, target->y, target->h))
+ result = _eina_quadtree_collide(result, root->right,
+ !direction, size,
+ target);
+
+ size->y -= middle;
+ size->h += middle;
}
return result;
static void
_eina_quadtree_remove(Eina_QuadTree_Item *object)
{
- if (!object->root) return ;
+ if (!object->root)
+ return;
object->root->both = eina_list_remove(object->root->both, object);
- if (object->root->both) goto end;
- if (object->root->left) goto end;
- if (object->root->right) goto end;
+ if (object->root->both)
+ goto end;
+
+ if (object->root->left)
+ goto end;
+
+ if (object->root->right)
+ goto end;
/* The root is not usefull anymore... */
if (object->root->parent)
{
- if (object->root->parent->left == object->root)
- object->root->parent->left = NULL;
- else
- object->root->parent->right = NULL;
- object->root->parent = NULL;
+ if (object->root->parent->left == object->root)
+ object->root->parent->left = NULL;
+ else
+ object->root->parent->right = NULL;
+
+ object->root->parent = NULL;
}
else
- {
- object->quad->root = NULL;
- }
+ object->quad->root = NULL;
if (object->quad->root_count > 50)
- {
- eina_mempool_free(root_mp, object->root);
- }
+ eina_mempool_free(root_mp, object->root);
else
{
- eina_trash_push(&object->quad->root_trash, object->root);
- object->quad->root_count++;
+ eina_trash_push(&object->quad->root_trash, object->root);
+ object->quad->root_count++;
}
- end:
+end:
object->root = NULL;
}
EAPI Eina_QuadTree *
eina_quadtree_new(size_t w, size_t h,
- Eina_Quad_Callback vertical, Eina_Quad_Callback horizontal)
+ Eina_Quad_Callback vertical, Eina_Quad_Callback horizontal)
{
Eina_QuadTree *result;
if (!vertical || !horizontal || h == 0 || w == 0)
- return NULL;
+ return NULL;
result = calloc(1, sizeof (Eina_QuadTree));
if (!result)
- return NULL;
+ return NULL;
result->func.v = vertical;
result->func.h = horizontal;
{
Eina_QuadTree_Item *item;
- if (!q) return ;
+ if (!q)
+ return;
EINA_MAGIC_CHECK_QUADTREE(q);
while (q->change)
{
- item = EINA_INLIST_CONTAINER_GET(q->change, Eina_QuadTree_Item);
- q->change = q->change->next;
- if (!item->hidden)
- eina_mempool_free(items_mp, item);
+ item = EINA_INLIST_CONTAINER_GET(q->change, Eina_QuadTree_Item);
+ q->change = q->change->next;
+ if (!item->hidden)
+ eina_mempool_free(items_mp, item);
}
EINA_LIST_FREE(q->hidden, item)
- eina_mempool_free(items_mp, item);
+ eina_mempool_free(items_mp, item);
eina_quadtree_root_free(q, q->root);
while (q->items_trash)
{
- item = eina_trash_pop(&q->items_trash);
- eina_mempool_free(items_mp, item);
+ item = eina_trash_pop(&q->items_trash);
+ eina_mempool_free(items_mp, item);
}
while (q->root_trash)
{
- Eina_QuadTree_Root *root;
+ Eina_QuadTree_Root *root;
- root = eina_trash_pop(&q->root_trash);
- eina_mempool_free(root_mp, root);
+ root = eina_trash_pop(&q->root_trash);
+ eina_mempool_free(root_mp, root);
}
- EINA_MAGIC_SET(q, 0);
+ EINA_MAGIC_SET(q, 0);
free(q);
}
EINA_MAGIC_CHECK_QUADTREE(q, NULL);
- if (!object) return NULL;
+ if (!object)
+ return NULL;
result = eina_trash_pop(&q->items_trash);
- if (!result) result = eina_mempool_malloc(items_mp, sizeof (Eina_QuadTree_Item));
- else q->items_count--;
- if (!result) return NULL;
+ if (!result)
+ result = eina_mempool_malloc(items_mp, sizeof (Eina_QuadTree_Item));
+ else
+ q->items_count--;
+
+ if (!result)
+ return NULL;
result->quad = q;
result->root = NULL;
EAPI Eina_Bool
eina_quadtree_del(Eina_QuadTree_Item *object)
{
- if (!object) return EINA_FALSE;
+ if (!object)
+ return EINA_FALSE;
EINA_MAGIC_CHECK_QUADTREE_ITEM(object, EINA_FALSE);
if (object->change)
{
- /* This object is still in the update array, delaying it's removal !*/
- object->delete_me = EINA_TRUE;
- object->visible = EINA_TRUE;
- return EINA_TRUE;
+ /* This object is still in the update array, delaying it's removal !*/
+ object->delete_me = EINA_TRUE;
+ object->visible = EINA_TRUE;
+ return EINA_TRUE;
}
if (object->hidden)
{
- object->quad->hidden = eina_list_remove(object->quad->hidden, object);
- object->hidden = EINA_TRUE;
+ object->quad->hidden = eina_list_remove(object->quad->hidden, object);
+ object->hidden = EINA_TRUE;
}
/* This object is not anymore inside the tree, we can remove it now !*/
EINA_MAGIC_SET(object, 0);
if (object->quad->items_count > 256)
- {
- eina_mempool_free(items_mp, object);
- }
+ eina_mempool_free(items_mp, object);
else
{
- object->quad->items_count++;
- eina_trash_push(&object->quad->items_trash, object);
+ object->quad->items_count++;
+ eina_trash_push(&object->quad->items_trash, object);
}
return EINA_TRUE;
EINA_MAGIC_CHECK_QUADTREE_ITEM(object, EINA_FALSE);
if (object->delete_me || !object->visible)
- return EINA_FALSE;
+ return EINA_FALSE;
if (object->quad->resize)
- return EINA_TRUE;
+ return EINA_TRUE;
/* Delaying change until needed */
if (!object->change)
- object->quad->change = eina_inlist_append(object->quad->change,
- EINA_INLIST_GET(object));
+ object->quad->change = eina_inlist_append(object->quad->change,
+ EINA_INLIST_GET(object));
+
object->change = EINA_TRUE;
_eina_quadtree_remove(object);
object->quad->lost = EINA_TRUE;
- if (object->visible) return EINA_TRUE;
+ if (object->visible)
+ return EINA_TRUE;
object->visible = EINA_TRUE;
if (!object->change)
- return eina_quadtree_change(object);
+ return eina_quadtree_change(object);
return EINA_TRUE;
}
/* Now we need the tree to be up to date, so it's time */
if (q->resize) /* Full rebuild needed ! */
{
- DBG("resizing quadtree");
- q->root = eina_quadtree_root_rebuild_pre(q, &q->change, q->root);
- q->resize = EINA_FALSE;
+ DBG("resizing quadtree");
+ q->root = eina_quadtree_root_rebuild_pre(q, &q->change, q->root);
+ q->resize = EINA_FALSE;
}
EINA_RECTANGLE_SET(&canvas, 0, 0, q->geom.w, q->geom.h);
if (q->change)
{
- DBG("updating quadtree content");
- q->root = _eina_quadtree_update(q, NULL, q->root, q->change,
- EINA_FALSE, &canvas);
- q->change = NULL;
- q->lost = EINA_TRUE;
+ DBG("updating quadtree content");
+ q->root = _eina_quadtree_update(q, NULL, q->root, q->change,
+ EINA_FALSE, &canvas);
+ q->change = NULL;
+ q->lost = EINA_TRUE;
}
if (q->target.x != x
|| q->target.w != w
|| q->target.h != h)
{
- DBG("new target");
- EINA_RECTANGLE_SET(&q->target, x, y, w, h);
- q->lost = EINA_TRUE;
+ DBG("new target");
+ EINA_RECTANGLE_SET(&q->target, x, y, w, h);
+ q->lost = EINA_TRUE;
}
if (q->lost)
{
- DBG("computing collide");
- q->cached = _eina_quadtree_collide(NULL, q->root,
- EINA_FALSE, &canvas,
- &q->target);
- q->lost = EINA_FALSE;
+ DBG("computing collide");
+ q->cached = _eina_quadtree_collide(NULL, q->root,
+ EINA_FALSE, &canvas,
+ &q->target);
+ q->lost = EINA_FALSE;
}
return q->cached;
{
Eina_QuadTree_Item *qi;
- if (!item) return NULL;
+ if (!item)
+ return NULL;
qi = EINA_INLIST_CONTAINER_GET(item, Eina_QuadTree_Item);
- if (!qi) return NULL;
+ if (!qi)
+ return NULL;
EINA_MAGIC_CHECK_QUADTREE_ITEM(qi, NULL);
- if (!qi->visible) return NULL;
+ if (!qi->visible)
+ return NULL;
- return (void*) qi->object;
+ return (void *)qi->object;
}
EAPI void
if (q->geom.w == w
&& q->geom.h == h)
- return ;
+ return;
q->resize = EINA_TRUE;
q->geom.w = w;
tmp = object->quad->index++;
if (object->index == tmp)
- return ;
+ return;
object->index = tmp;
if (object->root)
- object->root->sorted = EINA_FALSE;
+ object->root->sorted = EINA_FALSE;
}
Eina_Bool
eina_quadtree_init(void)
{
- _eina_log_qd_dom = eina_log_domain_register("eina_quadtree", EINA_LOG_COLOR_DEFAULT);
+ _eina_log_qd_dom = eina_log_domain_register("eina_quadtree",
+ EINA_LOG_COLOR_DEFAULT);
if (_eina_log_qd_dom < 0)
{
- EINA_LOG_ERR("Could not register log domain: eina_quadtree");
- return EINA_FALSE;
+ EINA_LOG_ERR("Could not register log domain: eina_quadtree");
+ return EINA_FALSE;
}
-#define EMS(n) eina_magic_string_static_set(n, n##_STR)
+#define EMS(n) eina_magic_string_static_set(n, n ## _STR)
EMS(EINA_MAGIC_QUADTREE);
EMS(EINA_MAGIC_QUADTREE_ROOT);
EMS(EINA_MAGIC_QUADTREE_ITEM);
#undef EMS
items_mp = eina_mempool_add("chained_mempool", "QuadTree Item", NULL,
- sizeof (Eina_QuadTree_Item), 320);
+ sizeof (Eina_QuadTree_Item), 320);
root_mp = eina_mempool_add("chained_mempool", "QuadTree Root", NULL,
- sizeof (Eina_QuadTree_Root), 32);
+ sizeof (Eina_QuadTree_Root), 32);
return EINA_TRUE;
}
#include "eina_rbtree.h"
/*============================================================================*
- * Local *
- *============================================================================*/
+* Local *
+*============================================================================*/
#define EINA_RBTREE_ITERATOR_PREFIX_MASK 0x1
#define EINA_RBTREE_ITERATOR_INFIX_MASK 0x2
{
Eina_Iterator_Rbtree_List *new;
- eina_error_set(0);
+ eina_error_set(0);
new = malloc(sizeof (Eina_Iterator_Rbtree_List));
- if (!new) {
- eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
- return NULL;
- }
+ if (!new)
+ {
+ eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+ return NULL;
+ }
- new->tree = (Eina_Rbtree*) tree;
+ new->tree = (Eina_Rbtree *)tree;
new->dir = EINA_RBTREE_RIGHT;
new->up = EINA_FALSE;
static Eina_Rbtree *
_eina_rbtree_iterator_get_content(Eina_Iterator_Rbtree *it)
{
- if (eina_array_count_get(it->stack) <= 0) return NULL;
+ if (eina_array_count_get(it->stack) <= 0)
+ return NULL;
+
return eina_array_data_get(it->stack, 0);
}
unsigned int i;
EINA_ARRAY_ITER_NEXT(it->stack, i, item, et)
- free(item);
+ free(item);
eina_array_free(it->stack);
- free(it);
+ free(it);
}
static Eina_Bool
Eina_Iterator_Rbtree_List *new;
Eina_Rbtree *tree;
- if (eina_array_count_get(it->stack) <= 0) return EINA_FALSE;
+ if (eina_array_count_get(it->stack) <= 0)
+ return EINA_FALSE;
last = eina_array_data_get(it->stack, eina_array_count_get(it->stack) - 1);
tree = last->tree;
if (last->tree == NULL || last->up == EINA_TRUE)
{
- last = eina_array_pop(it->stack);
- while (last->dir == EINA_RBTREE_LEFT
- || last->tree == NULL)
- {
- if (tree)
- if ((it->mask & EINA_RBTREE_ITERATOR_POSTFIX_MASK) == EINA_RBTREE_ITERATOR_POSTFIX_MASK)
- {
- free(last);
-
- if (eina_array_count_get(it->stack) > 0)
- {
- last = eina_array_data_get(it->stack, eina_array_count_get(it->stack) - 1);
- last->up = EINA_TRUE;
- }
-
- goto onfix;
- }
-
- free(last);
-
- last = eina_array_pop(it->stack);
- if (!last) return EINA_FALSE;
- tree = last->tree;
- }
-
- last->dir = EINA_RBTREE_LEFT;
- last->up = EINA_FALSE;
-
- eina_array_push(it->stack, last);
-
- if ((it->mask & EINA_RBTREE_ITERATOR_INFIX_MASK) == EINA_RBTREE_ITERATOR_INFIX_MASK)
- goto onfix;
+ last = eina_array_pop(it->stack);
+ while (last->dir == EINA_RBTREE_LEFT
+ || last->tree == NULL)
+ {
+ if (tree)
+ if ((it->mask & EINA_RBTREE_ITERATOR_POSTFIX_MASK) ==
+ EINA_RBTREE_ITERATOR_POSTFIX_MASK)
+ {
+ free(last);
+
+ if (eina_array_count_get(it->stack) > 0)
+ {
+ last = eina_array_data_get(it->stack,
+ eina_array_count_get(
+ it->
+ stack)
+ - 1);
+ last->up = EINA_TRUE;
+ }
+
+ goto onfix;
+ }
+
+ free(last);
+
+ last = eina_array_pop(it->stack);
+ if (!last)
+ return EINA_FALSE;
+
+ tree = last->tree;
+ }
+
+ last->dir = EINA_RBTREE_LEFT;
+ last->up = EINA_FALSE;
+
+ eina_array_push(it->stack, last);
+
+ if ((it->mask & EINA_RBTREE_ITERATOR_INFIX_MASK) ==
+ EINA_RBTREE_ITERATOR_INFIX_MASK)
+ goto onfix;
}
new = _eina_rbtree_iterator_list_new(last->tree->son[last->dir]);
- if (!new) return EINA_FALSE;
- eina_array_push(it->stack, new);
+ if (!new)
+ return EINA_FALSE;
+
+ eina_array_push(it->stack, new);
if (last->dir == EINA_RBTREE_RIGHT)
- if ((it->mask & EINA_RBTREE_ITERATOR_PREFIX_MASK) == EINA_RBTREE_ITERATOR_PREFIX_MASK)
- goto onfix;
+ if ((it->mask & EINA_RBTREE_ITERATOR_PREFIX_MASK) ==
+ EINA_RBTREE_ITERATOR_PREFIX_MASK)
+ goto onfix;
return _eina_rbtree_iterator_next(it, data);
- onfix:
+onfix:
*data = tree;
return EINA_TRUE;
}
Eina_Iterator_Rbtree_List *first;
Eina_Iterator_Rbtree *it;
- eina_error_set(0);
+ eina_error_set(0);
it = calloc(1, sizeof (Eina_Iterator_Rbtree));
- if (!it) {
- eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
- return NULL;
- }
+ if (!it)
+ {
+ eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+ return NULL;
+ }
it->stack = eina_array_new(8);
- if (!it->stack) goto on_error2;
+ if (!it->stack)
+ goto on_error2;
first = _eina_rbtree_iterator_list_new(root);
- if (!first) goto on_error;
+ if (!first)
+ goto on_error;
+
eina_array_push(it->stack, first);
it->mask = mask;
it->iterator.next = FUNC_ITERATOR_NEXT(_eina_rbtree_iterator_next);
- it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(_eina_rbtree_iterator_get_content);
+ it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(
+ _eina_rbtree_iterator_get_content);
it->iterator.free = FUNC_ITERATOR_FREE(_eina_rbtree_iterator_free);
EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_ITERATOR);
static void
_eina_rbtree_node_init(Eina_Rbtree *node)
{
- if (!node) return ;
+ if (!node)
+ return;
node->son[0] = NULL;
node->son[1] = NULL;
}
static inline Eina_Rbtree *
-_eina_rbtree_inline_single_rotation(Eina_Rbtree *node, Eina_Rbtree_Direction dir)
+_eina_rbtree_inline_single_rotation(Eina_Rbtree *node,
+ Eina_Rbtree_Direction dir)
{
Eina_Rbtree *save = node->son[!dir];
}
static inline Eina_Rbtree *
-_eina_rbtree_inline_double_rotation(Eina_Rbtree *node, Eina_Rbtree_Direction dir)
+_eina_rbtree_inline_double_rotation(Eina_Rbtree *node,
+ Eina_Rbtree_Direction dir)
{
node->son[!dir] = _eina_rbtree_inline_single_rotation(node->son[!dir], !dir);
return _eina_rbtree_inline_single_rotation(node, dir);
}
/*============================================================================*
- * Global *
- *============================================================================*/
+* Global *
+*============================================================================*/
/*============================================================================*
- * API *
- *============================================================================*/
+* API *
+*============================================================================*/
EAPI Eina_Rbtree *
-eina_rbtree_inline_insert(Eina_Rbtree *root, Eina_Rbtree *node, Eina_Rbtree_Cmp_Node_Cb cmp, const void *data)
+eina_rbtree_inline_insert(Eina_Rbtree *root,
+ Eina_Rbtree *node,
+ Eina_Rbtree_Cmp_Node_Cb cmp,
+ const void *data)
{
Eina_Rbtree head;
- Eina_Rbtree *g, *t; /* Grandparent & parent */
- Eina_Rbtree *p, *q; /* Iterator & parent */
+ Eina_Rbtree *g, *t; /* Grandparent & parent */
+ Eina_Rbtree *p, *q; /* Iterator & parent */
/* WARNING:
Compiler is not able to understand the underlying algorithm and don't know that
first top node is always black, so it will never use last before running the loop
Eina_Rbtree_Direction dir, last;
EINA_SAFETY_ON_NULL_RETURN_VAL(node, root);
- EINA_SAFETY_ON_NULL_RETURN_VAL(cmp, root);
+ EINA_SAFETY_ON_NULL_RETURN_VAL( cmp, root);
- if (!node) return root;
+ if (!node)
+ return root;
_eina_rbtree_node_init(node);
if (!root)
{
- root = node;
- goto end_add;
+ root = node;
+ goto end_add;
}
memset(&head, 0, sizeof (Eina_Rbtree));
q = t->son[1] = root;
/* Search down the tree */
- for (;;)
+ for (;; )
{
- if (q == NULL)
- {
- /* Insert new node at the bottom */
- p->son[dir] = q = node;
- }
- else if (_eina_rbtree_is_red(q->son[0])
- && _eina_rbtree_is_red(q->son[1]))
- {
- /* Color flip */
- q->color = EINA_RBTREE_RED;
- q->son[0]->color = EINA_RBTREE_BLACK;
- q->son[1]->color = EINA_RBTREE_BLACK;
- }
-
- /* Fix red violation */
- if (_eina_rbtree_is_red(q) && _eina_rbtree_is_red(p))
- {
- Eina_Rbtree_Direction dir2;
-
- dir2 = (t->son[1] == g) ? EINA_RBTREE_RIGHT : EINA_RBTREE_LEFT;
-
- if (q == p->son[last])
- t->son[dir2] = _eina_rbtree_inline_single_rotation(g, !last);
- else
- t->son[dir2] = _eina_rbtree_inline_double_rotation(g, !last);
- }
-
- /* Stop if found */
- if (q == node)
- break;
-
- last = dir;
- dir = cmp(q, node, (void*) data);
-
- /* Update helpers */
- if ( g != NULL )
- t = g;
- g = p, p = q;
- q = q->son[dir];
+ if (q == NULL)
+ /* Insert new node at the bottom */
+ p->son[dir] = q = node;
+ else if (_eina_rbtree_is_red(q->son[0])
+ && _eina_rbtree_is_red(q->son[1]))
+ {
+ /* Color flip */
+ q->color = EINA_RBTREE_RED;
+ q->son[0]->color = EINA_RBTREE_BLACK;
+ q->son[1]->color = EINA_RBTREE_BLACK;
+ }
+
+ /* Fix red violation */
+ if (_eina_rbtree_is_red(q) && _eina_rbtree_is_red(p))
+ {
+ Eina_Rbtree_Direction dir2;
+
+ dir2 = (t->son[1] == g) ? EINA_RBTREE_RIGHT : EINA_RBTREE_LEFT;
+
+ if (q == p->son[last])
+ t->son[dir2] = _eina_rbtree_inline_single_rotation(g, !last);
+ else
+ t->son[dir2] = _eina_rbtree_inline_double_rotation(g, !last);
+ }
+
+ /* Stop if found */
+ if (q == node)
+ break;
+
+ last = dir;
+ dir = cmp(q, node, (void *)data);
+
+ /* Update helpers */
+ if ( g != NULL )
+ t = g;
+
+ g = p, p = q;
+ q = q->son[dir];
}
root = head.son[1];
- end_add:
+end_add:
/* Make root black */
root->color = EINA_RBTREE_BLACK;
}
EAPI Eina_Rbtree *
-eina_rbtree_inline_remove(Eina_Rbtree *root, Eina_Rbtree *node, Eina_Rbtree_Cmp_Node_Cb cmp, const void *data)
+eina_rbtree_inline_remove(Eina_Rbtree *root,
+ Eina_Rbtree *node,
+ Eina_Rbtree_Cmp_Node_Cb cmp,
+ const void *data)
{
Eina_Rbtree head;
Eina_Rbtree *q, *p;
Eina_Rbtree_Direction dir;
EINA_SAFETY_ON_NULL_RETURN_VAL(node, root);
- EINA_SAFETY_ON_NULL_RETURN_VAL(cmp, root);
+ EINA_SAFETY_ON_NULL_RETURN_VAL( cmp, root);
- if (!root || !node) return root;
+ if (!root || !node)
+ return root;
memset(&head, 0, sizeof(Eina_Rbtree));
/* Search and push a red down */
while (q->son[dir] != NULL)
{
- Eina_Rbtree_Direction last = dir;
- Eina_Rbtree *g;
-
- /* Update helpers */
- g = p; p = q;
- q = q->son[dir];
- dir = cmp(q, node, (void*) data);
-
- /* Save parent node found */
- if (q == node)
- f = p;
-
- /* Push the red node down */
- if (!_eina_rbtree_is_red(q)
- && !_eina_rbtree_is_red(q->son[dir]))
- {
- if (_eina_rbtree_is_red(q->son[!dir]))
- q = p->son[last] = _eina_rbtree_inline_single_rotation(q, dir);
- else if (!_eina_rbtree_is_red(q->son[!dir])) {
- Eina_Rbtree *s = p->son[!last];
-
- if (s != NULL)
- {
- if (!_eina_rbtree_is_red(s->son[EINA_RBTREE_LEFT])
- && !_eina_rbtree_is_red(s->son[EINA_RBTREE_RIGHT]))
- {
- /* Color flip */
- p->color = EINA_RBTREE_BLACK;
- p->son[EINA_RBTREE_LEFT]->color = EINA_RBTREE_RED;
- p->son[EINA_RBTREE_RIGHT]->color = EINA_RBTREE_RED;
- }
- else
- {
- Eina_Rbtree_Direction dir2;
-
- dir2 = g->son[1] == p ? EINA_RBTREE_RIGHT : EINA_RBTREE_LEFT;
-
- if (_eina_rbtree_is_red(s->son[last]))
- {
- g->son[dir2] = _eina_rbtree_inline_double_rotation(p, last);
- if (f == g)
- {
- p = g->son[dir2]->son[last];
- f = g->son[dir2];
- }
- }
- else if (_eina_rbtree_is_red(s->son[!last]))
- {
- g->son[dir2] = _eina_rbtree_inline_single_rotation(p, last);
- if (f == g)
- {
- p = g->son[dir2]->son[last];
- f = g->son[dir2];
- }
- }
-
- /* Ensure correct coloring */
- q->color = g->son[dir2]->color = EINA_RBTREE_RED;
- g->son[dir2]->son[EINA_RBTREE_LEFT]->color = EINA_RBTREE_BLACK;
- g->son[dir2]->son[EINA_RBTREE_RIGHT]->color = EINA_RBTREE_BLACK;
- }
- }
- }
- }
+ Eina_Rbtree_Direction last = dir;
+ Eina_Rbtree *g;
+
+ /* Update helpers */
+ g = p; p = q;
+ q = q->son[dir];
+ dir = cmp(q, node, (void *)data);
+
+ /* Save parent node found */
+ if (q == node)
+ f = p;
+
+ /* Push the red node down */
+ if (!_eina_rbtree_is_red(q)
+ && !_eina_rbtree_is_red(q->son[dir]))
+ {
+ if (_eina_rbtree_is_red(q->son[!dir]))
+ q = p->son[last] = _eina_rbtree_inline_single_rotation(q, dir);
+ else if (!_eina_rbtree_is_red(q->son[!dir]))
+ {
+ Eina_Rbtree *s = p->son[!last];
+
+ if (s != NULL)
+ {
+ if (!_eina_rbtree_is_red(s->son[EINA_RBTREE_LEFT])
+ && !_eina_rbtree_is_red(s->son[EINA_RBTREE_RIGHT]))
+ {
+/* Color flip */
+ p->color = EINA_RBTREE_BLACK;
+ p->son[EINA_RBTREE_LEFT]->color = EINA_RBTREE_RED;
+ p->son[EINA_RBTREE_RIGHT]->color = EINA_RBTREE_RED;
+ }
+ else
+ {
+ Eina_Rbtree_Direction dir2;
+
+ dir2 = g->son[1] ==
+ p ? EINA_RBTREE_RIGHT : EINA_RBTREE_LEFT;
+
+ if (_eina_rbtree_is_red(s->son[last]))
+ {
+ g->son[dir2] =
+ _eina_rbtree_inline_double_rotation(p, last);
+ if (f == g)
+ {
+ p = g->son[dir2]->son[last];
+ f = g->son[dir2];
+ }
+ }
+ else if (_eina_rbtree_is_red(s->son[!last]))
+ {
+ g->son[dir2] =
+ _eina_rbtree_inline_single_rotation(p, last);
+ if (f == g)
+ {
+ p = g->son[dir2]->son[last];
+ f = g->son[dir2];
+ }
+ }
+
+/* Ensure correct coloring */
+ q->color = g->son[dir2]->color = EINA_RBTREE_RED;
+ g->son[dir2]->son[EINA_RBTREE_LEFT]->color =
+ EINA_RBTREE_BLACK;
+ g->son[dir2]->son[EINA_RBTREE_RIGHT]->color =
+ EINA_RBTREE_BLACK;
+ }
+ }
+ }
+ }
}
/* Replace and remove if found */
if (f != NULL)
{
- /* 'q' should take the place of 'node' parent */
- f->son[f->son[1] == node] = q;
+ /* 'q' should take the place of 'node' parent */
+ f->son[f->son[1] == node] = q;
- /* Switch the link from the parent to q's son */
- p->son[p->son[1] == q] = q->son[q->son[0] == NULL];
+ /* Switch the link from the parent to q's son */
+ p->son[p->son[1] == q] = q->son[q->son[0] == NULL];
- /* Put q at the place of node */
- q->son[0] = node->son[0];
- q->son[1] = node->son[1];
- q->color = node->color;
+ /* Put q at the place of node */
+ q->son[0] = node->son[0];
+ q->son[1] = node->son[1];
+ q->color = node->color;
- /* Reset node link */
- node->son[0] = NULL;
- node->son[1] = NULL;
+ /* Reset node link */
+ node->son[0] = NULL;
+ node->son[1] = NULL;
}
root = head.son[1];
if (root != NULL)
- root->color = EINA_RBTREE_BLACK;
+ root->color = EINA_RBTREE_BLACK;
return root;
}
EAPI void
eina_rbtree_delete(Eina_Rbtree *root, Eina_Rbtree_Free_Cb func, void *data)
{
- if (!root) return ;
+ if (!root)
+ return;
EINA_SAFETY_ON_NULL_RETURN(func);
#include "eina_rectangle.h"
/*============================================================================*
- * Local *
- *============================================================================*/
+* Local *
+*============================================================================*/
/**
* @cond LOCAL
EINA_MAGIC
};
-#define EINA_MAGIC_CHECK_RECTANGLE_POOL(d) \
- do { \
- if (!EINA_MAGIC_CHECK((d), EINA_RECTANGLE_POOL_MAGIC)) \
- EINA_MAGIC_FAIL((d), EINA_RECTANGLE_POOL_MAGIC); \
- } while (0)
+#define EINA_MAGIC_CHECK_RECTANGLE_POOL(d) \
+ do { \
+ if (!EINA_MAGIC_CHECK((d), EINA_RECTANGLE_POOL_MAGIC)) { \
+ EINA_MAGIC_FAIL((d), EINA_RECTANGLE_POOL_MAGIC); } \
+ } while (0)
-#define EINA_MAGIC_CHECK_RECTANGLE_ALLOC(d) \
- do { \
- if (!EINA_MAGIC_CHECK((d), EINA_RECTANGLE_ALLOC_MAGIC)) \
- EINA_MAGIC_FAIL((d), EINA_RECTANGLE_ALLOC_MAGIC); \
- } while (0)
+#define EINA_MAGIC_CHECK_RECTANGLE_ALLOC(d) \
+ do { \
+ if (!EINA_MAGIC_CHECK((d), EINA_RECTANGLE_ALLOC_MAGIC)) { \
+ EINA_MAGIC_FAIL((d), EINA_RECTANGLE_ALLOC_MAGIC); } \
+ } while (0)
static Eina_Mempool *_eina_rectangle_alloc_mp = NULL;
static Eina_Mempool *_eina_rectangle_mp = NULL;
if (r->w == 0 || r->h == 0)
{
- eina_rectangle_free(r);
- return empty;
+ eina_rectangle_free(r);
+ return empty;
}
- start_again:
+start_again:
xw = r->x + r->w;
yh = r->y + r->h;
EINA_LIST_FOREACH(empty, l, match)
- {
- if (match->x == r->x && match->w == r->w
- && (match->y == yh || r->y == match->y + match->h))
- {
- if (match->y > r->y)
- match->y = r->y;
- match->h += r->h;
+ {
+ if (match->x == r->x && match->w == r->w
+ && (match->y == yh || r->y == match->y + match->h))
+ {
+ if (match->y > r->y)
+ match->y = r->y;
- eina_rectangle_free(r);
+ match->h += r->h;
- empty = eina_list_remove_list(empty, l);
+ eina_rectangle_free(r);
- r = match;
+ empty = eina_list_remove_list(empty, l);
- goto start_again;
- }
- else if (match->y == r->y && match->h == r->h
- && (match->x == xw || r->x == match->x + match->w))
- {
- if (match->x > r->x)
- match->x = r->x;
- match->w += r->w;
+ r = match;
- eina_rectangle_free(r);
+ goto start_again;
+ }
+ else if (match->y == r->y && match->h == r->h
+ && (match->x == xw || r->x == match->x + match->w))
+ {
+ if (match->x > r->x)
+ match->x = r->x;
- empty = eina_list_remove_list(empty, l);
+ match->w += r->w;
- r = match;
+ eina_rectangle_free(r);
- goto start_again;
- }
- }
+ empty = eina_list_remove_list(empty, l);
+
+ r = match;
+
+ goto start_again;
+ }
+ }
return eina_list_append(empty, r);
}
Eina_List *l;
EINA_LIST_FOREACH(empty, l, r)
- {
- if (r->w >= w && r->h >= h)
- {
- /* Remove l from empty */
- empty = eina_list_remove_list(empty, l);
- /* Remember x and y */
- *x = r->x;
- *y = r->y;
- /* Split r in 2 rectangle if needed (only the empty one) and insert them */
- if (r->w == w)
- {
- r->y += h;
- r->h -= h;
- }
- else if (r->h == h)
- {
- r->x += w;
- r->w -= w;
- }
- else
- {
- int rx1, ry1, rw1, rh1;
- int x2, y2, w2, h2;
-
- rx1 = r->x + w;
- ry1 = r->y;
- rw1 = r->w - w;
- /* h1 could be h or r->h */
- x2 = r->x;
- y2 = r->y + h;
- /* w2 could be w or r->w */
- h2 = r->h - h;
-
- if (rw1 * r->h > h2 * r->w)
- {
- rh1 = r->h;
- w2 = w;
- }
- else
- {
- rh1 = h;
- w2 = r->w;
- }
-
- EINA_RECTANGLE_SET(r, rx1, ry1, rw1, rh1);
- empty = _eina_rectangle_merge_list(empty, r);
-
- r = eina_rectangle_new(x2, y2, w2, h2);
- }
- if (r) empty = _eina_rectangle_merge_list(empty, r);
- /* Return empty */
- return empty;
- }
- }
+ {
+ if (r->w >= w && r->h >= h)
+ {
+ /* Remove l from empty */
+ empty = eina_list_remove_list(empty, l);
+ /* Remember x and y */
+ *x = r->x;
+ *y = r->y;
+ /* Split r in 2 rectangle if needed (only the empty one) and insert them */
+ if (r->w == w)
+ {
+ r->y += h;
+ r->h -= h;
+ }
+ else if (r->h == h)
+ {
+ r->x += w;
+ r->w -= w;
+ }
+ else
+ {
+ int rx1, ry1, rw1, rh1;
+ int x2, y2, w2, h2;
+
+ rx1 = r->x + w;
+ ry1 = r->y;
+ rw1 = r->w - w;
+ /* h1 could be h or r->h */
+ x2 = r->x;
+ y2 = r->y + h;
+ /* w2 could be w or r->w */
+ h2 = r->h - h;
+
+ if (rw1 * r->h > h2 * r->w)
+ {
+ rh1 = r->h;
+ w2 = w;
+ }
+ else
+ {
+ rh1 = h;
+ w2 = r->w;
+ }
+
+ EINA_RECTANGLE_SET(r, rx1, ry1, rw1, rh1);
+ empty = _eina_rectangle_merge_list(empty, r);
+
+ r = eina_rectangle_new(x2, y2, w2, h2);
+ }
+
+ if (r)
+ empty = _eina_rectangle_merge_list(empty, r); /* Return empty */
+
+ return empty;
+ }
+ }
*x = -1;
*y = -1;
*/
/*============================================================================*
- * Global *
- *============================================================================*/
+* Global *
+*============================================================================*/
Eina_Bool
eina_rectangle_init(void)
{
const char *choice, *tmp;
- _eina_rectangle_log_dom = eina_log_domain_register("eina_rectangle", EINA_LOG_COLOR_DEFAULT);
+ _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");
- return EINA_FALSE;
+ EINA_LOG_ERR("Could not register log domain: eina_rectangle");
+ return EINA_FALSE;
}
#ifdef EINA_DEFAULT_MEMPOOL
#endif
tmp = getenv("EINA_MEMPOOL");
if (tmp && tmp[0])
- choice = tmp;
+ choice = tmp;
_eina_rectangle_alloc_mp = eina_mempool_add
- (choice, "rectangle-alloc", NULL,
- sizeof(Eina_Rectangle_Alloc) + sizeof(Eina_Rectangle), 1024);
+ (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.");
}
_eina_rectangle_mp = eina_mempool_add
- (choice, "rectangle", NULL, sizeof(Eina_Rectangle), 256);
+ (choice, "rectangle", NULL, sizeof(Eina_Rectangle), 256);
if (!_eina_rectangle_mp)
{
ERR("Mempool for rectangle cannot be allocated in rectangle init.");
return EINA_TRUE;
- init_error:
+init_error:
eina_log_domain_unregister(_eina_rectangle_log_dom);
_eina_rectangle_log_dom = -1;
Eina_Rectangle *del;
while ((del = eina_trash_pop(&_eina_rectangles)))
- eina_mempool_free(_eina_rectangle_mp, del);
+ eina_mempool_free(_eina_rectangle_mp, del);
_eina_rectangles_count = 0;
eina_mempool_del(_eina_rectangle_alloc_mp);
}
/*============================================================================*
- * API *
- *============================================================================*/
+* API *
+*============================================================================*/
/**
* @brief Create a new rectangle.
if (_eina_rectangles)
{
- rect = eina_trash_pop(&_eina_rectangles);
- _eina_rectangles_count--;
+ rect = eina_trash_pop(&_eina_rectangles);
+ _eina_rectangles_count--;
}
else
- {
- rect = eina_mempool_malloc(_eina_rectangle_mp, sizeof (Eina_Rectangle));
- }
- if (!rect) return NULL;
+ rect = eina_mempool_malloc(_eina_rectangle_mp, sizeof (Eina_Rectangle));
+
+ if (!rect)
+ return NULL;
EINA_RECTANGLE_SET(rect, x, y, w, h);
EINA_SAFETY_ON_NULL_RETURN(rect);
if (_eina_rectangles_count > BUCKET_THRESHOLD)
- {
- eina_mempool_free(_eina_rectangle_mp, rect);
- }
+ eina_mempool_free(_eina_rectangle_mp, rect);
else
{
- eina_trash_push(&_eina_rectangles, rect);
- _eina_rectangles_count++;
+ eina_trash_push(&_eina_rectangles, rect);
+ _eina_rectangles_count++;
}
}
Eina_Rectangle_Pool *new;
new = malloc(sizeof (Eina_Rectangle_Pool));
- if (!new) return NULL;
+ if (!new)
+ return NULL;
new->head = NULL;
new->empty = eina_list_append(NULL, eina_rectangle_new(0, 0, w, h));
pool, pool->w, pool->h, pool->references);
while (pool->head)
{
- del = (Eina_Rectangle_Alloc*) pool->head;
+ del = (Eina_Rectangle_Alloc *)pool->head;
- pool->head = (EINA_INLIST_GET(del))->next;
+ pool->head = (EINA_INLIST_GET(del))->next;
- EINA_MAGIC_SET(del, EINA_MAGIC_NONE);
- eina_mempool_free(_eina_rectangle_alloc_mp, del);
+ EINA_MAGIC_SET(del, EINA_MAGIC_NONE);
+ eina_mempool_free(_eina_rectangle_alloc_mp, del);
}
while (pool->bucket)
{
- del = eina_trash_pop(&pool->bucket);
- eina_mempool_free(_eina_rectangle_alloc_mp, del);
+ del = eina_trash_pop(&pool->bucket);
+ eina_mempool_free(_eina_rectangle_alloc_mp, del);
}
- MAGIC_FREE(pool);
+ MAGIC_FREE(pool);
}
/**
DBG("pool=%p, size=(%d, %d), references=%u",
pool, pool->w, pool->h, pool->references);
- if (w <= 0 || h <= 0) return NULL;
- if (w > pool->w || h > pool->h) return NULL;
+ if (w <= 0 || h <= 0)
+ return NULL;
+
+ if (w > pool->w || h > pool->h)
+ return NULL;
/* Sort empty if dirty */
if (pool->sorted)
{
- pool->empty = eina_list_sort(pool->empty, 0, EINA_COMPARE_CB(_eina_rectangle_cmp));
- pool->sorted = EINA_TRUE;
+ pool->empty =
+ eina_list_sort(pool->empty, 0, EINA_COMPARE_CB(_eina_rectangle_cmp));
+ pool->sorted = EINA_TRUE;
}
pool->empty = _eina_rectangle_empty_space_find(pool->empty, w, h, &x, &y);
- if (x == -1) return NULL;
+ if (x == -1)
+ return NULL;
+
pool->sorted = EINA_FALSE;
if (pool->bucket_count > 0)
{
- new = eina_trash_pop(&pool->bucket);
- pool->bucket_count--;
+ new = eina_trash_pop(&pool->bucket);
+ pool->bucket_count--;
}
else
- {
- new = eina_mempool_malloc(_eina_rectangle_alloc_mp,
- sizeof (Eina_Rectangle_Alloc) + sizeof (Eina_Rectangle));
- }
- if (!new) return NULL;
+ new = eina_mempool_malloc(_eina_rectangle_alloc_mp,
+ sizeof (Eina_Rectangle_Alloc) +
+ sizeof (Eina_Rectangle));
- rect = (Eina_Rectangle*) (new + 1);
+ if (!new)
+ return NULL;
+
+ rect = (Eina_Rectangle *)(new + 1);
eina_rectangle_coords_from(rect, x, y, w, h);
pool->head = eina_inlist_prepend(pool->head, EINA_INLIST_GET(new));
EAPI void
eina_rectangle_pool_release(Eina_Rectangle *rect)
{
- Eina_Rectangle_Alloc *era = ((Eina_Rectangle_Alloc *) rect) - 1;
+ Eina_Rectangle_Alloc *era = ((Eina_Rectangle_Alloc *)rect) - 1;
Eina_Rectangle *r;
EINA_SAFETY_ON_NULL_RETURN(rect);
r = eina_rectangle_new(rect->x, rect->y, rect->w, rect->h);
if (r)
{
- era->pool->empty = _eina_rectangle_merge_list(era->pool->empty, r);
- era->pool->sorted = EINA_FALSE;
+ era->pool->empty = _eina_rectangle_merge_list(era->pool->empty, r);
+ era->pool->sorted = EINA_FALSE;
}
if (era->pool->bucket_count < BUCKET_THRESHOLD)
{
- Eina_Rectangle_Pool *pool;
+ Eina_Rectangle_Pool *pool;
- pool = era->pool;
+ pool = era->pool;
- pool->bucket_count++;
- eina_trash_push(&pool->bucket, era);
+ pool->bucket_count++;
+ eina_trash_push(&pool->bucket, era);
}
else
{
- EINA_MAGIC_SET(era, EINA_MAGIC_NONE);
- eina_mempool_free(_eina_rectangle_alloc_mp, era);
+ EINA_MAGIC_SET(era, EINA_MAGIC_NONE);
+ eina_mempool_free(_eina_rectangle_alloc_mp, era);
}
}
EAPI Eina_Rectangle_Pool *
eina_rectangle_pool_get(Eina_Rectangle *rect)
{
- Eina_Rectangle_Alloc *era = ((Eina_Rectangle_Alloc *) rect) - 1;
+ Eina_Rectangle_Alloc *era = ((Eina_Rectangle_Alloc *)rect) - 1;
EINA_SAFETY_ON_NULL_RETURN_VAL(rect, NULL);
DBG("data=%p pool=%p, size=(%d, %d), references=%u",
data, pool, pool->w, pool->h, pool->references);
- pool->data = (void*) data;
+ pool->data = (void *)data;
}
/**
EAPI Eina_Bool
eina_rectangle_pool_geometry_get(Eina_Rectangle_Pool *pool, int *w, int *h)
{
- if (!pool) return EINA_FALSE;
+ if (!pool)
+ return EINA_FALSE;
EINA_MAGIC_CHECK_RECTANGLE_POOL(pool);
EINA_SAFETY_ON_NULL_RETURN_VAL(pool, EINA_FALSE);
- if (w) *w = pool->w;
- if (h) *h = pool->h;
+ if (w)
+ *w = pool->w;
+
+ if (h)
+ *h = pool->h;
return EINA_TRUE;
}
#include "eina_safety_checks.h"
/*============================================================================*
- * Local *
- *============================================================================*/
+* Local *
+*============================================================================*/
/*============================================================================*
- * Global *
- *============================================================================*/
+* Global *
+*============================================================================*/
/**
* @internal
}
/*============================================================================*
- * API *
- *============================================================================*/
+* API *
+*============================================================================*/
/**
* @addtogroup Eina_Safety_Checks_Group Safety Checks
Eina_Bool
eina_safety_checks_init(void)
{
- EINA_ERROR_SAFETY_FAILED = eina_error_msg_static_register(EINA_ERROR_SAFETY_FAILED_STR);
+ EINA_ERROR_SAFETY_FAILED = eina_error_msg_static_register(
+ EINA_ERROR_SAFETY_FAILED_STR);
return EINA_TRUE;
}
#include "eina_share_common.h"
/*============================================================================*
- * Local *
- *============================================================================*/
+* Local *
+*============================================================================*/
/**
* @cond LOCAL
static const char EINA_MAGIC_SHARE_HEAD_STR[] = "Eina Share Head";
-#define EINA_MAGIC_CHECK_SHARE_COMMON_HEAD(d, unlock, ...) \
- do { \
- if (!EINA_MAGIC_CHECK((d), EINA_MAGIC_SHARE_HEAD)) \
- { \
- EINA_MAGIC_FAIL((d), EINA_MAGIC_SHARE_HEAD); \
- unlock; \
- return __VA_ARGS__; \
- } \
- } while (0)
-
-#define EINA_MAGIC_CHECK_SHARE_COMMON_NODE(d, _node_magic, unlock) \
- do { \
- if (!EINA_MAGIC_CHECK((d), _node_magic)) \
- { \
- unlock; \
- EINA_MAGIC_FAIL((d), _node_magic); \
- } \
- } while (0)
+#define EINA_MAGIC_CHECK_SHARE_COMMON_HEAD(d, unlock, ...) \
+ do { \
+ if (!EINA_MAGIC_CHECK((d), EINA_MAGIC_SHARE_HEAD)) \
+ { \
+ EINA_MAGIC_FAIL((d), EINA_MAGIC_SHARE_HEAD); \
+ unlock; \
+ return __VA_ARGS__; \
+ } \
+ } while (0)
+
+#define EINA_MAGIC_CHECK_SHARE_COMMON_NODE(d, _node_magic, unlock) \
+ do { \
+ if (!EINA_MAGIC_CHECK((d), _node_magic)) \
+ { \
+ unlock; \
+ EINA_MAGIC_FAIL((d), _node_magic); \
+ } \
+ } while (0)
#ifdef EINA_SHARE_USAGE
-typedef struct _Eina_Share_Common_Population Eina_Share_Common_Population;
-#endif
+typedef struct _Eina_Share_Common_Population Eina_Share_Common_Population;
+#endif
-typedef struct _Eina_Share_Common Eina_Share_Common;
-typedef struct _Eina_Share_Common_Node Eina_Share_Common_Node;
-typedef struct _Eina_Share_Common_Head Eina_Share_Common_Head;
+typedef struct _Eina_Share_Common Eina_Share_Common;
+typedef struct _Eina_Share_Common_Node Eina_Share_Common_Node;
+typedef struct _Eina_Share_Common_Head Eina_Share_Common_Head;
int _eina_share_common_log_dom = -1;
-struct _Eina_Share
+struct _Eina_Share
{
Eina_Share_Common *share;
Eina_Magic node_magic;
EINA_MAGIC
- unsigned int length;
- unsigned int references;
- char str[];
+ unsigned int length;
+ unsigned int references;
+ char str[];
};
struct _Eina_Share_Common_Head
EINA_RBTREE;
EINA_MAGIC
- int hash;
+ int hash;
#ifdef EINA_SHARE_COMMON_USAGE
- int population;
+ int population;
#endif
Eina_Share_Common_Node *head;
- Eina_Share_Common_Node builtin_node;
+ Eina_Share_Common_Node builtin_node;
};
#ifdef EFL_HAVE_THREADS
# ifdef EFL_HAVE_POSIX_THREADS
static pthread_mutex_t _mutex_big = PTHREAD_MUTEX_INITIALIZER;
-# define SHARE_COMMON_LOCK_BIG() if(_share_common_threads_activated) pthread_mutex_lock(&_mutex_big)
-# define SHARE_COMMON_UNLOCK_BIG() if(_share_common_threads_activated) pthread_mutex_unlock(&_mutex_big)
+# define SHARE_COMMON_LOCK_BIG() if(_share_common_threads_activated) \
+ pthread_mutex_lock(&_mutex_big)
+# define SHARE_COMMON_UNLOCK_BIG() if(_share_common_threads_activated) \
+ pthread_mutex_unlock(&_mutex_big)
# else /* EFL_HAVE_WIN32_THREADS */
static HANDLE _mutex_big = NULL;
-# define SHARE_COMMON_LOCK_BIG() if(_share_common_threads_activated) WaitForSingleObject(_mutex_big, INFINITE)
-# define SHARE_COMMON_UNLOCK_BIG() if(_share_common_threads_activated) ReleaseMutex(_mutex_big)
+# define SHARE_COMMON_LOCK_BIG() if(_share_common_threads_activated) \
+ WaitForSingleObject(_mutex_big, INFINITE)
+# define SHARE_COMMON_UNLOCK_BIG() if(_share_common_threads_activated) \
+ ReleaseMutex(_mutex_big)
# endif /* EFL_HAVE_WIN32_THREADS */
#else /* EFL_HAVE_THREADS */
static Eina_Share_Common_Population population = { 0, 0 };
static Eina_Share_Common_Population population_group[4] =
- {
- { 0, 0 },
- { 0, 0 },
- { 0, 0 },
- { 0, 0 }
- };
+{
+ { 0, 0 },
+ { 0, 0 },
+ { 0, 0 },
+ { 0, 0 }
+};
static void
_eina_share_common_population_init(Eina_Share *share)
{
unsigned int i;
- for (i = 0; i < sizeof (share->population_group) / sizeof (share->population_group[0]); ++i)
+ for (i = 0;
+ i < sizeof (share->population_group) /
+ sizeof (share->population_group[0]);
+ ++i)
{
share->population_group[i].count = 0;
share->population_group[i].max = 0;
share->population.count = 0;
share->population.max = 0;
- for (i = 0; i < sizeof (share->population_group) / sizeof (share->population_group[0]); ++i)
+ for (i = 0;
+ i < sizeof (share->population_group) /
+ sizeof (share->population_group[0]);
+ ++i)
{
share->population_group[i].count = 0;
share->population_group[i].max = 0;
{
unsigned int i;
- fprintf(stderr, "eina share_common statistic:\n");
- fprintf(stderr, " * maximum shared strings : %i\n", share->population.max);
- fprintf(stderr, " * maximum shared strings per node : %i\n", share->max_node_population);
-
- for (i = 0; i < sizeof (share->population_group) / sizeof (share->population_group[0]); ++i)
- fprintf(stderr, "DDD: %i strings of length %i, max strings: %i\n", share->population_group[i].count, i, share->population_group[i].max);
+ fprintf(stderr, "eina share_common statistic:\n");
+ fprintf(stderr,
+ " * maximum shared strings : %i\n",
+ share->population.max);
+ fprintf(stderr,
+ " * maximum shared strings per node : %i\n",
+ share->max_node_population);
+
+ for (i = 0;
+ i < sizeof (share->population_group) /
+ sizeof (share->population_group[0]);
+ ++i)
+ fprintf(stderr,
+ "DDD: %i strings of length %i, max strings: %i\n",
+ share->population_group[i].count,
+ i,
+ share->population_group[i].max);
}
void
share->population.count++;
if (share->population.count > share->population.max)
- share->population.max = share->population.count;
+ share->population.max = share->population.count;
if (slen < 4)
{
- share->population_group[slen].count++;
- if (share->population_group[slen].count > share->population_group[slen].max)
- share->population_group[slen].max = share->population_group[slen].count;
+ share->population_group[slen].count++;
+ if (share->population_group[slen].count >
+ share->population_group[slen].max)
+ share->population_group[slen].max =
+ share->population_group[slen].count;
}
SHARE_COMMON_UNLOCK_BIG();
share->population.count--;
if (slen < 4)
- share->population_group[slen].count--;
+ share->population_group[slen].count--;
SHARE_COMMON_UNLOCK_BIG();
}
static void
-_eina_share_common_population_head_init(Eina_Share *share, Eina_Share_Common_Head *head)
+_eina_share_common_population_head_init(Eina_Share *share,
+ Eina_Share_Common_Head *head)
{
head->population = 1;
}
static void
-_eina_share_common_population_head_add(Eina_Share *share, Eina_Share_Common_Head *head)
+_eina_share_common_population_head_add(Eina_Share *share,
+ Eina_Share_Common_Head *head)
{
head->population++;
if (head->population > share->max_node_population)
- share->max_node_population = head->population;
+ share->max_node_population = head->population;
}
static void
-_eina_share_common_population_head_del(Eina_Share *share, Eina_Share_Common_Head *head)
+_eina_share_common_population_head_del(Eina_Share *share,
+ Eina_Share_Common_Head *head)
{
head->population--;
}
#else /* EINA_SHARE_COMMON_USAGE undefined */
-static void _eina_share_common_population_init(__UNUSED__ Eina_Share *share) {}
-static void _eina_share_common_population_shutdown(__UNUSED__ Eina_Share *share) {}
-static void _eina_share_common_population_stats(__UNUSED__ Eina_Share *share) {}
-void eina_share_common_population_add(__UNUSED__ Eina_Share *share, __UNUSED__ int slen) {}
-void eina_share_common_population_del(__UNUSED__ Eina_Share *share, __UNUSED__ int slen) {}
-static void _eina_share_common_population_head_init(__UNUSED__ Eina_Share *share, __UNUSED__ Eina_Share_Common_Head *head) {}
-static void _eina_share_common_population_head_add(__UNUSED__ Eina_Share *share, __UNUSED__ Eina_Share_Common_Head *head) {}
-static void _eina_share_common_population_head_del(__UNUSED__ Eina_Share *share, __UNUSED__ Eina_Share_Common_Head *head) {}
+static void _eina_share_common_population_init(__UNUSED__ Eina_Share *share) {
+}
+static void _eina_share_common_population_shutdown(__UNUSED__ Eina_Share *share)
+{
+}
+static void _eina_share_common_population_stats(__UNUSED__ Eina_Share *share) {
+}
+void eina_share_common_population_add(__UNUSED__ Eina_Share *share,
+ __UNUSED__ int slen) {
+}
+void eina_share_common_population_del(__UNUSED__ Eina_Share *share,
+ __UNUSED__ int slen) {
+}
+static void _eina_share_common_population_head_init(
+ __UNUSED__ Eina_Share *share,
+ __UNUSED__ Eina_Share_Common_Head *head) {
+}
+static void _eina_share_common_population_head_add(
+ __UNUSED__ Eina_Share *share,
+ __UNUSED__
+ Eina_Share_Common_Head *head) {
+}
+static void _eina_share_common_population_head_del(
+ __UNUSED__ Eina_Share *share,
+ __UNUSED__
+ Eina_Share_Common_Head *head) {
+}
#endif
static int
-_eina_share_common_cmp(const Eina_Share_Common_Head *ed, const int *hash, __UNUSED__ int length, __UNUSED__ void *data)
+_eina_share_common_cmp(const Eina_Share_Common_Head *ed,
+ const int *hash,
+ __UNUSED__ int length,
+ __UNUSED__ void *data)
{
EINA_MAGIC_CHECK_SHARE_COMMON_HEAD(ed, , 0);
}
static Eina_Rbtree_Direction
-_eina_share_common_node(const Eina_Share_Common_Head *left, const Eina_Share_Common_Head *right, __UNUSED__ void *data)
+_eina_share_common_node(const Eina_Share_Common_Head *left,
+ const Eina_Share_Common_Head *right,
+ __UNUSED__ void *data)
{
- EINA_MAGIC_CHECK_SHARE_COMMON_HEAD(left, , 0);
+ EINA_MAGIC_CHECK_SHARE_COMMON_HEAD(left, , 0);
EINA_MAGIC_CHECK_SHARE_COMMON_HEAD(right, , 0);
if (left->hash - right->hash < 0)
- return EINA_RBTREE_LEFT;
+ return EINA_RBTREE_LEFT;
+
return EINA_RBTREE_RIGHT;
}
while (ed->head)
{
- Eina_Share_Common_Node *el = ed->head;
+ Eina_Share_Common_Node *el = ed->head;
- ed->head = ed->head->next;
- if (el != &ed->builtin_node)
- MAGIC_FREE(el);
+ ed->head = ed->head->next;
+ if (el != &ed->builtin_node)
+ MAGIC_FREE(el);
}
- MAGIC_FREE(ed);
+ MAGIC_FREE(ed);
}
static void
-_eina_share_common_node_init(Eina_Share_Common_Node *node, const char *str, int slen, unsigned int null_size, Eina_Magic node_magic)
+_eina_share_common_node_init(Eina_Share_Common_Node *node,
+ const char *str,
+ int slen,
+ unsigned int null_size,
+ Eina_Magic node_magic)
{
EINA_MAGIC_SET(node, node_magic);
node->references = 1;
head = malloc(head_size + slen);
if (!head)
- eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+ eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
return head;
}
static const char *
-_eina_share_common_add_head(Eina_Share *share, Eina_Share_Common_Head **p_bucket, int hash, const char *str, unsigned int slen, unsigned int null_size)
+_eina_share_common_add_head(Eina_Share *share,
+ Eina_Share_Common_Head **p_bucket,
+ int hash,
+ const char *str,
+ unsigned int slen,
+ unsigned int null_size)
{
Eina_Rbtree **p_tree = (Eina_Rbtree **)p_bucket;
Eina_Share_Common_Head *head;
head = _eina_share_common_head_alloc(slen + null_size);
if (!head)
- return NULL;
+ return NULL;
EINA_MAGIC_SET(head, EINA_MAGIC_SHARE_HEAD);
head->hash = hash;
head->head = &head->builtin_node;
- _eina_share_common_node_init(head->head, str, slen, null_size, share->node_magic);
+ _eina_share_common_node_init(head->head,
+ str,
+ slen,
+ null_size,
+ share->node_magic);
head->head->next = NULL;
_eina_share_common_population_head_init(share, head);
*p_tree = eina_rbtree_inline_insert
- (*p_tree, EINA_RBTREE_GET(head),
- EINA_RBTREE_CMP_NODE_CB(_eina_share_common_node), NULL);
+ (*p_tree, EINA_RBTREE_GET(head),
+ EINA_RBTREE_CMP_NODE_CB(_eina_share_common_node), NULL);
return head->head->str;
}
static void
-_eina_share_common_del_head(Eina_Share_Common_Head **p_bucket, Eina_Share_Common_Head *head)
+_eina_share_common_del_head(Eina_Share_Common_Head **p_bucket,
+ Eina_Share_Common_Head *head)
{
Eina_Rbtree **p_tree = (Eina_Rbtree **)p_bucket;
*p_tree = eina_rbtree_inline_remove
- (*p_tree, EINA_RBTREE_GET(head),
- EINA_RBTREE_CMP_NODE_CB(_eina_share_common_node), NULL);
+ (*p_tree, EINA_RBTREE_GET(head),
+ EINA_RBTREE_CMP_NODE_CB(_eina_share_common_node), NULL);
- MAGIC_FREE(head);
+ MAGIC_FREE(head);
}
static inline Eina_Bool
-_eina_share_common_node_eq(const Eina_Share_Common_Node *node, const char *str, unsigned int slen)
+_eina_share_common_node_eq(const Eina_Share_Common_Node *node,
+ const char *str,
+ unsigned int slen)
{
return ((node->length == slen) &&
- (memcmp(node->str, str, slen) == 0));
+ (memcmp(node->str, str, slen) == 0));
}
static Eina_Share_Common_Node *
-_eina_share_common_head_find(Eina_Share_Common_Head *head, const char *str, unsigned int slen)
+_eina_share_common_head_find(Eina_Share_Common_Head *head,
+ const char *str,
+ unsigned int slen)
{
Eina_Share_Common_Node *node, *prev;
node = head->head;
if (_eina_share_common_node_eq(node, str, slen))
- return node;
+ return node;
prev = node;
node = node->next;
for (; node != NULL; prev = node, node = node->next)
- if (_eina_share_common_node_eq(node, str, slen))
- {
- /* promote node, make hot items be at the beginning */
- prev->next = node->next;
- node->next = head->head;
- head->head = node;
- return node;
- }
+ if (_eina_share_common_node_eq(node, str, slen))
+ {
+ /* promote node, make hot items be at the beginning */
+ prev->next = node->next;
+ node->next = head->head;
+ head->head = node;
+ return node;
+ }
return NULL;
}
static Eina_Bool
-_eina_share_common_head_remove_node(Eina_Share_Common_Head *head, const Eina_Share_Common_Node *node)
+_eina_share_common_head_remove_node(Eina_Share_Common_Head *head,
+ const Eina_Share_Common_Node *node)
{
Eina_Share_Common_Node *cur, *prev;
if (head->head == node)
{
- head->head = node->next;
- return 1;
+ head->head = node->next;
+ return 1;
}
prev = head->head;
cur = head->head->next;
for (; cur != NULL; prev = cur, cur = cur->next)
- if (cur == node)
- {
- prev->next = cur->next;
- return 1;
- }
+ if (cur == node)
+ {
+ prev->next = cur->next;
+ return 1;
+ }
return 0;
}
static Eina_Share_Common_Head *
_eina_share_common_find_hash(Eina_Share_Common_Head *bucket, int hash)
{
- return (Eina_Share_Common_Head*) eina_rbtree_inline_lookup
- (EINA_RBTREE_GET(bucket), &hash, 0,
- EINA_RBTREE_CMP_KEY_CB(_eina_share_common_cmp), NULL);
+ return (Eina_Share_Common_Head *)eina_rbtree_inline_lookup
+ (EINA_RBTREE_GET(bucket), &hash, 0,
+ EINA_RBTREE_CMP_KEY_CB(_eina_share_common_cmp), NULL);
}
static Eina_Share_Common_Node *
node = malloc(node_size + slen + null_size);
if (!node)
- eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+ eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
return node;
}
}
static Eina_Bool
-eina_iterator_array_check(const Eina_Rbtree *rbtree __UNUSED__, Eina_Share_Common_Head *head, struct dumpinfo *fdata)
+eina_iterator_array_check(const Eina_Rbtree *rbtree __UNUSED__,
+ Eina_Share_Common_Head *head,
+ struct dumpinfo *fdata)
{
Eina_Share_Common_Node *node;
fdata->used += sizeof(Eina_Share_Common_Head);
for (node = head->head; node; node = node->next)
{
- printf("DDD: %5i %5i ", node->length, node->references);
- printf("'%s'\n", ((char *)node) + sizeof(Eina_Share_Common_Node));
- fdata->used += sizeof(Eina_Share_Common_Node);
- fdata->used += node->length;
- fdata->saved += (node->references - 1) * node->length;
- fdata->dups += node->references - 1;
- fdata->unique++;
+ printf("DDD: %5i %5i ", node->length, node->references);
+ printf("'%s'\n", ((char *)node) + sizeof(Eina_Share_Common_Node));
+ fdata->used += sizeof(Eina_Share_Common_Node);
+ fdata->used += node->length;
+ fdata->saved += (node->references - 1) * node->length;
+ fdata->dups += node->references - 1;
+ fdata->unique++;
}
SHARE_COMMON_UNLOCK_BIG();
/*============================================================================*
- * Global *
- *============================================================================*/
+* Global *
+*============================================================================*/
/**
* @internal
* @see eina_init()
*/
Eina_Bool
-eina_share_common_init(Eina_Share **_share, Eina_Magic node_magic, const char *node_magic_STR)
+eina_share_common_init(Eina_Share **_share,
+ Eina_Magic node_magic,
+ const char *node_magic_STR)
{
Eina_Share *share;
share = *_share = calloc(sizeof(Eina_Share), 1);
if (!share)
return EINA_FALSE;
+
if (_eina_share_common_log_dom < 0) /*Only register if not already */
- _eina_share_common_log_dom = eina_log_domain_register("eina_share", EINA_LOG_COLOR_DEFAULT);
+ _eina_share_common_log_dom = eina_log_domain_register(
+ "eina_share",
+ EINA_LOG_COLOR_DEFAULT);
+
if (_eina_share_common_log_dom < 0)
{
- EINA_LOG_ERR("Could not register log domain: eina_share_common");
- return EINA_FALSE;
+ EINA_LOG_ERR("Could not register log domain: eina_share_common");
+ return EINA_FALSE;
}
share->share = calloc(1, sizeof(Eina_Share_Common));
eina_log_domain_unregister(_eina_share_common_log_dom);
_eina_share_common_log_dom = -1;
}
+
return EINA_FALSE;
- }
+ }
+
share->node_magic = node_magic;
-#define EMS(n) eina_magic_string_static_set(n, n##_STR)
+#define EMS(n) eina_magic_string_static_set(n, n ## _STR)
EMS(EINA_MAGIC_SHARE);
EMS(EINA_MAGIC_SHARE_HEAD);
EMS(node_magic);
/* remove any string still in the table */
for (i = 0; i < EINA_SHARE_COMMON_BUCKETS; i++)
{
- eina_rbtree_delete(EINA_RBTREE_GET(share->share->buckets[i]), EINA_RBTREE_FREE_CB(_eina_share_common_head_free), NULL);
- share->share->buckets[i] = NULL;
+ eina_rbtree_delete(EINA_RBTREE_GET(
+ share->share->buckets[i]),
+ EINA_RBTREE_FREE_CB(
+ _eina_share_common_head_free), NULL);
+ share->share->buckets[i] = NULL;
}
MAGIC_FREE(share->share);
#endif
/*============================================================================*
- * API *
- *============================================================================*/
+* API *
+*============================================================================*/
/**
* @cond LOCAL
*/
const char *
-eina_share_common_add_length(Eina_Share *share, const char *str, unsigned int slen, unsigned int null_size)
+eina_share_common_add_length(Eina_Share *share,
+ const char *str,
+ unsigned int slen,
+ unsigned int null_size)
{
Eina_Share_Common_Head **p_bucket, *ed;
Eina_Share_Common_Node *el;
int hash_num, hash;
- if (!str) return NULL;
+ if (!str)
+ return NULL;
eina_share_common_population_add(share, slen);
if (slen <= 0)
- return NULL;
+ return NULL;
hash = eina_hash_superfast(str, slen);
hash_num = hash & 0xFF;
ed = _eina_share_common_find_hash(*p_bucket, hash);
if (!ed)
{
- const char *s = _eina_share_common_add_head(share, p_bucket, hash, str, slen, null_size);
+ const char *s = _eina_share_common_add_head(share,
+ p_bucket,
+ hash,
+ str,
+ slen,
+ null_size);
SHARE_COMMON_UNLOCK_BIG();
return s;
}
el = _eina_share_common_head_find(ed, str, slen);
if (el)
{
- EINA_MAGIC_CHECK_SHARE_COMMON_NODE(el, share->node_magic, SHARE_COMMON_UNLOCK_BIG());
- el->references++;
- SHARE_COMMON_UNLOCK_BIG();
- return el->str;
+ EINA_MAGIC_CHECK_SHARE_COMMON_NODE(el,
+ share->node_magic,
+ SHARE_COMMON_UNLOCK_BIG());
+ el->references++;
+ SHARE_COMMON_UNLOCK_BIG();
+ return el->str;
}
el = _eina_share_common_node_alloc(slen, null_size);
if (!el)
{
- SHARE_COMMON_UNLOCK_BIG();
- return NULL;
+ SHARE_COMMON_UNLOCK_BIG();
+ return NULL;
}
_eina_share_common_node_init(el, str, slen, null_size, share->node_magic);
{
Eina_Share_Common_Node *node;
- if (!str) return NULL;
+ if (!str)
+ return NULL;
SHARE_COMMON_LOCK_BIG();
node = _eina_share_common_node_from_str(str, share->node_magic);
Eina_Share_Common_Node *node;
int hash_num, hash;
- if (!str) return;
+ if (!str)
+ return;
SHARE_COMMON_LOCK_BIG();
eina_share_common_population_del(share, slen);
if (node->references > 1)
{
- node->references--;
- DBG("str=%p refs=%u", str, node->references);
- SHARE_COMMON_UNLOCK_BIG();
- return;
+ node->references--;
+ DBG("str=%p refs=%u", str, node->references);
+ SHARE_COMMON_UNLOCK_BIG();
+ return;
}
DBG("str=%p refs=0, delete.", str);
p_bucket = share->share->buckets + hash_num;
ed = _eina_share_common_find_hash(*p_bucket, hash);
if (!ed)
- goto on_error;
+ goto on_error;
EINA_MAGIC_CHECK_SHARE_COMMON_HEAD(ed, SHARE_COMMON_UNLOCK_BIG());
if (!_eina_share_common_head_remove_node(ed, node))
- goto on_error;
+ goto on_error;
if (node != &ed->builtin_node)
- MAGIC_FREE(node);
+ MAGIC_FREE(node);
if (!ed->head)
- _eina_share_common_del_head(p_bucket, ed);
+ _eina_share_common_del_head(p_bucket, ed);
else
- _eina_share_common_population_head_del(share, ed);
+ _eina_share_common_population_head_del(share, ed);
SHARE_COMMON_UNLOCK_BIG();
return;
- on_error:
+on_error:
SHARE_COMMON_UNLOCK_BIG();
/* possible segfault happened before here, but... */
CRITICAL("EEEK trying to del non-shared share_common \"%s\"", str);
const Eina_Share_Common_Node *node;
if (!str)
- return -1;
+ return -1;
node = _eina_share_common_node_from_str(str, share->node_magic);
return node->length;
}
void
-eina_share_common_dump(Eina_Share *share, void (* additional_dump)(struct dumpinfo *), int used)
+eina_share_common_dump(Eina_Share *share, void (*additional_dump)(
+ struct dumpinfo *), int used)
{
Eina_Iterator *it;
unsigned int i;
struct dumpinfo di;
- if (!share) return;
+ if (!share)
+ return;
+
di.used = used;
di.saved = 0;
di.dups = 0;
SHARE_COMMON_LOCK_BIG();
for (i = 0; i < EINA_SHARE_COMMON_BUCKETS; i++)
{
- if (!share->share->buckets[i]) continue;
-// printf("DDD: BUCKET # %i (HEAD=%i, NODE=%i)\n", i,
+ if (!share->share->buckets[i])
+ continue; // printf("DDD: BUCKET # %i (HEAD=%i, NODE=%i)\n", i,
+
// sizeof(Eina_Share_Common_Head), sizeof(Eina_Share_Common_Node));
- it = eina_rbtree_iterator_prefix((Eina_Rbtree *)share->share->buckets[i]);
- eina_iterator_foreach(it, EINA_EACH(eina_iterator_array_check), &di);
- eina_iterator_free(it);
+ it = eina_rbtree_iterator_prefix(
+ (Eina_Rbtree *)share->share->buckets[i]);
+ eina_iterator_foreach(it, EINA_EACH(eina_iterator_array_check), &di);
+ eina_iterator_free(it);
}
if (additional_dump)
additional_dump(&di);
+
#ifdef EINA_SHARE_COMMON_USAGE
/* One character strings are not counted in the hash. */
di.saved += share->population_group[0].count * sizeof(char);
#endif
printf("DDD:-------------------\n");
printf("DDD: usage (bytes) = %i, saved = %i (%3.0f%%)\n",
- di.used, di.saved, di.used ? (di.saved * 100.0 / di.used) : 0.0);
+ di.used, di.saved, di.used ? (di.saved * 100.0 / di.used) : 0.0);
printf("DDD: unique: %d, duplicates: %d (%3.0f%%)\n",
- di.unique, di.dups, di.unique ? (di.dups * 100.0 / di.unique) : 0.0);
+ di.unique, di.dups, di.unique ? (di.dups * 100.0 / di.unique) : 0.0);
#ifdef EINA_SHARE_COMMON_USAGE
- printf("DDD: Allocated strings: %i\n", share->population.count);
+ printf("DDD: Allocated strings: %i\n", share->population.count);
printf("DDD: Max allocated strings: %i\n", share->population.max);
- for (i = 0; i < sizeof (share->population_group) / sizeof (share->population_group[0]); ++i)
- fprintf(stderr, "DDD: %i strings of length %i, max strings: %i\n", share->population_group[i].count, i, share->population_group[i].max);
+ for (i = 0;
+ i < sizeof (share->population_group) /
+ sizeof (share->population_group[0]);
+ ++i)
+ fprintf(stderr,
+ "DDD: %i strings of length %i, max strings: %i\n",
+ share->population_group[i].count,
+ i,
+ share->population_group[i].max);
#endif
SHARE_COMMON_UNLOCK_BIG();
#include "eina_types.h"
#include "eina_magic.h"
-typedef struct _Eina_Share Eina_Share;
+typedef struct _Eina_Share Eina_Share;
struct dumpinfo
{
int used, saved, dups, unique;
};
-Eina_Bool eina_share_common_init(Eina_Share **share, Eina_Magic node_magic, const char *node_magic_STR);
-Eina_Bool eina_share_common_shutdown(Eina_Share **share);
-const char *eina_share_common_add_length(Eina_Share *share, const char *str, unsigned int slen, unsigned int null_size) EINA_WARN_UNUSED_RESULT;
+Eina_Bool eina_share_common_init(Eina_Share **share,
+ Eina_Magic node_magic,
+ const char *node_magic_STR);
+Eina_Bool eina_share_common_shutdown(Eina_Share **share);
+const char *eina_share_common_add_length(Eina_Share *share,
+ const char *str,
+ unsigned int slen,
+ unsigned int null_size)
+EINA_WARN_UNUSED_RESULT;
const char *eina_share_common_ref(Eina_Share *share, const char *str);
-void eina_share_common_del(Eina_Share *share, const char *str);
-int eina_share_common_length(Eina_Share *share, const char *str) EINA_CONST EINA_WARN_UNUSED_RESULT;
-void eina_share_common_dump(Eina_Share *share, void (* additional_dump)(struct dumpinfo *), int used);
+void eina_share_common_del(Eina_Share *share, const char *str);
+int eina_share_common_length(Eina_Share *share,
+ const char *str) EINA_CONST
+EINA_WARN_UNUSED_RESULT;
+void eina_share_common_dump(Eina_Share *share, void (*additional_dump)(
+ struct dumpinfo *), int used);
/* Population functions */
-void eina_share_common_population_add(Eina_Share *share, int slen);
-void eina_share_common_population_del(Eina_Share *share, int slen);
+void eina_share_common_population_add(Eina_Share *share, int slen);
+void eina_share_common_population_del(Eina_Share *share, int slen);
/* Share logging */
#ifdef CRITICAL
#include "eina_str.h"
/*============================================================================*
- * Local *
- *============================================================================*/
+* Local *
+*============================================================================*/
/**
* @cond LOCAL
*/
static inline Eina_Bool
eina_str_has_suffix_helper(const char *str,
- const char *suffix,
- int (*cmp)(const char *, const char *))
+ const char *suffix,
+ int (*cmp)(const char *, const char *))
{
size_t str_len;
size_t suffix_len;
str_len = strlen(str);
suffix_len = eina_strlen_bounded(suffix, str_len);
if (suffix_len == (size_t)-1)
- return EINA_FALSE;
+ return EINA_FALSE;
return cmp(str + str_len - suffix_len, suffix) == 0;
}
static inline char **
-eina_str_split_full_helper(const char *str, const char *delim, int max_tokens, unsigned int *elements)
+eina_str_split_full_helper(const char *str,
+ const char *delim,
+ int max_tokens,
+ unsigned int *elements)
{
char *s, **str_array;
const char *src;
dlen = strlen(delim);
if (dlen == 0)
{
- if (elements) *elements = 0;
- return NULL;
+ if (elements)
+ *elements = 0;
+
+ return NULL;
}
tokens = 0;
/* count tokens and check strlen(str) */
while (*src != '\0')
{
- const char *d = delim, *d_end = d + dlen;
- const char *tmp = src;
- for (; (d < d_end) && (*tmp != '\0'); d++, tmp++)
- {
- if (EINA_LIKELY(*d != *tmp))
- break;
- }
- if (EINA_UNLIKELY(d == d_end))
- {
- src = tmp;
- tokens++;
- }
- else
- src++;
+ const char *d = delim, *d_end = d + dlen;
+ const char *tmp = src;
+ for (; (d < d_end) && (*tmp != '\0'); d++, tmp++)
+ {
+ if (EINA_LIKELY(*d != *tmp))
+ break;
+ }
+ if (EINA_UNLIKELY(d == d_end))
+ {
+ src = tmp;
+ tokens++;
+ }
+ else
+ src++;
}
len = src - str;
if ((max_tokens > 0) && (tokens > (unsigned int)max_tokens))
- tokens = max_tokens;
+ tokens = max_tokens;
str_array = malloc(sizeof(char *) * (tokens + 2));
if (!str_array)
{
- if (elements) *elements = 0;
- return NULL;
+ if (elements)
+ *elements = 0;
+
+ return NULL;
}
s = malloc(len + 1);
if (!s)
{
- free(str_array);
- if (elements) *elements = 0;
- return NULL;
+ free(str_array);
+ if (elements)
+ *elements = 0;
+
+ return NULL;
}
/* copy tokens and string */
src = str;
while (*src != '\0')
{
- const char *d = delim, *d_end = d + dlen;
- const char *tmp = src;
- for (; (d < d_end) && (*tmp != '\0'); d++, tmp++)
- {
- if (EINA_LIKELY(*d != *tmp))
- break;
- }
- if (EINA_UNLIKELY(d == d_end))
- {
- src = tmp;
- *s = '\0';
- s += dlen;
- tokens++;
- str_array[tokens] = s;
- }
- else
- {
- *s = *src;
- s++;
- src++;
- }
+ const char *d = delim, *d_end = d + dlen;
+ const char *tmp = src;
+ for (; (d < d_end) && (*tmp != '\0'); d++, tmp++)
+ {
+ if (EINA_LIKELY(*d != *tmp))
+ break;
+ }
+ if (EINA_UNLIKELY(d == d_end))
+ {
+ src = tmp;
+ *s = '\0';
+ s += dlen;
+ tokens++;
+ str_array[tokens] = s;
+ }
+ else
+ {
+ *s = *src;
+ s++;
+ src++;
+ }
}
*s = '\0';
str_array[tokens + 1] = NULL;
- if (elements) *elements = (tokens + 1);
+ if (elements)
+ *elements = (tokens + 1);
+
return str_array;
}
*/
/*============================================================================*
- * Global *
- *============================================================================*/
+* Global *
+*============================================================================*/
/*============================================================================*
- * API *
- *============================================================================*/
+* API *
+*============================================================================*/
/**
* @addtogroup Eina_String_Group String
/* Copy as many bytes as will fit */
if (n != 0)
- {
- while (--n != 0)
- {
- if ((*d++ = *s++) == '\0')
- break;
- }
- }
+ while (--n != 0)
+ {
+ if ((*d++ = *s++) == '\0')
+ break;
+ }
/* Not enough room in dst, add NUL and traverse rest of src */
if (n == 0)
{
- if (siz != 0)
- *d = '\0'; /* NUL-terminate dst */
- while (*s++)
- ;
+ if (siz != 0)
+ {
+ *d = '\0'; /* NUL-terminate dst */
+ }
+
+ while (*s++)
+ ;
}
- return(s - src - 1); /* count does not include NUL */
+ return(s - src - 1); /* count does not include NUL */
#endif
}
/* Find the end of dst and adjust bytes left but don't go past end */
while (n-- != 0 && *d != '\0')
- d++;
+ d++;
dlen = d - dst;
n = siz - dlen;
if (n == 0)
- return(dlen + strlen(s));
+ return(dlen + strlen(s));
+
while (*s != '\0') {
- if (n != 1) {
- *d++ = *s;
- n--;
- }
- s++;
- }
+ if (n != 1)
+ {
+ *d++ = *s;
+ n--;
+ }
+
+ s++;
+ }
*d = '\0';
- return(dlen + (s - src)); /* count does not include NUL */
+ return(dlen + (s - src)); /* count does not include NUL */
}
/**
str_len = strlen(str);
prefix_len = eina_strlen_bounded(prefix, str_len);
if (prefix_len == (size_t)-1)
- return EINA_FALSE;
+ return EINA_FALSE;
return (strncmp(str, prefix, prefix_len) == 0);
}
* @see eina_str_split()
*/
EAPI char **
-eina_str_split_full(const char *str, const char *delim, int max_tokens, unsigned int *elements)
+eina_str_split_full(const char *str,
+ const char *delim,
+ int max_tokens,
+ unsigned int *elements)
{
return eina_str_split_full_helper(str, delim, max_tokens, elements);
}
* @see eina_str_join_static()
*/
EAPI size_t
-eina_str_join_len(char *dst, size_t size, char sep, const char *a, size_t a_len, const char *b, size_t b_len)
+eina_str_join_len(char *dst,
+ size_t size,
+ char sep,
+ const char *a,
+ size_t a_len,
+ const char *b,
+ size_t b_len)
{
size_t ret = a_len + b_len + 1;
size_t off;
- if (size < 1) return ret;
+ if (size < 1)
+ return ret;
if (size <= a_len)
{
- memcpy(dst, a, size - 1);
- dst[size - 1] = '\0';
- return ret;
+ memcpy(dst, a, size - 1);
+ dst[size - 1] = '\0';
+ return ret;
}
- memcpy(dst, a, a_len);
+ memcpy(dst, a, a_len);
off = a_len;
if (size <= off + 1)
{
- dst[size - 1] = '\0';
- return ret;
+ dst[size - 1] = '\0';
+ return ret;
}
dst[off] = sep;
if (size <= off + b_len + 1)
{
- memcpy(dst + off, b, size - off - 1);
- dst[size - 1] = '\0';
- return ret;
+ memcpy(dst + off, b, size - off - 1);
+ dst[size - 1] = '\0';
+ return ret;
}
- memcpy(dst + off, b, b_len);
+ memcpy(dst + off, b, b_len);
dst[off + b_len] = '\0';
return ret;
}
char *new_txt, *inp, *outp;
size_t inb, outb, outlen, tob, outalloc;
- if (!text) return NULL;
+ if (!text)
+ return NULL;
+
ic = iconv_open(enc_to, enc_from);
- if (ic == (iconv_t)(-1)) return NULL;
- new_txt = malloc(64);
- inb = strlen(text);
- outb = 64;
- inp = (char*)text;
- outp = new_txt;
+ if (ic == (iconv_t)(-1))
+ return NULL;
+
+ new_txt = malloc(64);
+ inb = strlen(text);
+ outb = 64;
+ inp = (char *)text;
+ outp = new_txt;
outalloc = 64;
- outlen = 0;
+ outlen = 0;
- for (;;)
+ for (;; )
{
- size_t count;
-
- tob = outb;
- count = iconv(ic, &inp, &inb, &outp, &outb);
- outlen += tob - outb;
- if (count == (size_t)(-1))
- {
- if (errno == E2BIG)
- {
- new_txt = realloc(new_txt, outalloc + 64);
- outp = new_txt + outlen;
- outalloc += 64;
- outb += 64;
- }
- else if (errno == EILSEQ)
- {
- if (new_txt) free(new_txt);
- new_txt = NULL;
- break;
- }
- else if (errno == EINVAL)
- {
- if (new_txt) free(new_txt);
- new_txt = NULL;
- break;
- }
- else
- {
- if (new_txt) free(new_txt);
- new_txt = NULL;
- break;
- }
- }
- if (inb == 0)
- {
- if (outalloc == outlen) new_txt = realloc(new_txt, outalloc + 1);
- new_txt[outlen] = 0;
- break;
- }
+ size_t count;
+
+ tob = outb;
+ count = iconv(ic, &inp, &inb, &outp, &outb);
+ outlen += tob - outb;
+ if (count == (size_t)(-1))
+ {
+ if (errno == E2BIG)
+ {
+ new_txt = realloc(new_txt, outalloc + 64);
+ outp = new_txt + outlen;
+ outalloc += 64;
+ outb += 64;
+ }
+ else if (errno == EILSEQ)
+ {
+ if (new_txt)
+ free(new_txt);
+
+ new_txt = NULL;
+ break;
+ }
+ else if (errno == EINVAL)
+ {
+ if (new_txt)
+ free(new_txt);
+
+ new_txt = NULL;
+ break;
+ }
+ else
+ {
+ if (new_txt)
+ free(new_txt);
+
+ new_txt = NULL;
+ break;
+ }
+ }
+
+ if (inb == 0)
+ {
+ if (outalloc == outlen)
+ new_txt = realloc(new_txt, outalloc + 1);
+
+ new_txt[outlen] = 0;
+ break;
+ }
}
iconv_close(ic);
return new_txt;
}
#else
EAPI char *
-eina_str_convert(const char *enc_from __UNUSED__, const char *enc_to __UNUSED__, const char *text __UNUSED__)
+eina_str_convert(const char *enc_from __UNUSED__,
+ const char *enc_to __UNUSED__,
+ const char *text __UNUSED__)
{
return NULL;
}
const char *s;
s2 = malloc((strlen(str) * 2) + 1);
- if (!s2) return NULL;
+ if (!s2)
+ return NULL;
+
for (s = str, d = s2; *s != 0; s++, d++)
{
- if ((*s == ' ') || (*s == '\\') || (*s == '\''))
- {
- *d = '\\';
- d++;
- }
- *d = *s;
+ if ((*s == ' ') || (*s == '\\') || (*s == '\''))
+ {
+ *d = '\\';
+ d++;
+ }
+
+ *d = *s;
}
*d = 0;
return s2;
eina_str_tolower(char **str)
{
char *p;
- if ((!str) || (!(*str))) return;
+ if ((!str) || (!(*str)))
+ return;
for (p = *str; (*p); p++)
- *p = tolower(*p);
+ *p = tolower(*p);
}
/**
eina_str_toupper(char **str)
{
char *p;
- if ((!str) || (!(*str))) return;
+ if ((!str) || (!(*str)))
+ return;
for (p = *str; (*p); p++)
- *p = toupper(*p);
+ *p = toupper(*p);
}
#define _STRBUF_MAGIC_STR __STRBUF_MAGIC_STR
static const char __STRBUF_MAGIC_STR[] = "Eina Strbuf";
-#define _FUNC_EXPAND(y) eina_strbuf_##y
+#define _FUNC_EXPAND(y) eina_strbuf_ ## y
#define _GNU_SOURCE
#include <stdio.h>
va_end(args);
if (len <= 0 || !str)
- return EINA_FALSE;
+ return EINA_FALSE;
ret = eina_strbuf_append_length(buf, str, len);
free(str);
len = vasprintf(&str, fmt, args);
if (len <= 0 || !str)
- return EINA_FALSE;
+ return EINA_FALSE;
ret = eina_strbuf_append_length(buf, str, len);
free(str);
va_end(args);
if (len <= 0 || !str)
- return EINA_FALSE;
+ return EINA_FALSE;
ret = eina_strbuf_insert(buf, str, pos);
free(str);
}
EAPI Eina_Bool
-eina_strbuf_insert_vprintf(Eina_Strbuf *buf, const char *fmt, size_t pos, va_list args)
+eina_strbuf_insert_vprintf(Eina_Strbuf *buf,
+ const char *fmt,
+ size_t pos,
+ va_list args)
{
char *str;
size_t len;
len = vasprintf(&str, fmt, args);
if (len <= 0 || !str)
- return EINA_FALSE;
+ return EINA_FALSE;
ret = eina_strbuf_insert(buf, str, pos);
free(str);
#include "eina_strbuf_common.h"
/*============================================================================*
- * Local *
- *============================================================================*/
+* Local *
+*============================================================================*/
/**
* @cond LOCAL
buf->size = EINA_STRBUF_INIT_SIZE;
buf->step = EINA_STRBUF_INIT_STEP;
- eina_error_set(0);
+ eina_error_set(0);
buf->buf = calloc(csize, buf->size);
if (EINA_UNLIKELY(!buf->buf))
{
- eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
- return EINA_FALSE;
+ eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+ return EINA_FALSE;
}
+
return EINA_TRUE;
}
size += 1; // Add extra space for '\0'
if (size == buf->size)
- /* nothing to do */
- return EINA_TRUE;
+ /* nothing to do */
+ return EINA_TRUE;
else if (size > buf->size)
- delta = size - buf->size;
+ delta = size - buf->size;
else
- delta = buf->size - size;
+ delta = buf->size - size;
/* check if should keep the same step (just used while growing) */
if ((delta <= buf->step) && (size > buf->size))
- new_step = buf->step;
+ new_step = buf->step;
else
{
- new_step = (((delta / EINA_STRBUF_INIT_STEP) + 1)
- * EINA_STRBUF_INIT_STEP);
+ new_step = (((delta / EINA_STRBUF_INIT_STEP) + 1)
+ * EINA_STRBUF_INIT_STEP);
- if (new_step > EINA_STRBUF_MAX_STEP)
- new_step = EINA_STRBUF_MAX_STEP;
+ if (new_step > EINA_STRBUF_MAX_STEP)
+ new_step = EINA_STRBUF_MAX_STEP;
}
new_size = (((size / new_step) + 1) * new_step);
buffer = realloc(buf->buf, new_size * csize);
if (EINA_UNLIKELY(!buffer))
{
- eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
- return EINA_FALSE;
+ eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+ return EINA_FALSE;
}
buf->buf = buffer;
buf->size = new_size;
buf->step = new_step;
- eina_error_set(0);
+ eina_error_set(0);
return EINA_TRUE;
}
_eina_strbuf_common_grow(size_t csize, Eina_Strbuf *buf, size_t size)
{
if ((size + 1) < buf->size)
- return EINA_TRUE;
+ return EINA_TRUE;
+
return _eina_strbuf_common_resize(csize, buf, size);
}
* @return #EINA_TRUE on success, #EINA_FALSE on failure.
*/
static inline Eina_Bool
-_eina_strbuf_common_insert_length(size_t csize, Eina_Strbuf *buf, const void *str, size_t len, size_t pos)
+_eina_strbuf_common_insert_length(size_t csize,
+ Eina_Strbuf *buf,
+ const void *str,
+ size_t len,
+ size_t pos)
{
if (EINA_UNLIKELY(!_eina_strbuf_common_grow(csize, buf, buf->len + len)))
- return EINA_FALSE;
+ return EINA_FALSE;
/* move the existing text */
- memmove(buf->buf + ((len + pos) * csize), buf->buf + (pos * csize), (buf->len - pos) * csize);
+ memmove(buf->buf + ((len + pos) * csize), buf->buf + (pos * csize),
+ (buf->len - pos) * csize);
/* and now insert the given string */
memcpy(buf->buf + (pos * csize), str, len * csize);
*/
/*============================================================================*
- * Global *
- *============================================================================*/
+* Global *
+*============================================================================*/
/**
* @cond LOCAL
}
/*============================================================================*
- * API *
- *============================================================================*/
+* API *
+*============================================================================*/
/**
* @brief Create a new string buffer.
{
Eina_Strbuf *buf;
- eina_error_set(0);
+ eina_error_set(0);
buf = malloc(sizeof(Eina_Strbuf));
if (EINA_UNLIKELY(!buf))
{
- eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
- return NULL;
+ eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+ return NULL;
}
if (EINA_UNLIKELY(!_eina_strbuf_common_init(csize, buf)))
{
- eina_strbuf_common_free(buf);
- return NULL;
+ eina_strbuf_common_free(buf);
+ return NULL;
}
return buf;
* @see eina_strbuf_common_append_length()
*/
Eina_Bool
-eina_strbuf_common_append(size_t csize, Eina_Strbuf *buf, const void *str, size_t len)
+eina_strbuf_common_append(size_t csize,
+ Eina_Strbuf *buf,
+ const void *str,
+ size_t len)
{
EINA_SAFETY_ON_NULL_RETURN_VAL(str, EINA_FALSE);
if (EINA_UNLIKELY(!_eina_strbuf_common_grow(csize, buf, buf->len + len)))
- return EINA_FALSE;
+ return EINA_FALSE;
+
memcpy(buf->buf + (buf->len * csize), str, (len + 1) * csize);
buf->len += len;
return EINA_TRUE;
* @see eina_strbuf_common_append_length()
*/
Eina_Bool
-eina_strbuf_common_append_n(size_t csize, Eina_Strbuf *buf, const void *str, size_t len, size_t maxlen)
+eina_strbuf_common_append_n(size_t csize,
+ Eina_Strbuf *buf,
+ const void *str,
+ size_t len,
+ size_t maxlen)
{
EINA_SAFETY_ON_NULL_RETURN_VAL(str, EINA_FALSE);
- if (len > maxlen) len = maxlen;
+ if (len > maxlen)
+ len = maxlen;
+
if (EINA_UNLIKELY(!_eina_strbuf_common_grow(csize, buf, buf->len + len)))
- return EINA_FALSE;
+ return EINA_FALSE;
memcpy(buf->buf + (buf->len * csize), str, len * csize);
buf->len += len;
* @see eina_strbuf_common_append_n()
*/
Eina_Bool
-eina_strbuf_common_append_length(size_t csize, Eina_Strbuf *buf, const void *str, size_t length)
+eina_strbuf_common_append_length(size_t csize,
+ Eina_Strbuf *buf,
+ const void *str,
+ size_t length)
{
EINA_SAFETY_ON_NULL_RETURN_VAL(str, EINA_FALSE);
if (EINA_UNLIKELY(!_eina_strbuf_common_grow(csize, buf, buf->len + length)))
- return EINA_FALSE;
+ return EINA_FALSE;
memcpy(buf->buf + (buf->len * csize), str, length * csize);
buf->len += length;
* is returned, otherwise #EINA_TRUE is returned.
*/
Eina_Bool
-eina_strbuf_common_insert(size_t csize, Eina_Strbuf *buf, const void *str, size_t len, size_t pos)
+eina_strbuf_common_insert(size_t csize,
+ Eina_Strbuf *buf,
+ const void *str,
+ size_t len,
+ size_t pos)
{
EINA_SAFETY_ON_NULL_RETURN_VAL(str, EINA_FALSE);
if (pos >= buf->len)
- return eina_strbuf_common_append(csize, buf, str, len);
+ return eina_strbuf_common_append(csize, buf, str, len);
return _eina_strbuf_common_insert_length(csize, buf, str, len, pos);
}
* otherwise, #EINA_TRUE is returned.
*/
Eina_Bool
-eina_strbuf_common_insert_n(size_t csize, Eina_Strbuf *buf, const void *str, size_t len, size_t maxlen, size_t pos)
+eina_strbuf_common_insert_n(size_t csize,
+ Eina_Strbuf *buf,
+ const void *str,
+ size_t len,
+ size_t maxlen,
+ size_t pos)
{
EINA_SAFETY_ON_NULL_RETURN_VAL(str, EINA_FALSE);
if (pos >= buf->len)
- return eina_strbuf_common_append_n(csize, buf, str, len, maxlen);
+ return eina_strbuf_common_append_n(csize, buf, str, len, maxlen);
+
+ if (len > maxlen)
+ len = maxlen;
- if (len > maxlen) len = maxlen;
return _eina_strbuf_common_insert_length(csize, buf, str, len, pos);
}
* @see eina_strbuf_common_insert_n()
*/
Eina_Bool
-eina_strbuf_common_insert_length(size_t csize, Eina_Strbuf *buf, const void *str, size_t length, size_t pos)
+eina_strbuf_common_insert_length(size_t csize,
+ Eina_Strbuf *buf,
+ const void *str,
+ size_t length,
+ size_t pos)
{
EINA_SAFETY_ON_NULL_RETURN_VAL(str, EINA_FALSE);
if (pos >= buf->len)
- return eina_strbuf_common_append_length(csize, buf, str, length);
+ return eina_strbuf_common_append_length(csize, buf, str, length);
return _eina_strbuf_common_insert_length(csize, buf, str, length, pos);
}
{
if (EINA_UNLIKELY(!_eina_strbuf_common_grow(csize, buf, buf->len + 1)))
- return EINA_FALSE;
- memcpy(buf->buf + ((buf->len)++ * csize), c, csize);
+ return EINA_FALSE;
+
+ memcpy(buf->buf + ((buf->len)++ *csize), c, csize);
memset(buf->buf + (buf->len * csize), 0, csize);
return EINA_TRUE;
}
* returned.
*/
Eina_Bool
-eina_strbuf_common_insert_char(size_t csize, Eina_Strbuf *buf, const void *c, size_t pos)
+eina_strbuf_common_insert_char(size_t csize,
+ Eina_Strbuf *buf,
+ const void *c,
+ size_t pos)
{
if (pos >= buf->len)
- return eina_strbuf_common_append_char(csize, buf, c);
+ return eina_strbuf_common_append_char(csize, buf, c);
return _eina_strbuf_common_insert_length(csize, buf, c, 1, pos);
}
* in bytes. It returns #EINA_FALSE on failure, #EINA_TRUE otherwise.
*/
Eina_Bool
-eina_strbuf_common_remove(size_t csize, Eina_Strbuf *buf, size_t start, size_t end)
+eina_strbuf_common_remove(size_t csize,
+ Eina_Strbuf *buf,
+ size_t start,
+ size_t end)
{
size_t remove_len, tail_len;
if (end >= buf->len)
- end = buf->len;
+ end = buf->len;
if (end <= start)
- return EINA_TRUE;
+ return EINA_TRUE;
remove_len = end - start;
if (remove_len == buf->len)
{
- free(buf->buf);
- return _eina_strbuf_common_init(csize, buf);
+ free(buf->buf);
+ return _eina_strbuf_common_init(csize, buf);
}
tail_len = buf->len - end + 1; /* includes '\0' */
- memmove(buf->buf + (start * csize), buf->buf + (end * csize), tail_len * csize);
+ memmove(buf->buf + (start * csize),
+ buf->buf + (end * csize),
+ tail_len * csize);
buf->len -= remove_len;
return _eina_strbuf_common_resize(csize, buf, buf->len);
}
* This function returns the string contained in @p buf. @p buf is
* then initialized and does not own the returned string anymore. The
* caller must release the memory of the returned string by calling
- * free().
+ * free().
*
* @see eina_strbuf_common_string_get()
*/
* @brief Free the contents of a string buffer but not the buffer.
*
* @param buf The string buffer to free the string of.
- *
+ *
* This function frees the string contained in @p buf without freeing
* @p buf.
*/
* @brief These functions provide string buffers management.
*
* The String Buffer data type is designed to be a mutable string,
- * allowing to append, prepend or insert a string to a buffer.
+ * allowing to append, prepend or insert a string to a buffer.
*
* @{
*/
* @p with. It returns #EINA_FALSE on failure, #EINA_TRUE otherwise.
*/
EAPI Eina_Bool
-eina_strbuf_replace(Eina_Strbuf *buf, const char *str, const char *with, unsigned int n)
+eina_strbuf_replace(Eina_Strbuf *buf,
+ const char *str,
+ const char *with,
+ unsigned int n)
{
size_t len1, len2;
char *spos;
size_t pos;
- EINA_SAFETY_ON_NULL_RETURN_VAL(str, EINA_FALSE);
+ EINA_SAFETY_ON_NULL_RETURN_VAL( str, EINA_FALSE);
EINA_SAFETY_ON_NULL_RETURN_VAL(with, EINA_FALSE);
EINA_MAGIC_CHECK_STRBUF(buf, 0);
if (n == 0)
- return EINA_FALSE;
+ return EINA_FALSE;
spos = buf->buf;
while (n--)
{
- spos = strstr(spos, str);
- if (!spos || *spos == '\0')
- return EINA_FALSE;
- if (n) spos++;
+ spos = strstr(spos, str);
+ if (!spos || *spos == '\0')
+ return EINA_FALSE;
+
+ if (n)
+ spos++;
}
- pos = spos - (const char *) buf->buf;
+ pos = spos - (const char *)buf->buf;
len1 = strlen(str);
len2 = strlen(with);
if (len1 != len2)
{
- /* resize the buffer if necessary */
- if (EINA_UNLIKELY(!_eina_strbuf_common_grow(_STRBUF_CSIZE, buf, buf->len - len1 + len2)))
- return EINA_FALSE;
- /* move the existing text */
- memmove(buf->buf + pos + len2, buf->buf + pos + len1,
- buf->len - pos - len1);
+ /* resize the buffer if necessary */
+ if (EINA_UNLIKELY(!_eina_strbuf_common_grow(_STRBUF_CSIZE, buf,
+ buf->len - len1 + len2)))
+ return EINA_FALSE; /* move the existing text */
+
+ memmove(buf->buf + pos + len2, buf->buf + pos + len1,
+ buf->len - pos - len1);
}
+
/* and now insert the given string */
memcpy(buf->buf + pos, with, len2);
buf->len += len2 - len1;
- memset((char *) buf->buf + buf->len, 0, 1);
+ memset((char *)buf->buf + buf->len, 0, 1);
return EINA_TRUE;
}
size_t pos_tmp, start_tmp;
int n = 0;
- EINA_SAFETY_ON_NULL_RETURN_VAL(str, 0);
+ EINA_SAFETY_ON_NULL_RETURN_VAL( str, 0);
EINA_SAFETY_ON_NULL_RETURN_VAL(with, 0);
EINA_MAGIC_CHECK_STRBUF(buf, 0);
spos = strstr(buf->buf, str);
if (!spos || *spos == '\0')
- return 0;
+ return 0;
len1 = strlen(str);
len2 = strlen(with);
* we don't need to resize the buffer or doing other calculations */
if (len1 == len2)
{
- while (spos)
- {
- memcpy(spos, with, len2);
- spos = strstr(spos + len2, str);
- n++;
- }
- return n;
+ while (spos)
+ {
+ memcpy(spos, with, len2);
+ spos = strstr(spos + len2, str);
+ n++;
+ }
+ return n;
}
- pos = pos_tmp = spos - (const char *) buf->buf;
+ pos = pos_tmp = spos - (const char *)buf->buf;
tmp_buf = buf->buf;
buf->buf = malloc(buf->size);
if (EINA_UNLIKELY(!buf->buf))
{
- buf->buf = tmp_buf;
- return 0;
+ buf->buf = tmp_buf;
+ return 0;
}
+
start = start_tmp = 0;
len = buf->len;
while (spos)
{
- n++;
- len = (len + len2) - len1;
- /* resize the buffer if necessary */
- if (EINA_UNLIKELY(!_eina_strbuf_common_grow(_STRBUF_CSIZE, buf, len)))
- {
- /* we have to stop replacing here, because we haven't enough
- * memory to go on */
- len = (len + len1) - len2;
- break;
- }
-
- /* copy the untouched text */
- memcpy(buf->buf + start, tmp_buf + start_tmp, pos - start);
- /* copy the new string */
- memcpy(buf->buf + pos, with, len2);
-
- /* calculate the next positions */
- start_tmp = pos_tmp + len1;
- start = pos + len2;
- spos = strstr(tmp_buf + start_tmp, str);
- /* this calculations don't make sense if spos == NULL, but the
- * calculated values won't be used, because the loop will stop
- * then */
- pos_tmp = spos - tmp_buf;
- pos = start + pos_tmp - start_tmp;
+ n++;
+ len = (len + len2) - len1;
+ /* resize the buffer if necessary */
+ if (EINA_UNLIKELY(!_eina_strbuf_common_grow(_STRBUF_CSIZE, buf, len)))
+ {
+ /* we have to stop replacing here, because we haven't enough
+ * memory to go on */
+ len = (len + len1) - len2;
+ break;
+ }
+
+ /* copy the untouched text */
+ memcpy(buf->buf + start, tmp_buf + start_tmp, pos - start);
+ /* copy the new string */
+ memcpy(buf->buf + pos, with, len2);
+
+ /* calculate the next positions */
+ start_tmp = pos_tmp + len1;
+ start = pos + len2;
+ spos = strstr(tmp_buf + start_tmp, str);
+ /* this calculations don't make sense if spos == NULL, but the
+ * calculated values won't be used, because the loop will stop
+ * then */
+ pos_tmp = spos - tmp_buf;
+ pos = start + pos_tmp - start_tmp;
}
/* and now copy the rest of the text */
- memcpy(buf->buf + start, tmp_buf + start_tmp, len - start);
+ memcpy(buf->buf + start, tmp_buf + start_tmp, len - start);
buf->len = len;
- memset((char *) buf->buf + buf->len, 0, 1);
+ memset((char *)buf->buf + buf->len, 0, 1);
free(tmp_buf);
EINA_MAGIC
};
-#define EINA_MAGIC_CHECK_STRBUF(d, ...) \
- do { \
- if (!EINA_MAGIC_CHECK((d), _STRBUF_MAGIC)) \
- { \
- EINA_MAGIC_FAIL((d), _STRBUF_MAGIC); \
- return __VA_ARGS__; \
- } \
- } while (0)
+#define EINA_MAGIC_CHECK_STRBUF(d, ...) \
+ do { \
+ if (!EINA_MAGIC_CHECK((d), _STRBUF_MAGIC)) \
+ { \
+ EINA_MAGIC_FAIL((d), _STRBUF_MAGIC); \
+ return __VA_ARGS__; \
+ } \
+ } while (0)
Eina_Bool
eina_strbuf_common_init(void);
void
eina_strbuf_common_reset(size_t csize, Eina_Strbuf *buf);
Eina_Bool
-eina_strbuf_common_append(size_t csize, Eina_Strbuf *buf, const void *str, size_t len);
+eina_strbuf_common_append(size_t csize,
+ Eina_Strbuf *buf,
+ const void *str,
+ size_t len);
Eina_Bool
-eina_strbuf_common_append_escaped(size_t csize, Eina_Strbuf *buf, const void *str);
+eina_strbuf_common_append_escaped(size_t csize,
+ Eina_Strbuf *buf,
+ const void *str);
Eina_Bool
-eina_strbuf_common_append_n(size_t csize, Eina_Strbuf *buf, const void *str, size_t len, size_t maxlen);
+eina_strbuf_common_append_n(size_t csize,
+ Eina_Strbuf *buf,
+ const void *str,
+ size_t len,
+ size_t maxlen);
Eina_Bool
-eina_strbuf_common_append_length(size_t csize, Eina_Strbuf *buf, const void *str, size_t length);
+eina_strbuf_common_append_length(size_t csize,
+ Eina_Strbuf *buf,
+ const void *str,
+ size_t length);
Eina_Bool
-eina_strbuf_common_insert(size_t csize, Eina_Strbuf *buf, const void *str, size_t len, size_t pos);
+eina_strbuf_common_insert(size_t csize,
+ Eina_Strbuf *buf,
+ const void *str,
+ size_t len,
+ size_t pos);
Eina_Bool
-eina_strbuf_common_insert_escaped(size_t csize, Eina_Strbuf *buf, const void *str,
- size_t len, size_t pos);
+eina_strbuf_common_insert_escaped(size_t csize,
+ Eina_Strbuf *buf,
+ const void *str,
+ size_t len,
+ size_t pos);
Eina_Bool
-eina_strbuf_common_insert_n(size_t csize, Eina_Strbuf *buf, const void *str, size_t len, size_t maxlen, size_t pos);
+eina_strbuf_common_insert_n(size_t csize,
+ Eina_Strbuf *buf,
+ const void *str,
+ size_t len,
+ size_t maxlen,
+ size_t pos);
Eina_Bool
-eina_strbuf_common_insert_length(size_t csize, Eina_Strbuf *buf, const void *str, size_t length, size_t pos);
+eina_strbuf_common_insert_length(size_t csize,
+ Eina_Strbuf *buf,
+ const void *str,
+ size_t length,
+ size_t pos);
Eina_Bool
eina_strbuf_common_append_char(size_t csize, Eina_Strbuf *buf, const void *c);
Eina_Bool
-eina_strbuf_common_insert_char(size_t csize, Eina_Strbuf *buf, const void *c, size_t pos);
+eina_strbuf_common_insert_char(size_t csize,
+ Eina_Strbuf *buf,
+ const void *c,
+ size_t pos);
Eina_Bool
-eina_strbuf_common_remove(size_t csize, Eina_Strbuf *buf, size_t start, size_t end);
+eina_strbuf_common_remove(size_t csize,
+ Eina_Strbuf *buf,
+ size_t start,
+ size_t end);
const void *
eina_strbuf_common_string_get(const Eina_Strbuf *buf);
void *
* You should have received a copy of the GNU Lesser General Public
* License along with this library;
* if not, see <http://www.gnu.org/licenses/>.
-*/
+ */
- /**
+/**
* @page tutorial_stringshare_page Stringshare Tutorial
*
* to be written...
# ifdef EFL_HAVE_POSIX_THREADS
static pthread_mutex_t _mutex_small = PTHREAD_MUTEX_INITIALIZER;
-# define STRINGSHARE_LOCK_SMALL() if(_share_common_threads_activated) pthread_mutex_lock(&_mutex_small)
-# define STRINGSHARE_UNLOCK_SMALL() if(_share_common_threads_activated) pthread_mutex_unlock(&_mutex_small)
+# define STRINGSHARE_LOCK_SMALL() if(_share_common_threads_activated) \
+ pthread_mutex_lock(&_mutex_small)
+# define STRINGSHARE_UNLOCK_SMALL() if(_share_common_threads_activated) \
+ pthread_mutex_unlock(&_mutex_small)
# else /* EFL_HAVE_WIN32_THREADS */
static HANDLE _mutex_small = NULL;
-# define STRINGSHARE_LOCK_SMALL() if(_share_common_threads_activated) WaitForSingleObject(_mutex_small, INFINITE)
-# define STRINGSHARE_UNLOCK_SMALL() if(_share_common_threads_activated) ReleaseMutex(_mutex_small)
+# define STRINGSHARE_LOCK_SMALL() if(_share_common_threads_activated) \
+ WaitForSingleObject(_mutex_small, INFINITE)
+# define STRINGSHARE_UNLOCK_SMALL() if(_share_common_threads_activated) \
+ ReleaseMutex(_mutex_small)
# endif /* EFL_HAVE_WIN32_THREADS */
#else /* EFL_HAVE_THREADS */
/* Stringshare optimizations */
static const unsigned char _eina_stringshare_single[512] = {
- 0,0,1,0,2,0,3,0,4,0,5,0,6,0,7,0,8,0,9,0,10,0,11,0,12,0,13,0,14,0,15,0,
- 16,0,17,0,18,0,19,0,20,0,21,0,22,0,23,0,24,0,25,0,26,0,27,0,28,0,29,0,30,0,
- 31,0,32,0,33,0,34,0,35,0,36,0,37,0,38,0,39,0,40,0,41,0,42,0,43,0,44,0,45,0,
- 46,0,47,0,48,0,49,0,50,0,51,0,52,0,53,0,54,0,55,0,56,0,57,0,58,0,59,0,60,0,
- 61,0,62,0,63,0,64,0,65,0,66,0,67,0,68,0,69,0,70,0,71,0,72,0,73,0,74,0,75,0,
- 76,0,77,0,78,0,79,0,80,0,81,0,82,0,83,0,84,0,85,0,86,0,87,0,88,0,89,0,90,0,
- 91,0,92,0,93,0,94,0,95,0,96,0,97,0,98,0,99,0,100,0,101,0,102,0,103,0,104,0,105,0,
- 106,0,107,0,108,0,109,0,110,0,111,0,112,0,113,0,114,0,115,0,116,0,117,0,118,0,119,0,120,0,
- 121,0,122,0,123,0,124,0,125,0,126,0,127,0,128,0,129,0,130,0,131,0,132,0,133,0,134,0,135,0,
- 136,0,137,0,138,0,139,0,140,0,141,0,142,0,143,0,144,0,145,0,146,0,147,0,148,0,149,0,150,0,
- 151,0,152,0,153,0,154,0,155,0,156,0,157,0,158,0,159,0,160,0,161,0,162,0,163,0,164,0,165,0,
- 166,0,167,0,168,0,169,0,170,0,171,0,172,0,173,0,174,0,175,0,176,0,177,0,178,0,179,0,180,0,
- 181,0,182,0,183,0,184,0,185,0,186,0,187,0,188,0,189,0,190,0,191,0,192,0,193,0,194,0,195,0,
- 196,0,197,0,198,0,199,0,200,0,201,0,202,0,203,0,204,0,205,0,206,0,207,0,208,0,209,0,210,0,
- 211,0,212,0,213,0,214,0,215,0,216,0,217,0,218,0,219,0,220,0,221,0,222,0,223,0,224,0,225,0,
- 226,0,227,0,228,0,229,0,230,0,231,0,232,0,233,0,234,0,235,0,236,0,237,0,238,0,239,0,240,0,
- 241,0,242,0,243,0,244,0,245,0,246,0,247,0,248,0,249,0,250,0,251,0,252,0,253,0,254,0,255,0
+ 0,0,1,0,2,0,3,0,4,0,5,0,6,0,7,0,8,0,9,0,10,0,11,0,12,0,13,0,14,0,15,0,
+ 16,0,17,0,18,0,19,0,20,0,21,0,22,0,23,0,24,0,25,0,26,0,27,0,28,0,29,0,30,0,
+ 31,0,32,0,33,0,34,0,35,0,36,0,37,0,38,0,39,0,40,0,41,0,42,0,43,0,44,0,45,0,
+ 46,0,47,0,48,0,49,0,50,0,51,0,52,0,53,0,54,0,55,0,56,0,57,0,58,0,59,0,60,0,
+ 61,0,62,0,63,0,64,0,65,0,66,0,67,0,68,0,69,0,70,0,71,0,72,0,73,0,74,0,75,0,
+ 76,0,77,0,78,0,79,0,80,0,81,0,82,0,83,0,84,0,85,0,86,0,87,0,88,0,89,0,90,0,
+ 91,0,92,0,93,0,94,0,95,0,96,0,97,0,98,0,99,0,100,0,101,0,102,0,103,0,104,0,
+ 105,0,
+ 106,0,107,0,108,0,109,0,110,0,111,0,112,0,113,0,114,0,115,0,116,0,117,0,118,
+ 0,119,0,120,0,
+ 121,0,122,0,123,0,124,0,125,0,126,0,127,0,128,0,129,0,130,0,131,0,132,0,133,
+ 0,134,0,135,0,
+ 136,0,137,0,138,0,139,0,140,0,141,0,142,0,143,0,144,0,145,0,146,0,147,0,148,
+ 0,149,0,150,0,
+ 151,0,152,0,153,0,154,0,155,0,156,0,157,0,158,0,159,0,160,0,161,0,162,0,163,
+ 0,164,0,165,0,
+ 166,0,167,0,168,0,169,0,170,0,171,0,172,0,173,0,174,0,175,0,176,0,177,0,178,
+ 0,179,0,180,0,
+ 181,0,182,0,183,0,184,0,185,0,186,0,187,0,188,0,189,0,190,0,191,0,192,0,193,
+ 0,194,0,195,0,
+ 196,0,197,0,198,0,199,0,200,0,201,0,202,0,203,0,204,0,205,0,206,0,207,0,208,
+ 0,209,0,210,0,
+ 211,0,212,0,213,0,214,0,215,0,216,0,217,0,218,0,219,0,220,0,221,0,222,0,223,
+ 0,224,0,225,0,
+ 226,0,227,0,228,0,229,0,230,0,231,0,232,0,233,0,234,0,235,0,236,0,237,0,238,
+ 0,239,0,240,0,
+ 241,0,242,0,243,0,244,0,245,0,246,0,247,0,248,0,249,0,250,0,251,0,252,0,253,
+ 0,254,0,255,0
};
-typedef struct _Eina_Stringshare_Small Eina_Stringshare_Small;
+typedef struct _Eina_Stringshare_Small Eina_Stringshare_Small;
typedef struct _Eina_Stringshare_Small_Bucket Eina_Stringshare_Small_Bucket;
struct _Eina_Stringshare_Small_Bucket
{
/* separate arrays for faster lookups */
- const char **strings;
- unsigned char *lengths;
+ const char **strings;
+ unsigned char *lengths;
unsigned short *references;
int count;
int size;
static Eina_Stringshare_Small _eina_small_share;
static inline int
-_eina_stringshare_small_cmp(const Eina_Stringshare_Small_Bucket *bucket, int i, const char *pstr, unsigned char plength)
+_eina_stringshare_small_cmp(const Eina_Stringshare_Small_Bucket *bucket,
+ int i,
+ const char *pstr,
+ unsigned char plength)
{
/* pstr and plength are from second char and on, since the first is
* always the same.
const char *cur_pstr;
if (cur_plength > plength)
- return 1;
+ return 1;
else if (cur_plength < plength)
- return -1;
+ return -1;
cur_pstr = bucket->strings[i] + 1;
if (cur_pstr[0] > pstr[0])
- return 1;
+ return 1;
else if (cur_pstr[0] < pstr[0])
- return -1;
+ return -1;
if (plength == 1)
- return 0;
+ return 0;
if (cur_pstr[1] > pstr[1])
- return 1;
+ return 1;
else if (cur_pstr[1] < pstr[1])
- return -1;
+ return -1;
return 0;
}
static const char *
-_eina_stringshare_small_bucket_find(const Eina_Stringshare_Small_Bucket *bucket, const char *str, unsigned char length, int *idx)
+_eina_stringshare_small_bucket_find(const Eina_Stringshare_Small_Bucket *bucket,
+ const char *str,
+ unsigned char length,
+ int *idx)
{
const char *pstr = str + 1; /* skip first letter, it's always the same */
unsigned char plength = length - 1;
if (bucket->count == 0)
{
- *idx = 0;
- return NULL;
+ *idx = 0;
+ return NULL;
}
low = 0;
while (low < high)
{
- int r;
-
- i = (low + high - 1) / 2;
-
- r = _eina_stringshare_small_cmp(bucket, i, pstr, plength);
- if (r > 0)
- {
- high = i;
- }
- else if (r < 0)
- {
- low = i + 1;
- }
- else
- {
- *idx = i;
- return bucket->strings[i];
- }
+ int r;
+
+ i = (low + high - 1) / 2;
+
+ r = _eina_stringshare_small_cmp(bucket, i, pstr, plength);
+ if (r > 0)
+ high = i;
+ else if (r < 0)
+ low = i + 1;
+ else
+ {
+ *idx = i;
+ return bucket->strings[i];
+ }
}
*idx = low;
}
static Eina_Bool
-_eina_stringshare_small_bucket_resize(Eina_Stringshare_Small_Bucket *bucket, int size)
+_eina_stringshare_small_bucket_resize(Eina_Stringshare_Small_Bucket *bucket,
+ int size)
{
void *tmp;
- tmp = realloc((void*)bucket->strings, size * sizeof(bucket->strings[0]));
+ tmp = realloc((void *)bucket->strings, size * sizeof(bucket->strings[0]));
if (!tmp)
{
- eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
- return 0;
+ eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+ return 0;
}
+
bucket->strings = tmp;
tmp = realloc(bucket->lengths, size * sizeof(bucket->lengths[0]));
if (!tmp)
{
- eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
- return 0;
+ eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+ return 0;
}
+
bucket->lengths = tmp;
tmp = realloc(bucket->references, size * sizeof(bucket->references[0]));
if (!tmp)
{
- eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
- return 0;
+ eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+ return 0;
}
+
bucket->references = tmp;
bucket->size = size;
}
static const char *
-_eina_stringshare_small_bucket_insert_at(Eina_Stringshare_Small_Bucket **p_bucket, const char *str, unsigned char length, int idx)
+_eina_stringshare_small_bucket_insert_at(
+ Eina_Stringshare_Small_Bucket **p_bucket,
+ const char *str,
+ unsigned char length,
+ int idx)
{
Eina_Stringshare_Small_Bucket *bucket = *p_bucket;
int todo, off;
if (!bucket)
{
- *p_bucket = bucket = calloc(1, sizeof(*bucket));
- if (!bucket)
- {
- eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
- return NULL;
- }
+ *p_bucket = bucket = calloc(1, sizeof(*bucket));
+ if (!bucket)
+ {
+ eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+ return NULL;
+ }
}
if (bucket->count + 1 >= bucket->size)
{
- int size = bucket->size + EINA_STRINGSHARE_SMALL_BUCKET_STEP;
- if (!_eina_stringshare_small_bucket_resize(bucket, size))
- return NULL;
+ int size = bucket->size + EINA_STRINGSHARE_SMALL_BUCKET_STEP;
+ if (!_eina_stringshare_small_bucket_resize(bucket, size))
+ return NULL;
}
snew = malloc(length + 1);
if (!snew)
{
- eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
- return NULL;
+ eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+ return NULL;
}
+
memcpy(snew, str, length);
snew[length] = '\0';
todo = bucket->count - idx;
if (todo > 0)
{
- memmove((void *)(bucket->strings + off), bucket->strings + idx,
- todo * sizeof(bucket->strings[0]));
- memmove(bucket->lengths + off, bucket->lengths + idx,
- todo * sizeof(bucket->lengths[0]));
- memmove(bucket->references + off, bucket->references + idx,
- todo * sizeof(bucket->references[0]));
+ memmove((void *)(bucket->strings + off), bucket->strings + idx,
+ todo * sizeof(bucket->strings[0]));
+ memmove(bucket->lengths + off, bucket->lengths + idx,
+ todo * sizeof(bucket->lengths[0]));
+ memmove(bucket->references + off, bucket->references + idx,
+ todo * sizeof(bucket->references[0]));
}
bucket->strings[idx] = snew;
}
static void
-_eina_stringshare_small_bucket_remove_at(Eina_Stringshare_Small_Bucket **p_bucket, int idx)
+_eina_stringshare_small_bucket_remove_at(
+ Eina_Stringshare_Small_Bucket **p_bucket,
+ int idx)
{
Eina_Stringshare_Small_Bucket *bucket = *p_bucket;
int todo, off;
if (bucket->references[idx] > 1)
{
- bucket->references[idx]--;
- return;
+ bucket->references[idx]--;
+ return;
}
- free((char *)bucket->strings[idx]);
+ free((char *)bucket->strings[idx]);
if (bucket->count == 1)
{
- free((void *)bucket->strings);
- free(bucket->lengths);
- free(bucket->references);
- free(bucket);
- *p_bucket = NULL;
- return;
+ free((void *)bucket->strings);
+ free(bucket->lengths);
+ free(bucket->references);
+ free(bucket);
+ *p_bucket = NULL;
+ return;
}
bucket->count--;
if (idx == bucket->count)
- goto end;
+ goto end;
off = idx + 1;
todo = bucket->count - idx;
memmove((void *)(bucket->strings + idx), bucket->strings + off,
- todo * sizeof(bucket->strings[0]));
- memmove(bucket->lengths + idx, bucket->lengths + off,
- todo * sizeof(bucket->lengths[0]));
- memmove(bucket->references + idx, bucket->references + off,
- todo * sizeof(bucket->references[0]));
+ todo * sizeof(bucket->strings[0]));
+ memmove(bucket->lengths + idx, bucket->lengths + off,
+ todo * sizeof(bucket->lengths[0]));
+ memmove(bucket->references + idx, bucket->references + off,
+ todo * sizeof(bucket->references[0]));
- end:
+end:
if (bucket->count + EINA_STRINGSHARE_SMALL_BUCKET_STEP < bucket->size)
{
- int size = bucket->size - EINA_STRINGSHARE_SMALL_BUCKET_STEP;
- _eina_stringshare_small_bucket_resize(bucket, size);
+ int size = bucket->size - EINA_STRINGSHARE_SMALL_BUCKET_STEP;
+ _eina_stringshare_small_bucket_resize(bucket, size);
}
}
bucket = _eina_small_share.buckets + (unsigned char)str[0];
if (!*bucket)
- i = 0;
+ i = 0;
else
{
- const char *ret;
- ret = _eina_stringshare_small_bucket_find(*bucket, str, length, &i);
- if (ret)
- {
- (*bucket)->references[i]++;
- return ret;
- }
+ const char *ret;
+ ret = _eina_stringshare_small_bucket_find(*bucket, str, length, &i);
+ if (ret)
+ {
+ (*bucket)->references[i]++;
+ return ret;
+ }
}
return _eina_stringshare_small_bucket_insert_at(bucket, str, length, i);
bucket = _eina_small_share.buckets + (unsigned char)str[0];
if (!*bucket)
- goto error;
+ goto error;
ret = _eina_stringshare_small_bucket_find(*bucket, str, length, &i);
if (!ret)
- goto error;
+ goto error;
_eina_stringshare_small_bucket_remove_at(bucket, i);
return;
- error:
+error:
CRITICAL("EEEK trying to del non-shared stringshare \"%s\"", str);
}
for (; p_bucket < p_bucket_end; p_bucket++)
{
- Eina_Stringshare_Small_Bucket *bucket = *p_bucket;
- char **s, **s_end;
-
- if (!bucket)
- continue;
-
- s = (char **)bucket->strings;
- s_end = s + bucket->count;
- for (; s < s_end; s++)
- free(*s);
-
- free((void *)bucket->strings);
- free(bucket->lengths);
- free(bucket->references);
- free(bucket);
- *p_bucket = NULL;
+ Eina_Stringshare_Small_Bucket *bucket = *p_bucket;
+ char **s, **s_end;
+
+ if (!bucket)
+ continue;
+
+ s = (char **)bucket->strings;
+ s_end = s + bucket->count;
+ for (; s < s_end; s++)
+ free(*s);
+
+ free((void *)bucket->strings);
+ free(bucket->lengths);
+ free(bucket->references);
+ free(bucket);
+ *p_bucket = NULL;
}
}
static void
-_eina_stringshare_small_bucket_dump(Eina_Stringshare_Small_Bucket *bucket, struct dumpinfo *di)
+_eina_stringshare_small_bucket_dump(Eina_Stringshare_Small_Bucket *bucket,
+ struct dumpinfo *di)
{
const char **s = bucket->strings;
unsigned char *l = bucket->lengths;
for (i = 0; i < bucket->count; i++, s++, l++, r++)
{
- int dups;
+ int dups;
#ifdef _WIN32
- printf("DDD: %5hu %5hu '%s'\n", *l, *r, *s);
+ printf("DDD: %5hu %5hu '%s'\n", *l, *r, *s);
#else
- printf("DDD: %5hhu %5hu '%s'\n", *l, *r, *s);
+ printf("DDD: %5hhu %5hu '%s'\n", *l, *r, *s);
#endif
- dups = (*r - 1);
+ dups = (*r - 1);
- di->used += *l;
- di->saved += *l * dups;
- di->dups += dups;
+ di->used += *l;
+ di->saved += *l * dups;
+ di->dups += dups;
}
}
for (; p_bucket < p_bucket_end; p_bucket++)
{
- Eina_Stringshare_Small_Bucket *bucket = *p_bucket;
+ Eina_Stringshare_Small_Bucket *bucket = *p_bucket;
- if (!bucket)
- continue;
+ if (!bucket)
+ continue;
- _eina_stringshare_small_bucket_dump(bucket, di);
+ _eina_stringshare_small_bucket_dump(bucket, di);
}
}
/*============================================================================*
- * Global *
- *============================================================================*/
+* Global *
+*============================================================================*/
/**
* @internal
eina_stringshare_init(void)
{
Eina_Bool ret;
- ret = eina_share_common_init(&stringshare_share, EINA_MAGIC_STRINGSHARE_NODE, EINA_MAGIC_STRINGSHARE_NODE_STR);
+ ret = eina_share_common_init(&stringshare_share,
+ EINA_MAGIC_STRINGSHARE_NODE,
+ EINA_MAGIC_STRINGSHARE_NODE_STR);
if (ret)
- {
- _eina_stringshare_small_init();
- }
+ _eina_stringshare_small_init();
+
return ret;
}
}
/*============================================================================*
- * API *
- *============================================================================*/
+* API *
+*============================================================================*/
/**
* @addtogroup Eina_Stringshare_Group Stringshare
DBG("str=%p (%s)", str, str ? str : "");
if (!str)
return;
-
+
/* special cases */
- if (str[0] == '\0') slen = 0;
- else if (str[1] == '\0') slen = 1;
- else if (str[2] == '\0') slen = 2;
- else if (str[3] == '\0') slen = 3;
- else slen = 4; /* handled later */
+ if (str[0] == '\0')
+ slen = 0;
+ else if (str[1] == '\0')
+ slen = 1;
+ else if (str[2] == '\0')
+ slen = 2;
+ else if (str[3] == '\0')
+ slen = 3;
+ else
+ {
+ slen = 4; /* handled later */
+
+ }
if (slen < 2)
- return;
+ return;
else if (slen < 4)
{
eina_share_common_population_del(stringshare_share, slen);
STRINGSHARE_UNLOCK_SMALL();
return;
}
+
eina_share_common_del(stringshare_share, str);
}
eina_stringshare_add_length(const char *str, unsigned int slen)
{
DBG("str=%p (%.*s), slen=%u", str, slen, str ? str : "", slen);
-
+
if (slen <= 0)
- return "";
+ return "";
else if (slen == 1)
- return (const char *)_eina_stringshare_single + ((*str) << 1);
+ return (const char *)_eina_stringshare_single + ((*str) << 1);
else if (slen < 4)
{
const char *s;
STRINGSHARE_UNLOCK_SMALL();
return s;
}
- return eina_share_common_add_length(stringshare_share, str, slen * sizeof(char), sizeof(char));
+
+ return eina_share_common_add_length(stringshare_share, str, slen *
+ sizeof(char), sizeof(char));
}
/**
eina_stringshare_add(const char *str)
{
int slen;
- if (!str) return NULL;
-
- if (str[0] == '\0') slen = 0;
- else if (str[1] == '\0') slen = 1;
- else if (str[2] == '\0') slen = 2;
- else if (str[3] == '\0') slen = 3;
- else slen = 3 + (int)strlen(str + 3);
-
+ if (!str)
+ return NULL;
+
+ if (str[0] == '\0')
+ slen = 0;
+ else if (str[1] == '\0')
+ slen = 1;
+ else if (str[2] == '\0')
+ slen = 2;
+ else if (str[3] == '\0')
+ slen = 3;
+ else
+ slen = 3 + (int)strlen(str + 3);
+
return eina_stringshare_add_length(str, slen);
}
const char *ret;
int len;
- if (!fmt) return NULL;
+ if (!fmt)
+ return NULL;
va_start(args, fmt);
len = vasprintf(&tmp, fmt, args);
va_end(args);
if (len < 1)
- return NULL;
+ return NULL;
ret = eina_stringshare_add_length(tmp, len);
free(tmp);
const char *ret;
int len;
- if (!fmt) return NULL;
+ if (!fmt)
+ return NULL;
len = vasprintf(&tmp, fmt, args);
if (len < 1)
- return NULL;
+ return NULL;
ret = eina_stringshare_add_length(tmp, len);
free(tmp);
* it is added to the strings to be searched and a duplicated string
* is returned.
*
- * @p len length of the format string will be used. To use the
+ * @p len length of the format string will be used. To use the
* entire format string, use eina_stringshare_printf() instead.
*
* @see eina_stringshare_printf()
char *tmp;
int size;
- if (!fmt) return NULL;
- if (len < 1) return NULL;
+ if (!fmt)
+ return NULL;
+
+ if (len < 1)
+ return NULL;
tmp = alloca(sizeof(char) * len + 1);
va_end(args);
if (size < 1)
- return NULL;
+ return NULL;
return eina_stringshare_add_length(tmp, len);
}
int slen;
DBG("str=%p (%s)", str, str ? str : "");
- if (!str)
- {
- return eina_share_common_ref(stringshare_share, str);
- }
+ if (!str)
+ return eina_share_common_ref(stringshare_share, str);
/* special cases */
- if (str[0] == '\0') slen = 0;
- else if (str[1] == '\0') slen = 1;
- else if (str[2] == '\0') slen = 2;
- else if (str[3] == '\0') slen = 3;
- else slen = 3 + (int)strlen(str + 3);
+ if (str[0] == '\0')
+ slen = 0;
+ else if (str[1] == '\0')
+ slen = 1;
+ else if (str[2] == '\0')
+ slen = 2;
+ else if (str[3] == '\0')
+ slen = 3;
+ else
+ slen = 3 + (int)strlen(str + 3);
if (slen < 2)
{
- eina_share_common_population_add(stringshare_share, slen);
+ eina_share_common_population_add(stringshare_share, slen);
- return str;
+ return str;
}
else if (slen < 4)
{
- const char *s;
- eina_share_common_population_add(stringshare_share, slen);
+ const char *s;
+ eina_share_common_population_add(stringshare_share, slen);
- STRINGSHARE_LOCK_SMALL();
- s = _eina_stringshare_small_add(str, slen);
- STRINGSHARE_UNLOCK_SMALL();
+ STRINGSHARE_LOCK_SMALL();
+ s = _eina_stringshare_small_add(str, slen);
+ STRINGSHARE_UNLOCK_SMALL();
- return s;
+ return s;
}
return eina_share_common_ref(stringshare_share, str);
{
int len;
/* special cases */
- if (str[0] == '\0') return 0;
- if (str[1] == '\0') return 1;
- if (str[2] == '\0') return 2;
- if (str[3] == '\0') return 3;
+ if (str[0] == '\0')
+ return 0;
+
+ if (str[1] == '\0')
+ return 1;
+
+ if (str[2] == '\0')
+ return 2;
+
+ if (str[3] == '\0')
+ return 3;
- len = eina_share_common_length(stringshare_share, (const char *) str);
- len = (len > 0) ? len / (int) sizeof(char) : -1;
+ len = eina_share_common_length(stringshare_share, (const char *)str);
+ len = (len > 0) ? len / (int)sizeof(char) : -1;
return len;
}
EAPI void
eina_stringshare_dump(void)
{
- eina_share_common_dump(stringshare_share, _eina_stringshare_small_dump, sizeof(_eina_stringshare_single));
+ eina_share_common_dump(stringshare_share,
+ _eina_stringshare_small_dump,
+ sizeof(_eina_stringshare_single));
}
/**
#include "eina_error.h"
/*============================================================================*
- * Local *
- *============================================================================*/
+* Local *
+*============================================================================*/
/* The splitter data types */
typedef struct list_node list_node_t;
struct list_node
{
- struct list_node *next;
+ struct list_node *next;
};
struct list
{
- struct list_node *head;
- struct list_node *tail;
+ struct list_node *head;
+ struct list_node *tail;
};
struct rect
{
- short right;
- short bottom;
- short left;
- short top;
- short width;
- short height;
- int area;
+ short right;
+ short bottom;
+ short left;
+ short top;
+ short width;
+ short height;
+ int area;
};
struct rect_node
{
- struct list_node _lst;
- struct rect rect;
+ struct list_node _lst;
+ struct rect rect;
};
typedef struct splitter
{
- Eina_Bool need_merge;
- list_t rects;
+ Eina_Bool need_merge;
+ list_t rects;
} splitter_t;
typedef struct list_node_pool
{
- list_node_t *node;
- int len;
- int max;
+ list_node_t *node;
+ int len;
+ int max;
} list_node_pool_t;
typedef struct _Eina_Iterator_Tiler
{
- Eina_Iterator iterator;
- const Eina_Tiler *tiler;
- list_node_t *curr;
- EINA_MAGIC
+ Eina_Iterator iterator;
+ const Eina_Tiler *tiler;
+ list_node_t *curr;
+ EINA_MAGIC
} Eina_Iterator_Tiler;
struct _Eina_Tiler
{
- struct
- {
- int w, h;
- } tile;
- Eina_Rectangle area;
- EINA_MAGIC
- splitter_t splitter;
+ struct
+ {
+ int w, h;
+ } tile;
+ Eina_Rectangle area;
+ EINA_MAGIC
+ splitter_t splitter;
};
-#define EINA_MAGIC_CHECK_TILER(d, ...) \
- do { \
- if (!EINA_MAGIC_CHECK(d, EINA_MAGIC_TILER)) \
- { \
- EINA_MAGIC_FAIL(d, EINA_MAGIC_TILER); \
- return __VA_ARGS__; \
- } \
- } while(0)
-
-
-#define EINA_MAGIC_CHECK_TILER_ITERATOR(d, ...) \
- do { \
- if (!EINA_MAGIC_CHECK(d, EINA_MAGIC_TILER_ITERATOR)) \
- { \
- EINA_MAGIC_FAIL(d, EINA_MAGIC_TILER_ITERATOR); \
- return __VA_ARGS__; \
- } \
- } while(0)
+#define EINA_MAGIC_CHECK_TILER(d, ...) \
+ do { \
+ if (!EINA_MAGIC_CHECK(d, EINA_MAGIC_TILER)) \
+ { \
+ EINA_MAGIC_FAIL(d, EINA_MAGIC_TILER); \
+ return __VA_ARGS__; \
+ } \
+ } while(0)
+
+
+#define EINA_MAGIC_CHECK_TILER_ITERATOR(d, ...) \
+ do { \
+ if (!EINA_MAGIC_CHECK(d, EINA_MAGIC_TILER_ITERATOR)) \
+ { \
+ EINA_MAGIC_FAIL(d, EINA_MAGIC_TILER_ITERATOR); \
+ return __VA_ARGS__; \
+ } \
+ } while(0)
/* The Splitter algorithm */
static inline void rect_init(rect_t *r, int x, int y, int w, int h)
{
- r->area = w * h;
+ r->area = w * h;
- r->left = x;
- r->top = y;
+ r->left = x;
+ r->top = y;
- r->right = x + w;
- r->bottom = y + h;
+ r->right = x + w;
+ r->bottom = y + h;
- r->width = w;
- r->height = h;
+ r->width = w;
+ r->height = h;
}
static inline list_node_t *
rect_list_node_pool_get(void)
{
- if (list_node_pool.node)
- {
- list_node_t *node;
-
- node = list_node_pool.node;
- list_node_pool.node = node->next;
- list_node_pool.len--;
-
- return node;
- }
- else
- return malloc(sizeof(rect_node_t));
+ if (list_node_pool.node)
+ {
+ list_node_t *node;
+
+ node = list_node_pool.node;
+ list_node_pool.node = node->next;
+ list_node_pool.len--;
+
+ return node;
+ }
+ else
+ return malloc(sizeof(rect_node_t));
}
static inline void rect_list_concat(list_t *rects, list_t *other)
{
- if (!other->head)
- return;
-
- if (rects->tail)
- {
- rects->tail->next = other->head;
- rects->tail = other->tail;
- }
- else
- {
- rects->head = other->head;
- rects->tail = other->tail;
- }
- *other = list_zeroed;
+ if (!other->head)
+ return;
+
+ if (rects->tail)
+ {
+ rects->tail->next = other->head;
+ rects->tail = other->tail;
+ }
+ else
+ {
+ rects->head = other->head;
+ rects->tail = other->tail;
+ }
+
+ *other = list_zeroed;
}
static inline void rect_list_append_node(list_t *rects, list_node_t *node)
{
- if (rects->tail)
- {
- rects->tail->next = node;
- rects->tail = node;
- }
- else
- {
- rects->head = node;
- rects->tail = node;
- }
+ if (rects->tail)
+ {
+ rects->tail->next = node;
+ rects->tail = node;
+ }
+ else
+ {
+ rects->head = node;
+ rects->tail = node;
+ }
}
static inline void rect_list_append(list_t *rects, const rect_t r)
{
- rect_node_t *rect_node;
+ rect_node_t *rect_node;
- rect_node = (rect_node_t *) rect_list_node_pool_get();
- rect_node->rect = r;
- rect_node->_lst = list_node_zeroed;
+ rect_node = (rect_node_t *)rect_list_node_pool_get();
+ rect_node->rect = r;
+ rect_node->_lst = list_node_zeroed;
- rect_list_append_node(rects, (list_node_t *) rect_node);
+ rect_list_append_node(rects, (list_node_t *)rect_node);
}
-static inline void rect_list_append_xywh(list_t *rects, int x, int y, int w, int h)
+static inline void rect_list_append_xywh(list_t *rects,
+ int x,
+ int y,
+ int w,
+ int h)
{
- rect_t r;
+ rect_t r;
- rect_init(&r, x, y, w, h);
- rect_list_append(rects, r);
+ rect_init(&r, x, y, w, h);
+ rect_list_append(rects, r);
}
static inline void _calc_intra_rect_area(const rect_t a, const rect_t b,
- int *width, int *height)
+ int *width, int *height)
{
- int max_left, min_right, max_top, min_bottom;
+ int max_left, min_right, max_top, min_bottom;
- if (a.left < b.left)
- max_left = b.left;
- else
- max_left = a.left;
+ if (a.left < b.left)
+ max_left = b.left;
+ else
+ max_left = a.left;
- if (a.right < b.right)
- min_right = a.right;
- else
- min_right = b.right;
+ if (a.right < b.right)
+ min_right = a.right;
+ else
+ min_right = b.right;
- *width = min_right - max_left;
+ *width = min_right - max_left;
- if (a.top < b.top)
- max_top = b.top;
- else
- max_top = a.top;
+ if (a.top < b.top)
+ max_top = b.top;
+ else
+ max_top = a.top;
- if (a.bottom < b.bottom)
- min_bottom = a.bottom;
- else
- min_bottom = b.bottom;
+ if (a.bottom < b.bottom)
+ min_bottom = a.bottom;
+ else
+ min_bottom = b.bottom;
- *height = min_bottom - max_top;
+ *height = min_bottom - max_top;
}
static inline void _split_strict(list_t *dirty, const rect_t current, rect_t r)
{
- int h_1, h_2, w_1, w_2;
-
- h_1 = current.top - r.top;
- h_2 = r.bottom - current.bottom;
- w_1 = current.left - r.left;
- w_2 = r.right - current.right;
-
- if (h_1 > 0)
- {
- /* .--.r (b) .---.r2
- * | | | |
- * .-------.cur (a) .---.r '---'
- * | | | | -> | | +
- * | `--' | `---'
- * `-------'
- */
- rect_list_append_xywh(dirty, r.left, r.top, r.width, h_1);
- r.height -= h_1;
- r.top = current.top;
- }
-
- if (h_2 > 0)
- {
- /* .-------.cur (a)
- * | .---. | .---.r
- * | | | | -> | |
- * `-------' `---' + .---.r2
- * | | | |
- * `---'r (b) `---'
- */
- rect_list_append_xywh(dirty, r.left, current.bottom, r.width,
- h_2);
- r.height -= h_2;
- }
-
- if (w_1 > 0)
- {
- /* (b) r .----.cur (a)
- * .--|-. | .--.r2 .-.r
- * | | | | -> | | + | |
- * `--|-' | `--' `-'
- * `----'
- */
- rect_list_append_xywh(dirty, r.left, r.top, w_1, r.height);
- /* not necessary to keep these, r (b) will be destroyed */
- /* r.width -= w_1; */
- /* r.left = current.left; */
- }
-
- if (w_2 > 0)
- {
- /* .----.cur (a)
- * | |
- * | .-|--.r (b) .-.r .--.r2
- * | | | | -> | | + | |
- * | `-|--' `-' `--'
- * `----'
- */
- rect_list_append_xywh(dirty, current.right, r.top, w_2,
- r.height);
- /* not necessary to keep this, r (b) will be destroyed */
- /* r.width -= w_2; */
- }
+ int h_1, h_2, w_1, w_2;
+
+ h_1 = current.top - r.top;
+ h_2 = r.bottom - current.bottom;
+ w_1 = current.left - r.left;
+ w_2 = r.right - current.right;
+
+ if (h_1 > 0)
+ {
+ /* .--.r (b) .---.r2
+ * | | | |
+ * .-------.cur (a) .---.r '---'
+ * | | | | -> | | +
+ * | `--' | `---'
+ * `-------'
+ */
+ rect_list_append_xywh(dirty, r.left, r.top, r.width, h_1);
+ r.height -= h_1;
+ r.top = current.top;
+ }
+
+ if (h_2 > 0)
+ {
+ /* .-------.cur (a)
+ * | .---. | .---.r
+ * | | | | -> | |
+ * `-------' `---' + .---.r2
+ * | | | |
+ * `---'r (b) `---'
+ */
+ rect_list_append_xywh(dirty, r.left, current.bottom, r.width,
+ h_2);
+ r.height -= h_2;
+ }
+
+ if (w_1 > 0)
+ /* (b) r .----.cur (a)
+ * .--|-. | .--.r2 .-.r
+ * | | | | -> | | + | |
+ * `--|-' | `--' `-'
+ * `----'
+ */
+ rect_list_append_xywh(dirty, r.left, r.top, w_1, r.height);
+ /* not necessary to keep these, r (b) will be destroyed */
+ /* r.width -= w_1; */
+ /* r.left = current.left; */
+
+ if (w_2 > 0)
+ /* .----.cur (a)
+ * | |
+ * | .-|--.r (b) .-.r .--.r2
+ * | | | | -> | | + | |
+ * | `-|--' `-' `--'
+ * `----'
+ */
+ rect_list_append_xywh(dirty, current.right, r.top, w_2,
+ r.height);
+ /* not necessary to keep this, r (b) will be destroyed */
+ /* r.width -= w_2; */
}
static inline void _calc_intra_outer_rect_area(const rect_t a, const rect_t b,
- rect_t *intra, rect_t *outer)
+ rect_t *intra, rect_t *outer)
{
- int min_left, max_left, min_right, max_right;
- int min_top, max_top, min_bottom, max_bottom;
-
- if (a.left < b.left)
- {
- max_left = b.left;
- min_left = a.left;
- }
- else
- {
- max_left = a.left;
- min_left = b.left;
- }
-
- if (a.right < b.right)
- {
- min_right = a.right;
- max_right = b.right;
- }
- else
- {
- min_right = b.right;
- max_right = a.right;
- }
-
- intra->left = max_left;
- intra->right = min_right;
- intra->width = min_right - max_left;
-
- outer->left = min_left;
- outer->right = max_right;
- outer->width = max_right - min_left;
-
- if (a.top < b.top)
- {
- max_top = b.top;
- min_top = a.top;
- }
- else
- {
- max_top = a.top;
- min_top = b.top;
- }
-
- if (a.bottom < b.bottom)
- {
- min_bottom = a.bottom;
- max_bottom = b.bottom;
- }
- else
- {
- min_bottom = b.bottom;
- max_bottom = a.bottom;
- }
-
- intra->top = max_top;
- intra->bottom = min_bottom;
- intra->height = min_bottom - max_top;
- if ((intra->width > 0) && (intra->height > 0))
- intra->area = intra->width * intra->height;
- else
- intra->area = 0;
-
- outer->top = min_top;
- outer->bottom = max_bottom;
- outer->height = max_bottom - min_top;
- outer->area = outer->width * outer->height;
+ int min_left, max_left, min_right, max_right;
+ int min_top, max_top, min_bottom, max_bottom;
+
+ if (a.left < b.left)
+ {
+ max_left = b.left;
+ min_left = a.left;
+ }
+ else
+ {
+ max_left = a.left;
+ min_left = b.left;
+ }
+
+ if (a.right < b.right)
+ {
+ min_right = a.right;
+ max_right = b.right;
+ }
+ else
+ {
+ min_right = b.right;
+ max_right = a.right;
+ }
+
+ intra->left = max_left;
+ intra->right = min_right;
+ intra->width = min_right - max_left;
+
+ outer->left = min_left;
+ outer->right = max_right;
+ outer->width = max_right - min_left;
+
+ if (a.top < b.top)
+ {
+ max_top = b.top;
+ min_top = a.top;
+ }
+ else
+ {
+ max_top = a.top;
+ min_top = b.top;
+ }
+
+ if (a.bottom < b.bottom)
+ {
+ min_bottom = a.bottom;
+ max_bottom = b.bottom;
+ }
+ else
+ {
+ min_bottom = b.bottom;
+ max_bottom = a.bottom;
+ }
+
+ intra->top = max_top;
+ intra->bottom = min_bottom;
+ intra->height = min_bottom - max_top;
+ if ((intra->width > 0) && (intra->height > 0))
+ intra->area = intra->width * intra->height;
+ else
+ intra->area = 0;
+
+ outer->top = min_top;
+ outer->bottom = max_bottom;
+ outer->height = max_bottom - min_top;
+ outer->area = outer->width * outer->height;
}
enum
{
- SPLIT_FUZZY_ACTION_NONE,
- SPLIT_FUZZY_ACTION_SPLIT,
- SPLIT_FUZZY_ACTION_MERGE
+ SPLIT_FUZZY_ACTION_NONE,
+ SPLIT_FUZZY_ACTION_SPLIT,
+ SPLIT_FUZZY_ACTION_MERGE
};
static inline int _split_fuzzy(list_t *dirty, const rect_t a, rect_t *b)
{
- int h_1, h_2, w_1, w_2, action;
-
- h_1 = a.top - b->top;
- h_2 = b->bottom - a.bottom;
- w_1 = a.left - b->left;
- w_2 = b->right - a.right;
-
- action = SPLIT_FUZZY_ACTION_NONE;
-
- if (h_1 > 0)
- {
- /* .--.r (b) .---.r2
- * | | | |
- * .-------.cur (a) .---.r '---'
- * | | | | -> | | +
- * | `--' | `---'
- * `-------'
- */
- rect_list_append_xywh(dirty, b->left, b->top, b->width, h_1);
- b->height -= h_1;
- b->top = a.top;
- action = SPLIT_FUZZY_ACTION_SPLIT;
- }
-
- if (h_2 > 0)
- {
- /* .-------.cur (a)
- * | .---. | .---.r
- * | | | | -> | |
- * `-------' `---' + .---.r2
- * | | | |
- * `---'r (b) `---'
- */
- rect_list_append_xywh(dirty, b->left, a.bottom, b->width, h_2);
- b->height -= h_2;
- action = SPLIT_FUZZY_ACTION_SPLIT;
- }
-
- if (((w_1 > 0) || (w_2 > 0)) && (a.height == b->height))
- return SPLIT_FUZZY_ACTION_MERGE;
-
- if (w_1 > 0)
- {
- /* (b) r .----.cur (a)
- * .--|-. | .--.r2 .-.r
- * | | | | -> | | + | |
- * `--|-' | `--' `-'
- * `----'
- */
- rect_list_append_xywh(dirty, b->left, b->top, w_1, b->height);
- /* not necessary to keep these, r (b) will be destroyed */
- /* b->width -= w_1; */
- /* b->left = a.left; */
- action = SPLIT_FUZZY_ACTION_SPLIT;
- }
-
- if (w_2 > 0)
- {
- /* .----.cur (a)
- * | |
- * | .-|--.r (b) .-.r .--.r2
- * | | | | -> | | + | |
- * | `-|--' `-' `--'
- * `----'
- */
- rect_list_append_xywh(dirty, a.right, b->top, w_2, b->height);
- /* not necessary to keep these, r (b) will be destroyed */
- /* b->width -= w_2; */
- action = SPLIT_FUZZY_ACTION_SPLIT;
- }
-
- return action;
+ int h_1, h_2, w_1, w_2, action;
+
+ h_1 = a.top - b->top;
+ h_2 = b->bottom - a.bottom;
+ w_1 = a.left - b->left;
+ w_2 = b->right - a.right;
+
+ action = SPLIT_FUZZY_ACTION_NONE;
+
+ if (h_1 > 0)
+ {
+ /* .--.r (b) .---.r2
+ * | | | |
+ * .-------.cur (a) .---.r '---'
+ * | | | | -> | | +
+ * | `--' | `---'
+ * `-------'
+ */
+ rect_list_append_xywh(dirty, b->left, b->top, b->width, h_1);
+ b->height -= h_1;
+ b->top = a.top;
+ action = SPLIT_FUZZY_ACTION_SPLIT;
+ }
+
+ if (h_2 > 0)
+ {
+ /* .-------.cur (a)
+ * | .---. | .---.r
+ * | | | | -> | |
+ * `-------' `---' + .---.r2
+ * | | | |
+ * `---'r (b) `---'
+ */
+ rect_list_append_xywh(dirty, b->left, a.bottom, b->width, h_2);
+ b->height -= h_2;
+ action = SPLIT_FUZZY_ACTION_SPLIT;
+ }
+
+ if (((w_1 > 0) || (w_2 > 0)) && (a.height == b->height))
+ return SPLIT_FUZZY_ACTION_MERGE;
+
+ if (w_1 > 0)
+ {
+ /* (b) r .----.cur (a)
+ * .--|-. | .--.r2 .-.r
+ * | | | | -> | | + | |
+ * `--|-' | `--' `-'
+ * `----'
+ */
+ rect_list_append_xywh(dirty, b->left, b->top, w_1, b->height);
+ /* not necessary to keep these, r (b) will be destroyed */
+ /* b->width -= w_1; */
+ /* b->left = a.left; */
+ action = SPLIT_FUZZY_ACTION_SPLIT;
+ }
+
+ if (w_2 > 0)
+ {
+ /* .----.cur (a)
+ * | |
+ * | .-|--.r (b) .-.r .--.r2
+ * | | | | -> | | + | |
+ * | `-|--' `-' `--'
+ * `----'
+ */
+ rect_list_append_xywh(dirty, a.right, b->top, w_2, b->height);
+ /* not necessary to keep these, r (b) will be destroyed */
+ /* b->width -= w_2; */
+ action = SPLIT_FUZZY_ACTION_SPLIT;
+ }
+
+ return action;
}
#if 0
static void rect_list_node_pool_set_max(int max)
{
- int diff;
+ int diff;
- diff = list_node_pool.len - max;
- for (; diff > 0 && list_node_pool.node != NULL; diff--)
- {
- list_node_t *node;
+ diff = list_node_pool.len - max;
+ for (; diff > 0 && list_node_pool.node != NULL; diff--)
+ {
+ list_node_t *node;
- node = list_node_pool.node;
- list_node_pool.node = node->next;
- list_node_pool.len--;
+ node = list_node_pool.node;
+ list_node_pool.node = node->next;
+ list_node_pool.len--;
- free(node);
- }
+ free(node);
+ }
- list_node_pool.max = max;
+ list_node_pool.max = max;
}
#endif
static void rect_list_node_pool_flush(void)
{
- while (list_node_pool.node)
- {
- list_node_t *node;
+ while (list_node_pool.node)
+ {
+ list_node_t *node;
- node = list_node_pool.node;
- list_node_pool.node = node->next;
- list_node_pool.len--;
+ node = list_node_pool.node;
+ list_node_pool.node = node->next;
+ list_node_pool.len--;
- free(node);
- }
+ free(node);
+ }
}
static inline void rect_list_node_pool_put(list_node_t *node)
{
- if (list_node_pool.len < list_node_pool.max)
- {
- node->next = list_node_pool.node;
- list_node_pool.node = node;
- list_node_pool.len++;
- }
- else
- free(node);
+ if (list_node_pool.len < list_node_pool.max)
+ {
+ node->next = list_node_pool.node;
+ list_node_pool.node = node;
+ list_node_pool.len++;
+ }
+ else
+ free(node);
}
#if 0
static void rect_print(const rect_t r)
{
- printf("<rect(%d, %d, %d, %d)>", r.left, r.top, r.width, r.height);
+ printf("<rect(%d, %d, %d, %d)>", r.left, r.top, r.width, r.height);
}
static void rect_list_print(const list_t rects)
{
- list_node_t *node;
- int len;
-
- len = 0;
- for (node = rects.head; node != NULL; node = node->next)
- len++;
-
- printf("[");
- for (node = rects.head; node != NULL; node = node->next)
- {
- rect_print(((rect_node_t *) node)->rect);
- if (node->next)
- {
- putchar(',');
- if (len < 4)
- putchar(' ');
- else
- {
- putchar('\n');
- putchar(' ');
- }
- }
- }
- printf("]\n");
+ list_node_t *node;
+ int len;
+
+ len = 0;
+ for (node = rects.head; node != NULL; node = node->next)
+ len++;
+
+ printf("[");
+ for (node = rects.head; node != NULL; node = node->next)
+ {
+ rect_print(((rect_node_t *)node)->rect);
+ if (node->next)
+ {
+ putchar(',');
+ if (len < 4)
+ putchar(' ');
+ else
+ {
+ putchar('\n');
+ putchar(' ');
+ }
+ }
+ }
+ printf("]\n");
}
#endif
static inline list_node_t *
rect_list_unlink_next(list_t *rects, list_node_t *parent_node)
{
- list_node_t *node;
-
- if (parent_node)
- {
- node = parent_node->next;
- parent_node->next = node->next;
- }
- else
- {
- node = rects->head;
- rects->head = node->next;
- }
-
- if (rects->tail == node)
- rects->tail = parent_node;
- *node = list_node_zeroed;
- return node;
+ list_node_t *node;
+
+ if (parent_node)
+ {
+ node = parent_node->next;
+ parent_node->next = node->next;
+ }
+ else
+ {
+ node = rects->head;
+ rects->head = node->next;
+ }
+
+ if (rects->tail == node)
+ rects->tail = parent_node;
+
+ *node = list_node_zeroed;
+ return node;
}
static inline void rect_list_del_next(list_t *rects, list_node_t *parent_node)
{
- list_node_t *node;
+ list_node_t *node;
- node = rect_list_unlink_next(rects, parent_node);
- rect_list_node_pool_put(node);
+ node = rect_list_unlink_next(rects, parent_node);
+ rect_list_node_pool_put(node);
}
static void rect_list_clear(list_t *rects)
{
- list_node_t *node;
-
- node = rects->head;
- while (node)
- {
- list_node_t *aux;
-
- aux = node->next;
- rect_list_node_pool_put(node);
- node = aux;
- }
- *rects = list_zeroed;
+ list_node_t *node;
+
+ node = rects->head;
+ while (node)
+ {
+ list_node_t *aux;
+
+ aux = node->next;
+ rect_list_node_pool_put(node);
+ node = aux;
+ }
+ *rects = list_zeroed;
}
static void rect_list_del_split_strict(list_t *rects, const rect_t del_r)
{
- list_t modified = list_zeroed;
- list_node_t *cur_node, *prev_node;
-
- prev_node = NULL;
- cur_node = rects->head;
- while (cur_node)
- {
- int intra_width, intra_height;
- rect_t current;
-
- current = ((rect_node_t*) cur_node)->rect;
-
- _calc_intra_rect_area(del_r, current, &intra_width,
- &intra_height);
- if ((intra_width <= 0) || (intra_height <= 0))
- {
- /* .---.current .---.del_r
- * | | | |
- * `---+---.del_r `---+---.current
- * | | | |
- * `---' `---'
- * no intersection, nothing to do
- */
- prev_node = cur_node;
- cur_node = cur_node->next;
- }
- else if ((intra_width == current.width) && (intra_height
- == current.height))
- {
- /* .-------.del_r
- * | .---. |
- * | | | |
- * | `---'current
- * `-------'
- * current is contained, remove from rects
- */
- cur_node = cur_node->next;
- rect_list_del_next(rects, prev_node);
- }
- else
- {
- _split_strict(&modified, del_r, current);
- cur_node = cur_node->next;
- rect_list_del_next(rects, prev_node);
- }
- }
-
- rect_list_concat(rects, &modified);
+ list_t modified = list_zeroed;
+ list_node_t *cur_node, *prev_node;
+
+ prev_node = NULL;
+ cur_node = rects->head;
+ while (cur_node)
+ {
+ int intra_width, intra_height;
+ rect_t current;
+
+ current = ((rect_node_t *)cur_node)->rect;
+
+ _calc_intra_rect_area(del_r, current, &intra_width,
+ &intra_height);
+ if ((intra_width <= 0) || (intra_height <= 0))
+ {
+ /* .---.current .---.del_r
+ * | | | |
+ * `---+---.del_r `---+---.current
+ * | | | |
+ * `---' `---'
+ * no intersection, nothing to do
+ */
+ prev_node = cur_node;
+ cur_node = cur_node->next;
+ }
+ else if ((intra_width == current.width) && (intra_height
+ == current.height))
+ {
+ /* .-------.del_r
+ * | .---. |
+ * | | | |
+ * | `---'current
+ * `-------'
+ * current is contained, remove from rects
+ */
+ cur_node = cur_node->next;
+ rect_list_del_next(rects, prev_node);
+ }
+ else
+ {
+ _split_strict(&modified, del_r, current);
+ cur_node = cur_node->next;
+ rect_list_del_next(rects, prev_node);
+ }
+ }
+
+ rect_list_concat(rects, &modified);
}
#if 0
static void rect_list_add_split_strict(list_t *rects, list_node_t *node)
{
- list_t dirty = list_zeroed;
- list_t new_dirty = list_zeroed;
- list_node_t *cur_node;
-
- if (!rects->head)
- {
- rect_list_append_node(rects, node);
- return;
- }
-
- rect_list_append_node(&dirty, node);
-
- cur_node = rects->head;
- while (dirty.head)
- {
- rect_t current;
-
- if (!cur_node)
- {
- rect_list_concat(rects, &dirty);
- break;
- }
-
- current = ((rect_node_t*) cur_node)->rect;
-
- while (dirty.head)
- {
- int intra_width, intra_height;
- rect_t r;
-
- r = ((rect_node_t *) dirty.head)->rect;
- _calc_intra_rect_area(r, current, &intra_width,
- &intra_height);
- if ((intra_width == r.width) && (intra_height
- == r.height))
- /* .-------.cur
- * | .---.r|
- * | | | |
- * | `---' |
- * `-------'
- */
- rect_list_del_next(&dirty, NULL);
- else if ((intra_width <= 0) || (intra_height <= 0))
- {
- /* .---.cur .---.r
- * | | | |
- * `---+---.r `---+---.cur
- * | | | |
- * `---' `---'
- */
- list_node_t *tmp;
- tmp = rect_list_unlink_next(&dirty, NULL);
- rect_list_append_node(&new_dirty, tmp);
- }
- else
- {
- _split_strict(&new_dirty, current, r);
- rect_list_del_next(&dirty, NULL);
- }
- }
- dirty = new_dirty;
- new_dirty = list_zeroed;
-
- cur_node = cur_node->next;
- }
+ list_t dirty = list_zeroed;
+ list_t new_dirty = list_zeroed;
+ list_node_t *cur_node;
+
+ if (!rects->head)
+ {
+ rect_list_append_node(rects, node);
+ return;
+ }
+
+ rect_list_append_node(&dirty, node);
+
+ cur_node = rects->head;
+ while (dirty.head)
+ {
+ rect_t current;
+
+ if (!cur_node)
+ {
+ rect_list_concat(rects, &dirty);
+ break;
+ }
+
+ current = ((rect_node_t *)cur_node)->rect;
+
+ while (dirty.head)
+ {
+ int intra_width, intra_height;
+ rect_t r;
+
+ r = ((rect_node_t *)dirty.head)->rect;
+ _calc_intra_rect_area(r, current, &intra_width,
+ &intra_height);
+ if ((intra_width == r.width) && (intra_height
+ == r.height))
+ /* .-------.cur
+ * | .---.r|
+ * | | | |
+ * | `---' |
+ * `-------'
+ */
+ rect_list_del_next(&dirty, NULL);
+ else if ((intra_width <= 0) || (intra_height <= 0))
+ {
+ /* .---.cur .---.r
+ * | | | |
+ * `---+---.r `---+---.cur
+ * | | | |
+ * `---' `---'
+ */
+ list_node_t *tmp;
+ tmp = rect_list_unlink_next(&dirty, NULL);
+ rect_list_append_node(&new_dirty, tmp);
+ }
+ else
+ {
+ _split_strict(&new_dirty, current, r);
+ rect_list_del_next(&dirty, NULL);
+ }
+ }
+ dirty = new_dirty;
+ new_dirty = list_zeroed;
+
+ cur_node = cur_node->next;
+ }
}
#endif
static list_node_t *
rect_list_add_split_fuzzy(list_t *rects, list_node_t *node, int accepted_error)
{
- list_t dirty = list_zeroed;
- list_node_t *old_last;
-
- old_last = rects->tail;
-
- if (!rects->head)
- {
- rect_list_append_node(rects, node);
- return old_last;
- }
-
- rect_list_append_node(&dirty, node);
- while (dirty.head)
- {
- list_node_t *d_node, *cur_node, *prev_cur_node;
- int keep_dirty;
- rect_t r;
-
- d_node = rect_list_unlink_next(&dirty, NULL);
- r = ((rect_node_t *) d_node)->rect;
-
- prev_cur_node = NULL;
- cur_node = rects->head;
- keep_dirty = 1;
- while (cur_node)
- {
- int area, action;
- rect_t current, intra, outer;
-
- current = ((rect_node_t *) cur_node)->rect;
-
- _calc_intra_outer_rect_area(r, current, &intra, &outer);
- area = current.area + r.area - intra.area;
-
- if ((intra.width == r.width) && (intra.height
- == r.height))
- {
- /* .-------.cur
- * | .---.r|
- * | | | |
- * | `---' |
- * `-------'
- */
- keep_dirty = 0;
- break;
- }
- else if ((intra.width == current.width)
- && (intra.height == current.height))
- {
- /* .-------.r
- * | .---.cur
- * | | | |
- * | `---' |
- * `-------'
- */
- if (old_last == cur_node)
- old_last = prev_cur_node;
- cur_node = cur_node->next;
- rect_list_del_next(rects, prev_cur_node);
- }
- else if ((outer.area - area) <= accepted_error)
- {
- /* .-----------. bounding box (outer)
- * |.---. .---.|
- * ||cur| |r ||
- * || | | ||
- * |`---' `---'|
- * `-----------'
- * merge them, remove both and add merged
- */
- rect_node_t *n;
-
- if (old_last == cur_node)
- old_last = prev_cur_node;
-
- n = (rect_node_t *) rect_list_unlink_next(
- rects, prev_cur_node);
- n->rect = outer;
- rect_list_append_node(&dirty, (list_node_t *) n);
-
- keep_dirty = 0;
- break;
- }
- else if (intra.area <= accepted_error)
- {
- /* .---.cur .---.r
- * | | | |
- * `---+---.r `---+---.cur
- * | | | |
- * `---' `---'
- * no split, no merge
- */
- prev_cur_node = cur_node;
- cur_node = cur_node->next;
- }
- else
- {
- /* split is required */
- action = _split_fuzzy(&dirty, current, &r);
- if (action == SPLIT_FUZZY_ACTION_MERGE)
- {
- /* horizontal merge is possible: remove both, add merged */
- rect_node_t *n;
-
- if (old_last == cur_node)
- old_last = prev_cur_node;
-
- n
- = (rect_node_t *) rect_list_unlink_next(
- rects,
- prev_cur_node);
-
- n->rect.left = outer.left;
- n->rect.width = outer.width;
- n->rect.right = outer.right;
- n->rect.area = outer.width * r.height;
- rect_list_append_node(&dirty,
- (list_node_t *) n);
- }
- else if (action == SPLIT_FUZZY_ACTION_NONE)
- {
- /*
- * this rect check was totally useless,
- * should never happen
- */
- /* prev_cur_node = cur_node; */
- /* cur_node = cur_node->next; */
- printf("Should not get here!\n");
- abort();
- }
-
- keep_dirty = 0;
- break;
- }
- }
- if (EINA_UNLIKELY(keep_dirty))
- {
- rect_list_append_node(rects, d_node);
- }
- else
- rect_list_node_pool_put(d_node);
- }
-
- return old_last;
+ list_t dirty = list_zeroed;
+ list_node_t *old_last;
+
+ old_last = rects->tail;
+
+ if (!rects->head)
+ {
+ rect_list_append_node(rects, node);
+ return old_last;
+ }
+
+ rect_list_append_node(&dirty, node);
+ while (dirty.head)
+ {
+ list_node_t *d_node, *cur_node, *prev_cur_node;
+ int keep_dirty;
+ rect_t r;
+
+ d_node = rect_list_unlink_next(&dirty, NULL);
+ r = ((rect_node_t *)d_node)->rect;
+
+ prev_cur_node = NULL;
+ cur_node = rects->head;
+ keep_dirty = 1;
+ while (cur_node)
+ {
+ int area, action;
+ rect_t current, intra, outer;
+
+ current = ((rect_node_t *)cur_node)->rect;
+
+ _calc_intra_outer_rect_area(r, current, &intra, &outer);
+ area = current.area + r.area - intra.area;
+
+ if ((intra.width == r.width) && (intra.height
+ == r.height))
+ {
+ /* .-------.cur
+ * | .---.r|
+ * | | | |
+ * | `---' |
+ * `-------'
+ */
+ keep_dirty = 0;
+ break;
+ }
+ else if ((intra.width == current.width)
+ && (intra.height == current.height))
+ {
+ /* .-------.r
+ * | .---.cur
+ * | | | |
+ * | `---' |
+ * `-------'
+ */
+ if (old_last == cur_node)
+ old_last = prev_cur_node;
+
+ cur_node = cur_node->next;
+ rect_list_del_next(rects, prev_cur_node);
+ }
+ else if ((outer.area - area) <= accepted_error)
+ {
+ /* .-----------. bounding box (outer)
+ * |.---. .---.|
+ * ||cur| |r ||
+ * || | | ||
+ * |`---' `---'|
+ * `-----------'
+ * merge them, remove both and add merged
+ */
+ rect_node_t *n;
+
+ if (old_last == cur_node)
+ old_last = prev_cur_node;
+
+ n = (rect_node_t *)rect_list_unlink_next(
+ rects, prev_cur_node);
+ n->rect = outer;
+ rect_list_append_node(&dirty, (list_node_t *)n);
+
+ keep_dirty = 0;
+ break;
+ }
+ else if (intra.area <= accepted_error)
+ {
+ /* .---.cur .---.r
+ * | | | |
+ * `---+---.r `---+---.cur
+ * | | | |
+ * `---' `---'
+ * no split, no merge
+ */
+ prev_cur_node = cur_node;
+ cur_node = cur_node->next;
+ }
+ else
+ {
+ /* split is required */
+ action = _split_fuzzy(&dirty, current, &r);
+ if (action == SPLIT_FUZZY_ACTION_MERGE)
+ {
+/* horizontal merge is possible: remove both, add merged */
+ rect_node_t *n;
+
+ if (old_last == cur_node)
+ old_last = prev_cur_node;
+
+ n
+ = (rect_node_t *)rect_list_unlink_next(
+ rects,
+ prev_cur_node);
+
+ n->rect.left = outer.left;
+ n->rect.width = outer.width;
+ n->rect.right = outer.right;
+ n->rect.area = outer.width * r.height;
+ rect_list_append_node(&dirty,
+ (list_node_t *)n);
+ }
+ else if (action == SPLIT_FUZZY_ACTION_NONE)
+ {
+/*
+ * this rect check was totally useless,
+ * should never happen
+ */
+ /* prev_cur_node = cur_node; */
+/* cur_node = cur_node->next; */
+ printf("Should not get here!\n");
+ abort();
+ }
+
+ keep_dirty = 0;
+ break;
+ }
+ }
+ if (EINA_UNLIKELY(keep_dirty))
+ rect_list_append_node(rects, d_node);
+ else
+ rect_list_node_pool_put(d_node);
+ }
+
+ return old_last;
}
static inline void _calc_outer_rect_area(const rect_t a, const rect_t b,
- rect_t *outer)
+ rect_t *outer)
{
- int min_left, max_right;
- int min_top, max_bottom;
-
- if (a.left < b.left)
- min_left = a.left;
- else
- min_left = b.left;
-
- if (a.right < b.right)
- max_right = b.right;
- else
- max_right = a.right;
-
- outer->left = min_left;
- outer->right = max_right;
- outer->width = max_right - min_left;
-
- if (a.top < b.top)
- min_top = a.top;
- else
- min_top = b.top;
-
- if (a.bottom < b.bottom)
- max_bottom = b.bottom;
- else
- max_bottom = a.bottom;
-
- outer->top = min_top;
- outer->bottom = max_bottom;
- outer->height = max_bottom - min_top;
-
- outer->area = outer->width * outer->height;
+ int min_left, max_right;
+ int min_top, max_bottom;
+
+ if (a.left < b.left)
+ min_left = a.left;
+ else
+ min_left = b.left;
+
+ if (a.right < b.right)
+ max_right = b.right;
+ else
+ max_right = a.right;
+
+ outer->left = min_left;
+ outer->right = max_right;
+ outer->width = max_right - min_left;
+
+ if (a.top < b.top)
+ min_top = a.top;
+ else
+ min_top = b.top;
+
+ if (a.bottom < b.bottom)
+ max_bottom = b.bottom;
+ else
+ max_bottom = a.bottom;
+
+ outer->top = min_top;
+ outer->bottom = max_bottom;
+ outer->height = max_bottom - min_top;
+
+ outer->area = outer->width * outer->height;
}
-static void rect_list_merge_rects(list_t *rects, list_t *to_merge, int accepted_error)
+static void rect_list_merge_rects(list_t *rects,
+ list_t *to_merge,
+ int accepted_error)
{
- while (to_merge->head)
- {
- list_node_t *node, *parent_node;
- rect_t r1;
- int merged;
-
- r1 = ((rect_node_t *) to_merge->head)->rect;
-
- merged = 0;
- parent_node = NULL;
- node = rects->head;
- while (node != NULL)
- {
- rect_t r2, outer;
- int area;
-
- r2 = ((rect_node_t *) node)->rect;
-
- _calc_outer_rect_area(r1, r2, &outer);
- area = r1.area + r2.area; /* intra area is taken as 0 */
- if (outer.area - area <= accepted_error)
- {
- /*
- * remove both r1 and r2, create r3
- * actually r3 uses r2 instance, saves memory
- */
- rect_node_t *n;
-
- n = (rect_node_t *) rect_list_unlink_next(
- rects, parent_node);
- n->rect = outer;
- rect_list_append_node(to_merge,
- (list_node_t *) n);
- merged = 1;
- break;
- }
-
- parent_node = node;
- node = node->next;
- }
-
- if (!merged)
- {
- list_node_t *n;
- n = rect_list_unlink_next(to_merge, NULL);
- rect_list_append_node(rects, n);
- }
- else
- rect_list_del_next(to_merge, NULL);
- }
+ while (to_merge->head)
+ {
+ list_node_t *node, *parent_node;
+ rect_t r1;
+ int merged;
+
+ r1 = ((rect_node_t *)to_merge->head)->rect;
+
+ merged = 0;
+ parent_node = NULL;
+ node = rects->head;
+ while (node != NULL)
+ {
+ rect_t r2, outer;
+ int area;
+
+ r2 = ((rect_node_t *)node)->rect;
+
+ _calc_outer_rect_area(r1, r2, &outer);
+ area = r1.area + r2.area; /* intra area is taken as 0 */
+ if (outer.area - area <= accepted_error)
+ {
+ /*
+ * remove both r1 and r2, create r3
+ * actually r3 uses r2 instance, saves memory
+ */
+ rect_node_t *n;
+
+ n = (rect_node_t *)rect_list_unlink_next(
+ rects, parent_node);
+ n->rect = outer;
+ rect_list_append_node(to_merge,
+ (list_node_t *)n);
+ merged = 1;
+ break;
+ }
+
+ parent_node = node;
+ node = node->next;
+ }
+
+ if (!merged)
+ {
+ list_node_t *n;
+ n = rect_list_unlink_next(to_merge, NULL);
+ rect_list_append_node(rects, n);
+ }
+ else
+ rect_list_del_next(to_merge, NULL);
+ }
}
-static void rect_list_add_split_fuzzy_and_merge(list_t *rects, list_node_t *node,
- int split_accepted_error, int merge_accepted_error)
+static void rect_list_add_split_fuzzy_and_merge(list_t *rects,
+ list_node_t *node,
+ int split_accepted_error,
+ int merge_accepted_error)
{
- list_node_t *n;
+ list_node_t *n;
- n = rect_list_add_split_fuzzy(rects, node, split_accepted_error);
- if (n && n->next)
- {
- list_t to_merge;
+ n = rect_list_add_split_fuzzy(rects, node, split_accepted_error);
+ if (n && n->next)
+ {
+ list_t to_merge;
- /* split list into 2 segments, already merged and to merge */
- to_merge.head = n->next;
- to_merge.tail = rects->tail;
- rects->tail = n;
- n->next = NULL;
+ /* split list into 2 segments, already merged and to merge */
+ to_merge.head = n->next;
+ to_merge.tail = rects->tail;
+ rects->tail = n;
+ n->next = NULL;
- rect_list_merge_rects(rects, &to_merge, merge_accepted_error);
- }
+ rect_list_merge_rects(rects, &to_merge, merge_accepted_error);
+ }
}
static inline void _splitter_new(Eina_Tiler *t)
{
- t->splitter.rects = list_zeroed;
- t->splitter.need_merge = EINA_FALSE;
+ t->splitter.rects = list_zeroed;
+ t->splitter.need_merge = EINA_FALSE;
}
static inline void _splitter_del(Eina_Tiler *t)
{
- rect_list_clear(&t->splitter.rects);
- rect_list_node_pool_flush();
+ rect_list_clear(&t->splitter.rects);
+ rect_list_node_pool_flush();
}
-static inline void _splitter_tile_size_set(Eina_Tiler *t, int w __UNUSED__, int h __UNUSED__)
+static inline void _splitter_tile_size_set(Eina_Tiler *t,
+ int w __UNUSED__,
+ int h __UNUSED__)
{
- /* TODO are w and h used for something? */
- t->splitter.rects = list_zeroed;
+ /* TODO are w and h used for something? */
+ t->splitter.rects = list_zeroed;
}
static inline Eina_Bool _splitter_rect_add(Eina_Tiler *t, Eina_Rectangle *rect)
{
- rect_node_t *rn;
-
- //printf("ACCOUNTING[1]: add_redraw: %4d,%4d %3dx%3d\n", x, y, w, h);
- rect->x >>= 1;
- rect->y >>= 1;
- rect->w += 2;
- rect->w >>= 1;
- rect->h += 2;
- rect->h >>= 1;
-
- rn = (rect_node_t *) rect_list_node_pool_get();
- rn->_lst = list_node_zeroed;
- rect_init(&rn->rect, rect->x, rect->y, rect->w, rect->h);
- //printf("ACCOUNTING[2]: add_redraw: %4d,%4d %3dx%3d\n", x, y, w, h);
- //testing on my core2 duo desktop - fuzz of 32 or 48 is best.
+ rect_node_t *rn;
+
+ //printf("ACCOUNTING[1]: add_redraw: %4d,%4d %3dx%3d\n", x, y, w, h);
+ rect->x >>= 1;
+ rect->y >>= 1;
+ rect->w += 2;
+ rect->w >>= 1;
+ rect->h += 2;
+ rect->h >>= 1;
+
+ rn = (rect_node_t *)rect_list_node_pool_get();
+ rn->_lst = list_node_zeroed;
+ rect_init(&rn->rect, rect->x, rect->y, rect->w, rect->h);
+ //printf("ACCOUNTING[2]: add_redraw: %4d,%4d %3dx%3d\n", x, y, w, h);
+ //testing on my core2 duo desktop - fuzz of 32 or 48 is best.
#define FUZZ 32
- rect_list_add_split_fuzzy_and_merge(&t->splitter.rects,
- (list_node_t *) rn, FUZZ * FUZZ, FUZZ * FUZZ);
- return EINA_TRUE;
+ rect_list_add_split_fuzzy_and_merge(&t->splitter.rects,
+ (list_node_t *)rn,
+ FUZZ * FUZZ,
+ FUZZ * FUZZ);
+ return EINA_TRUE;
}
static inline void _splitter_rect_del(Eina_Tiler *t, Eina_Rectangle *rect)
{
- rect_t r;
-
- if (!t->splitter.rects.head)
- return;
- rect->x += 1;
- rect->y += 1;
- rect->x >>= 1;
- rect->y >>= 1;
- rect->w -= 1;
- rect->w >>= 1;
- rect->h -= 1;
- rect->h >>= 1;
-
- if ((rect->w <= 0) || (rect->h <= 0))
- return;
-
- rect_init(&r, rect->x, rect->y, rect->w, rect->h);
- //fprintf(stderr, "ACCOUNTING: del_redraw: %4d,%4d %3dx%3d\n", x, y, w, h);
-
- rect_list_del_split_strict(&t->splitter.rects, r);
- t->splitter.need_merge = EINA_TRUE;
- return;
+ rect_t r;
+
+ if (!t->splitter.rects.head)
+ return;
+
+ rect->x += 1;
+ rect->y += 1;
+ rect->x >>= 1;
+ rect->y >>= 1;
+ rect->w -= 1;
+ rect->w >>= 1;
+ rect->h -= 1;
+ rect->h >>= 1;
+
+ if ((rect->w <= 0) || (rect->h <= 0))
+ return;
+
+ rect_init(&r, rect->x, rect->y, rect->w, rect->h);
+ //fprintf(stderr, "ACCOUNTING: del_redraw: %4d,%4d %3dx%3d\n", x, y, w, h);
+
+ rect_list_del_split_strict(&t->splitter.rects, r);
+ t->splitter.need_merge = EINA_TRUE;
+ return;
}
static inline void _splitter_clear(Eina_Tiler *t)
{
- rect_list_clear(&t->splitter.rects);
- t->splitter.need_merge = EINA_FALSE;
+ rect_list_clear(&t->splitter.rects);
+ t->splitter.need_merge = EINA_FALSE;
}
/* end of splitter algorithm */
static Eina_Bool _iterator_next(Eina_Iterator_Tiler *it, void **data)
{
- Eina_Rectangle *rect = (Eina_Rectangle *)data;
- list_node_t *n;
+ Eina_Rectangle *rect = (Eina_Rectangle *)data;
+ list_node_t *n;
+
+ for (n = it->curr; n != NULL; n = n->next)
+ {
+ rect_t cur;
- for (n = it->curr; n != NULL; n = n->next)
- {
- rect_t cur;
+ cur = ((rect_node_t *)n)->rect;
- cur = ((rect_node_t *) n)->rect;
+ rect->x = cur.left << 1;
+ rect->y = cur.top << 1;
+ rect->w = cur.width << 1;
+ rect->h = cur.height << 1;
- rect->x = cur.left << 1;
- rect->y = cur.top << 1;
- rect->w = cur.width << 1;
- rect->h = cur.height << 1;
+ if (eina_rectangle_intersection(rect, &it->tiler->area) == EINA_FALSE)
+ continue;
- if (eina_rectangle_intersection(rect, &it->tiler->area) == EINA_FALSE)
- continue;
- if ((rect->w <= 0) || (rect->h <= 0))
- continue;
+ if ((rect->w <= 0) || (rect->h <= 0))
+ continue;
- it->curr = n->next;
- return EINA_TRUE;
- }
- return EINA_FALSE;
+ it->curr = n->next;
+ return EINA_TRUE;
+ }
+ return EINA_FALSE;
}
-static void * _iterator_get_container(Eina_Iterator_Tiler *it)
+static void *_iterator_get_container(Eina_Iterator_Tiler *it)
{
- EINA_MAGIC_CHECK_TILER_ITERATOR(it, NULL);
- return (void *)it->tiler;
+ EINA_MAGIC_CHECK_TILER_ITERATOR(it, NULL);
+ return (void *)it->tiler;
}
static void _iterator_free(Eina_Iterator_Tiler *it)
{
- EINA_MAGIC_CHECK_TILER_ITERATOR(it);
- free(it);
+ EINA_MAGIC_CHECK_TILER_ITERATOR(it);
+ free(it);
}
/*============================================================================*
- * Global *
- *============================================================================*/
+* Global *
+*============================================================================*/
/*============================================================================*
- * API *
- *============================================================================*/
+* API *
+*============================================================================*/
EAPI Eina_Tiler *eina_tiler_new(int w, int h)
{
- Eina_Tiler *t;
-
- t = calloc(1, sizeof(Eina_Tiler));
- t->area.w = w;
- t->area.h = h;
- t->tile.w = w;
- t->tile.h = h;
- EINA_MAGIC_SET(t, EINA_MAGIC_TILER);
- _splitter_new(t);
- return t;
+ Eina_Tiler *t;
+
+ t = calloc(1, sizeof(Eina_Tiler));
+ t->area.w = w;
+ t->area.h = h;
+ t->tile.w = w;
+ t->tile.h = h;
+ EINA_MAGIC_SET(t, EINA_MAGIC_TILER);
+ _splitter_new(t);
+ return t;
}
EAPI void eina_tiler_free(Eina_Tiler *t)
{
- EINA_MAGIC_CHECK_TILER(t);
- _splitter_del(t);
- free(t);
+ EINA_MAGIC_CHECK_TILER(t);
+ _splitter_del(t);
+ free(t);
}
EAPI void eina_tiler_tile_size_set(Eina_Tiler *t, int w, int h)
{
- EINA_MAGIC_CHECK_TILER(t);
- if ((w <= 0) || (h <= 0)) return;
+ EINA_MAGIC_CHECK_TILER(t);
+ if ((w <= 0) || (h <= 0))
+ return;
- t->tile.w = w;
- t->tile.h = h;
- _splitter_tile_size_set(t, w, h);
+ t->tile.w = w;
+ t->tile.h = h;
+ _splitter_tile_size_set(t, w, h);
}
EAPI Eina_Bool eina_tiler_rect_add(Eina_Tiler *t, const Eina_Rectangle *r)
{
- Eina_Rectangle tmp;
-
- EINA_MAGIC_CHECK_TILER(t, EINA_FALSE);
- if ((r->w <= 0) || (r->h <= 0))
- return EINA_FALSE;
- tmp = *r;
- if (eina_rectangle_intersection(&tmp, &t->area) == EINA_FALSE)
- return EINA_FALSE;
- if ((tmp.w <= 0) || (tmp.h <= 0))
- return EINA_FALSE;
- return _splitter_rect_add(t, &tmp);
+ Eina_Rectangle tmp;
+
+ EINA_MAGIC_CHECK_TILER(t, EINA_FALSE);
+ if ((r->w <= 0) || (r->h <= 0))
+ return EINA_FALSE;
+
+ tmp = *r;
+ if (eina_rectangle_intersection(&tmp, &t->area) == EINA_FALSE)
+ return EINA_FALSE;
+
+ if ((tmp.w <= 0) || (tmp.h <= 0))
+ return EINA_FALSE;
+
+ return _splitter_rect_add(t, &tmp);
}
EAPI void eina_tiler_rect_del(Eina_Tiler *t, const Eina_Rectangle *r)
{
- Eina_Rectangle tmp;
-
- EINA_MAGIC_CHECK_TILER(t);
- if ((r->w <= 0) || (r->h <= 0))
- return;
- tmp = *r;
- if (eina_rectangle_intersection(&tmp, &t->area) == EINA_FALSE)
- return;
- if ((tmp.w <= 0) || (tmp.h <= 0))
- return;
- _splitter_rect_del(t, &tmp);
+ Eina_Rectangle tmp;
+
+ EINA_MAGIC_CHECK_TILER(t);
+ if ((r->w <= 0) || (r->h <= 0))
+ return;
+
+ tmp = *r;
+ if (eina_rectangle_intersection(&tmp, &t->area) == EINA_FALSE)
+ return;
+
+ if ((tmp.w <= 0) || (tmp.h <= 0))
+ return;
+
+ _splitter_rect_del(t, &tmp);
}
EAPI void eina_tiler_clear(Eina_Tiler *t)
{
- EINA_MAGIC_CHECK_TILER(t);
- _splitter_clear(t);
+ EINA_MAGIC_CHECK_TILER(t);
+ _splitter_clear(t);
}
-EAPI Eina_Iterator * eina_tiler_iterator_new(const Eina_Tiler *t)
+EAPI Eina_Iterator *eina_tiler_iterator_new(const Eina_Tiler *t)
{
- Eina_Iterator_Tiler *it;
+ Eina_Iterator_Tiler *it;
- EINA_MAGIC_CHECK_TILER(t, NULL);
- it = calloc(1, sizeof (Eina_Iterator_Tiler));
- if (!it) return NULL;
-
- it->tiler = t;
+ EINA_MAGIC_CHECK_TILER(t, NULL);
+ it = calloc(1, sizeof (Eina_Iterator_Tiler));
+ if (!it)
+ return NULL;
- if (t->splitter.need_merge == EINA_TRUE)
- {
- list_t to_merge;
- splitter_t *sp;
+ it->tiler = t;
- sp = (splitter_t *)&(t->splitter);
- to_merge = t->splitter.rects;
- sp->rects = list_zeroed;
- rect_list_merge_rects(&sp->rects, &to_merge, FUZZ * FUZZ);
- sp->need_merge = 0;
- }
+ if (t->splitter.need_merge == EINA_TRUE)
+ {
+ list_t to_merge;
+ splitter_t *sp;
+
+ sp = (splitter_t *)&(t->splitter);
+ to_merge = t->splitter.rects;
+ sp->rects = list_zeroed;
+ rect_list_merge_rects(&sp->rects, &to_merge, FUZZ * FUZZ);
+ sp->need_merge = 0;
+ }
- it->curr = it->tiler->splitter.rects.head;
- it->iterator.next = FUNC_ITERATOR_NEXT(_iterator_next);
- it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(_iterator_get_container);
- it->iterator.free = FUNC_ITERATOR_FREE(_iterator_free);
+ it->curr = it->tiler->splitter.rects.head;
+ it->iterator.next = FUNC_ITERATOR_NEXT(_iterator_next);
+ it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(
+ _iterator_get_container);
+ it->iterator.free = FUNC_ITERATOR_FREE(_iterator_free);
- EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_ITERATOR);
- EINA_MAGIC_SET(it, EINA_MAGIC_TILER_ITERATOR);
+ EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_ITERATOR);
+ EINA_MAGIC_SET(it, EINA_MAGIC_TILER_ITERATOR);
- return &it->iterator;
+ return &it->iterator;
}
struct _Eina_Tile_Grid_Slicer_Iterator
}
static Eina_Bool
-eina_tile_grid_slicer_iterator_next(Eina_Tile_Grid_Slicer_Iterator *it, void **data)
+eina_tile_grid_slicer_iterator_next(Eina_Tile_Grid_Slicer_Iterator *it,
+ void **data)
{
return eina_tile_grid_slicer_next
- (&it->priv, (const Eina_Tile_Grid_Info **)data);
+ (&it->priv, (const Eina_Tile_Grid_Info **)data);
}
/**
* is set.
*/
EAPI Eina_Iterator *
-eina_tile_grid_slicer_iterator_new(int x, int y, int w, int h, int tile_w, int tile_h)
+eina_tile_grid_slicer_iterator_new(int x,
+ int y,
+ int w,
+ int h,
+ int tile_w,
+ int tile_h)
{
Eina_Tile_Grid_Slicer_Iterator *it;
it = calloc(1, sizeof(*it));
if (!it)
{
- eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
- return NULL;
+ eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+ return NULL;
}
EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_ITERATOR);
EAPI int
eina_unicode_strcmp(const Eina_Unicode *a, const Eina_Unicode *b)
{
- for ( ; *a && *a == *b ; a++, b++)
+ for (; *a && *a == *b; a++, b++)
;
if (*a == *b)
return 0;
else if (*a < *b)
return -1;
- else
+ else
return 1;
}
eina_unicode_strcpy(Eina_Unicode *dest, const Eina_Unicode *source)
{
Eina_Unicode *ret = dest;
-
+
while (*source)
*dest++ = *source++;
return ret;
eina_unicode_strncpy(Eina_Unicode *dest, const Eina_Unicode *source, size_t n)
{
Eina_Unicode *ret = dest;
-
- for (n = 0 ; *source && n ; n--)
+
+ for (n = 0; *source && n; n--)
*dest++ = *source++;
- for ( ; n ; n--)
+ for (; n; n--)
*dest++ = 0;
return ret;
}
eina_unicode_strlen(const Eina_Unicode *ustr)
{
const Eina_Unicode *end;
- for (end = ustr ; *end ; end++)
+ for (end = ustr; *end; end++)
;
return end - ustr;
}
int len;
len = eina_unicode_strlen(text);
- ustr = (Eina_Unicode *) calloc(sizeof(Eina_Unicode), len + 1);
+ ustr = (Eina_Unicode *)calloc(sizeof(Eina_Unicode), len + 1);
memcpy(ustr, text, len * sizeof(Eina_Unicode));
return ustr;
{
const Eina_Unicode *i, *j;
- for (i = haystack ; *i ; i++)
+ for (i = haystack; *i; i++)
{
haystack = i; /* set this location as the base position */
- for (j = needle ; *j && *i && *j == *i ; j++, i++)
+ for (j = needle; *j && *i && *j == *i; j++, i++)
;
if (!*j) /*if we got to the end of j this means we got a full match */
- {
- return (Eina_Unicode *) haystack; /* return the new base position */
- }
+ return (Eina_Unicode *)haystack; /* return the new base position */
}
return NULL;
const Eina_Unicode *s;
s2 = malloc((eina_unicode_strlen(str) * 2) + 1);
- if (!s2) return NULL;
+ if (!s2)
+ return NULL;
+
for (s = str, d = s2; *s != 0; s++, d++)
{
- if ((*s == ' ') || (*s == '\\') || (*s == '\''))
- {
- *d = '\\';
- d++;
- }
- *d = *s;
+ if ((*s == ' ') || (*s == '\\') || (*s == '\''))
+ {
+ *d = '\\';
+ d++;
+ }
+
+ *d = *s;
}
*d = 0;
return s2;
#define _STRBUF_MAGIC_STR __USTRBUF_MAGIC_STR
static const char __USTRBUF_MAGIC_STR[] = "Eina UStrbuf";
-#define _FUNC_EXPAND(y) eina_ustrbuf_##y
+#define _FUNC_EXPAND(y) eina_ustrbuf_ ## y
#include "eina_strbuf_template_c.i"
\ No newline at end of file
* if not, see <http://www.gnu.org/licenses/>.
*/
- /**
+/**
* @page tutorial_ustringshare_page UStringshare Tutorial
*
* to be written...
static const char EINA_MAGIC_USTRINGSHARE_NODE_STR[] = "Eina UStringshare Node";
/*============================================================================*
- * Global *
- *============================================================================*/
+* Global *
+*============================================================================*/
/**
* @internal
Eina_Bool
eina_ustringshare_init(void)
{
- return eina_share_common_init(&ustringshare_share, EINA_MAGIC_USTRINGSHARE_NODE, EINA_MAGIC_USTRINGSHARE_NODE_STR);
+ return eina_share_common_init(&ustringshare_share,
+ EINA_MAGIC_USTRINGSHARE_NODE,
+ EINA_MAGIC_USTRINGSHARE_NODE_STR);
}
/**
}
/*============================================================================*
- * API *
- *============================================================================*/
+* API *
+*============================================================================*/
/**
* @addtogroup Eina_UStringshare_Group Unicode Stringshare
*
{
if (!str)
return;
- eina_share_common_del(ustringshare_share,(const char *) str);
+
+ eina_share_common_del(ustringshare_share,(const char *)str);
}
/**
EAPI const Eina_Unicode *
eina_ustringshare_add_length(const Eina_Unicode *str, unsigned int slen)
{
- return (const Eina_Unicode *) eina_share_common_add_length(ustringshare_share,(const char *) str, slen * sizeof(Eina_Unicode), sizeof(Eina_Unicode));
+ return (const Eina_Unicode *)eina_share_common_add_length(ustringshare_share,
+ (const char *)str,
+ slen *
+ sizeof(Eina_Unicode),
+ sizeof(
+ Eina_Unicode));
}
/**
EAPI const Eina_Unicode *
eina_ustringshare_add(const Eina_Unicode *str)
{
- int slen = (str) ? (int) eina_unicode_strlen(str) : -1;
+ int slen = (str) ? (int)eina_unicode_strlen(str) : -1;
return eina_ustringshare_add_length(str, slen);
}
EAPI const Eina_Unicode *
eina_ustringshare_ref(const Eina_Unicode *str)
{
- return (const Eina_Unicode *) eina_share_common_ref(ustringshare_share, (const char *) str);
+ return (const Eina_Unicode *)eina_share_common_ref(ustringshare_share,
+ (const char *)str);
}
/**
EAPI int
eina_ustringshare_strlen(const Eina_Unicode *str)
{
- int len = eina_share_common_length(ustringshare_share, (const char *) str);
- len = (len > 0) ? len / (int) sizeof(Eina_Unicode) : -1;
+ int len = eina_share_common_length(ustringshare_share, (const char *)str);
+ len = (len > 0) ? len / (int)sizeof(Eina_Unicode) : -1;
return len;
}
/* eina_value.c
-Copyright (C) 2001 Christopher Rosendahl <smugg@fatelabs.com>
+ Copyright (C) 2001 Christopher Rosendahl <smugg@fatelabs.com>
Nathan Ingersoll <ningerso@d.umn.edu>
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to
-deal in the Software without restriction, including without limitation the
-rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-sell copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to
+ deal in the Software without restriction, including without limitation the
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ sell copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
-The above copyright notice and this permission notice shall be included in
-all copies of the Software and its documentation and acknowledgment shall be
-given in the documentation and software packages that this Software was
-used.
+ The above copyright notice and this permission notice shall be included in
+ all copies of the Software and its documentation and acknowledgment shall be
+ given in the documentation and software packages that this Software was
+ used.
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
-THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
-IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-*/
+ */
#ifdef HAVE_CONFIG_H
# include "config.h"
#include "eina_private.h"
/*============================================================================*
- * Global *
- *============================================================================*/
+* Global *
+*============================================================================*/
/*============================================================================*
- * API *
- *============================================================================*/
+* API *
+*============================================================================*/
EAPI const unsigned int eina_prime_table[] =
{
17, 31, 61, 127, 257, 509, 1021,
- 2053, 4093, 8191, 16381, 32771, 65537, 131071, 262147, 524287, 1048573,
- 2097143, 4194301, 8388617, 16777213
+ 2053, 4093, 8191, 16381, 32771, 65537, 131071, 262147, 524287, 1048573,
+ 2097143, 4194301, 8388617, 16777213
};
typedef struct _Block
{
- EINA_INLIST;
- Eina_Bool available : 1;
- unsigned short int order : 7; /* final order is order + min_order */
+ EINA_INLIST;
+ Eina_Bool available : 1;
+ unsigned short int order : 7; /* final order is order + min_order */
} Block;
typedef struct _Buddy
{
- void *heap; /* start address of the heap */
- size_t size; /* total size in bytes of the heap */
- unsigned int min_order; /* minimum size is 1 << min_order */
- unsigned int max_order; /* maximum size is 1 << max_order */
- unsigned int num_order; /* number of orders */
- Eina_Inlist **areas; /* one area per order */
- Block *blocks; /* the allocated block information */
+ void *heap; /* start address of the heap */
+ size_t size; /* total size in bytes of the heap */
+ unsigned int min_order; /* minimum size is 1 << min_order */
+ unsigned int max_order; /* maximum size is 1 << max_order */
+ unsigned int num_order; /* number of orders */
+ Eina_Inlist **areas; /* one area per order */
+ Block *blocks; /* the allocated block information */
} Buddy;
/* get the minimum order greater or equal to size */
static inline unsigned int _get_order(Buddy *b, size_t size)
{
- unsigned int i;
- size_t bytes;
-
- bytes = 1 << b->min_order;
- for (i = 0; bytes < size && i < b->num_order; i++)
- {
- bytes += bytes;
- }
- //printf("order for size %d is %d\n", size, i + b->min_order);
- return i;
+ unsigned int i;
+ size_t bytes;
+
+ bytes = 1 << b->min_order;
+ for (i = 0; bytes < size && i < b->num_order; i++)
+ {
+ bytes += bytes;
+ }
+ //printf("order for size %d is %d\n", size, i + b->min_order);
+ return i;
}
-static inline void * _get_offset(Buddy *b, Block *block)
+static inline void *_get_offset(Buddy *b, Block *block)
{
- void *ret;
+ void *ret;
- ret = (char *)b->heap + ((block - &b->blocks[0]) << b->min_order);
- return ret;
+ ret = (char *)b->heap + ((block - &b->blocks[0]) << b->min_order);
+ return ret;
}
-static void *_init(__UNUSED__ const char *context, __UNUSED__ const char *options, va_list args)
+static void *_init(__UNUSED__ const char *context,
+ __UNUSED__ const char *options,
+ va_list args)
{
- Buddy *b;
- int i;
- size_t bytes;
- size_t size;
- size_t min_order;
- void *heap;
-
- heap = va_arg(args, void *);
- size = va_arg(args, size_t);
- min_order = va_arg(args, int);
- /* the minimum order we support is 15 (32K) */
- min_order = min_order < 15 ? 15 : min_order;
- bytes = 1 << min_order;
- for (i = 0; bytes <= size; i++)
- {
- bytes += bytes;
- }
- if (!i)
- {
- return NULL;
- }
- b = malloc(sizeof(Buddy));
- b->heap = heap;
- b->size = size;
- b->min_order = min_order;
- b->max_order = min_order + i - 1;
- b->num_order = i;
- b->areas = calloc(b->num_order, sizeof(Eina_Inlist *));
- b->blocks = calloc(1 << (b->num_order - 1), sizeof(Block));
- /* setup the initial free area */
- b->blocks[0].available = EINA_TRUE;
- b->areas[b->num_order - 1] = EINA_INLIST_GET(&(b->blocks[0]));
-
- return b;
+ Buddy *b;
+ int i;
+ size_t bytes;
+ size_t size;
+ size_t min_order;
+ void *heap;
+
+ heap = va_arg(args, void *);
+ size = va_arg(args, size_t);
+ min_order = va_arg(args, int);
+ /* the minimum order we support is 15 (32K) */
+ min_order = min_order < 15 ? 15 : min_order;
+ bytes = 1 << min_order;
+ for (i = 0; bytes <= size; i++)
+ {
+ bytes += bytes;
+ }
+ if (!i)
+ return NULL;
+
+ b = malloc(sizeof(Buddy));
+ b->heap = heap;
+ b->size = size;
+ b->min_order = min_order;
+ b->max_order = min_order + i - 1;
+ b->num_order = i;
+ b->areas = calloc(b->num_order, sizeof(Eina_Inlist *));
+ b->blocks = calloc(1 << (b->num_order - 1), sizeof(Block));
+ /* setup the initial free area */
+ b->blocks[0].available = EINA_TRUE;
+ b->areas[b->num_order - 1] = EINA_INLIST_GET(&(b->blocks[0]));
+
+ return b;
}
static void _shutdown(void *data)
{
- Buddy *b = data;
+ Buddy *b = data;
- free(b->blocks);
- free(b->areas);
- free(b);
+ free(b->blocks);
+ free(b->areas);
+ free(b);
}
static void _free(void *data, void *element)
{
- Buddy *b = data;
- Block *block, *buddy;
- unsigned int offset;
- unsigned int index;
-
- offset = (unsigned char *)element - (unsigned char *)b->heap;
- if (offset > b->size)
- return;
- index = offset >> b->min_order;
- block = &b->blocks[index];
-
- //printf("free %x index = %d order = %d buddy = %d\n", offset, index, block->order, index ^ (1 << block->order));
- /* we should always work with the buddy at right */
- if (index & (1 << block->order))
- {
- Block *left;
-
- index = index ^ (1 << block->order);
- left = &b->blocks[index];
- if (!left->available)
- goto end;
- else
- {
- buddy = block;
- block = left;
- b->areas[block->order] = eina_inlist_remove(b->areas[block->order], EINA_INLIST_GET(block));
- block->order++;
- }
- }
+ Buddy *b = data;
+ Block *block, *buddy;
+ unsigned int offset;
+ unsigned int index;
+
+ offset = (unsigned char *)element - (unsigned char *)b->heap;
+ if (offset > b->size)
+ return;
+
+ index = offset >> b->min_order;
+ block = &b->blocks[index];
+
+ //printf("free %x index = %d order = %d buddy = %d\n", offset, index, block->order, index ^ (1 << block->order));
+ /* we should always work with the buddy at right */
+ if (index & (1 << block->order))
+ {
+ Block *left;
+
+ index = index ^ (1 << block->order);
+ left = &b->blocks[index];
+ if (!left->available)
+ goto end;
+ else
+ {
+ buddy = block;
+ block = left;
+ b->areas[block->order] = eina_inlist_remove(b->areas[block->order],
+ EINA_INLIST_GET(block));
+ block->order++;
+ }
+ }
+
check:
- /* already on the last order */
- if (block->order + b->min_order == b->max_order)
- goto end;
- /* get the buddy */
- buddy = &b->blocks[index ^ (1 << block->order)];
- if (!buddy->available)
- goto end;
- /* merge two blocks */
- b->areas[block->order] = eina_inlist_remove(b->areas[block->order], EINA_INLIST_GET(buddy));
- block->order++;
- goto check;
+ /* already on the last order */
+ if (block->order + b->min_order == b->max_order)
+ goto end; /* get the buddy */
+
+ buddy = &b->blocks[index ^ (1 << block->order)];
+ if (!buddy->available)
+ goto end; /* merge two blocks */
+
+ b->areas[block->order] = eina_inlist_remove(b->areas[block->order],
+ EINA_INLIST_GET(buddy));
+ block->order++;
+ goto check;
end:
- /* add the block to the free list */
- block->available = EINA_TRUE;
- b->areas[block->order] = eina_inlist_append(b->areas[block->order], EINA_INLIST_GET(block));
+ /* add the block to the free list */
+ block->available = EINA_TRUE;
+ b->areas[block->order] = eina_inlist_append(b->areas[block->order],
+ EINA_INLIST_GET(block));
}
static void *_alloc(void *data, unsigned int size)
{
- Buddy *b = data;
- Block *block, *buddy;
- unsigned int k, j;
-
- k = j = _get_order(b, size);
- /* get a free list of order k where k <= j <= max_order */
- while ((j < b->num_order) && !b->areas[j])
- j++;
- /* check that the order is on our range */
- if (j + b->min_order > b->max_order)
- return NULL;
-
- /* get a free element on this order, if not, go splitting until we find one */
- //printf("getting order %d (%d) for size %d\n", j, k, size);
+ Buddy *b = data;
+ Block *block, *buddy;
+ unsigned int k, j;
+
+ k = j = _get_order(b, size);
+ /* get a free list of order k where k <= j <= max_order */
+ while ((j < b->num_order) && !b->areas[j])
+ j++;
+ /* check that the order is on our range */
+ if (j + b->min_order > b->max_order)
+ return NULL;
+
+ /* get a free element on this order, if not, go splitting until we find one */
+ //printf("getting order %d (%d) for size %d\n", j, k, size);
found:
- if (j == k)
- {
- void *ret;
-
- block = EINA_INLIST_CONTAINER_GET(b->areas[j], Block);
- block->available = EINA_FALSE;
- block->order = j;
- /* remove the block from the list */
- b->areas[j] = eina_inlist_remove(b->areas[j], EINA_INLIST_GET(block));
- ret = _get_offset(b, block);
-
- return ret;
- }
- block = EINA_INLIST_CONTAINER_GET(b->areas[j], Block);
- /* split */
- b->areas[j] = eina_inlist_remove(b->areas[j], EINA_INLIST_GET(block));
- j--;
- b->areas[j] = eina_inlist_append(b->areas[j], EINA_INLIST_GET(block));
- buddy = block + (1 << j);
- buddy->order = j;
- buddy->available = EINA_TRUE;
- b->areas[j] = eina_inlist_append(b->areas[j], EINA_INLIST_GET(buddy));
-
- goto found;
+ if (j == k)
+ {
+ void *ret;
+
+ block = EINA_INLIST_CONTAINER_GET(b->areas[j], Block);
+ block->available = EINA_FALSE;
+ block->order = j;
+ /* remove the block from the list */
+ b->areas[j] = eina_inlist_remove(b->areas[j], EINA_INLIST_GET(block));
+ ret = _get_offset(b, block);
+
+ return ret;
+ }
+
+ block = EINA_INLIST_CONTAINER_GET(b->areas[j], Block);
+ /* split */
+ b->areas[j] = eina_inlist_remove(b->areas[j], EINA_INLIST_GET(block));
+ j--;
+ b->areas[j] = eina_inlist_append(b->areas[j], EINA_INLIST_GET(block));
+ buddy = block + (1 << j);
+ buddy->order = j;
+ buddy->available = EINA_TRUE;
+ b->areas[j] = eina_inlist_append(b->areas[j], EINA_INLIST_GET(buddy));
+
+ goto found;
}
static void _statistics(void *data)
{
- Buddy *b = data;
- unsigned int i;
-
- printf("Information:\n");
- printf("size = %li, min_order = %d, max_order = %d, num_order = %d, num_blocks = %d (%luKB)\n", b->size, b->min_order, b->max_order, b->num_order, 1 << b->num_order, ((1 << (b->num_order)) * sizeof(Block)) / 1024);
- printf("Area dumping:");
- /* iterate over the free lists and dump the maps */
- for (i = 0; i < b->num_order; i++)
- {
- Block *block;
-
- printf("\n2^%d:", b->min_order + i);
- EINA_INLIST_FOREACH(b->areas[i], block)
- {
- printf(" %li", (block - &b->blocks[0]));
- }
- }
- printf("\nBlocks dumping:\n");
+ Buddy *b = data;
+ unsigned int i;
+
+ printf("Information:\n");
+ printf(
+ "size = %li, min_order = %d, max_order = %d, num_order = %d, num_blocks = %d (%luKB)\n",
+ b->size,
+ b->min_order,
+ b->max_order,
+ b->num_order,
+ 1 << b->num_order,
+ ((1 << (b->num_order)) * sizeof(Block)) / 1024);
+ printf("Area dumping:");
+ /* iterate over the free lists and dump the maps */
+ for (i = 0; i < b->num_order; i++)
+ {
+ Block *block;
+
+ printf("\n2^%d:", b->min_order + i);
+ EINA_INLIST_FOREACH(b->areas[i], block)
+ {
+ printf(" %li", (block - &b->blocks[0]));
+ }
+ }
+ printf("\nBlocks dumping:\n");
}
static Eina_Mempool_Backend _backend = {
- "buddy",
- &_init,
- &_free,
- &_alloc,
- NULL, /* realloc */
- NULL, /* garbage collect */
- &_statistics,
- &_shutdown
+ "buddy",
+ &_init,
+ &_free,
+ &_alloc,
+ NULL, /* realloc */
+ NULL, /* garbage collect */
+ &_statistics,
+ &_shutdown
};
Eina_Bool buddy_init(void)
{
- return eina_mempool_register(&_backend);
+ return eina_mempool_register(&_backend);
}
void buddy_shutdown(void)
{
- eina_mempool_unregister(&_backend);
+ eina_mempool_unregister(&_backend);
}
typedef struct _Chained_Mempool Chained_Mempool;
struct _Chained_Mempool
{
- Eina_Inlist *first;
+ Eina_Inlist *first;
const char *name;
int item_size;
int item_alloc;
unsigned char *ptr;
int i;
- eina_error_set(0);
+ eina_error_set(0);
p = malloc(sizeof(Chained_Pool) + (pool->pool_size * pool->item_alloc));
if (!p)
{
- eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
- return NULL;
+ eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+ return NULL;
}
- ptr = (unsigned char *) (p + 1);
+ ptr = (unsigned char *)(p + 1);
p->usage = 0;
p->base = NULL;
for (i = 0; i < pool->pool_size; ++i, ptr += pool->item_alloc)
- eina_trash_push(&p->base, ptr);
+ eina_trash_push(&p->base, ptr);
return p;
}
// look 4 pool from 2nd bucket on
EINA_INLIST_FOREACH(pool->first, p)
- {
- // base is not NULL - has a free slot
- if (p->base)
- {
- pool->first = eina_inlist_demote(pool->first, EINA_INLIST_GET(p));
- break;
- }
- }
+ {
+ // base is not NULL - has a free slot
+ if (p->base)
+ {
+ pool->first = eina_inlist_demote(pool->first, EINA_INLIST_GET(p));
+ break;
+ }
+ }
// we have reached the end of the list - no free pools
if (!p)
{
- p = _eina_chained_mp_pool_new(pool);
- if (!p)
- {
+ p = _eina_chained_mp_pool_new(pool);
+ if (!p)
+ {
#ifdef EFL_HAVE_PTHREAD
# ifdef EFL_HAVE_POSIX_THREADS
- pthread_mutex_unlock(&pool->mutex);
+ pthread_mutex_unlock(&pool->mutex);
# else
- ReleaseMutex(pool->mutex);
+ ReleaseMutex(pool->mutex);
# endif
#endif
- return NULL;
- }
- pool->first = eina_inlist_prepend(pool->first, EINA_INLIST_GET(p));
+ return NULL;
+ }
+
+ pool->first = eina_inlist_prepend(pool->first, EINA_INLIST_GET(p));
}
+
// Request a free pointer
mem = eina_trash_pop(&p->base);
// move to end - it just filled up
if (!p->base)
- {
- pool->first = eina_inlist_demote(pool->first, EINA_INLIST_GET(p));
- }
+ pool->first = eina_inlist_demote(pool->first, EINA_INLIST_GET(p));
+
p->usage++;
pool->usage++;
void *pmem;
int item_alloc, psize;
- item_alloc = ((pool->item_size + sizeof(void *) - 1) / sizeof(void *)) * sizeof(void *);
+ item_alloc =
+ ((pool->item_size + sizeof(void *) - 1) / sizeof(void *)) * sizeof(void *);
psize = item_alloc * pool->pool_size;
// look 4 pool
#endif
EINA_INLIST_FOREACH(pool->first, p)
- {
- // pool mem base
- pmem = (void *)(((unsigned char *)p) + sizeof(Chained_Pool));
- // is it in pool mem?
- if ((ptr >= pmem) && ((unsigned char *)ptr < (((unsigned char *)pmem) + psize)))
- {
- // freed node points to prev free node
- eina_trash_push(&p->base, ptr);
- // next free node is now the one we freed
- p->usage--;
- pool->usage--;
- if (p->usage == 0)
- {
- // free bucket
- pool->first = eina_inlist_remove(pool->first, EINA_INLIST_GET(p));
- _eina_chained_mp_pool_free(p);
- }
- else
- {
- // move to front
- pool->first = eina_inlist_promote(pool->first, EINA_INLIST_GET(p));
- }
- break;
- }
- }
+ {
+ // pool mem base
+ pmem = (void *)(((unsigned char *)p) + sizeof(Chained_Pool));
+ // is it in pool mem?
+ if ((ptr >= pmem) &&
+ ((unsigned char *)ptr < (((unsigned char *)pmem) + psize)))
+ {
+ // freed node points to prev free node
+ eina_trash_push(&p->base, ptr);
+ // next free node is now the one we freed
+ p->usage--;
+ pool->usage--;
+ if (p->usage == 0)
+ {
+ // free bucket
+ pool->first = eina_inlist_remove(pool->first, EINA_INLIST_GET(p));
+ _eina_chained_mp_pool_free(p);
+ }
+ else
+ // move to front
+ pool->first = eina_inlist_promote(pool->first, EINA_INLIST_GET(p));
+
+ break;
+ }
+ }
#ifdef EFL_HAVE_THREADS
# ifdef EFL_HAVE_POSIX_THREADS
#endif
}
-static void*
-eina_chained_mempool_realloc(__UNUSED__ void *data, __UNUSED__ void *element, __UNUSED__ unsigned int size)
+static void *
+eina_chained_mempool_realloc(__UNUSED__ void *data,
+ __UNUSED__ void *element,
+ __UNUSED__ unsigned int size)
{
return NULL;
}
-static void*
-eina_chained_mempool_init(const char *context, __UNUSED__ const char *option, va_list args)
+static void *
+eina_chained_mempool_init(const char *context,
+ __UNUSED__ const char *option,
+ va_list args)
{
Chained_Mempool *mp;
size_t length;
length = context ? strlen(context) + 1 : 0;
mp = calloc(1, sizeof(Chained_Mempool) + length);
- if (!mp) return NULL;
+ if (!mp)
+ return NULL;
mp->item_size = va_arg(args, int);
mp->pool_size = va_arg(args, int);
if (length)
{
- mp->name = (const char*) (mp + 1);
- memcpy((char*) mp->name, context, length);
+ mp->name = (const char *)(mp + 1);
+ memcpy((char *)mp->name, context, length);
}
mp->item_alloc = eina_mempool_alignof(mp->item_size);
{
Chained_Mempool *mp;
- mp = (Chained_Mempool *) data;
+ mp = (Chained_Mempool *)data;
while (mp->first)
{
- Chained_Pool *p = (Chained_Pool *) mp->first;
+ Chained_Pool *p = (Chained_Pool *)mp->first;
#ifdef DEBUG
- if (p->usage > 0)
- INF("Bad news we are destroying not an empty mempool [%s]\n", mp->name);
+ if (p->usage > 0)
+ INF("Bad news we are destroying not an empty mempool [%s]\n",
+ mp->name);
+
#endif
- mp->first = eina_inlist_remove(mp->first, mp->first);
- _eina_chained_mp_pool_free(p);
+ mp->first = eina_inlist_remove(mp->first, mp->first);
+ _eina_chained_mp_pool_free(p);
}
#ifdef EFL_HAVE_THREADS
Eina_Bool chained_init(void)
{
#ifdef DEBUG
- _eina_mempool_log_dom = eina_log_domain_register("eina_mempool", EINA_LOG_COLOR_DEFAULT);
+ _eina_mempool_log_dom = eina_log_domain_register("eina_mempool",
+ EINA_LOG_COLOR_DEFAULT);
if (_eina_mempool_log_dom < 0)
{
- EINA_LOG_ERR("Could not register log domain: eina_mempool");
- return EINA_FALSE;
+ EINA_LOG_ERR("Could not register log domain: eina_mempool");
+ return EINA_FALSE;
}
+
#endif
return eina_mempool_register(&_eina_chained_mp_backend);
}
ememoa_mempool_fixed_push_object(efm->pool, ptr);
}
-static void*
-eina_ememoa_fixed_realloc(__UNUSED__ void *data, __UNUSED__ void *element, __UNUSED__ unsigned int size)
+static void *
+eina_ememoa_fixed_realloc(__UNUSED__ void *data,
+ __UNUSED__ void *element,
+ __UNUSED__ unsigned int size)
{
return NULL;
}
Eina_Ememoa_Fixed_Mempool *efm = data;
ememoa_mempool_fixed_display_statistic(efm->pool);
- (void) efm;
+ (void)efm;
}
-static void*
-eina_ememoa_fixed_init(const char *context, __UNUSED__ const char *option, va_list args)
+static void *
+eina_ememoa_fixed_init(const char *context,
+ __UNUSED__ const char *option,
+ va_list args)
{
struct ememoa_mempool_desc_s *desc = NULL;
Eina_Ememoa_Fixed_Mempool *efm = NULL;
if (context)
{
- context_length = strlen(context) + 1;
+ context_length = strlen(context) + 1;
- desc = calloc(1, sizeof (struct ememoa_mempool_desc_s) + context_length);
- if (!desc) goto on_error;
+ desc = calloc(1, sizeof (struct ememoa_mempool_desc_s) + context_length);
+ if (!desc)
+ goto on_error;
- desc->name = (char*) (desc + 1);
- memcpy((char*) desc->name, context, context_length);
+ desc->name = (char *)(desc + 1);
+ memcpy((char *)desc->name, context, context_length);
}
item_size = va_arg(args, int);
thread_protect = va_arg(args, int);
efm = malloc(sizeof (Eina_Ememoa_Fixed_Mempool));
- if (!efm) goto on_error;
+ if (!efm)
+ goto on_error;
efm->desc = desc;
- efm->pool = ememoa_mempool_fixed_init(item_size,
- pool_size,
- thread_protect ? EMEMOA_THREAD_PROTECTION : 0,
- efm->desc);
- if (efm->pool < 0) goto on_error;
+ efm->pool = ememoa_mempool_fixed_init(
+ item_size,
+ pool_size,
+ thread_protect ?
+ EMEMOA_THREAD_PROTECTION : 0,
+ efm->desc);
+ if (efm->pool < 0)
+ goto on_error;
return efm;
- on_error:
- if (desc) free(desc);
- if (efm) free(efm);
+on_error:
+ if (desc)
+ free(desc);
+
+ if (efm)
+ free(efm);
+
return NULL;
}
{
Eina_Ememoa_Fixed_Mempool *efm = data;
- if (efm->desc) free(efm->desc);
- ememoa_mempool_fixed_clean(efm->pool);
+ if (efm->desc)
+ free(efm->desc);
+
+ ememoa_mempool_fixed_clean(efm->pool);
free(efm);
}
static Eina_Mempool_Backend _eina_ememoa_mp_backend = {
- .name = "ememoa_fixed",
- .init = &eina_ememoa_fixed_init,
- .shutdown = &eina_ememoa_fixed_shutdown,
- .realloc = &eina_ememoa_fixed_realloc,
- .alloc = &eina_ememoa_fixed_malloc,
- .free = &eina_ememoa_fixed_free,
- .garbage_collect = &eina_ememoa_fixed_gc,
- .statistics = &eina_ememoa_fixed_statistics
+ .name = "ememoa_fixed",
+ .init = &eina_ememoa_fixed_init,
+ .shutdown = &eina_ememoa_fixed_shutdown,
+ .realloc = &eina_ememoa_fixed_realloc,
+ .alloc = &eina_ememoa_fixed_malloc,
+ .free = &eina_ememoa_fixed_free,
+ .garbage_collect = &eina_ememoa_fixed_gc,
+ .statistics = &eina_ememoa_fixed_statistics
};
Eina_Bool ememoa_fixed_init(void)
{
- return eina_mempool_register(&_eina_ememoa_mp_backend);
+ return eina_mempool_register(&_eina_ememoa_mp_backend);
}
void ememoa_fixed_shutdown(void)
{
- eina_mempool_unregister(&_eina_ememoa_mp_backend);
+ eina_mempool_unregister(&_eina_ememoa_mp_backend);
}
#include "eina_private.h"
#include "eina_mempool.h"
-typedef struct _Eina_Ememoa_Unknown_Size_Mempool Eina_Ememoa_Unknown_Size_Mempool;
+typedef struct _Eina_Ememoa_Unknown_Size_Mempool
+Eina_Ememoa_Unknown_Size_Mempool;
struct _Eina_Ememoa_Unknown_Size_Mempool
{
struct ememoa_mempool_desc_s *desc;
ememoa_mempool_unknown_size_push_object(efm->pool, ptr);
}
-static void*
+static void *
eina_ememoa_unknown_size_realloc(void *data, void *element, unsigned int size)
{
Eina_Ememoa_Unknown_Size_Mempool *efm = data;
ememoa_mempool_unknown_size_display_statistic(efm->pool);
}
-static void*
-eina_ememoa_unknown_size_init(const char *context, __UNUSED__ const char *option, va_list args)
+static void *
+eina_ememoa_unknown_size_init(const char *context,
+ __UNUSED__ const char *option,
+ va_list args)
{
struct ememoa_mempool_desc_s *desc = NULL;
Eina_Ememoa_Unknown_Size_Mempool *efm = NULL;
if (context)
{
- context_length = strlen(context) + 1;
+ context_length = strlen(context) + 1;
- desc = calloc(1, sizeof (struct ememoa_mempool_desc_s) + context_length);
- if (!desc) goto on_error;
+ desc = calloc(1, sizeof (struct ememoa_mempool_desc_s) + context_length);
+ if (!desc)
+ goto on_error;
- desc->name = (char*) (desc + 1);
- memcpy((char*) desc->name, context, context_length);
+ desc->name = (char *)(desc + 1);
+ memcpy((char *)desc->name, context, context_length);
}
thread_protect = va_arg(args, int);
items_map = malloc(sizeof (unsigned int) * 2 * items_count);
for (i = 0; i < (items_count << 1); ++i)
- items_map[i] = va_arg(args, unsigned int);
+ items_map[i] = va_arg(args, unsigned int);
efm = malloc(sizeof (Eina_Ememoa_Unknown_Size_Mempool));
- if (!efm) goto on_error;
+ if (!efm)
+ goto on_error;
efm->desc = desc;
- efm->pool = ememoa_mempool_unknown_size_init(items_count,
- items_map,
- thread_protect ? EMEMOA_THREAD_PROTECTION : 0,
- efm->desc);
- if (efm->pool < 0) goto on_error;
+ efm->pool = ememoa_mempool_unknown_size_init(
+ items_count,
+ items_map,
+ thread_protect ?
+ EMEMOA_THREAD_PROTECTION : 0,
+ efm->desc);
+ if (efm->pool < 0)
+ goto on_error;
return efm;
- on_error:
- if (desc) free(desc);
- if (efm) free(efm);
+on_error:
+ if (desc)
+ free(desc);
+
+ if (efm)
+ free(efm);
+
return NULL;
}
{
Eina_Ememoa_Unknown_Size_Mempool *efm = data;
- if (efm->desc) free(efm->desc);
- ememoa_mempool_unknown_size_clean(efm->pool);
+ if (efm->desc)
+ free(efm->desc);
+
+ ememoa_mempool_unknown_size_clean(efm->pool);
free(efm);
}
static Eina_Mempool_Backend _eina_ememoa_unknown_mp_backend = {
- .name = "ememoa_unknown",
- .init = &eina_ememoa_unknown_size_init,
- .shutdown = &eina_ememoa_unknown_size_shutdown,
- .realloc = &eina_ememoa_unknown_size_realloc,
- .alloc = &eina_ememoa_unknown_size_malloc,
- .free = &eina_ememoa_unknown_size_free,
- .garbage_collect = &eina_ememoa_unknown_size_gc,
- .statistics = &eina_ememoa_unknown_size_statistics
+ .name = "ememoa_unknown",
+ .init = &eina_ememoa_unknown_size_init,
+ .shutdown = &eina_ememoa_unknown_size_shutdown,
+ .realloc = &eina_ememoa_unknown_size_realloc,
+ .alloc = &eina_ememoa_unknown_size_malloc,
+ .free = &eina_ememoa_unknown_size_free,
+ .garbage_collect = &eina_ememoa_unknown_size_gc,
+ .statistics = &eina_ememoa_unknown_size_statistics
};
Eina_Bool ememoa_unknown_init(void)
{
- return eina_mempool_register(&_eina_ememoa_unknown_mp_backend);
+ return eina_mempool_register(&_eina_ememoa_unknown_mp_backend);
}
void ememoa_unknown_shutdown(void)
{
- eina_mempool_unregister(&_eina_ememoa_unknown_mp_backend);
+ eina_mempool_unregister(&_eina_ememoa_unknown_mp_backend);
}
#ifndef EINA_STATIC_BUILD_EMEMOA_UNKNOWN
}
static Eina_Rbtree_Direction
-_eina_fixed_cmp(const Eina_Rbtree *left, const Eina_Rbtree *right, __UNUSED__ void *data)
+_eina_fixed_cmp(const Eina_Rbtree *left,
+ const Eina_Rbtree *right,
+ __UNUSED__ void *data)
{
if (left - right < 0)
- return EINA_RBTREE_LEFT;
+ return EINA_RBTREE_LEFT;
+
return EINA_RBTREE_RIGHT;
}
static int
-_eina_fixed_cmp_key(const Eina_Rbtree *node, const void *key, __UNUSED__ int length, Eina_Fixed_Bitmap *mp)
+_eina_fixed_cmp_key(const Eina_Rbtree *node,
+ const void *key,
+ __UNUSED__ int length,
+ Eina_Fixed_Bitmap *mp)
{
const void *a = node;
const void *b = key;
delta = (char *)a - (char *)b;
if (delta > 0)
- return 1;
+ return 1;
+
if (delta + limit < 0)
- return -1;
+ return -1;
+
return 0;
}
static void
-_eina_fixed_bitmap_pool_free(Eina_Fixed_Bitmap_Pool *pool, __UNUSED__ void *data)
+_eina_fixed_bitmap_pool_free(Eina_Fixed_Bitmap_Pool *pool,
+ __UNUSED__ void *data)
{
free(pool);
}
if (mp->head)
{
- pool = (Eina_Fixed_Bitmap_Pool*) ((unsigned char*) mp->head + _eina_rbtree_inlist_delta());
+ pool =
+ (Eina_Fixed_Bitmap_Pool *)((unsigned char *)mp->head +
+ _eina_rbtree_inlist_delta());
- if (pool->bitmask == 0) pool = NULL;
+ if (pool->bitmask == 0)
+ pool = NULL;
}
if (!pool)
{
- eina_error_set(0);
- pool = malloc(sizeof (Eina_Fixed_Bitmap_Pool) + mp->item_size * 32);
- if (!pool)
- {
- eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
- return NULL;
- }
-
- pool->bitmask = 0xFFFFFFFF;
-
- mp->head = eina_inlist_prepend(mp->head, EINA_INLIST_GET(pool));
- mp->lookup = eina_rbtree_inline_insert(mp->lookup, EINA_RBTREE_GET(pool), EINA_RBTREE_CMP_NODE_CB(_eina_fixed_cmp), NULL);
+ eina_error_set(0);
+ pool = malloc(sizeof (Eina_Fixed_Bitmap_Pool) + mp->item_size * 32);
+ if (!pool)
+ {
+ eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+ return NULL;
+ }
+
+ pool->bitmask = 0xFFFFFFFF;
+
+ mp->head = eina_inlist_prepend(mp->head, EINA_INLIST_GET(pool));
+ mp->lookup = eina_rbtree_inline_insert(mp->lookup, EINA_RBTREE_GET(
+ pool),
+ EINA_RBTREE_CMP_NODE_CB(
+ _eina_fixed_cmp), NULL);
}
idx = ffs(pool->bitmask) - 1;
pool->bitmask &= ~(1 << idx);
- ptr = (unsigned char*) (pool + 1) + idx * mp->item_size;
+ ptr = (unsigned char *)(pool + 1) + idx * mp->item_size;
if (pool->bitmask == 0)
- mp->head = eina_inlist_demote(mp->head, EINA_INLIST_GET(pool));
+ mp->head = eina_inlist_demote(mp->head, EINA_INLIST_GET(pool));
return ptr;
}
Eina_Bool push_front = EINA_FALSE;
ssize_t delta;
- pool = (Eina_Fixed_Bitmap_Pool*) eina_rbtree_inline_lookup(mp->lookup,
- ptr, 0,
- EINA_RBTREE_CMP_KEY_CB(_eina_fixed_cmp_key), mp);
- if (!pool) return ;
- if (pool->bitmask != 0xFFFFFFFF) push_front = EINA_TRUE;
+ pool = (Eina_Fixed_Bitmap_Pool *)eina_rbtree_inline_lookup(
+ mp->lookup,
+ ptr,
+ 0,
+ EINA_RBTREE_CMP_KEY_CB(
+ _eina_fixed_cmp_key),
+ mp);
+ if (!pool)
+ return;
+
+ if (pool->bitmask != 0xFFFFFFFF)
+ push_front = EINA_TRUE;
a = pool;
- delta = ((char *)ptr - (char *)a - sizeof (Eina_Fixed_Bitmap_Pool)) / mp->item_size;
+ delta =
+ ((char *)ptr - (char *)a -
+ sizeof (Eina_Fixed_Bitmap_Pool)) / mp->item_size;
assert(delta >= 0 && delta < 32);
if (pool->bitmask == 0xFFFFFFFF)
{
- mp->head = eina_inlist_remove(mp->head, EINA_INLIST_GET(pool));
- mp->lookup = eina_rbtree_inline_remove(mp->lookup, EINA_RBTREE_GET(pool), EINA_RBTREE_CMP_NODE_CB(_eina_fixed_cmp), NULL);
- free(pool);
+ mp->head = eina_inlist_remove(mp->head, EINA_INLIST_GET(pool));
+ mp->lookup = eina_rbtree_inline_remove(mp->lookup, EINA_RBTREE_GET(
+ pool),
+ EINA_RBTREE_CMP_NODE_CB(
+ _eina_fixed_cmp), NULL);
+ free(pool);
}
else if (push_front)
- mp->head = eina_inlist_promote(mp->head, EINA_INLIST_GET(pool));
+ mp->head = eina_inlist_promote(mp->head, EINA_INLIST_GET(pool));
}
static void *
-eina_fixed_bitmap_realloc(__UNUSED__ void *data, __UNUSED__ void *element, __UNUSED__ unsigned int size)
+eina_fixed_bitmap_realloc(__UNUSED__ void *data,
+ __UNUSED__ void *element,
+ __UNUSED__ unsigned int size)
{
return NULL;
}
-static void*
-eina_fixed_bitmap_init(__UNUSED__ const char *context, __UNUSED__ const char *option, va_list args)
+static void *
+eina_fixed_bitmap_init(__UNUSED__ const char *context,
+ __UNUSED__ const char *option,
+ va_list args)
{
Eina_Fixed_Bitmap *mp;
int item_size;
mp = malloc(sizeof (Eina_Fixed_Bitmap));
- if (!mp) return NULL;
+ if (!mp)
+ return NULL;
item_size = va_arg(args, int);
{
Eina_Fixed_Bitmap *mp = data;
- eina_rbtree_delete(mp->lookup, EINA_RBTREE_FREE_CB(_eina_fixed_bitmap_pool_free), NULL);
+ eina_rbtree_delete(mp->lookup,
+ EINA_RBTREE_FREE_CB(_eina_fixed_bitmap_pool_free), NULL);
free(mp);
}
if (pool->base)
{
- mem = eina_trash_pop(&pool->empty);
- pool->usage++;
- goto on_exit;
+ mem = eina_trash_pop(&pool->empty);
+ pool->usage++;
+ goto on_exit;
}
if (pool->served < pool->max)
{
- mem = pool->base + (pool->served++ * pool->item_size);
- pool->usage++;
- goto on_exit;
+ mem = pool->base + (pool->served++ *pool->item_size);
+ pool->usage++;
+ goto on_exit;
}
- eina_error_set(0);
+ eina_error_set(0);
mem = malloc(pool->item_size);
if (!mem)
- {
- eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
- }
+ eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
else
- {
- pool->over++;
- }
+ pool->over++;
- on_exit:
+on_exit:
#ifdef EFL_HAVE_THREADS
# ifdef EFL_HAVE_POSIX_THREADS
pthread_mutex_unlock(&pool->mutex);
# endif
#endif
- if ((void*) pool->base <= ptr
- && ptr < (void*) (pool->base + (pool->max * pool->item_size)))
+ if ((void *)pool->base <= ptr
+ && ptr < (void *)(pool->base + (pool->max * pool->item_size)))
{
- eina_trash_push(&pool->empty, ptr);
- pool->usage--;
+ eina_trash_push(&pool->empty, ptr);
+ pool->usage--;
}
else
{
- free(ptr);
- pool->over--;
+ free(ptr);
+ pool->over--;
}
#ifdef EFL_HAVE_THREADS
#endif
}
-static void*
-eina_one_big_realloc(__UNUSED__ void *data, __UNUSED__ void *element, __UNUSED__ unsigned int size)
+static void *
+eina_one_big_realloc(__UNUSED__ void *data,
+ __UNUSED__ void *element,
+ __UNUSED__ unsigned int size)
{
return NULL;
}
-static void*
-eina_one_big_init(const char *context, __UNUSED__ const char *option, va_list args)
+static void *
+eina_one_big_init(const char *context,
+ __UNUSED__ const char *option,
+ va_list args)
{
One_Big *pool;
int item_size;
length = context ? strlen(context) + 1 : 0;
pool = calloc(1, sizeof (One_Big) + length);
- if (!pool) return NULL;
+ if (!pool)
+ return NULL;
item_size = va_arg(args, int);
if (length)
{
- pool->name = (const char*) (pool + 1);
- memcpy((char*) pool->name, context, length);
+ pool->name = (const char *)(pool + 1);
+ memcpy((char *)pool->name, context, length);
}
pool->base = malloc(pool->item_size * pool->max);
if (!pool->base)
{
- free(pool);
- return NULL;
+ free(pool);
+ return NULL;
}
#ifdef EFL_HAVE_THREADS
#ifdef DEBUG
if (pool->usage > 0)
- INF("Bad news we are destroying memory still referenced in mempool [%s]\n", pool->name);
+ INF(
+ "Bad news we are destroying memory still referenced in mempool [%s]\n",
+ pool->name);
if (pool->over > 0)
- INF("Bad news we are loosing track of pointer from mempool [%s]\n", pool->name);
+ INF("Bad news we are loosing track of pointer from mempool [%s]\n",
+ pool->name);
+
#endif
free(pool->base);
static Eina_Mempool_Backend _eina_one_big_mp_backend = {
- "one_big",
- &eina_one_big_init,
- &eina_one_big_free,
- &eina_one_big_malloc,
- &eina_one_big_realloc,
- NULL,
- NULL,
- &eina_one_big_shutdown
+ "one_big",
+ &eina_one_big_init,
+ &eina_one_big_free,
+ &eina_one_big_malloc,
+ &eina_one_big_realloc,
+ NULL,
+ NULL,
+ &eina_one_big_shutdown
};
Eina_Bool one_big_init(void)
{
#ifdef DEBUG
- _eina_mempool_log_dom = eina_log_domain_register("eina_one_big_mempool", EINA_LOG_COLOR_DEFAULT);
+ _eina_mempool_log_dom = eina_log_domain_register("eina_one_big_mempool",
+ EINA_LOG_COLOR_DEFAULT);
if (_eina_mempool_log_dom < 0)
{
- EINA_LOG_ERR("Could not register log domain: eina_one_big_mempool");
- return EINA_FALSE;
+ EINA_LOG_ERR("Could not register log domain: eina_one_big_mempool");
+ return EINA_FALSE;
}
+
#endif
return eina_mempool_register(&_eina_one_big_mp_backend);
}
free(ptr);
}
-static void*
+static void *
eina_pass_through_realloc(__UNUSED__ void *data, void *ptr, unsigned int size)
{
return realloc(ptr, size);
}
-static void*
-eina_pass_through_init(__UNUSED__ const char *context, __UNUSED__ const char *option, __UNUSED__ va_list args)
+static void *
+eina_pass_through_init(__UNUSED__ const char *context,
+ __UNUSED__ const char *option,
+ __UNUSED__ va_list args)
{
- return (void*) 0x1;
+ return (void *)0x1;
}
static void
Eina_Bool pass_through_init(void)
{
- return eina_mempool_register(&_eina_pass_through_mp_backend);
+ return eina_mempool_register(&_eina_pass_through_mp_backend);
}
void pass_through_shutdown(void)
{
- eina_mempool_unregister(&_eina_pass_through_mp_backend);
+ eina_mempool_unregister(&_eina_pass_through_mp_backend);
}
#ifndef EINA_STATIC_BUILD_PASS_THROUGH
#ifdef IF_FREE
# undef IF_FREE
#endif
-#define IF_FREE(ptr) if (ptr) free(ptr); ptr = NULL;
+#define IF_FREE(ptr) if (ptr) {free(ptr); } ptr = NULL;
/* convenience macros for checking pointer parameters for non-NULL */
#undef CHECK_PARAM_POINTER_RETURN
#define CHECK_PARAM_POINTER_RETURN(sparam, param, ret) \
- if (!(param)) \
- { \
- printf("***** Developer Warning ***** :\n" \
- "\tThis program is calling:\n\n" \
- "\t%s();\n\n" \
- "\tWith the parameter:\n\n" \
- "\t%s\n\n" \
- "\tbeing NULL. Please fix your program.", __FUNCTION__, sparam); \
- if (getenv("ECORE_ERROR_ABORT")) abort(); \
- return ret; \
- }
+ if (!(param)) \
+ { \
+ printf("***** Developer Warning ***** :\n" \
+ "\tThis program is calling:\n\n" \
+ "\t%s();\n\n" \
+ "\tWith the parameter:\n\n" \
+ "\t%s\n\n" \
+ "\tbeing NULL. Please fix your program.", __FUNCTION__, sparam); \
+ if (getenv("ECORE_ERROR_ABORT")) { abort(); } \
+ return ret; \
+ }
#undef CHECK_PARAM_POINTER
#define CHECK_PARAM_POINTER(sparam, param) \
- if (!(param)) \
- { \
- printf("***** Developer Warning ***** :\n" \
- "\tThis program is calling:\n\n" \
- "\t%s();\n\n" \
- "\tWith the parameter:\n\n" \
- "\t%s\n\n" \
- "\tbeing NULL. Please fix your program.", __FUNCTION__, sparam); \
- if (getenv("ECORE_ERROR_ABORT")) abort(); \
- return; \
- }
+ if (!(param)) \
+ { \
+ printf("***** Developer Warning ***** :\n" \
+ "\tThis program is calling:\n\n" \
+ "\t%s();\n\n" \
+ "\tWith the parameter:\n\n" \
+ "\t%s\n\n" \
+ "\tbeing NULL. Please fix your program.", __FUNCTION__, sparam); \
+ if (getenv("ECORE_ERROR_ABORT")) { abort(); } \
+ return; \
+ }
# ifdef __sgi
# define inline
# endif
# endif
-
+
# define ECORE_SORT_MIN 0
# define ECORE_SORT_MAX 1
- typedef void (*Ecore_For_Each) (void *value, void *user_data);
+typedef void (*Ecore_For_Each)(void *value, void *user_data);
# define ECORE_FOR_EACH(function) ((Ecore_For_Each)function)
-
- typedef void (*Ecore_Free_Cb) (void *data);
+
+typedef void (*Ecore_Free_Cb)(void *data);
# define ECORE_FREE_CB(func) ((Ecore_Free_Cb)func)
-
- typedef unsigned int (*Ecore_Hash_Cb) (const void *key);
+
+typedef unsigned int (*Ecore_Hash_Cb)(const void *key);
# define ECORE_HASH_CB(function) ((Ecore_Hash_Cb)function)
-
- typedef int (*Ecore_Compare_Cb) (const void *data1, const void *data2);
+
+typedef int (*Ecore_Compare_Cb)(const void *data1, const void *data2);
# define ECORE_COMPARE_CB(function) ((Ecore_Compare_Cb)function)
-
- typedef struct _ecore_list Ecore_List;
+
+typedef struct _ecore_list Ecore_List;
# define ECORE_LIST(list) ((Ecore_List *)list)
-
- typedef struct _ecore_list_node Ecore_List_Node;
+
+typedef struct _ecore_list_node Ecore_List_Node;
# define ECORE_LIST_NODE(node) ((Ecore_List_Node *)node)
- typedef struct _ecore_strbuf Ecore_Strbuf;
+typedef struct _ecore_strbuf Ecore_Strbuf;
# define ECORE_STRBUF(buf) ((Ecore_Strbuf *)buf)
-
- struct _ecore_list_node {
- void *data;
- struct _ecore_list_node *next;
- };
-
- struct _ecore_list {
- Ecore_List_Node *first; /* The first node in the list */
- Ecore_List_Node *last; /* The last node in the list */
- Ecore_List_Node *current; /* The current node in the list */
-
- Ecore_Free_Cb free_func; /* The callback to free data in nodes */
-
- int nodes; /* The number of nodes in the list */
- int index; /* The position from the front of the
- list of current node */
- };
-
- EAPI int ecore_direct_compare(const void *key1, const void *key2);
- EAPI int ecore_str_compare(const void *key1, const void *key2);
-
- EAPI unsigned int ecore_direct_hash(const void *key);
- EAPI unsigned int ecore_str_hash(const void *key);
-
- /* Creating and initializing new list structures */
- EAPI Ecore_List *ecore_list_new(void);
- EAPI int ecore_list_init(Ecore_List *list);
-
- /* Adding items to the list */
- EAPI int ecore_list_append(Ecore_List * list, void *_data);
- EAPI int ecore_list_prepend(Ecore_List * list, void *_data);
- EAPI int ecore_list_insert(Ecore_List * list, void *_data);
- EAPI int ecore_list_append_list(Ecore_List * list, Ecore_List * append);
- EAPI int ecore_list_prepend_list(Ecore_List * list, Ecore_List * prepend);
-
- /* Removing items from the list */
- EAPI int ecore_list_remove_destroy(Ecore_List *list);
- EAPI void *ecore_list_remove(Ecore_List * list);
- EAPI void *ecore_list_first_remove(Ecore_List * list);
- EAPI void *ecore_list_last_remove(Ecore_List * list);
-
- /* Retrieve the current position in the list */
- EAPI void *ecore_list_current(Ecore_List * list);
- EAPI void *ecore_list_first(Ecore_List * list);
- EAPI void *ecore_list_last(Ecore_List * list);
- EAPI int ecore_list_index(Ecore_List * list);
- EAPI int ecore_list_count(Ecore_List * list);
-
- /* Traversing the list */
- EAPI int ecore_list_for_each(Ecore_List *list, Ecore_For_Each function,
- void *user_data);
- EAPI void *ecore_list_first_goto(Ecore_List * list);
- EAPI void *ecore_list_last_goto(Ecore_List * list);
- EAPI void *ecore_list_index_goto(Ecore_List * list, int index);
- EAPI void *ecore_list_goto(Ecore_List * list, const void *_data);
-
- /* Traversing the list and returning data */
- EAPI void *ecore_list_next(Ecore_List * list);
- EAPI void *ecore_list_find(Ecore_List *list, Ecore_Compare_Cb function,
- const void *user_data);
-
- /* Sorting the list */
- EAPI int ecore_list_sort(Ecore_List *list, Ecore_Compare_Cb compare,
- char order);
- EAPI int ecore_list_mergesort(Ecore_List *list, Ecore_Compare_Cb compare,
- char order);
- EAPI int ecore_list_heapsort(Ecore_List *list, Ecore_Compare_Cb compare,
- char order);
- EAPI void ecore_list_merge(Ecore_List *list, Ecore_List *l2,
- Ecore_Compare_Cb, char order);
-
- /* Check to see if there is any data in the list */
- EAPI int ecore_list_empty_is(Ecore_List * list);
-
- /* Remove every node in the list without freeing the list itself */
- EAPI int ecore_list_clear(Ecore_List * list);
- /* Free the list and it's contents */
- EAPI void ecore_list_destroy(Ecore_List *list);
-
- /* Creating and initializing list nodes */
- EAPI Ecore_List_Node *ecore_list_node_new(void);
- EAPI int ecore_list_node_init(Ecore_List_Node *newNode);
-
- /* Destroying nodes */
- EAPI int ecore_list_node_destroy(Ecore_List_Node * _e_node, Ecore_Free_Cb free_func);
-
- EAPI int ecore_list_free_cb_set(Ecore_List * list, Ecore_Free_Cb free_func);
-
- typedef Ecore_List Ecore_DList;
+
+struct _ecore_list_node
+{
+ void *data;
+ struct _ecore_list_node *next;
+};
+
+struct _ecore_list
+{
+ Ecore_List_Node *first; /* The first node in the list */
+ Ecore_List_Node *last; /* The last node in the list */
+ Ecore_List_Node *current; /* The current node in the list */
+
+ Ecore_Free_Cb free_func; /* The callback to free data in nodes */
+
+ int nodes; /* The number of nodes in the list */
+ int index; /* The position from the front of the
+ list of current node */
+};
+
+EAPI int ecore_direct_compare(const void *key1, const void *key2);
+EAPI int ecore_str_compare(const void *key1, const void *key2);
+
+EAPI unsigned int ecore_direct_hash(const void *key);
+EAPI unsigned int ecore_str_hash(const void *key);
+
+/* Creating and initializing new list structures */
+EAPI Ecore_List * ecore_list_new(void);
+EAPI int ecore_list_init(Ecore_List *list);
+
+/* Adding items to the list */
+EAPI int ecore_list_append(Ecore_List *list, void *_data);
+EAPI int ecore_list_prepend(Ecore_List *list, void *_data);
+EAPI int ecore_list_insert(Ecore_List *list, void *_data);
+EAPI int ecore_list_append_list(Ecore_List *list,
+ Ecore_List *append);
+EAPI int ecore_list_prepend_list(Ecore_List *list,
+ Ecore_List *prepend);
+
+/* Removing items from the list */
+EAPI int ecore_list_remove_destroy(Ecore_List *list);
+EAPI void * ecore_list_remove(Ecore_List *list);
+EAPI void * ecore_list_first_remove(Ecore_List *list);
+EAPI void * ecore_list_last_remove(Ecore_List *list);
+
+/* Retrieve the current position in the list */
+EAPI void * ecore_list_current(Ecore_List *list);
+EAPI void * ecore_list_first(Ecore_List *list);
+EAPI void * ecore_list_last(Ecore_List *list);
+EAPI int ecore_list_index(Ecore_List *list);
+EAPI int ecore_list_count(Ecore_List *list);
+
+/* Traversing the list */
+EAPI int ecore_list_for_each(Ecore_List *list,
+ Ecore_For_Each function,
+ void *user_data);
+EAPI void * ecore_list_first_goto(Ecore_List *list);
+EAPI void * ecore_list_last_goto(Ecore_List *list);
+EAPI void * ecore_list_index_goto(Ecore_List *list, int index);
+EAPI void * ecore_list_goto(Ecore_List *list, const void *_data);
+
+/* Traversing the list and returning data */
+EAPI void * ecore_list_next(Ecore_List *list);
+EAPI void * ecore_list_find(Ecore_List *list,
+ Ecore_Compare_Cb function,
+ const void *user_data);
+
+/* Sorting the list */
+EAPI int ecore_list_sort(Ecore_List *list,
+ Ecore_Compare_Cb compare,
+ char order);
+EAPI int ecore_list_mergesort(Ecore_List *list,
+ Ecore_Compare_Cb compare,
+ char order);
+EAPI int ecore_list_heapsort(Ecore_List *list,
+ Ecore_Compare_Cb compare,
+ char order);
+EAPI void ecore_list_merge(Ecore_List *list, Ecore_List *l2,
+ Ecore_Compare_Cb, char order);
+
+/* Check to see if there is any data in the list */
+EAPI int ecore_list_empty_is(Ecore_List *list);
+
+/* Remove every node in the list without freeing the list itself */
+EAPI int ecore_list_clear(Ecore_List *list);
+/* Free the list and it's contents */
+EAPI void ecore_list_destroy(Ecore_List *list);
+
+/* Creating and initializing list nodes */
+EAPI Ecore_List_Node *ecore_list_node_new(void);
+EAPI int ecore_list_node_init(Ecore_List_Node *newNode);
+
+/* Destroying nodes */
+EAPI int ecore_list_node_destroy(Ecore_List_Node *_e_node,
+ Ecore_Free_Cb free_func);
+
+EAPI int ecore_list_free_cb_set(Ecore_List *list,
+ Ecore_Free_Cb free_func);
+
+typedef Ecore_List Ecore_DList;
# define ECORE_DLIST(dlist) ((Ecore_DList *)dlist)
-
- typedef struct _ecore_dlist_node Ecore_DList_Node;
+
+typedef struct _ecore_dlist_node Ecore_DList_Node;
# define ECORE_DLIST_NODE(dlist) ((Ecore_DList_Node *)dlist)
-
- struct _ecore_dlist_node {
- Ecore_List_Node single;
- Ecore_DList_Node *previous;
- };
-
- /* Creating and initializing new list structures */
- EAPI Ecore_DList *ecore_dlist_new(void);
- EAPI int ecore_dlist_init(Ecore_DList *list);
- EAPI void ecore_dlist_destroy(Ecore_DList *list);
-
- /* Adding items to the list */
- EAPI int ecore_dlist_append(Ecore_DList * _e_dlist, void *_data);
- EAPI int ecore_dlist_prepend(Ecore_DList * _e_dlist, void *_data);
- EAPI int ecore_dlist_insert(Ecore_DList * _e_dlist, void *_data);
- EAPI int ecore_dlist_append_list(Ecore_DList * _e_dlist, Ecore_DList * append);
- EAPI int ecore_dlist_prepend_list(Ecore_DList * _e_dlist, Ecore_DList * prepend);
-
- /* Info about list's state */
+
+struct _ecore_dlist_node
+{
+ Ecore_List_Node single;
+ Ecore_DList_Node *previous;
+};
+
+/* Creating and initializing new list structures */
+EAPI Ecore_DList *ecore_dlist_new(void);
+EAPI int ecore_dlist_init(Ecore_DList *list);
+EAPI void ecore_dlist_destroy(Ecore_DList *list);
+
+/* Adding items to the list */
+EAPI int ecore_dlist_append(Ecore_DList *_e_dlist, void *_data);
+EAPI int ecore_dlist_prepend(Ecore_DList *_e_dlist, void *_data);
+EAPI int ecore_dlist_insert(Ecore_DList *_e_dlist, void *_data);
+EAPI int ecore_dlist_append_list(Ecore_DList *_e_dlist,
+ Ecore_DList *append);
+EAPI int ecore_dlist_prepend_list(Ecore_DList *_e_dlist,
+ Ecore_DList *prepend);
+
+/* Info about list's state */
# define ecore_dlist_first(list) ecore_list_first(list)
# define ecore_dlist_last(list) ecore_list_last(list)
- EAPI void *ecore_dlist_current(Ecore_DList *list);
- EAPI int ecore_dlist_index(Ecore_DList *list);
+EAPI void * ecore_dlist_current(Ecore_DList *list);
+EAPI int ecore_dlist_index(Ecore_DList *list);
# define ecore_dlist_count(list) ecore_list_count(list)
-
- /* Removing items from the list */
- EAPI void *ecore_dlist_remove(Ecore_DList * _e_dlist);
- EAPI void *ecore_dlist_first_remove(Ecore_DList * _e_dlist);
- EAPI int ecore_dlist_remove_destroy(Ecore_DList *list);
- EAPI void *ecore_dlist_last_remove(Ecore_DList * _e_dlist);
-
- /* Traversing the list */
+
+/* Removing items from the list */
+EAPI void * ecore_dlist_remove(Ecore_DList *_e_dlist);
+EAPI void * ecore_dlist_first_remove(Ecore_DList *_e_dlist);
+EAPI int ecore_dlist_remove_destroy(Ecore_DList *list);
+EAPI void * ecore_dlist_last_remove(Ecore_DList *_e_dlist);
+
+/* Traversing the list */
# define ecore_dlist_for_each(list, function, user_data) \
ecore_list_for_each(list, function, user_data)
- EAPI void *ecore_dlist_first_goto(Ecore_DList * _e_dlist);
- EAPI void *ecore_dlist_last_goto(Ecore_DList * _e_dlist);
- EAPI void *ecore_dlist_index_goto(Ecore_DList * _e_dlist, int index);
- EAPI void *ecore_dlist_goto(Ecore_DList * _e_dlist, void *_data);
-
- /* Traversing the list and returning data */
- EAPI void *ecore_dlist_next(Ecore_DList * list);
- EAPI void *ecore_dlist_previous(Ecore_DList * list);
-
- /* Sorting the list */
- EAPI int ecore_dlist_sort(Ecore_DList *list, Ecore_Compare_Cb compare,
- char order);
- EAPI int ecore_dlist_mergesort(Ecore_DList *list, Ecore_Compare_Cb compare,
- char order);
+EAPI void * ecore_dlist_first_goto(Ecore_DList *_e_dlist);
+EAPI void * ecore_dlist_last_goto(Ecore_DList *_e_dlist);
+EAPI void * ecore_dlist_index_goto(Ecore_DList *_e_dlist, int index);
+EAPI void * ecore_dlist_goto(Ecore_DList *_e_dlist, void *_data);
+
+/* Traversing the list and returning data */
+EAPI void * ecore_dlist_next(Ecore_DList *list);
+EAPI void * ecore_dlist_previous(Ecore_DList *list);
+
+/* Sorting the list */
+EAPI int ecore_dlist_sort(Ecore_DList *list,
+ Ecore_Compare_Cb compare,
+ char order);
+EAPI int ecore_dlist_mergesort(Ecore_DList *list,
+ Ecore_Compare_Cb compare,
+ char order);
# define ecore_dlist_heapsort(list, compare, order) \
ecore_list_heapsort(list, compare, order)
- EAPI void ecore_dlist_merge(Ecore_DList *list, Ecore_DList *l2,
- Ecore_Compare_Cb, char order);
-
- /* Check to see if there is any data in the list */
- EAPI int ecore_dlist_empty_is(Ecore_DList * _e_dlist);
-
- /* Remove every node in the list without free'ing it */
- EAPI int ecore_dlist_clear(Ecore_DList * _e_dlist);
-
- /* Creating and initializing list nodes */
- EAPI int ecore_dlist_node_init(Ecore_DList_Node * node);
- EAPI Ecore_DList_Node *ecore_dlist_node_new(void);
-
- /* Destroying nodes */
- EAPI int ecore_dlist_node_destroy(Ecore_DList_Node * node, Ecore_Free_Cb free_func);
-
- EAPI int ecore_dlist_free_cb_set(Ecore_DList * dlist, Ecore_Free_Cb free_func);
-
-
-
- /*
- * Hash Table Implementation:
- *
- * Traditional hash table implementation. I had tried a list of tables
- * approach to save on the realloc's but it ended up being much slower than
- * the traditional approach.
- */
-
- typedef struct _ecore_hash_node Ecore_Hash_Node;
+EAPI void ecore_dlist_merge(Ecore_DList *list, Ecore_DList *l2,
+ Ecore_Compare_Cb, char order);
+
+/* Check to see if there is any data in the list */
+EAPI int ecore_dlist_empty_is(Ecore_DList *_e_dlist);
+
+/* Remove every node in the list without free'ing it */
+EAPI int ecore_dlist_clear(Ecore_DList *_e_dlist);
+
+/* Creating and initializing list nodes */
+EAPI int ecore_dlist_node_init(Ecore_DList_Node *node);
+EAPI Ecore_DList_Node *ecore_dlist_node_new(void);
+
+/* Destroying nodes */
+EAPI int ecore_dlist_node_destroy(Ecore_DList_Node *node,
+ Ecore_Free_Cb free_func);
+
+EAPI int ecore_dlist_free_cb_set(Ecore_DList *dlist,
+ Ecore_Free_Cb free_func);
+
+
+
+/*
+ * Hash Table Implementation:
+ *
+ * Traditional hash table implementation. I had tried a list of tables
+ * approach to save on the realloc's but it ended up being much slower than
+ * the traditional approach.
+ */
+
+typedef struct _ecore_hash_node Ecore_Hash_Node;
# define ECORE_HASH_NODE(hash) ((Ecore_Hash_Node *)hash)
-
- struct _ecore_hash_node {
- Ecore_Hash_Node *next; /* Pointer to the next node in the bucket list */
- void *key; /* The key for the data node */
- void *value; /* The value associated with this node */
- };
-
- typedef struct _ecore_hash Ecore_Hash;
+
+struct _ecore_hash_node
+{
+ Ecore_Hash_Node *next; /* Pointer to the next node in the bucket list */
+ void *key; /* The key for the data node */
+ void *value; /* The value associated with this node */
+};
+
+typedef struct _ecore_hash Ecore_Hash;
# define ECORE_HASH(hash) ((Ecore_Hash *)hash)
-
- struct _ecore_hash {
- Ecore_Hash_Node **buckets;
- int size; /* An index into the table of primes to
- determine size */
- int nodes; /* The number of nodes currently in the hash */
-
- int index; /* The current index into the bucket table */
-
- Ecore_Compare_Cb compare; /* The function used to compare node values */
- Ecore_Hash_Cb hash_func; /* The callback function to determine hash */
-
- Ecore_Free_Cb free_key; /* The callback function to free key */
- Ecore_Free_Cb free_value; /* The callback function to free value */
- };
-
- /* Create and initialize a hash */
- EAPI Ecore_Hash *ecore_hash_new(Ecore_Hash_Cb hash_func, Ecore_Compare_Cb compare);
- EAPI int ecore_hash_init(Ecore_Hash *hash, Ecore_Hash_Cb hash_func, Ecore_Compare_Cb compare);
-
- /* Functions related to freeing the data in the hash table */
- EAPI int ecore_hash_free_key_cb_set(Ecore_Hash *hash, Ecore_Free_Cb function);
- EAPI int ecore_hash_free_value_cb_set(Ecore_Hash *hash, Ecore_Free_Cb function);
- EAPI void ecore_hash_destroy(Ecore_Hash *hash);
-
- EAPI int ecore_hash_count(Ecore_Hash *hash);
- EAPI int ecore_hash_for_each_node(Ecore_Hash *hash, Ecore_For_Each for_each_func,
- void *user_data);
- EAPI Ecore_List *ecore_hash_keys(Ecore_Hash *hash);
-
- /* Retrieve and store data into the hash */
- EAPI void *ecore_hash_get(Ecore_Hash *hash, const void *key);
- EAPI int ecore_hash_set(Ecore_Hash *hash, void *key, void *value);
- EAPI int ecore_hash_hash_set(Ecore_Hash *hash, Ecore_Hash *set);
- EAPI void *ecore_hash_remove(Ecore_Hash *hash, const void *key);
- EAPI void *ecore_hash_find(Ecore_Hash *hash, Ecore_Compare_Cb compare, const void *value);
- EAPI void ecore_hash_dump_graph(Ecore_Hash *hash);
- EAPI void ecore_hash_dump_stats(Ecore_Hash *hash);
-
-
- typedef struct _ecore_heap Ecore_Sheap;
+
+struct _ecore_hash
+{
+ Ecore_Hash_Node **buckets;
+ int size; /* An index into the table of primes to
+ determine size */
+ int nodes; /* The number of nodes currently in the hash */
+
+ int index; /* The current index into the bucket table */
+
+ Ecore_Compare_Cb compare; /* The function used to compare node values */
+ Ecore_Hash_Cb hash_func; /* The callback function to determine hash */
+
+ Ecore_Free_Cb free_key; /* The callback function to free key */
+ Ecore_Free_Cb free_value; /* The callback function to free value */
+};
+
+/* Create and initialize a hash */
+EAPI Ecore_Hash *ecore_hash_new(Ecore_Hash_Cb hash_func,
+ Ecore_Compare_Cb compare);
+EAPI int ecore_hash_init(Ecore_Hash *hash,
+ Ecore_Hash_Cb hash_func,
+ Ecore_Compare_Cb compare);
+
+/* Functions related to freeing the data in the hash table */
+EAPI int ecore_hash_free_key_cb_set(Ecore_Hash *hash,
+ Ecore_Free_Cb function);
+EAPI int ecore_hash_free_value_cb_set(Ecore_Hash *hash,
+ Ecore_Free_Cb function);
+EAPI void ecore_hash_destroy(Ecore_Hash *hash);
+
+EAPI int ecore_hash_count(Ecore_Hash *hash);
+EAPI int ecore_hash_for_each_node(Ecore_Hash *hash,
+ Ecore_For_Each for_each_func,
+ void *user_data);
+EAPI Ecore_List *ecore_hash_keys(Ecore_Hash *hash);
+
+/* Retrieve and store data into the hash */
+EAPI void * ecore_hash_get(Ecore_Hash *hash, const void *key);
+EAPI int ecore_hash_set(Ecore_Hash *hash, void *key, void *value);
+EAPI int ecore_hash_hash_set(Ecore_Hash *hash, Ecore_Hash *set);
+EAPI void * ecore_hash_remove(Ecore_Hash *hash, const void *key);
+EAPI void * ecore_hash_find(Ecore_Hash *hash,
+ Ecore_Compare_Cb compare,
+ const void *value);
+EAPI void ecore_hash_dump_graph(Ecore_Hash *hash);
+EAPI void ecore_hash_dump_stats(Ecore_Hash *hash);
+
+
+typedef struct _ecore_heap Ecore_Sheap;
# define ECORE_HEAP(heap) ((Ecore_Sheap *)heap)
-
- struct _ecore_heap {
- void **data;
- int size;
- int space;
-
- char order, sorted;
-
- /* Callback for comparing node values, default is direct comparison */
- Ecore_Compare_Cb compare;
-
- /* Callback for freeing node data, default is NULL */
- Ecore_Free_Cb free_func;
- };
-
- EAPI Ecore_Sheap *ecore_sheap_new(Ecore_Compare_Cb compare, int size);
- EAPI void ecore_sheap_destroy(Ecore_Sheap *heap);
- EAPI int ecore_sheap_init(Ecore_Sheap *heap, Ecore_Compare_Cb compare, int size);
- EAPI int ecore_sheap_free_cb_set(Ecore_Sheap *heap, Ecore_Free_Cb free_func);
- EAPI int ecore_sheap_insert(Ecore_Sheap *heap, void *data);
- EAPI void *ecore_sheap_extract(Ecore_Sheap *heap);
- EAPI void *ecore_sheap_extreme(Ecore_Sheap *heap);
- EAPI int ecore_sheap_change(Ecore_Sheap *heap, void *item, void *newval);
- EAPI int ecore_sheap_compare_set(Ecore_Sheap *heap, Ecore_Compare_Cb compare);
- EAPI void ecore_sheap_order_set(Ecore_Sheap *heap, char order);
- EAPI void ecore_sheap_sort(Ecore_Sheap *heap);
-
- EAPI void *ecore_sheap_item(Ecore_Sheap *heap, int i);
-
-
- typedef struct _ecore_string Ecore_String;
- struct _ecore_string {
- char *string;
- int references;
- };
-
- EAPI int ecore_string_init();
- EAPI void ecore_string_shutdown();
- EAPI const char *ecore_string_instance(const char *string);
- EAPI void ecore_string_release(const char *string);
-
- typedef struct _Ecore_Tree_Node Ecore_Tree_Node;
+
+struct _ecore_heap
+{
+ void **data;
+ int size;
+ int space;
+
+ char order, sorted;
+
+ /* Callback for comparing node values, default is direct comparison */
+ Ecore_Compare_Cb compare;
+
+ /* Callback for freeing node data, default is NULL */
+ Ecore_Free_Cb free_func;
+};
+
+EAPI Ecore_Sheap *ecore_sheap_new(Ecore_Compare_Cb compare, int size);
+EAPI void ecore_sheap_destroy(Ecore_Sheap *heap);
+EAPI int ecore_sheap_init(Ecore_Sheap *heap,
+ Ecore_Compare_Cb compare,
+ int size);
+EAPI int ecore_sheap_free_cb_set(Ecore_Sheap *heap,
+ Ecore_Free_Cb free_func);
+EAPI int ecore_sheap_insert(Ecore_Sheap *heap, void *data);
+EAPI void * ecore_sheap_extract(Ecore_Sheap *heap);
+EAPI void * ecore_sheap_extreme(Ecore_Sheap *heap);
+EAPI int ecore_sheap_change(Ecore_Sheap *heap,
+ void *item,
+ void *newval);
+EAPI int ecore_sheap_compare_set(Ecore_Sheap *heap,
+ Ecore_Compare_Cb compare);
+EAPI void ecore_sheap_order_set(Ecore_Sheap *heap, char order);
+EAPI void ecore_sheap_sort(Ecore_Sheap *heap);
+
+EAPI void * ecore_sheap_item(Ecore_Sheap *heap, int i);
+
+
+typedef struct _ecore_string Ecore_String;
+struct _ecore_string
+{
+ char *string;
+ int references;
+};
+
+EAPI int ecore_string_init();
+EAPI void ecore_string_shutdown();
+EAPI const char *ecore_string_instance(const char *string);
+EAPI void ecore_string_release(const char *string);
+
+typedef struct _Ecore_Tree_Node Ecore_Tree_Node;
# define ECORE_TREE_NODE(object) ((Ecore_Tree_Node *)object)
- struct _Ecore_Tree_Node {
-
- /* The actual data for each node */
- void *key;
- void *value;
-
- /* Pointers to surrounding nodes */
- Ecore_Tree_Node *parent;
- Ecore_Tree_Node *left_child;
- Ecore_Tree_Node *right_child;
-
- /* Book keeping information for quicker balancing of the tree */
- int max_right;
- int max_left;
- };
-
- typedef struct _Ecore_Tree Ecore_Tree;
+struct _Ecore_Tree_Node
+{
+
+ /* The actual data for each node */
+ void *key;
+ void *value;
+
+ /* Pointers to surrounding nodes */
+ Ecore_Tree_Node *parent;
+ Ecore_Tree_Node *left_child;
+ Ecore_Tree_Node *right_child;
+
+ /* Book keeping information for quicker balancing of the tree */
+ int max_right;
+ int max_left;
+};
+
+typedef struct _Ecore_Tree Ecore_Tree;
# define ECORE_TREE(object) ((Ecore_Tree *)object)
- struct _Ecore_Tree {
- /* Nodes of the tree */
- Ecore_Tree_Node *tree;
-
- /* Callback for comparing node values, default is direct comparison */
- Ecore_Compare_Cb compare_func;
-
- /* Callback for freeing node data, default is NULL */
- Ecore_Free_Cb free_value;
- /* Callback for freeing node key, default is NULL */
- Ecore_Free_Cb free_key;
- };
-
- /* Some basic tree functions */
- /* Allocate and initialize a new tree */
- EAPI Ecore_Tree *ecore_tree_new(Ecore_Compare_Cb compare_func);
- /* Initialize a new tree */
- EAPI int ecore_tree_init(Ecore_Tree * tree, Ecore_Compare_Cb compare_func);
-
- /* Free the tree */
- EAPI int ecore_tree_destroy(Ecore_Tree * tree);
- /* Check to see if the tree has any nodes in it */
- EAPI int ecore_tree_empty_is(Ecore_Tree * tree);
-
- /* Retrieve the value associated with key */
- EAPI void *ecore_tree_get(Ecore_Tree * tree, const void *key);
- EAPI Ecore_Tree_Node *ecore_tree_get_node(Ecore_Tree * tree, const void *key);
- /* Retrieve the value of node with key greater than or equal to key */
- EAPI void *ecore_tree_closest_larger_get(Ecore_Tree * tree, const void *key);
- /* Retrieve the value of node with key less than or equal to key */
- EAPI void *ecore_tree_closest_smaller_get(Ecore_Tree * tree, const void *key);
-
- /* Set the value associated with key to value */
- EAPI int ecore_tree_set(Ecore_Tree * tree, void *key, void *value);
- /* Remove the key from the tree */
- EAPI int ecore_tree_remove(Ecore_Tree * tree, const void *key);
-
- /* Add a node to the tree */
- EAPI int ecore_tree_node_add(Ecore_Tree * tree, Ecore_Tree_Node * node);
- /* Remove a node from the tree */
- EAPI int ecore_tree_node_remove(Ecore_Tree * tree, Ecore_Tree_Node * node);
-
- /* For each node in the tree perform the for_each_func function */
- /* For this one pass in the node */
- EAPI int ecore_tree_for_each_node(Ecore_Tree * tree, Ecore_For_Each for_each_func,
- void *user_data);
- /* And here pass in the node's value */
- EAPI int ecore_tree_for_each_node_value(Ecore_Tree * tree,
- Ecore_For_Each for_each_func,
- void *user_data);
-
- /* Some basic node functions */
- /* Initialize a node */
- EAPI int ecore_tree_node_init(Ecore_Tree_Node * new_node);
- /* Allocate and initialize a new node */
- EAPI Ecore_Tree_Node *ecore_tree_node_new(void);
- /* Free the desired node */
- EAPI int ecore_tree_node_destroy(Ecore_Tree_Node * node,
- Ecore_Free_Cb free_value, Ecore_Free_Cb free_key);
-
- /* Set the node's key to key */
- EAPI int ecore_tree_node_key_set(Ecore_Tree_Node * node, void *key);
- /* Retrieve the key in node */
- EAPI void *ecore_tree_node_key_get(Ecore_Tree_Node * node);
-
- /* Set the node's value to value */
- EAPI int ecore_tree_node_value_set(Ecore_Tree_Node * node, void *value);
- /* Retrieve the value in node */
- EAPI void *ecore_tree_node_value_get(Ecore_Tree_Node * node);
-
- /* Add a function to free the data stored in nodes */
- EAPI int ecore_tree_free_value_cb_set(Ecore_Tree * tree, Ecore_Free_Cb free_value);
- /* Add a function to free the keys stored in nodes */
- EAPI int ecore_tree_free_key_cb_set(Ecore_Tree * tree, Ecore_Free_Cb free_key);
-
-
- EAPI Ecore_Strbuf * ecore_strbuf_new(void);
- EAPI void ecore_strbuf_free(Ecore_Strbuf *buf);
- EAPI void ecore_strbuf_append(Ecore_Strbuf *buf, const char *str);
- EAPI void ecore_strbuf_append_char(Ecore_Strbuf *buf, char c);
- EAPI void ecore_strbuf_insert(Ecore_Strbuf *buf, const char *str,
- size_t pos);
+struct _Ecore_Tree
+{
+ /* Nodes of the tree */
+ Ecore_Tree_Node *tree;
+
+ /* Callback for comparing node values, default is direct comparison */
+ Ecore_Compare_Cb compare_func;
+
+ /* Callback for freeing node data, default is NULL */
+ Ecore_Free_Cb free_value;
+ /* Callback for freeing node key, default is NULL */
+ Ecore_Free_Cb free_key;
+};
+
+/* Some basic tree functions */
+/* Allocate and initialize a new tree */
+EAPI Ecore_Tree * ecore_tree_new(Ecore_Compare_Cb compare_func);
+/* Initialize a new tree */
+EAPI int ecore_tree_init(Ecore_Tree *tree,
+ Ecore_Compare_Cb compare_func);
+
+/* Free the tree */
+EAPI int ecore_tree_destroy(Ecore_Tree *tree);
+/* Check to see if the tree has any nodes in it */
+EAPI int ecore_tree_empty_is(Ecore_Tree *tree);
+
+/* Retrieve the value associated with key */
+EAPI void * ecore_tree_get(Ecore_Tree *tree, const void *key);
+EAPI Ecore_Tree_Node *ecore_tree_get_node(Ecore_Tree *tree, const void *key);
+/* Retrieve the value of node with key greater than or equal to key */
+EAPI void * ecore_tree_closest_larger_get(Ecore_Tree *tree,
+ const void *key);
+/* Retrieve the value of node with key less than or equal to key */
+EAPI void * ecore_tree_closest_smaller_get(Ecore_Tree *tree,
+ const void *key);
+
+/* Set the value associated with key to value */
+EAPI int ecore_tree_set(Ecore_Tree *tree, void *key, void *value);
+/* Remove the key from the tree */
+EAPI int ecore_tree_remove(Ecore_Tree *tree, const void *key);
+
+/* Add a node to the tree */
+EAPI int ecore_tree_node_add(Ecore_Tree *tree,
+ Ecore_Tree_Node *node);
+/* Remove a node from the tree */
+EAPI int ecore_tree_node_remove(Ecore_Tree *tree,
+ Ecore_Tree_Node *node);
+
+/* For each node in the tree perform the for_each_func function */
+/* For this one pass in the node */
+EAPI int ecore_tree_for_each_node(Ecore_Tree *tree,
+ Ecore_For_Each for_each_func,
+ void *user_data);
+/* And here pass in the node's value */
+EAPI int ecore_tree_for_each_node_value(
+ Ecore_Tree *tree,
+ Ecore_For_Each
+ for_each_func,
+ void *user_data);
+
+/* Some basic node functions */
+/* Initialize a node */
+EAPI int ecore_tree_node_init(Ecore_Tree_Node *new_node);
+/* Allocate and initialize a new node */
+EAPI Ecore_Tree_Node *ecore_tree_node_new(void);
+/* Free the desired node */
+EAPI int ecore_tree_node_destroy(Ecore_Tree_Node *node,
+ Ecore_Free_Cb free_value,
+ Ecore_Free_Cb free_key);
+
+/* Set the node's key to key */
+EAPI int ecore_tree_node_key_set(Ecore_Tree_Node *node, void *key);
+/* Retrieve the key in node */
+EAPI void * ecore_tree_node_key_get(Ecore_Tree_Node *node);
+
+/* Set the node's value to value */
+EAPI int ecore_tree_node_value_set(Ecore_Tree_Node *node,
+ void *value);
+/* Retrieve the value in node */
+EAPI void * ecore_tree_node_value_get(Ecore_Tree_Node *node);
+
+/* Add a function to free the data stored in nodes */
+EAPI int ecore_tree_free_value_cb_set(Ecore_Tree *tree,
+ Ecore_Free_Cb free_value);
+/* Add a function to free the keys stored in nodes */
+EAPI int ecore_tree_free_key_cb_set(Ecore_Tree *tree,
+ Ecore_Free_Cb free_key);
+
+
+EAPI Ecore_Strbuf * ecore_strbuf_new(void);
+EAPI void ecore_strbuf_free(Ecore_Strbuf *buf);
+EAPI void ecore_strbuf_append(Ecore_Strbuf *buf, const char *str);
+EAPI void ecore_strbuf_append_char(Ecore_Strbuf *buf, char c);
+EAPI void ecore_strbuf_insert(Ecore_Strbuf *buf, const char *str,
+ size_t pos);
# define ecore_strbuf_prepend(buf, str) ecore_strbuf_insert(buf, str, 0)
- EAPI const char * ecore_strbuf_string_get(Ecore_Strbuf *buf);
- EAPI size_t ecore_strbuf_length_get(Ecore_Strbuf *buf);
- EAPI int ecore_strbuf_replace(Ecore_Strbuf *buf, const char *str,
- const char *with, unsigned int n);
+EAPI const char * ecore_strbuf_string_get(Ecore_Strbuf *buf);
+EAPI size_t ecore_strbuf_length_get(Ecore_Strbuf *buf);
+EAPI int ecore_strbuf_replace(Ecore_Strbuf *buf, const char *str,
+ const char *with, unsigned int n);
# define ecore_strbuf_replace_first(buf, str, with) \
- ecore_strbuf_replace(buf, str, with, 1)
- EAPI int ecore_strbuf_replace_all(Ecore_Strbuf *buf, const char *str,
- const char *with);
+ ecore_strbuf_replace(buf, str, with, 1)
+EAPI int ecore_strbuf_replace_all(Ecore_Strbuf *buf,
+ const char *str,
+ const char *with);
- extern int ecore_str_compare(const void *key1, const void *key2);
- extern int ecore_direct_compare(const void *key1, const void *key2);
- extern unsigned int ecore_str_hash(const void *key);
+extern int ecore_str_compare(const void *key1, const void *key2);
+extern int ecore_direct_compare(const void *key1, const void *key2);
+extern unsigned int ecore_str_hash(const void *key);
#ifdef __cplusplus
}
#endif
-#endif /* _ECORE_DATA_H */
+#endif /* _ECORE_DATA_H */
typedef unsigned char Evas_Bool;
-typedef struct _Evas_Array_Hash Evas_Array_Hash;
-typedef struct _Evas_Hash Evas_Hash; /**< A Hash table handle */
-typedef struct _Evas_List Evas_List; /**< A generic linked list node handle */
+typedef struct _Evas_Array_Hash Evas_Array_Hash;
+typedef struct _Evas_Hash Evas_Hash; /**< A Hash table handle */
+typedef struct _Evas_List Evas_List; /**< A generic linked list node handle */
typedef struct _Evas_Object_List Evas_Object_List;
struct _Evas_Hash
{
- int population;
+ int population;
Evas_Object_List *buckets[256];
};
-struct _Evas_List /** A linked list node */
+struct _Evas_List /** A linked list node */
{
- void *data; /**< Pointer to list element payload */
- Evas_List *next; /**< Next member in the list */
- Evas_List *prev; /**< Previous member in the list */
- struct _Evas_List_Accounting *accounting; /**< Private list accounting info - don't touch */
+ void *data; /**< Pointer to list element payload */
+ Evas_List *next; /**< Next member in the list */
+ Evas_List *prev; /**< Previous member in the list */
+ struct _Evas_List_Accounting *accounting; /**< Private list accounting info - don't touch */
};
struct _Evas_Object_List
{
- Evas_Object_List *next, *prev;
- Evas_Object_List *last;
+ Evas_Object_List *next, *prev;
+ Evas_Object_List *last;
};
extern "C" {
#endif
- /*
- * Evas Array Hash functions
- */
-
- EAPI Evas_Array_Hash *evas_array_hash_new (void);
- EAPI void evas_array_hash_free (Evas_Array_Hash *hash);
- EAPI void evas_array_hash_add (Evas_Array_Hash *hash, int key, int data);
- EAPI int evas_array_hash_search (Evas_Array_Hash *hash, int key);
-
-
- /*
- * Evas Hash functions
- */
-
- /* FIXME: add:
- * api to add find, del members by data, size not just string and also
- * provide hash generation functions settable by the app
- *
- * do we really need this? hmmm - let me think... there may be a better way
- */
- EAPI Evas_Hash *evas_hash_add (Evas_Hash *hash, const char *key, const void *data);
- EAPI Evas_Hash *evas_hash_direct_add (Evas_Hash *hash, const char *key, const void *data);
- EAPI Evas_Hash *evas_hash_del (Evas_Hash *hash, const char *key, const void *data);
- EAPI void *evas_hash_find (const Evas_Hash *hash, const char *key);
- EAPI void *evas_hash_modify (Evas_Hash *hash, const char *key, const void *data);
- EAPI int evas_hash_size (const Evas_Hash *hash);
- EAPI void evas_hash_free (Evas_Hash *hash);
- EAPI void evas_hash_foreach (const Evas_Hash *hash, Evas_Bool (*func) (const Evas_Hash *hash, const char *key, void *data, void *fdata), const void *fdata);
- EAPI int evas_hash_alloc_error (void);
-
-
- /*
- * Evas List functions
- */
-
- EAPI Evas_List *evas_list_append (Evas_List *list, const void *data);
- EAPI Evas_List *evas_list_prepend (Evas_List *list, const void *data);
- EAPI Evas_List *evas_list_append_relative (Evas_List *list, const void *data, const void *relative);
- EAPI Evas_List *evas_list_append_relative_list (Evas_List *list, const void *data, Evas_List *relative);
- EAPI Evas_List *evas_list_prepend_relative (Evas_List *list, const void *data, const void *relative);
- EAPI Evas_List *evas_list_prepend_relative_list (Evas_List *list, const void *data, Evas_List *relative);
- EAPI Evas_List *evas_list_remove (Evas_List *list, const void *data);
- EAPI Evas_List *evas_list_remove_list (Evas_List *list, Evas_List *remove_list);
- EAPI Evas_List *evas_list_promote_list (Evas_List *list, Evas_List *move_list);
- EAPI void *evas_list_find (const Evas_List *list, const void *data);
- EAPI Evas_List *evas_list_find_list (const Evas_List *list, const void *data);
- EAPI Evas_List *evas_list_free (Evas_List *list);
- EAPI Evas_List *evas_list_last (const Evas_List *list);
- EAPI Evas_List *evas_list_next (const Evas_List *list);
- EAPI Evas_List *evas_list_prev (const Evas_List *list);
- EAPI void *evas_list_data (const Evas_List *list);
- EAPI int evas_list_count (const Evas_List *list);
- EAPI void *evas_list_nth (const Evas_List *list, int n);
- EAPI Evas_List *evas_list_nth_list (const Evas_List *list, int n);
- EAPI Evas_List *evas_list_reverse (Evas_List *list);
- EAPI Evas_List *evas_list_sort (Evas_List *list, int size, int(*func)(void*,void*));
- EAPI int evas_list_alloc_error (void);
-
-
- /*
- * Evas Object List functions
- */
-
- EAPI void *evas_object_list_append (void *in_list, void *in_item);
- EAPI void *evas_object_list_prepend (void *in_list, void *in_item);
- EAPI void *evas_object_list_append_relative (void *in_list, void *in_item, void *in_relative);
- EAPI void *evas_object_list_prepend_relative (void *in_list, void *in_item, void *in_relative);
- EAPI void *evas_object_list_remove (void *in_list, void *in_item);
- EAPI void *evas_object_list_find (void *in_list, void *in_item);
-
-
- /*
- * Evas Stringshare functions
- */
-
- EAPI void evas_stringshare_init (void); /* not implemented */
- EAPI void evas_stringshare_shutdown (void); /* not implemented */
- EAPI const char *evas_stringshare_add (const char *str);
- EAPI void evas_stringshare_del (const char *str);
+/*
+ * Evas Array Hash functions
+ */
+
+EAPI Evas_Array_Hash *evas_array_hash_new (void);
+EAPI void evas_array_hash_free (Evas_Array_Hash *hash);
+EAPI void evas_array_hash_add (Evas_Array_Hash *hash,
+ int key,
+ int data);
+EAPI int evas_array_hash_search (Evas_Array_Hash *hash,
+ int key);
+
+
+/*
+ * Evas Hash functions
+ */
+
+/* FIXME: add:
+ * api to add find, del members by data, size not just string and also
+ * provide hash generation functions settable by the app
+ *
+ * do we really need this? hmmm - let me think... there may be a better way
+ */
+EAPI Evas_Hash *evas_hash_add (Evas_Hash *hash,
+ const char *key,
+ const void *data);
+EAPI Evas_Hash *evas_hash_direct_add (Evas_Hash *hash,
+ const char *key,
+ const void *data);
+EAPI Evas_Hash *evas_hash_del (Evas_Hash *hash,
+ const char *key,
+ const void *data);
+EAPI void * evas_hash_find (const Evas_Hash *hash,
+ const char *key);
+EAPI void * evas_hash_modify (Evas_Hash *hash,
+ const char *key,
+ const void *data);
+EAPI int evas_hash_size (const Evas_Hash *hash);
+EAPI void evas_hash_free (Evas_Hash *hash);
+EAPI void evas_hash_foreach (const Evas_Hash *hash,
+ Evas_Bool (*func)(
+ const Evas_Hash *hash,
+ const char *
+ key,
+ void *data,
+ void *fdata),
+ const void *fdata);
+EAPI int evas_hash_alloc_error (void);
+
+
+/*
+ * Evas List functions
+ */
+
+EAPI Evas_List *evas_list_append (Evas_List *list,
+ const void *data);
+EAPI Evas_List *evas_list_prepend (Evas_List *list,
+ const void *data);
+EAPI Evas_List *evas_list_append_relative (Evas_List *list,
+ const void *data,
+ const void *relative);
+EAPI Evas_List *evas_list_append_relative_list (Evas_List *list,
+ const void *data,
+ Evas_List *relative);
+EAPI Evas_List *evas_list_prepend_relative (Evas_List *list,
+ const void *data,
+ const void *relative);
+EAPI Evas_List *evas_list_prepend_relative_list (Evas_List *list,
+ const void *data,
+ Evas_List *relative);
+EAPI Evas_List *evas_list_remove (Evas_List *list,
+ const void *data);
+EAPI Evas_List *evas_list_remove_list (Evas_List *list,
+ Evas_List *remove_list);
+EAPI Evas_List *evas_list_promote_list (Evas_List *list,
+ Evas_List *move_list);
+EAPI void * evas_list_find (const Evas_List *list,
+ const void *data);
+EAPI Evas_List *evas_list_find_list (const Evas_List *list,
+ const void *data);
+EAPI Evas_List *evas_list_free (Evas_List *list);
+EAPI Evas_List *evas_list_last (const Evas_List *list);
+EAPI Evas_List *evas_list_next (const Evas_List *list);
+EAPI Evas_List *evas_list_prev (const Evas_List *list);
+EAPI void * evas_list_data (const Evas_List *list);
+EAPI int evas_list_count (const Evas_List *list);
+EAPI void * evas_list_nth (const Evas_List *list, int n);
+EAPI Evas_List *evas_list_nth_list (const Evas_List *list, int n);
+EAPI Evas_List *evas_list_reverse (Evas_List *list);
+EAPI Evas_List *evas_list_sort (Evas_List *list,
+ int size,
+ int (*func)(void *,void *));
+EAPI int evas_list_alloc_error (void);
+
+
+/*
+ * Evas Object List functions
+ */
+
+EAPI void * evas_object_list_append (void *in_list,
+ void *in_item);
+EAPI void * evas_object_list_prepend (void *in_list,
+ void *in_item);
+EAPI void * evas_object_list_append_relative (void *in_list,
+ void *in_item,
+ void *in_relative);
+EAPI void * evas_object_list_prepend_relative (void *in_list,
+ void *in_item,
+ void *in_relative);
+EAPI void * evas_object_list_remove (void *in_list,
+ void *in_item);
+EAPI void * evas_object_list_find (void *in_list,
+ void *in_item);
+
+
+/*
+ * Evas Stringshare functions
+ */
+
+EAPI void evas_stringshare_init (void); /* not implemented */
+EAPI void evas_stringshare_shutdown (void); /* not implemented */
+EAPI const char *evas_stringshare_add (const char *str);
+EAPI void evas_stringshare_del (const char *str);
#ifdef __cplusplus
}
#define ECORE_HASH_CHAIN_MAX 3
#define ECORE_COMPUTE_HASH(hash, key) hash->hash_func(key) % \
- ecore_prime_table[hash->size];
+ ecore_prime_table[hash->size];
-#define ECORE_HASH_INCREASE(hash) ((hash && ecore_prime_table[hash->size] < PRIME_MAX) ? \
- (hash->nodes / ecore_prime_table[hash->size]) > \
- ECORE_HASH_CHAIN_MAX : FALSE)
-#define ECORE_HASH_REDUCE(hash) ((hash && ecore_prime_table[hash->size] > PRIME_MIN) ? \
- (double)hash->nodes / (double)ecore_prime_table[hash->size-1] \
- < ((double)ECORE_HASH_CHAIN_MAX * 0.375) : FALSE)
+#define ECORE_HASH_INCREASE(hash) ((hash && ecore_prime_table[hash->size] < \
+ PRIME_MAX) ? \
+ (hash->nodes / \
+ ecore_prime_table[hash->size]) > \
+ ECORE_HASH_CHAIN_MAX : FALSE)
+#define ECORE_HASH_REDUCE(hash) ((hash && ecore_prime_table[hash->size] > \
+ PRIME_MIN) ? \
+ (double)hash->nodes / \
+ (double)ecore_prime_table[hash->size - 1] \
+ < ((double)ECORE_HASH_CHAIN_MAX * \
+ 0.375) : FALSE)
static const unsigned int ecore_prime_table[] =
{
17, 31, 61, 127, 257, 509, 1021,
- 2053, 4093, 8191, 16381, 32771, 65537, 131071, 262147, 524287, 1048573,
- 2097143, 4194301, 8388617, 16777213
+ 2053, 4093, 8191, 16381, 32771, 65537, 131071, 262147, 524287, 1048573,
+ 2097143, 4194301, 8388617, 16777213
};
/* Private hash manipulation functions */
-static int _ecore_hash_node_add(Ecore_Hash *hash, Ecore_Hash_Node *node);
-static Ecore_Hash_Node * _ecore_hash_node_get(Ecore_Hash *hash, const void *key);
-static int _ecore_hash_increase(Ecore_Hash *hash);
-static int _ecore_hash_decrease(Ecore_Hash *hash);
-static inline int _ecore_hash_rehash(Ecore_Hash *hash, Ecore_Hash_Node **old_table, int old_size);
-static int _ecore_hash_bucket_destroy(Ecore_Hash_Node *list, Ecore_Free_Cb keyd,
- Ecore_Free_Cb valued);
-static inline Ecore_Hash_Node * _ecore_hash_bucket_get(Ecore_Hash *hash,
- Ecore_Hash_Node *bucket, const void *key);
-
-static Ecore_Hash_Node *_ecore_hash_node_new(void *key, void *value);
-static int _ecore_hash_node_init(Ecore_Hash_Node *node, void *key, void *value);
-static int _ecore_hash_node_destroy(Ecore_Hash_Node *node, Ecore_Free_Cb keyd,
- Ecore_Free_Cb valued);
+static int _ecore_hash_node_add(Ecore_Hash *hash,
+ Ecore_Hash_Node *node);
+static Ecore_Hash_Node * _ecore_hash_node_get(Ecore_Hash *hash,
+ const void *key);
+static int _ecore_hash_increase(Ecore_Hash *hash);
+static int _ecore_hash_decrease(Ecore_Hash *hash);
+static inline int _ecore_hash_rehash(Ecore_Hash *hash,
+ Ecore_Hash_Node **old_table,
+ int old_size);
+static int _ecore_hash_bucket_destroy(Ecore_Hash_Node *list,
+ Ecore_Free_Cb keyd,
+ Ecore_Free_Cb valued);
+static inline Ecore_Hash_Node *_ecore_hash_bucket_get(Ecore_Hash *hash,
+ Ecore_Hash_Node *bucket,
+ const void *key);
+
+static Ecore_Hash_Node * _ecore_hash_node_new(void *key, void *value);
+static int _ecore_hash_node_init(Ecore_Hash_Node *node,
+ void *key,
+ void *value);
+static int _ecore_hash_node_destroy(Ecore_Hash_Node *node,
+ Ecore_Free_Cb keyd,
+ Ecore_Free_Cb valued);
/**
* @defgroup Ecore_Data_Hash_ADT_Creation_Group Hash Creation Functions
{
Ecore_Hash *new_hash = (Ecore_Hash *)malloc(sizeof(Ecore_Hash));
if (!new_hash)
- return NULL;
+ return NULL;
if (!ecore_hash_init(new_hash, hash_func, compare))
{
- FREE(new_hash);
- return NULL;
+ FREE(new_hash);
+ return NULL;
}
return new_hash;
* @ingroup Ecore_Data_Hash_ADT_Creation_Group
*/
EAPI int
-ecore_hash_init(Ecore_Hash *hash, Ecore_Hash_Cb hash_func, Ecore_Compare_Cb compare)
+ecore_hash_init(Ecore_Hash *hash,
+ Ecore_Hash_Cb hash_func,
+ Ecore_Compare_Cb compare)
{
CHECK_PARAM_POINTER_RETURN("hash", hash, FALSE);
hash->compare = compare;
hash->buckets = (Ecore_Hash_Node **)calloc(ecore_prime_table[0],
- sizeof(Ecore_Hash_Node *));
+ sizeof(Ecore_Hash_Node *));
return TRUE;
}
node = _ecore_hash_node_get(hash, key);
if (node)
{
- if (hash->free_key) hash->free_key(key);
- if (node->value && hash->free_value) hash->free_value(node->value);
- node->value = value;
- ret = TRUE;
+ if (hash->free_key)
+ hash->free_key(key);
+
+ if (node->value && hash->free_value)
+ hash->free_value(node->value);
+
+ node->value = value;
+ ret = TRUE;
}
else
{
- node = _ecore_hash_node_new(key, value);
- if (node)
- ret = _ecore_hash_node_add(hash, node);
+ node = _ecore_hash_node_new(key, value);
+ if (node)
+ ret = _ecore_hash_node_add(hash, node);
}
return ret;
Ecore_Hash_Node *node, *old;
CHECK_PARAM_POINTER_RETURN("hash", hash, FALSE);
- CHECK_PARAM_POINTER_RETURN("set", set, FALSE);
+ CHECK_PARAM_POINTER_RETURN("set", set, FALSE);
for (i = 0; i < ecore_prime_table[set->size]; i++)
{
- /* Hash into a new list to avoid loops of rehashing the same nodes */
- while ((old = set->buckets[i]))
- {
- set->buckets[i] = old->next;
- old->next = NULL;
- node = _ecore_hash_node_get(hash, old->key);
- if (node)
- {
- /* This key already exists. Delete the old and add the new
- * value */
- if (hash->free_key) hash->free_key(node->key);
- if (hash->free_value) hash->free_key(node->value);
- node->key = old->key;
- node->value = old->value;
- free(old);
- }
- else
- _ecore_hash_node_add(hash, old);
- }
+ /* Hash into a new list to avoid loops of rehashing the same nodes */
+ while ((old = set->buckets[i]))
+ {
+ set->buckets[i] = old->next;
+ old->next = NULL;
+ node = _ecore_hash_node_get(hash, old->key);
+ if (node)
+ {
+ /* This key already exists. Delete the old and add the new
+ * value */
+ if (hash->free_key)
+ hash->free_key(node->key);
+
+ if (hash->free_value)
+ hash->free_key(node->value);
+
+ node->key = old->key;
+ node->value = old->value;
+ free(old);
+ }
+ else
+ _ecore_hash_node_add(hash, old);
+ }
}
FREE(set->buckets);
ecore_hash_init(set, set->hash_func, set->compare);
if (hash->buckets)
{
- while (i < ecore_prime_table[hash->size])
- {
- if (hash->buckets[i])
- {
- Ecore_Hash_Node *bucket;
-
- /*
- * Remove the bucket list to avoid possible recursion
- * on the free callbacks.
- */
- bucket = hash->buckets[i];
- hash->buckets[i] = NULL;
- _ecore_hash_bucket_destroy(bucket,
- hash->free_key,
- hash->free_value);
- }
- i++;
- }
-
- FREE(hash->buckets);
+ while (i < ecore_prime_table[hash->size])
+ {
+ if (hash->buckets[i])
+ {
+ Ecore_Hash_Node *bucket;
+
+ /*
+ * Remove the bucket list to avoid possible recursion
+ * on the free callbacks.
+ */
+ bucket = hash->buckets[i];
+ hash->buckets[i] = NULL;
+ _ecore_hash_bucket_destroy(bucket,
+ hash->free_key,
+ hash->free_value);
+ }
+
+ i++;
+ }
+
+ FREE(hash->buckets);
}
- FREE(hash);
+
+ FREE(hash);
return;
}
* @ingroup Ecore_Data_Hash_ADT_Traverse_Group
*/
EAPI int
-ecore_hash_for_each_node(Ecore_Hash *hash, Ecore_For_Each for_each_func, void *user_data)
+ecore_hash_for_each_node(Ecore_Hash *hash,
+ Ecore_For_Each for_each_func,
+ void *user_data)
{
unsigned int i = 0;
- CHECK_PARAM_POINTER_RETURN("hash", hash, FALSE);
+ CHECK_PARAM_POINTER_RETURN("hash", hash, FALSE);
CHECK_PARAM_POINTER_RETURN("for_each_func", for_each_func, FALSE);
while (i < ecore_prime_table[hash->size])
{
- if (hash->buckets[i])
- {
- Ecore_Hash_Node *node;
-
- for (node = hash->buckets[i]; node; node = node->next)
- {
- for_each_func(node, user_data);
- }
- }
- i++;
+ if (hash->buckets[i])
+ {
+ Ecore_Hash_Node *node;
+
+ for (node = hash->buckets[i]; node; node = node->next)
+ {
+ for_each_func(node, user_data);
+ }
+ }
+
+ i++;
}
return TRUE;
keys = ecore_list_new();
while (i < ecore_prime_table[hash->size])
{
- if (hash->buckets[i])
- {
- Ecore_Hash_Node *node;
-
- for (node = hash->buckets[i]; node; node = node->next)
- {
- ecore_list_append(keys, node->key);
- }
- }
- i++;
+ if (hash->buckets[i])
+ {
+ Ecore_Hash_Node *node;
+
+ for (node = hash->buckets[i]; node; node = node->next)
+ {
+ ecore_list_append(keys, node->key);
+ }
+ }
+
+ i++;
}
ecore_list_first_goto(keys);
unsigned int i;
for (i = 0; i < ecore_prime_table[hash->size]; i++)
- if (hash->buckets[i])
- {
- int n = 0;
- Ecore_Hash_Node *node;
- for (node = hash->buckets[i]; node; node = node->next)
- n++;
- printf("%d\t%u", i, n);
- }
- else
- printf("%d\t0", i);
+ if (hash->buckets[i])
+ {
+ int n = 0;
+ Ecore_Hash_Node *node;
+ for (node = hash->buckets[i]; node; node = node->next)
+ n++;
+ printf("%d\t%u", i, n);
+ }
+ else
+ printf("%d\t0", i);
+
}
/**
for (i = 0; i < ecore_prime_table[hash->size]; i++)
{
- if (hash->buckets[i])
- {
- int n = 0;
- Ecore_Hash_Node *node;
- for (node = hash->buckets[i]; node; node = node->next)
- n++;
- sum_n_2 += ((double)n * (double)n);
- sum_n += (double)n;
- }
+ if (hash->buckets[i])
+ {
+ int n = 0;
+ Ecore_Hash_Node *node;
+ for (node = hash->buckets[i]; node; node = node->next)
+ n++;
+ sum_n_2 += ((double)n * (double)n);
+ sum_n += (double)n;
+ }
}
variance = (sum_n_2 - ((sum_n * sum_n) / (double)i)) / (double)i;
- printf("Average length: %f\n\tvariance^2: %f", (sum_n / (double)i),
- variance);
+ printf("Average length: %f\n\tvariance^2: %f", (sum_n / (double)i),
+ variance);
}
static int
-_ecore_hash_bucket_destroy(Ecore_Hash_Node *list, Ecore_Free_Cb keyd, Ecore_Free_Cb valued)
+_ecore_hash_bucket_destroy(Ecore_Hash_Node *list,
+ Ecore_Free_Cb keyd,
+ Ecore_Free_Cb valued)
{
Ecore_Hash_Node *node;
for (node = list; node; node = list)
{
- list = list->next;
- _ecore_hash_node_destroy(node, keyd, valued);
+ list = list->next;
+ _ecore_hash_node_destroy(node, keyd, valued);
}
return TRUE;
/* Check to see if the hash needs to be resized */
if (ECORE_HASH_INCREASE(hash))
- _ecore_hash_increase(hash);
+ _ecore_hash_increase(hash);
/* Compute the position in the table */
if (!hash->hash_func)
- hash_val = (unsigned long)node->key % ecore_prime_table[hash->size];
+ hash_val = (unsigned long)node->key % ecore_prime_table[hash->size];
else
- hash_val = ECORE_COMPUTE_HASH(hash, node->key);
+ hash_val = ECORE_COMPUTE_HASH(hash, node->key);
/* Prepend the node to the list at the index position */
node->next = hash->buckets[hash_val];
node = _ecore_hash_node_get(hash, key);
if (!node)
- return NULL;
+ return NULL;
data = node->value;
/* Compute the position in the table */
if (!hash->hash_func)
- hash_val = (unsigned long )key % ecore_prime_table[hash->size];
+ hash_val = (unsigned long )key % ecore_prime_table[hash->size];
else
- hash_val = ECORE_COMPUTE_HASH(hash, key);
+ hash_val = ECORE_COMPUTE_HASH(hash, key);
/*
* If their is a list that could possibly hold the key/value pair
*/
if (hash->buckets[hash_val])
{
- list = hash->buckets[hash_val];
-
- /*
- * Traverse the list to find the specified key
- */
- node = list;
- if (hash->compare)
- {
- while ((node) && (hash->compare(node->key, key) != 0))
- {
- list = node;
- node = node->next;
- }
- }
- else
- {
- while ((node) && (node->key != key))
- {
- list = node;
- node = node->next;
- }
- }
-
- /*
- * Remove the node with the matching key and free it's memory
- */
- if (node)
- {
- if (list == node)
- hash->buckets[hash_val] = node->next;
- else
- list->next = node->next;
- ret = node->value;
- node->value = NULL;
- _ecore_hash_node_destroy(node, hash->free_key, NULL);
- hash->nodes--;
- }
+ list = hash->buckets[hash_val];
+
+ /*
+ * Traverse the list to find the specified key
+ */
+ node = list;
+ if (hash->compare)
+ while ((node) && (hash->compare(node->key, key) != 0))
+ {
+ list = node;
+ node = node->next;
+ }
+ else
+ while ((node) && (node->key != key))
+ {
+ list = node;
+ node = node->next;
+ }
+
+ /*
+ * Remove the node with the matching key and free it's memory
+ */
+ if (node)
+ {
+ if (list == node)
+ hash->buckets[hash_val] = node->next;
+ else
+ list->next = node->next;
+
+ ret = node->value;
+ node->value = NULL;
+ _ecore_hash_node_destroy(node, hash->free_key, NULL);
+ hash->nodes--;
+ }
}
if (ECORE_HASH_REDUCE(hash))
- _ecore_hash_decrease(hash);
+ _ecore_hash_decrease(hash);
return ret;
}
{
unsigned int i = 0;
- CHECK_PARAM_POINTER_RETURN("hash", hash, NULL);
+ CHECK_PARAM_POINTER_RETURN("hash", hash, NULL);
CHECK_PARAM_POINTER_RETURN("compare", compare, NULL);
- CHECK_PARAM_POINTER_RETURN("value", value, NULL);
+ CHECK_PARAM_POINTER_RETURN("value", value, NULL);
while (i < ecore_prime_table[hash->size])
{
- if (hash->buckets[i])
- {
- Ecore_Hash_Node *node;
-
- for (node = hash->buckets[i]; node; node = node->next)
- {
- if (!compare(node->value, value)) return node->value;
- }
- }
- i++;
+ if (hash->buckets[i])
+ {
+ Ecore_Hash_Node *node;
+
+ for (node = hash->buckets[i]; node; node = node->next)
+ {
+ if (!compare(node->value, value))
+ return node->value;
+ }
+ }
+
+ i++;
}
return NULL;
CHECK_PARAM_POINTER_RETURN("hash", hash, NULL);
if (!hash->buckets)
- {
- return NULL;
- }
+ return NULL;
/* Compute the position in the table */
if (!hash->hash_func)
- hash_val = (unsigned long)key % ecore_prime_table[hash->size];
+ hash_val = (unsigned long)key % ecore_prime_table[hash->size];
else
- hash_val = ECORE_COMPUTE_HASH(hash, key);
+ hash_val = ECORE_COMPUTE_HASH(hash, key);
/* Grab the bucket at the specified position */
if (hash->buckets[hash_val])
{
- node = _ecore_hash_bucket_get(hash, hash->buckets[hash_val], key);
- /*
- * Move matched node to the front of the list as it's likely
- * to be searched for again soon.
- */
- if (node && node != hash->buckets[hash_val])
- {
- node->next = hash->buckets[hash_val];
- hash->buckets[hash_val] = node;
- }
+ node = _ecore_hash_bucket_get(hash, hash->buckets[hash_val], key);
+ /*
+ * Move matched node to the front of the list as it's likely
+ * to be searched for again soon.
+ */
+ if (node && node != hash->buckets[hash_val])
+ {
+ node->next = hash->buckets[hash_val];
+ hash->buckets[hash_val] = node;
+ }
}
return node;
* @return Returns NULL on error or not found, the found node on success
*/
static inline Ecore_Hash_Node *
-_ecore_hash_bucket_get(Ecore_Hash *hash, Ecore_Hash_Node *bucket, const void *key)
+_ecore_hash_bucket_get(Ecore_Hash *hash,
+ Ecore_Hash_Node *bucket,
+ const void *key)
{
Ecore_Hash_Node *prev = NULL;
Ecore_Hash_Node *node = NULL;
* list, then return the node.
*/
if (hash->compare)
- {
- for (node = bucket; node; node = node->next)
- {
- if (hash->compare(node->key, key) == 0)
- break;
- prev = node;
- }
- }
+ for (node = bucket; node; node = node->next)
+ {
+ if (hash->compare(node->key, key) == 0)
+ break;
+
+ prev = node;
+ }
else
- {
- for (node = bucket; node; node = node->next)
- {
- if (node->key == key)
- break;
- prev = node;
- }
- }
+ for (node = bucket; node; node = node->next)
+ {
+ if (node->key == key)
+ break;
+
+ prev = node;
+ }
/*
* Remove node from the list to replace it at the beginning.
*/
if (node && prev)
{
- prev->next = node->next;
- node->next = NULL;
+ prev->next = node->next;
+ node->next = NULL;
}
return node;
CHECK_PARAM_POINTER_RETURN("hash", hash, FALSE);
/* Max size reached so return FALSE */
- if ((ecore_prime_table[hash->size] == PRIME_MAX) || (hash->size == PRIME_TABLE_MAX))
- return FALSE;
+ if ((ecore_prime_table[hash->size] == PRIME_MAX) ||
+ (hash->size == PRIME_TABLE_MAX))
+ return FALSE;
/*
* Increase the size of the hash and save a pointer to the old data
/*
* Allocate a new bucket area, of the new larger size
*/
- hash->buckets = calloc(ecore_prime_table[hash->size], sizeof(Ecore_Hash_Node *));
+ hash->buckets =
+ calloc(ecore_prime_table[hash->size], sizeof(Ecore_Hash_Node *));
/*
* Make sure the allocation succeeded, if not replace the old data and
*/
if (!hash->buckets)
{
- hash->buckets = old;
- hash->size--;
- return FALSE;
+ hash->buckets = old;
+ hash->size--;
+ return FALSE;
}
+
hash->nodes = 0;
/*
*/
if (_ecore_hash_rehash(hash, old, hash->size - 1))
{
- FREE(old);
- return TRUE;
+ FREE(old);
+ return TRUE;
}
/*
* Free the old buckets regardless of success.
*/
- FREE(old);
+ FREE(old);
return FALSE;
}
CHECK_PARAM_POINTER_RETURN("hash", hash, FALSE);
if (ecore_prime_table[hash->size] == PRIME_MIN)
- return FALSE;
+ return FALSE;
/*
* Decrease the hash size and store a pointer to the old data
* Allocate a new area to store the data
*/
hash->buckets = (Ecore_Hash_Node **)calloc(ecore_prime_table[hash->size],
- sizeof(Ecore_Hash_Node *));
+ sizeof(Ecore_Hash_Node *));
/*
* Make sure allocation succeeded otherwise rreturn to the previous
*/
if (!hash->buckets)
{
- hash->buckets = old;
- hash->size++;
- return FALSE;
+ hash->buckets = old;
+ hash->size++;
+ return FALSE;
}
hash->nodes = 0;
if (_ecore_hash_rehash(hash, old, hash->size + 1))
{
- FREE(old);
- return TRUE;
+ FREE(old);
+ return TRUE;
}
return FALSE;
unsigned int i;
Ecore_Hash_Node *old;
- CHECK_PARAM_POINTER_RETURN("hash", hash, FALSE);
+ CHECK_PARAM_POINTER_RETURN("hash", hash, FALSE);
CHECK_PARAM_POINTER_RETURN("old_table", old_table, FALSE);
for (i = 0; i < ecore_prime_table[old_size]; i++)
{
- /* Hash into a new list to avoid loops of rehashing the same nodes */
- while ((old = old_table[i]))
- {
- old_table[i] = old->next;
- old->next = NULL;
- _ecore_hash_node_add(hash, old);
- }
+ /* Hash into a new list to avoid loops of rehashing the same nodes */
+ while ((old = old_table[i]))
+ {
+ old_table[i] = old->next;
+ old->next = NULL;
+ _ecore_hash_node_add(hash, old);
+ }
}
return TRUE;
node = (Ecore_Hash_Node *)malloc(sizeof(Ecore_Hash_Node));
if (!node)
- return NULL;
+ return NULL;
if (!_ecore_hash_node_init(node, key, value))
{
- FREE(node);
- return NULL;
+ FREE(node);
+ return NULL;
}
return node;
static int
_ecore_hash_node_init(Ecore_Hash_Node *node, void *key, void *value)
{
- CHECK_PARAM_POINTER_RETURN("node", node, FALSE);
+ CHECK_PARAM_POINTER_RETURN("node", node, FALSE);
node->key = key;
node->value = value;
* @return Returns TRUE on success, FALSE on error
*/
static int
-_ecore_hash_node_destroy(Ecore_Hash_Node *node, Ecore_Free_Cb keyd, Ecore_Free_Cb valued)
+_ecore_hash_node_destroy(Ecore_Hash_Node *node,
+ Ecore_Free_Cb keyd,
+ Ecore_Free_Cb valued)
{
- CHECK_PARAM_POINTER_RETURN("node", node, FALSE);
+ CHECK_PARAM_POINTER_RETURN("node", node, FALSE);
if (keyd)
- keyd(node->key);
+ keyd(node->key);
if (valued)
- valued(node->value);
+ valued(node->value);
FREE(node);
const char *k1, *k2;
if (!key1 || !key2)
- return ecore_direct_compare(key1, key2);
+ return ecore_direct_compare(key1, key2);
else if (key1 == key2)
- return 0;
+ return 0;
k1 = key1;
k2 = key2;
const char *k = key;
if (!k)
- return 0;
+ return 0;
mask = (sizeof(unsigned int) * 8) - 1;
for (i = 0; k[i] != '\0'; i++)
{
- value ^= ((unsigned int) k[i] << ((i * 5) & mask));
+ value ^= ((unsigned int)k[i] << ((i * 5) & mask));
}
return value;
#define ECORE_MERGESORT_LIMIT 40000
/* Return information about the list */
-static void *_ecore_list_current(Ecore_List * list);
+static void * _ecore_list_current(Ecore_List *list);
/* Adding functions */
-static int _ecore_list_insert(Ecore_List * list, Ecore_List_Node *node);
-static int _ecore_list_append_0(Ecore_List * list, Ecore_List_Node *node);
-static int _ecore_list_prepend_0(Ecore_List * list, Ecore_List_Node *node);
+static int _ecore_list_insert(Ecore_List *list,
+ Ecore_List_Node *node);
+static int _ecore_list_append_0(Ecore_List *list,
+ Ecore_List_Node *node);
+static int _ecore_list_prepend_0(Ecore_List *list,
+ Ecore_List_Node *node);
/* Remove functions */
-static void *_ecore_list_remove_0(Ecore_List * list);
-static void *_ecore_list_first_remove(Ecore_List * list);
-static void *_ecore_list_last_remove(Ecore_List * list);
+static void * _ecore_list_remove_0(Ecore_List *list);
+static void * _ecore_list_first_remove(Ecore_List *list);
+static void * _ecore_list_last_remove(Ecore_List *list);
/* Basic traversal functions */
-static void *_ecore_list_next(Ecore_List * list);
-static void *_ecore_list_last_goto(Ecore_List * list);
-static void *_ecore_list_first_goto(Ecore_List * list);
-static void *_ecore_list_goto(Ecore_List * list, const void *data);
-static void *_ecore_list_index_goto(Ecore_List *list, int idx);
+static void * _ecore_list_next(Ecore_List *list);
+static void * _ecore_list_last_goto(Ecore_List *list);
+static void * _ecore_list_first_goto(Ecore_List *list);
+static void * _ecore_list_goto(Ecore_List *list, const void *data);
+static void * _ecore_list_index_goto(Ecore_List *list, int idx);
/* Iterative functions */
-static int _ecore_list_for_each(Ecore_List *list, Ecore_For_Each function,
- void *user_data);
-static void *_ecore_list_find(Ecore_List *list, Ecore_Compare_Cb function,
- const void *user_data);
+static int _ecore_list_for_each(Ecore_List *list,
+ Ecore_For_Each function,
+ void *user_data);
+static void * _ecore_list_find(Ecore_List *list,
+ Ecore_Compare_Cb function,
+ const void *user_data);
/* Sorting functions */
static Ecore_List_Node *_ecore_list_node_mergesort(Ecore_List_Node *first,
- int n, Ecore_Compare_Cb compare, int order);
+ int n,
+ Ecore_Compare_Cb compare,
+ int order);
static Ecore_List_Node *_ecore_list_node_merge(Ecore_List_Node *first,
Ecore_List_Node *second,
Ecore_Compare_Cb compare,
int order);
static Ecore_List_Node *_ecore_dlist_node_mergesort(Ecore_List_Node *first,
- int n, Ecore_Compare_Cb compare, int order);
+ int n,
+ Ecore_Compare_Cb compare,
+ int order);
static Ecore_List_Node *_ecore_dlist_node_merge(Ecore_List_Node *first,
- Ecore_List_Node *second,
- Ecore_Compare_Cb compare,
- int order);
+ Ecore_List_Node *second,
+ Ecore_Compare_Cb compare,
+ int order);
/* Private double linked list functions */
-static void *_ecore_dlist_previous(Ecore_DList * list);
+static void *_ecore_dlist_previous(Ecore_DList *list);
static void *_ecore_dlist_first_remove(Ecore_DList *list);
static void *_ecore_dlist_index_goto(Ecore_DList *list, int idx);
/**
-@defgroup Ecore_Data_List_Creation_Group List Creation/Destruction Functions
+ @defgroup Ecore_Data_List_Creation_Group List Creation/Destruction Functions
-Functions that create, initialize and destroy Ecore_Lists.
-*/
+ Functions that create, initialize and destroy Ecore_Lists.
+ */
/**
* Create and initialize a new list.
list = (Ecore_List *)malloc(sizeof(Ecore_List));
if (!list)
- return NULL;
+ return NULL;
if (!ecore_list_init(list))
{
- FREE(list);
- return NULL;
+ FREE(list);
+ return NULL;
}
return list;
while (list->first)
{
- data = _ecore_list_first_remove(list);
- if (list->free_func)
- list->free_func(data);
+ data = _ecore_list_first_remove(list);
+ if (list->free_func)
+ list->free_func(data);
}
FREE(list);
CHECK_PARAM_POINTER_RETURN("list", list, TRUE);
if (list->nodes)
- ret = FALSE;
+ ret = FALSE;
return ret;
}
}
/**
-@defgroup Ecore_Data_List_Add_Item_Group List Item Adding Functions
+ @defgroup Ecore_Data_List_Add_Item_Group List Item Adding Functions
-Functions that are used to add nodes to an Ecore_List.
-*/
+ Functions that are used to add nodes to an Ecore_List.
+ */
/**
* Append data to the list.
_ecore_list_append_0(Ecore_List *list, Ecore_List_Node *end)
{
if (list->last)
- list->last->next = end;
+ list->last->next = end;
list->last = end;
if (list->first == NULL)
{
- list->first = end;
- list->index = 0;
- list->current = NULL;
+ list->first = end;
+ list->index = 0;
+ list->current = NULL;
}
if (list->index >= list->nodes)
- list->index++;
+ list->index++;
list->nodes++;
/* If no last node, then the first node is the last node */
if (list->last == NULL)
- list->last = list->first;
+ list->last = list->first;
list->nodes++;
list->index++;
* same as prepending it to the list.
*/
if (list->current == list->first)
- return _ecore_list_prepend_0(list, new_node);
+ return _ecore_list_prepend_0(list, new_node);
if (list->current == NULL)
{
- int ret_value;
+ int ret_value;
- ret_value = _ecore_list_append_0(list, new_node);
- list->current = list->last;
+ ret_value = _ecore_list_append_0(list, new_node);
+ list->current = list->last;
- return ret_value;
+ return ret_value;
}
/* Setup the fields of the new node */
EAPI int
ecore_list_append_list(Ecore_List *list, Ecore_List *append)
{
- CHECK_PARAM_POINTER_RETURN("list", list, FALSE);
+ CHECK_PARAM_POINTER_RETURN("list", list, FALSE);
CHECK_PARAM_POINTER_RETURN("append", append, FALSE);
- if (ecore_list_empty_is(append)) return TRUE;
+ if (ecore_list_empty_is(append))
+ return TRUE;
if (ecore_list_empty_is(list))
{
- list->first = append->first;
- list->current = list->first;
- list->last = append->last;
- list->nodes = append->nodes;
+ list->first = append->first;
+ list->current = list->first;
+ list->last = append->last;
+ list->nodes = append->nodes;
}
else
{
- list->last->next = append->first;
- list->last = append->last;
- list->nodes += append->nodes;
+ list->last->next = append->first;
+ list->last = append->last;
+ list->nodes += append->nodes;
}
+
ecore_list_init(append);
return TRUE;
}
EAPI int
ecore_list_prepend_list(Ecore_List *list, Ecore_List *prepend)
{
- CHECK_PARAM_POINTER_RETURN("list", list, FALSE);
+ CHECK_PARAM_POINTER_RETURN("list", list, FALSE);
CHECK_PARAM_POINTER_RETURN("prepend", prepend, FALSE);
- if (ecore_list_empty_is(prepend)) return TRUE;
+ if (ecore_list_empty_is(prepend))
+ return TRUE;
if (ecore_list_empty_is(list))
{
- list->first = prepend->first;
- list->current = NULL;
- list->last = prepend->last;
- list->nodes = prepend->nodes;
+ list->first = prepend->first;
+ list->current = NULL;
+ list->last = prepend->last;
+ list->nodes = prepend->nodes;
}
else
{
- prepend->last->next = list->first;
- list->first = prepend->first;
- list->nodes += prepend->nodes;
- list->index += prepend->nodes;
+ prepend->last->next = list->first;
+ list->first = prepend->first;
+ list->nodes += prepend->nodes;
+ list->index += prepend->nodes;
}
+
ecore_list_init(prepend);
return TRUE;
}
/**
-@defgroup Ecore_Data_List_Remove_Item_Group List Item Removing Functions
+ @defgroup Ecore_Data_List_Remove_Item_Group List Item Removing Functions
-Functions that remove nodes from an Ecore_List.
-*/
+ Functions that remove nodes from an Ecore_List.
+ */
/**
* Remove the current item from the list.
Ecore_List_Node *old;
if (!list)
- return NULL;
+ return NULL;
if (ecore_list_empty_is(list))
- return NULL;
+ return NULL;
if (!list->current)
- return NULL;
+ return NULL;
if (list->current == list->first)
- return _ecore_list_first_remove(list);
+ return _ecore_list_first_remove(list);
if (list->current == list->last)
- return _ecore_list_last_remove(list);
+ return _ecore_list_last_remove(list);
old = list->current;
data = _ecore_list_remove_0(list);
if (list->free_func)
- list->free_func(data);
+ list->free_func(data);
return TRUE;
}
Ecore_List_Node *old;
if (!list)
- return NULL;
+ return NULL;
if (ecore_list_empty_is(list))
- return NULL;
+ return NULL;
old = list->first;
list->first = list->first->next;
if (list->current == old)
- list->current = list->first;
+ list->current = list->first;
else
- (list->index ? list->index-- : 0);
+ (list->index ? list->index-- : 0);
if (list->last == old)
- list->last = list->first;
+ list->last = list->first;
ret = old->data;
old->data = NULL;
Ecore_List_Node *old, *prev;
if (!list)
- return NULL;
+ return NULL;
if (ecore_list_empty_is(list))
- return NULL;
+ return NULL;
old = list->last;
if (list->current == old)
- list->current = NULL;
+ list->current = NULL;
if (list->first == old)
- list->first = NULL;
- for (prev = list->first; prev && prev->next != old; prev = prev->next);
+ list->first = NULL;
+
+ for (prev = list->first; prev && prev->next != old; prev = prev->next) ;
list->last = prev;
if (prev)
- prev->next = NULL;
+ prev->next = NULL;
old->next = NULL;
ret = old->data;
}
/**
-@defgroup Ecore_Data_List_Traverse_Group List Traversal Functions
+ @defgroup Ecore_Data_List_Traverse_Group List Traversal Functions
-Functions that can be used to traverse an Ecore_List.
-*/
+ Functions that can be used to traverse an Ecore_List.
+ */
/**
* Make the current item the item with the given index number.
int i;
if (!list)
- return NULL;
+ return NULL;
if (ecore_list_empty_is(list))
- return NULL;
+ return NULL;
if (idx > ecore_list_count(list) || idx < 0)
- return NULL;
+ return NULL;
if (idx < list->index)
{
- _ecore_list_first_goto(list);
- i = 0;
+ _ecore_list_first_goto(list);
+ i = 0;
}
else
- i = list->index;
+ i = list->index;
- for (; i < idx && _ecore_list_next(list); i++);
+ for (; i < idx && _ecore_list_next(list); i++) ;
if (i >= list->nodes)
- return NULL;
+ return NULL;
list->index = i;
{
void *ret;
- CHECK_PARAM_POINTER_RETURN("list", list, NULL);
+ CHECK_PARAM_POINTER_RETURN("list", list, NULL);
ret = _ecore_list_goto(list, data);
Ecore_List_Node *node;
if (!list)
- return NULL;
+ return NULL;
idx = 0;
node = list->first;
while (node && node->data)
{
- Ecore_List_Node *next;
+ Ecore_List_Node *next;
- if (node->data == data)
- break;
+ if (node->data == data)
+ break;
- next = node->next;
+ next = node->next;
- node = next;
+ node = next;
- idx++;
+ idx++;
}
if (!node)
- return NULL;
+ return NULL;
list->current = node;
list->index = idx;
{
void *ret;
- CHECK_PARAM_POINTER_RETURN("list", list, NULL);
+ CHECK_PARAM_POINTER_RETURN("list", list, NULL);
ret = _ecore_list_first_goto(list);
_ecore_list_first_goto(Ecore_List *list)
{
if (!list || !list->first)
- return NULL;
+ return NULL;
list->current = list->first;
list->index = 0;
{
void *ret;
- CHECK_PARAM_POINTER_RETURN("list", list, NULL);
+ CHECK_PARAM_POINTER_RETURN("list", list, NULL);
ret = _ecore_list_last_goto(list);
_ecore_list_last_goto(Ecore_List *list)
{
if (!list || !list->last)
- return NULL;
+ return NULL;
list->current = list->last;
list->index = (list->nodes - 1);
void *ret;
if (!list->first)
- return NULL;
+ return NULL;
+
ret = list->first->data;
return ret;
void *ret;
if (!list->last)
- return NULL;
+ return NULL;
+
ret = list->last->data;
return ret;
void *ret;
if (!list->current)
- return NULL;
+ return NULL;
ret = list->current->data;
{
void *data;
- CHECK_PARAM_POINTER_RETURN("list", list, NULL);
+ CHECK_PARAM_POINTER_RETURN("list", list, NULL);
data = _ecore_list_next(list);
Ecore_List_Node *next;
if (!list->current)
- return NULL;
+ return NULL;
ret = list->current;
next = list->current->next;
EAPI int
ecore_list_clear(Ecore_List *list)
{
- CHECK_PARAM_POINTER_RETURN("list", list, FALSE);
+ CHECK_PARAM_POINTER_RETURN("list", list, FALSE);
while (!ecore_list_empty_is(list))
- _ecore_list_first_remove(list);
+ _ecore_list_first_remove(list);
return TRUE;
}
void *value;
if (!list || !function)
- return FALSE;
+ return FALSE;
_ecore_list_first_goto(list);
while ((value = _ecore_list_next(list)) != NULL)
- function(value, user_data);
+ function(value, user_data);
return TRUE;
}
* @return the first matching data node, or NULL if none match
*/
EAPI void *
-ecore_list_find(Ecore_List *list, Ecore_Compare_Cb function, const void *user_data)
+ecore_list_find(Ecore_List *list,
+ Ecore_Compare_Cb function,
+ const void *user_data)
{
- CHECK_PARAM_POINTER_RETURN("list", list, NULL);
+ CHECK_PARAM_POINTER_RETURN("list", list, NULL);
- return _ecore_list_find(list, function, user_data);
+ return _ecore_list_find(list, function, user_data);
}
/* The real meat of finding a node via a compare cb */
static void *
-_ecore_list_find(Ecore_List *list, Ecore_Compare_Cb function, const void *user_data)
+_ecore_list_find(Ecore_List *list,
+ Ecore_Compare_Cb function,
+ const void *user_data)
{
- void *value;
- if (!list || !function) return NULL;
+ void *value;
+ if (!list || !function)
+ return NULL;
+
+ _ecore_list_first_goto(list);
+ while ((value = _ecore_list_current(list)) != NULL)
+ {
+ if (!function(value, user_data))
+ return value;
- _ecore_list_first_goto(list);
- while ((value = _ecore_list_current(list)) != NULL)
- {
- if (!function(value, user_data)) return value;
- ecore_list_next(list);
- }
+ ecore_list_next(list);
+ }
- return NULL;
+ return NULL;
}
/**
CHECK_PARAM_POINTER_RETURN("list", list, 0);
if (list->nodes < 2)
- return 1;
+ return 1;
+
if (list->nodes < ECORE_MERGESORT_LIMIT)
- return ecore_list_mergesort(list, compare, order);
+ return ecore_list_mergesort(list, compare, order);
+
if (!ecore_list_heapsort(list, compare, order))
- return ecore_list_mergesort(list, compare, order);
+ return ecore_list_mergesort(list, compare, order);
return 1;
}
CHECK_PARAM_POINTER_RETURN("list", list, 0);
if (list->nodes < 2)
- return 1;
+ return 1;
if (order == ECORE_SORT_MIN)
- order = 1;
+ order = 1;
else
- order = -1;
+ order = -1;
node = _ecore_list_node_mergesort(list->first, list->nodes, compare, order);
list->first = node;
/* maybe there is a better way to do that but our last node has changed */
while (node->next)
- node = node->next;
+ node = node->next;
list->last = node;
_ecore_list_first_goto(list);
* ECORE_SORT_MAX
*/
EAPI void
-ecore_list_merge(Ecore_List *list, Ecore_List *l2, Ecore_Compare_Cb compare, char order)
+ecore_list_merge(Ecore_List *list,
+ Ecore_List *l2,
+ Ecore_Compare_Cb compare,
+ char order)
{
CHECK_PARAM_POINTER("list", list);
- CHECK_PARAM_POINTER("l2", l2);
+ CHECK_PARAM_POINTER("l2", l2);
- if (ecore_list_empty_is(l2)) return;
+ if (ecore_list_empty_is(l2))
+ return;
if (ecore_list_empty_is(list))
{
- ecore_list_append_list(list, l2);
- return;
+ ecore_list_append_list(list, l2);
+ return;
}
if (order == ECORE_SORT_MIN)
- order = 1;
+ order = 1;
else
- order = -1;
+ order = -1;
list->first = _ecore_list_node_merge(list->first, l2->first, compare, order);
if ((order * compare(list->last->data, l2->last->data)) < 0)
- list->last = l2->last;
+ list->last = l2->last;
list->nodes += l2->nodes;
ecore_list_init(l2);
mid = n / 2;
if (n < 2)
- return first;
+ return first;
else if (n == 2)
{
- if (compare(first->data, first->next->data) * order > 0)
+ if (compare(first->data, first->next->data) * order > 0)
{
- /* swap the data */
- void *data;
- data = first->next->data;
- first->next->data = first->data;
- first->data = data;
- }
- return first;
- }
+ /* swap the data */
+ void *data;
+ data = first->next->data;
+ first->next->data = first->data;
+ first->data = data;
+ }
+
+ return first;
+ }
/* first find the premiddle node*/
for (premid = first, i = 0; i < mid - 1; i++)
- premid = premid->next;
+ premid = premid->next;
/* split the list */
middle = premid->next;
* a pointer to it */
if (compare(first->data, second->data) * order > 0)
{
- list = l = second;
- second = second->next;
+ list = l = second;
+ second = second->next;
}
else
{
- list = l = first;
- first = first->next;
+ list = l = first;
+ first = first->next;
}
/* and now start the merging */
while (first && second)
{
- if (compare(first->data, second->data) * order > 0)
- {
- l = l->next = second;
- second = second->next;
- }
- else
- {
- l = l->next = first;
- first = first->next;
- }
+ if (compare(first->data, second->data) * order > 0)
+ {
+ l = l->next = second;
+ second = second->next;
+ }
+ else
+ {
+ l = l->next = first;
+ first = first->next;
+ }
}
/* append the rest or set it to NULL */
if (first)
- l->next = first;
+ l->next = first;
else if (second)
- l->next = second;
+ l->next = second;
else
- l->next = NULL;
+ l->next = NULL;
return list;
}
*/
heap = ecore_sheap_new(compare, list->nodes);
if (!heap)
- return 0;
+ return 0;
ecore_sheap_order_set(heap, order);
_ecore_list_first_goto(list);
while ((data = _ecore_list_next(list)))
{
- ecore_sheap_insert(heap, data);
+ ecore_sheap_insert(heap, data);
}
/*
node = list->first;
while (node)
{
- node->data = ecore_sheap_extract(heap);
- node = node->next;
+ node->data = ecore_sheap_extract(heap);
+ node = node->next;
}
ecore_sheap_destroy(heap);
}
/**
-@defgroup Ecore_Data_List_Node_Group List Node Functions
+ @defgroup Ecore_Data_List_Node_Group List Node Functions
-Functions that are used in the creation, maintenance and destruction of
-Ecore_List nodes.
-*/
+ Functions that are used in the creation, maintenance and destruction of
+ Ecore_List nodes.
+ */
/**
* Allocates and initializes a new list node.
if (!ecore_list_node_init(new_node))
{
- FREE(new_node);
- return NULL;
+ FREE(new_node);
+ return NULL;
}
return new_node;
CHECK_PARAM_POINTER_RETURN("node", node, FALSE);
if (free_func && node->data)
- free_func(node->data);
+ free_func(node->data);
FREE(node);
list = (Ecore_DList *)malloc(sizeof(Ecore_DList));
if (!list)
- return NULL;
+ return NULL;
if (!ecore_dlist_init(list))
{
- IF_FREE(list);
- return NULL;
+ IF_FREE(list);
+ return NULL;
}
return list;
while (list->first)
{
- data = _ecore_dlist_first_remove(list);
- if (list->free_func)
- list->free_func(data);
+ data = _ecore_dlist_first_remove(list);
+ if (list->free_func)
+ list->free_func(data);
}
FREE(list);
prev = ECORE_DLIST_NODE(ECORE_LIST(list)->last);
ret = _ecore_list_append_0(ECORE_LIST(list), ECORE_LIST_NODE(node));
if (ret)
- node->previous = prev;
+ node->previous = prev;
return ret;
}
prev = ECORE_DLIST_NODE(ECORE_LIST(list)->first);
ret = _ecore_list_prepend_0(ECORE_LIST(list), ECORE_LIST_NODE(node));
if (ret && prev)
- prev->previous = node;
+ prev->previous = node;
return ret;
}
* Identify and shortcut the end cases.
*/
if (!ECORE_LIST(list)->current)
- return ecore_dlist_append(list, data);
+ return ecore_dlist_append(list, data);
+
if (ECORE_LIST(list)->current == ECORE_LIST(list)->first)
- return ecore_dlist_prepend(list, data);
+ return ecore_dlist_prepend(list, data);
node = ecore_dlist_node_new();
ECORE_LIST_NODE(node)->data = data;
EAPI int
ecore_dlist_append_list(Ecore_DList *list, Ecore_DList *append)
{
- CHECK_PARAM_POINTER_RETURN("list", list, FALSE);
+ CHECK_PARAM_POINTER_RETURN("list", list, FALSE);
CHECK_PARAM_POINTER_RETURN("append", append, FALSE);
- if (ecore_dlist_empty_is(append)) return TRUE;
+ if (ecore_dlist_empty_is(append))
+ return TRUE;
if (ecore_dlist_empty_is(list))
{
- list->first = append->first;
- list->current = NULL;
- list->last = append->last;
- list->nodes = append->nodes;
+ list->first = append->first;
+ list->current = NULL;
+ list->last = append->last;
+ list->nodes = append->nodes;
}
else
{
- list->last->next = append->first;
- ECORE_DLIST_NODE(append->first)->previous = ECORE_DLIST_NODE(list->last);
- list->last = append->last;
- list->nodes += append->nodes;
+ list->last->next = append->first;
+ ECORE_DLIST_NODE(append->first)->previous = ECORE_DLIST_NODE(list->last);
+ list->last = append->last;
+ list->nodes += append->nodes;
}
+
ecore_dlist_init(append);
return TRUE;
}
EAPI int
ecore_dlist_prepend_list(Ecore_DList *list, Ecore_DList *prepend)
{
- CHECK_PARAM_POINTER_RETURN("list", list, FALSE);
+ CHECK_PARAM_POINTER_RETURN("list", list, FALSE);
CHECK_PARAM_POINTER_RETURN("prepend", prepend, FALSE);
- if (ecore_dlist_empty_is(prepend)) return TRUE;
+ if (ecore_dlist_empty_is(prepend))
+ return TRUE;
if (ecore_dlist_empty_is(list))
{
- list->first = prepend->first;
- list->current = NULL;
- list->last = prepend->last;
- list->nodes = prepend->nodes;
+ list->first = prepend->first;
+ list->current = NULL;
+ list->last = prepend->last;
+ list->nodes = prepend->nodes;
}
else
{
- prepend->last->next = list->first;
- ECORE_DLIST_NODE(list->first)->previous = ECORE_DLIST_NODE(prepend->last);
- list->first = prepend->first;
- list->nodes += prepend->nodes;
- list->index += prepend->nodes;
+ prepend->last->next = list->first;
+ ECORE_DLIST_NODE(list->first)->previous = ECORE_DLIST_NODE(
+ prepend->last);
+ list->first = prepend->first;
+ list->nodes += prepend->nodes;
+ list->index += prepend->nodes;
}
+
ecore_dlist_init(prepend);
return TRUE;
}
if (l2->current)
{
- node = ECORE_DLIST_NODE(list->current->next);
- if (node)
- node->previous = ECORE_DLIST_NODE(l2->current)->previous;
+ node = ECORE_DLIST_NODE(list->current->next);
+ if (node)
+ node->previous = ECORE_DLIST_NODE(l2->current)->previous;
}
+
ret = _ecore_list_remove_0(list);
return ret;
data = ecore_dlist_remove(list);
if (!data)
- return FALSE;
+ return FALSE;
if (list->free_func)
- list->free_func(data);
+ list->free_func(data);
return TRUE;
}
void *ret;
if (!list)
- return NULL;
+ return NULL;
ret = _ecore_list_first_remove(list);
if (ret && ECORE_LIST(list)->first)
- ECORE_DLIST_NODE(ECORE_LIST(list)->first)->previous = NULL;
+ ECORE_DLIST_NODE(ECORE_LIST(list)->first)->previous = NULL;
return ret;
}
CHECK_PARAM_POINTER_RETURN("list", list, NULL);
if (ecore_list_empty_is(list))
- return NULL;
+ return NULL;
node = list->last;
list->last = ECORE_LIST_NODE(ECORE_DLIST_NODE(node)->previous);
if (list->last)
- list->last->next = NULL;
+ list->last->next = NULL;
+
if (list->first == node)
- list->first = NULL;
+ list->first = NULL;
+
if (list->current == node)
- list->current = NULL;
+ list->current = NULL;
ret = node->data;
ecore_list_node_destroy(node, NULL);
list->nodes--;
if (list->index >= list->nodes)
- list->index--;
+ list->index--;
return ret;
}
int i, increment;
if (!list)
- return NULL;
+ return NULL;
if (ecore_list_empty_is(ECORE_LIST(list)))
- return NULL;
+ return NULL;
if (idx > ecore_list_count(ECORE_LIST(list)) || idx < 0)
- return NULL;
+ return NULL;
if (ECORE_LIST(list)->index >= ECORE_LIST(list)->nodes)
- _ecore_list_last_goto(ECORE_LIST(list));
+ _ecore_list_last_goto(ECORE_LIST(list));
if (idx < ECORE_LIST(list)->index)
- increment = -1;
+ increment = -1;
else
- increment = 1;
+ increment = 1;
for (i = ECORE_LIST(list)->index; i != idx; i += increment)
{
- if (increment > 0)
- _ecore_list_next(list);
- else
- _ecore_dlist_previous(list);
+ if (increment > 0)
+ _ecore_list_next(list);
+ else
+ _ecore_dlist_previous(list);
}
return _ecore_list_current(list);
void *data = NULL;
if (!list)
- return NULL;
+ return NULL;
if (ECORE_LIST(list)->current)
{
- data = ECORE_LIST(list)->current->data;
- ECORE_LIST(list)->current = ECORE_LIST_NODE(ECORE_DLIST_NODE(
- ECORE_LIST(list)->current)->previous);
- ECORE_LIST(list)->index--;
+ data = ECORE_LIST(list)->current->data;
+ ECORE_LIST(list)->
+ current = ECORE_LIST_NODE(ECORE_DLIST_NODE(
+ ECORE_LIST(list)->
+ current)->previous);
+ ECORE_LIST(list)->index
+ --;
}
else
- _ecore_list_last_goto(ECORE_LIST(list));
+ _ecore_list_last_goto(
+ ECORE_LIST(list));
return data;
}
CHECK_PARAM_POINTER_RETURN("list", list, 0);
if (list->nodes < 2)
- return 1;
+ return 1;
+
if (list->nodes < ECORE_MERGESORT_LIMIT)
- return ecore_dlist_mergesort(list, compare, order);
+ return ecore_dlist_mergesort(list, compare, order);
+
if (!ecore_dlist_heapsort(list, compare, order))
- return ecore_dlist_mergesort(list, compare, order);
+ return ecore_dlist_mergesort(list, compare, order);
return 1;
}
CHECK_PARAM_POINTER_RETURN("list", list, 0);
if (list->nodes < 2)
- return 1;
+ return 1;
if (order == ECORE_SORT_MIN)
- order = 1;
+ order = 1;
else
- order = -1;
+ order = -1;
node = _ecore_dlist_node_mergesort(list->first, list->nodes, compare, order);
list->first = node;
/* maybe there is a better way to do that but our last node has changed */
while (node->next)
- node = node->next;
+ node = node->next;
list->last = node;
_ecore_list_first_goto(list);
* ECORE_SORT_MAX
*/
EAPI void
-ecore_dlist_merge(Ecore_DList *list, Ecore_DList *l2, Ecore_Compare_Cb compare, char order)
+ecore_dlist_merge(Ecore_DList *list,
+ Ecore_DList *l2,
+ Ecore_Compare_Cb compare,
+ char order)
{
CHECK_PARAM_POINTER("list", list);
- CHECK_PARAM_POINTER("l2", l2);
+ CHECK_PARAM_POINTER("l2", l2);
- if (ecore_dlist_empty_is(l2)) return;
+ if (ecore_dlist_empty_is(l2))
+ return;
if (ecore_dlist_empty_is(list))
{
- ecore_dlist_append_list(list, l2);
- return;
+ ecore_dlist_append_list(list, l2);
+ return;
}
if (order == ECORE_SORT_MIN)
- order = 1;
+ order = 1;
else
- order = -1;
+ order = -1;
list->first = _ecore_dlist_node_merge(list->first, l2->first, compare, order);
if ((order * compare(list->last->data, l2->last->data)) < 0)
- list->last = l2->last;
+ list->last = l2->last;
list->nodes += l2->nodes;
ecore_dlist_init(l2);
/* this is the internal recrusive function for the merge sort */
static Ecore_List_Node *
_ecore_dlist_node_mergesort(Ecore_List_Node *first, int n,
- Ecore_Compare_Cb compare, int order)
+ Ecore_Compare_Cb compare, int order)
{
Ecore_List_Node *middle;
Ecore_List_Node *premid;
int mid;
int i;
- mid = n/2;
+ mid = n / 2;
if (n < 2)
- return first;
+ return first;
else if (n == 2)
{
- if (compare(first->data, first->next->data) * order > 0)
+ if (compare(first->data, first->next->data) * order > 0)
{
- /* swap the data */
- void *data;
- data = first->next->data;
- first->next->data = first->data;
- first->data = data;
- }
- return first;
- }
+ /* swap the data */
+ void *data;
+ data = first->next->data;
+ first->next->data = first->data;
+ first->data = data;
+ }
+
+ return first;
+ }
/* first find the premiddle node*/
for (premid = first, i = 0; i < mid - 1; i++)
- premid = premid->next;
+ premid = premid->next;
/* split the list */
middle = premid->next;
premid->next = NULL;
- ECORE_DLIST_NODE(middle)->previous = NULL;
+ ECORE_DLIST_NODE(middle)->previous = NULL;
/* sort the the partial lists */
first = _ecore_dlist_node_mergesort(first, mid, compare, order);
/* this function is used to merge the partial sorted lists */
static Ecore_List_Node *
_ecore_dlist_node_merge(Ecore_List_Node *first, Ecore_List_Node *second,
- Ecore_Compare_Cb compare, int order)
+ Ecore_Compare_Cb compare, int order)
{
Ecore_List_Node *list;
Ecore_List_Node *l;
* a pointer to it */
if (compare(first->data, second->data) * order > 0)
{
- list = l = second;
- second = second->next;
+ list = l = second;
+ second = second->next;
}
else
{
- list = l = first;
- first = first->next;
+ list = l = first;
+ first = first->next;
}
/* and now start the merging */
while (first && second)
{
- if (compare(first->data, second->data) * order > 0)
- {
- ECORE_DLIST_NODE(second)->previous = ECORE_DLIST_NODE(l);
- l = l->next = second;
- second = second->next;
- }
- else
- {
- ECORE_DLIST_NODE(first)->previous = ECORE_DLIST_NODE(l);
- l = l->next = first;
- first = first->next;
- }
+ if (compare(first->data, second->data) * order > 0)
+ {
+ ECORE_DLIST_NODE(second)->previous = ECORE_DLIST_NODE(l);
+ l = l->next = second;
+ second = second->next;
+ }
+ else
+ {
+ ECORE_DLIST_NODE(first)->previous = ECORE_DLIST_NODE(l);
+ l = l->next = first;
+ first = first->next;
+ }
}
/* append the rest or set it to NULL */
if (first)
{
- ECORE_DLIST_NODE(first)->previous = ECORE_DLIST_NODE(l);
+ ECORE_DLIST_NODE(first)->previous = ECORE_DLIST_NODE(l);
l->next = first;
}
else if (second)
{
- ECORE_DLIST_NODE(second)->previous = ECORE_DLIST_NODE(l);
- l->next = second;
+ ECORE_DLIST_NODE(second)->previous = ECORE_DLIST_NODE(l);
+ l->next = second;
}
else
- l->next = NULL;
+ l->next = NULL;
return list;
}
ret = ecore_list_node_init(ECORE_LIST_NODE(node));
if (ret)
- node->previous = NULL;
+ node->previous = NULL;
return ret;
}
new_node = malloc(sizeof(Ecore_DList_Node));
if (!new_node)
- return NULL;
+ return NULL;
if (!ecore_dlist_node_init(new_node))
{
- FREE(new_node);
- return NULL;
+ FREE(new_node);
+ return NULL;
}
return new_node;
* @return Returns TRUE on success, FALSE on error
*/
EAPI int
-ecore_dlist_node_destroy(Ecore_DList_Node * node, Ecore_Free_Cb free_func)
+ecore_dlist_node_destroy(Ecore_DList_Node *node, Ecore_Free_Cb free_func)
{
CHECK_PARAM_POINTER_RETURN("node", node, FALSE);
heap = (Ecore_Sheap *)malloc(sizeof(Ecore_Sheap));
if (!heap)
- return NULL;
+ return NULL;
+
memset(heap, 0, sizeof(Ecore_Sheap));
if (!ecore_sheap_init(heap, compare, size))
{
- FREE(heap);
- return NULL;
+ FREE(heap);
+ return NULL;
}
return heap;
heap->space = size;
if (!compare)
- heap->compare = ecore_direct_compare;
+ heap->compare = ecore_direct_compare;
else
- heap->compare = compare;
+ heap->compare = compare;
+
heap->order = ECORE_SORT_MIN;
heap->data = (void **)malloc(heap->space * sizeof(void *));
if (!heap->data)
- return FALSE;
+ return FALSE;
+
memset(heap->data, 0, heap->space * sizeof(void *));
return TRUE;
* Free data in heap
*/
if (heap->free_func)
- for (i = 0; i < heap->size; i++)
- heap->free_func(heap->data[i]);
+ for (i = 0; i < heap->size; i++)
+ heap->free_func(heap->data[i]);
FREE(heap->data);
* space available to add this data
*/
if (heap->size >= heap->space)
- return FALSE;
+ return FALSE;
heap->sorted = FALSE;
* number of branching decisions that must be predicted.
*/
if (heap->order == ECORE_SORT_MIN)
- {
- while ((position > 0) && heap->compare(heap->data[parent],
- heap->data[position]) > 0)
- {
-
- /*
- * Swap the data with it's parents to move it up in
- * the heap.
- */
- temp = heap->data[position];
- heap->data[position] = heap->data[parent];
- heap->data[parent] = temp;
-
- /*
- * Now determine the new position for the next
- * iteration of the loop, as well as it's parents
- * position.
- */
- i = PARENT(i);
- position = i - 1;
- parent = PARENT(i) - 1;
- }
- }
+ while ((position > 0) && heap->compare(heap->data[parent],
+ heap->data[position]) > 0)
+ {
+
+ /*
+ * Swap the data with it's parents to move it up in
+ * the heap.
+ */
+ temp = heap->data[position];
+ heap->data[position] = heap->data[parent];
+ heap->data[parent] = temp;
+
+ /*
+ * Now determine the new position for the next
+ * iteration of the loop, as well as it's parents
+ * position.
+ */
+ i = PARENT(i);
+ position = i - 1;
+ parent = PARENT(i) - 1;
+ }
else
- {
- while ((position > 0) && heap->compare(heap->data[parent],
- heap->data[position]) < 0)
- {
-
- /*
- * Swap the data with it's parents to move it up in
- * the heap.
- */
- temp = heap->data[position];
- heap->data[position] = heap->data[PARENT(i) - 1];
- heap->data[PARENT(i) - 1] = temp;
-
- /*
- * Now determine the new position for the next
- * iteration of the loop, as well as it's parents
- * position.
- */
- i = PARENT(i);
- position = i - 1;
- parent = PARENT(i) - 1;
- }
- }
+ while ((position > 0) && heap->compare(heap->data[parent],
+ heap->data[position]) < 0)
+ {
+
+ /*
+ * Swap the data with it's parents to move it up in
+ * the heap.
+ */
+ temp = heap->data[position];
+ heap->data[position] = heap->data[PARENT(i) - 1];
+ heap->data[PARENT(i) - 1] = temp;
+
+ /*
+ * Now determine the new position for the next
+ * iteration of the loop, as well as it's parents
+ * position.
+ */
+ i = PARENT(i);
+ position = i - 1;
+ parent = PARENT(i) - 1;
+ }
return TRUE;
}
void *extreme;
if (heap->size < 1)
- return NULL;
+ return NULL;
heap->sorted = FALSE;
ecore_sheap_extreme(Ecore_Sheap *heap)
{
if (heap->size < 1)
- return NULL;
+ return NULL;
return heap->data[0];
}
CHECK_PARAM_POINTER_RETURN("heap", heap, FALSE);
- for (i = 0; i < heap->size && heap->compare(heap->data[i], item); i++);
+ for (i = 0; i < heap->size && heap->compare(heap->data[i], item); i++) ;
if (i < heap->size)
- heap->data[i] = newval;
+ heap->data[i] = newval;
else
- return FALSE;
+ return FALSE;
/*
* FIXME: This is not the correct procedure when a change occurs.
CHECK_PARAM_POINTER_RETURN("heap", heap, FALSE);
if (!compare)
- heap->compare = ecore_direct_compare;
+ heap->compare = ecore_direct_compare;
else
- heap->compare = compare;
+ heap->compare = compare;
_ecore_sheap_update_data(heap);
* Extract the heap and insert into the new data array in order.
*/
while (heap->size > 0)
- new_data[i++] = ecore_sheap_extract(heap);
+ new_data[i++] = ecore_sheap_extract(heap);
/*
* Free the old data array and update the heap with the new data, also
ecore_sheap_item(Ecore_Sheap *heap, int i)
{
if (i >= heap->size)
- return NULL;
+ return NULL;
/*
* Make sure the data is sorted so we return the correct value.
*/
if (!heap->sorted)
- ecore_sheap_sort(heap);
+ ecore_sheap_sort(heap);
return heap->data[i];
}
if (heap->order == ECORE_SORT_MIN)
{
- if (left <= heap->size && heap->compare(heap->data[left - 1],
- heap->data[i - 1]) < 0)
- extreme = left;
- else
- extreme = i;
-
- if (right <= heap->size && heap->compare(heap->data[right - 1],
- heap->data[extreme - 1]) < 0)
- extreme = right;
+ if (left <= heap->size && heap->compare(heap->data[left - 1],
+ heap->data[i - 1]) < 0)
+ extreme = left;
+ else
+ extreme = i;
+
+ if (right <= heap->size && heap->compare(heap->data[right - 1],
+ heap->data[extreme - 1]) < 0)
+ extreme = right;
}
else
{
- if (left <= heap->size && heap->compare(heap->data[left - 1],
- heap->data[i - 1]) > 0)
- extreme = left;
- else
- extreme = i;
-
- if (right <= heap->size && heap->compare(heap->data[right - 1],
- heap->data[extreme - 1]) > 0)
- extreme = right;
+ if (left <= heap->size && heap->compare(heap->data[left - 1],
+ heap->data[i - 1]) > 0)
+ extreme = left;
+ else
+ extreme = i;
+
+ if (right <= heap->size && heap->compare(heap->data[right - 1],
+ heap->data[extreme - 1]) > 0)
+ extreme = right;
}
/*
*/
if (extreme != i)
{
- void *temp;
+ void *temp;
- temp = heap->data[extreme - 1];
- heap->data[extreme - 1] = heap->data[i - 1];
- heap->data[i - 1] = temp;
+ temp = heap->data[extreme - 1];
+ heap->data[extreme - 1] = heap->data[i - 1];
+ heap->data[i - 1] = temp;
- _ecore_sheap_heapify(heap, extreme);
+ _ecore_sheap_heapify(heap, extreme);
}
}
heap->data = malloc(heap->space * sizeof(void *));
for (i = 0; i < old_size; i++)
- ecore_sheap_insert(heap, data[i]);
+ ecore_sheap_insert(heap, data[i]);
FREE(data);
}
{
unsigned long k1, k2;
- k1 = (unsigned long) key1;
- k2 = (unsigned long) key2;
+ k1 = (unsigned long)key1;
+ k2 = (unsigned long)key2;
if (k1 > k2)
- return 1;
+ return 1;
if (k1 < k2)
- return -1;
+ return -1;
return 0;
}
*/
if (!ecore_string_init_count)
{
- ecore_strings = ecore_hash_new(ecore_str_hash, ecore_str_compare);
- if (!ecore_strings)
- return 0;
- ecore_hash_free_value_cb_set(ecore_strings, ecore_string_free_cb);
+ ecore_strings = ecore_hash_new(ecore_str_hash, ecore_str_compare);
+ if (!ecore_strings)
+ return 0;
+
+ ecore_hash_free_value_cb_set(ecore_strings, ecore_string_free_cb);
}
+
ecore_string_init_count++;
return 1;
str = ecore_hash_get(ecore_strings, string);
if (!str)
{
- int length;
+ int length;
- /*
- * Allocate and initialize a new string reference.
- */
- length = strlen(string) + 1;
+ /*
+ * Allocate and initialize a new string reference.
+ */
+ length = strlen(string) + 1;
- str = (Ecore_String *)malloc(sizeof(Ecore_String) + length * sizeof(char));
+ str =
+ (Ecore_String *)malloc(sizeof(Ecore_String) + length * sizeof(char));
- str->string = (char*)(str + 1);
- str->references = 0;
+ str->string = (char *)(str + 1);
+ str->references = 0;
- memcpy(str->string, string, length);
+ memcpy(str->string, string, length);
- ecore_hash_set(ecore_strings, str->string, str);
+ ecore_hash_set(ecore_strings, str->string, str);
}
str->references++;
str = ecore_hash_get(ecore_strings, (char *)string);
if (!str)
- return;
+ return;
str->references--;
if (str->references < 1)
{
- ecore_hash_remove(ecore_strings, (char *)string);
- FREE(str);
+ ecore_hash_remove(ecore_strings, (char *)string);
+ FREE(str);
}
}
EAPI void
ecore_string_hash_dump_graph(void)
{
- ecore_hash_dump_graph(ecore_strings);
+ ecore_hash_dump_graph(ecore_strings);
}
EAPI void
ecore_string_hash_dump_stats(void)
{
- ecore_hash_dump_stats(ecore_strings);
+ ecore_hash_dump_stats(ecore_strings);
}
/**
--ecore_string_init_count;
if (!ecore_string_init_count)
{
- ecore_hash_destroy(ecore_strings);
- ecore_strings = NULL;
+ ecore_hash_destroy(ecore_strings);
+ ecore_strings = NULL;
}
}
};
static const Eina_Benchmark_Case etc[] = {
- /* { "Hash", eina_bench_hash }, */
- /* { "Array vs List vs Inlist", eina_bench_array }, */
- /* { "Stringshare", eina_bench_stringshare }, */
- /* { "Convert", eina_bench_convert }, */
- /* { "Sort", eina_bench_sort }, */
- /* { "Mempool", eina_bench_mempool }, */
- /* { "Rectangle_Pool", eina_bench_rectangle_pool }, */
- { "Render Loop", eina_bench_quadtree },
- { NULL, NULL }
+ /* { "Hash", eina_bench_hash }, */
+ /* { "Array vs List vs Inlist", eina_bench_array }, */
+ /* { "Stringshare", eina_bench_stringshare }, */
+ /* { "Convert", eina_bench_convert }, */
+ /* { "Sort", eina_bench_sort }, */
+ /* { "Mempool", eina_bench_mempool }, */
+ /* { "Rectangle_Pool", eina_bench_rectangle_pool }, */
+ { "Render Loop", eina_bench_quadtree },
+ { NULL, NULL }
};
/* FIXME this is a copy from eina_test_mempool
static Eina_Array *_modules;
static void _mempool_init(void)
{
- 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_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);
}
static void _mempool_shutdown(void)
Eina_Array *ea;
unsigned int i;
- if (argc != 2) return -1;
+ if (argc != 2)
+ return -1;
_mempool_init();
for (i = 0; etc[i].bench_case != NULL; ++i)
{
- test = eina_benchmark_new(etc[i].bench_case, argv[1]);
- if (!test) continue ;
+ test = eina_benchmark_new(etc[i].bench_case, argv[1]);
+ if (!test)
+ continue;
- etc[i].build(test);
+ etc[i].build(test);
- ea = eina_benchmark_run(test);
+ ea = eina_benchmark_run(test);
- eina_benchmark_free(test);
+ eina_benchmark_free(test);
}
eina_bench_e17();
{
Eina_Bench_Object *bo = data;
- if (bo->keep == EINA_TRUE) return EINA_TRUE;
+ if (bo->keep == EINA_TRUE)
+ return EINA_TRUE;
+
free(bo);
return EINA_FALSE;
}
for (i = 0; i < 1000; ++i)
{
- for (j = 0; j < (unsigned int) request; ++j)
- {
- ebo = malloc(sizeof (Eina_Bench_Object));
- if (!ebo) continue ;
+ for (j = 0; j < (unsigned int)request; ++j)
+ {
+ ebo = malloc(sizeof (Eina_Bench_Object));
+ if (!ebo)
+ continue;
- ebo->keep = rand() < (RAND_MAX / 2) ? EINA_TRUE : EINA_FALSE;
+ ebo->keep = rand() < (RAND_MAX / 2) ? EINA_TRUE : EINA_FALSE;
- eina_array_push(array, ebo);
- }
+ eina_array_push(array, ebo);
+ }
- if (i == 500)
- {
- EINA_ARRAY_ITER_NEXT(array, j, ebo, it)
- free(ebo);
+ if (i == 500)
+ {
+ EINA_ARRAY_ITER_NEXT(array, j, ebo, it)
+ free(ebo);
- eina_array_clean(array);
- }
- else if (i % 30 == 0) eina_array_remove(array, keep, NULL);
+ eina_array_clean(array);
+ }
+ else if (i % 30 == 0)
+ eina_array_remove(array, keep, NULL);
- EINA_ARRAY_ITER_NEXT(array, j, ebo, it)
- ebo->keep = rand() < (RAND_MAX / 2) ? ebo->keep : EINA_FALSE;
+ EINA_ARRAY_ITER_NEXT(array, j, ebo, it)
+ ebo->keep = rand() < (RAND_MAX / 2) ? ebo->keep : EINA_FALSE;
}
- EINA_ARRAY_ITER_NEXT(array, j, ebo, it)
- free(ebo);
+ EINA_ARRAY_ITER_NEXT(array, j, ebo, it)
+ free(ebo);
eina_array_free(array);
static Eina_Bool
eina_iterator_ebo_free(__UNUSED__ const Eina_Array *array,
- Eina_Bench_Object *ebo, __UNUSED__ void *fdata)
+ Eina_Bench_Object *ebo, __UNUSED__ void *fdata)
{
free(ebo);
return EINA_TRUE;
static Eina_Bool
eina_iterator_ebo_rand(__UNUSED__ const void *container,
- Eina_Bench_Object *ebo, __UNUSED__ void *fdata)
+ Eina_Bench_Object *ebo, __UNUSED__ void *fdata)
{
ebo->keep = rand() < (RAND_MAX / 2) ? ebo->keep : EINA_FALSE;
return EINA_TRUE;
for (i = 0; i < 1000; ++i)
{
- for (j = 0; j < (unsigned int) request; ++j)
- {
- ebo = malloc(sizeof (Eina_Bench_Object));
- if (!ebo) continue ;
-
- ebo->keep = rand() < (RAND_MAX / 2) ? EINA_TRUE : EINA_FALSE;
-
- eina_array_push(array, ebo);
- }
-
- if (i == 500)
- {
- it = eina_array_iterator_new(array);
- eina_iterator_foreach(it, EINA_EACH(eina_iterator_ebo_free), NULL);
- eina_iterator_free(it);
-
- eina_array_clean(array);
- }
- else if (i % 30 == 0) eina_array_remove(array, keep, NULL);
-
- it = eina_array_iterator_new(array);
- eina_iterator_foreach(it, EINA_EACH(eina_iterator_ebo_rand), NULL);
- eina_iterator_free(it);
+ for (j = 0; j < (unsigned int)request; ++j)
+ {
+ ebo = malloc(sizeof (Eina_Bench_Object));
+ if (!ebo)
+ continue;
+
+ ebo->keep = rand() < (RAND_MAX / 2) ? EINA_TRUE : EINA_FALSE;
+
+ eina_array_push(array, ebo);
+ }
+
+ if (i == 500)
+ {
+ it = eina_array_iterator_new(array);
+ eina_iterator_foreach(it, EINA_EACH(eina_iterator_ebo_free), NULL);
+ eina_iterator_free(it);
+
+ eina_array_clean(array);
+ }
+ else if (i % 30 == 0)
+ eina_array_remove(array, keep, NULL);
+
+ it = eina_array_iterator_new(array);
+ eina_iterator_foreach(it, EINA_EACH(eina_iterator_ebo_rand), NULL);
+ eina_iterator_free(it);
}
it = eina_array_iterator_new(array);
for (i = 0; i < 1000; ++i)
{
- for (j = 0; j < request; ++j)
- {
- ebo = malloc(sizeof (Eina_Bench_Object));
- if (!ebo) continue ;
-
- ebo->keep = rand() < (RAND_MAX / 2) ? EINA_TRUE : EINA_FALSE;
-
- list = eina_list_prepend(list, ebo);
- }
-
- if (i == 500)
- {
- while (list)
- {
- free(eina_list_data_get(list));
- list = eina_list_remove_list(list, list);
- }
- }
- else
- {
- if (i % 30 == 0)
- {
- tmp = list;
- while (tmp)
- {
- Eina_List *reminder = tmp;
-
- ebo = eina_list_data_get(reminder);
- tmp = eina_list_next(tmp);
-
- if (ebo->keep == EINA_FALSE)
- {
- list = eina_list_remove_list(list, reminder);
- free(ebo);
- }
- }
- }
- }
-
- for (tmp = list; tmp; tmp = eina_list_next(tmp))
- {
- ebo = eina_list_data_get(tmp);
-
- ebo->keep = rand() < (RAND_MAX / 2) ? ebo->keep : EINA_FALSE;
- }
+ for (j = 0; j < request; ++j)
+ {
+ ebo = malloc(sizeof (Eina_Bench_Object));
+ if (!ebo)
+ continue;
+
+ ebo->keep = rand() < (RAND_MAX / 2) ? EINA_TRUE : EINA_FALSE;
+
+ list = eina_list_prepend(list, ebo);
+ }
+
+ if (i == 500)
+ while (list)
+ {
+ free(eina_list_data_get(list));
+ list = eina_list_remove_list(list, list);
+ }
+ else if (i % 30 == 0)
+ {
+ tmp = list;
+ while (tmp)
+ {
+ Eina_List *reminder = tmp;
+
+ ebo = eina_list_data_get(reminder);
+ tmp = eina_list_next(tmp);
+
+ if (ebo->keep == EINA_FALSE)
+ {
+ list = eina_list_remove_list(list, reminder);
+ free(ebo);
+ }
+ }
+ }
+
+ for (tmp = list; tmp; tmp = eina_list_next(tmp))
+ {
+ ebo = eina_list_data_get(tmp);
+
+ ebo->keep = rand() < (RAND_MAX / 2) ? ebo->keep : EINA_FALSE;
+ }
}
while (list)
{
- free(eina_list_data_get(list));
- list = eina_list_remove_list(list, list);
+ free(eina_list_data_get(list));
+ list = eina_list_remove_list(list, list);
}
eina_shutdown();
for (i = 0; i < 1000; ++i)
{
- for (j = 0; j < request; ++j)
- {
- ebo = malloc(sizeof (Eina_Bench_Object));
- if (!ebo) continue ;
-
- ebo->keep = rand() < (RAND_MAX / 2) ? EINA_TRUE : EINA_FALSE;
-
- list = eina_list_prepend(list, ebo);
- }
-
- if (i == 500)
- {
- while (list)
- {
- free(eina_list_data_get(list));
- list = eina_list_remove_list(list, list);
- }
- }
- else
- {
- if (i % 30 == 0)
- {
- tmp = list;
- while (tmp)
- {
- Eina_List *reminder = tmp;
-
- ebo = eina_list_data_get(reminder);
- tmp = eina_list_next(tmp);
-
- if (ebo->keep == EINA_FALSE)
- {
- list = eina_list_remove_list(list, reminder);
- free(ebo);
- }
- }
- }
- }
-
- it = eina_list_iterator_new(list);
- eina_iterator_foreach(it, EINA_EACH(eina_iterator_ebo_rand), NULL);
- eina_iterator_free(it);
+ for (j = 0; j < request; ++j)
+ {
+ ebo = malloc(sizeof (Eina_Bench_Object));
+ if (!ebo)
+ continue;
+
+ ebo->keep = rand() < (RAND_MAX / 2) ? EINA_TRUE : EINA_FALSE;
+
+ list = eina_list_prepend(list, ebo);
+ }
+
+ if (i == 500)
+ while (list)
+ {
+ free(eina_list_data_get(list));
+ list = eina_list_remove_list(list, list);
+ }
+ else if (i % 30 == 0)
+ {
+ tmp = list;
+ while (tmp)
+ {
+ Eina_List *reminder = tmp;
+
+ ebo = eina_list_data_get(reminder);
+ tmp = eina_list_next(tmp);
+
+ if (ebo->keep == EINA_FALSE)
+ {
+ list = eina_list_remove_list(list, reminder);
+ free(ebo);
+ }
+ }
+ }
+
+ it = eina_list_iterator_new(list);
+ eina_iterator_foreach(it, EINA_EACH(eina_iterator_ebo_rand), NULL);
+ eina_iterator_free(it);
}
while (list)
{
- free(eina_list_data_get(list));
- list = eina_list_remove_list(list, list);
+ free(eina_list_data_get(list));
+ list = eina_list_remove_list(list, list);
}
eina_shutdown();
for (i = 0; i < 1000; ++i)
{
- for (j = 0; j < request; ++j)
- {
- ebo = malloc(sizeof (Eina_Bench_Object));
- if (!ebo) continue ;
-
- ebo->keep = rand() < (RAND_MAX / 2) ? EINA_TRUE : EINA_FALSE;
-
- head = eina_inlist_prepend(head, EINA_INLIST_GET(ebo));
- }
-
- if (i == 500)
- {
- while (head)
- {
- tmp = head;
- head = head->next;
- free(tmp);
- }
- }
- else
- {
- if (i % 30 == 0)
- {
- tmp = head;
- while(tmp)
- {
- ebo = (Eina_Bench_Object *) tmp;
-
- tmp = tmp->next;
- if (ebo->keep == EINA_FALSE)
- {
- head = eina_inlist_remove(head, EINA_INLIST_GET(ebo));
- free(ebo);
- }
- }
- }
- }
-
- EINA_INLIST_FOREACH(head, ebo)
- ebo->keep = rand() < (RAND_MAX / 2) ? ebo->keep : EINA_FALSE;
+ for (j = 0; j < request; ++j)
+ {
+ ebo = malloc(sizeof (Eina_Bench_Object));
+ if (!ebo)
+ continue;
+
+ ebo->keep = rand() < (RAND_MAX / 2) ? EINA_TRUE : EINA_FALSE;
+
+ head = eina_inlist_prepend(head, EINA_INLIST_GET(ebo));
+ }
+
+ if (i == 500)
+ while (head)
+ {
+ tmp = head;
+ head = head->next;
+ free(tmp);
+ }
+ else if (i % 30 == 0)
+ {
+ tmp = head;
+ while(tmp)
+ {
+ ebo = (Eina_Bench_Object *)tmp;
+
+ tmp = tmp->next;
+ if (ebo->keep == EINA_FALSE)
+ {
+ head = eina_inlist_remove(head, EINA_INLIST_GET(ebo));
+ free(ebo);
+ }
+ }
+ }
+
+ EINA_INLIST_FOREACH(head, ebo)
+ ebo->keep = rand() < (RAND_MAX / 2) ? ebo->keep : EINA_FALSE;
}
while (head)
{
- tmp = head;
- head = head->next;
- free(tmp);
+ tmp = head;
+ head = head->next;
+ free(tmp);
}
}
for (i = 0; i < 1000; ++i)
{
- for (j = 0; j < request; ++j)
- {
- ebo = malloc(sizeof (Eina_Bench_Object));
- if (!ebo) continue ;
-
- ebo->keep = rand() < (RAND_MAX / 2) ? EINA_TRUE : EINA_FALSE;
-
- head = eina_inlist_prepend(head, EINA_INLIST_GET(ebo));
- }
-
- if (i == 500)
- {
- while (head)
- {
- tmp = head;
- head = head->next;
- free(tmp);
- }
- }
- else
- {
- if (i % 30 == 0)
- {
- tmp = head;
- while(tmp)
- {
- ebo = (Eina_Bench_Object *) tmp;
-
- tmp = tmp->next;
- if (ebo->keep == EINA_FALSE)
- {
- head = eina_inlist_remove(head, EINA_INLIST_GET(ebo));
- free(ebo);
- }
- }
- }
- }
-
- it = eina_inlist_iterator_new(head);
- eina_iterator_foreach(it, EINA_EACH(eina_iterator_ebo_rand), NULL);
- eina_iterator_free(it);
+ for (j = 0; j < request; ++j)
+ {
+ ebo = malloc(sizeof (Eina_Bench_Object));
+ if (!ebo)
+ continue;
+
+ ebo->keep = rand() < (RAND_MAX / 2) ? EINA_TRUE : EINA_FALSE;
+
+ head = eina_inlist_prepend(head, EINA_INLIST_GET(ebo));
+ }
+
+ if (i == 500)
+ while (head)
+ {
+ tmp = head;
+ head = head->next;
+ free(tmp);
+ }
+ else if (i % 30 == 0)
+ {
+ tmp = head;
+ while(tmp)
+ {
+ ebo = (Eina_Bench_Object *)tmp;
+
+ tmp = tmp->next;
+ if (ebo->keep == EINA_FALSE)
+ {
+ head = eina_inlist_remove(head, EINA_INLIST_GET(ebo));
+ free(ebo);
+ }
+ }
+ }
+
+ it = eina_inlist_iterator_new(head);
+ eina_iterator_foreach(it, EINA_EACH(eina_iterator_ebo_rand), NULL);
+ eina_iterator_free(it);
}
while (head)
{
- tmp = head;
- head = head->next;
- free(tmp);
+ tmp = head;
+ head = head->next;
+ free(tmp);
}
}
for (i = 0; i < 1000; ++i)
{
- for (j = 0; j < request; ++j)
- {
- ebo = malloc(sizeof (Eina_Bench_Object));
- if (!ebo) continue ;
-
- ebo->keep = rand() < (RAND_MAX / 2) ? EINA_TRUE : EINA_FALSE;
-
- list = g_list_prepend(list, ebo);
- }
-
- if (i == 500)
- {
- while (list)
- {
- free(list->data);
- list = g_list_delete_link(list, list);
- }
- }
- else
- {
- if (i % 30 == 0)
- {
- tmp = list;
- while (tmp)
- {
- GList *reminder = tmp;
-
- ebo = reminder->data;
- tmp = g_list_next(tmp);
-
- if (ebo->keep == EINA_FALSE)
- {
- list = g_list_delete_link(list, reminder);
- free(ebo);
- }
- }
- }
- }
-
- for (tmp = list; tmp; tmp = g_list_next(tmp))
- {
- ebo = tmp->data;
-
- ebo->keep = rand() < (RAND_MAX / 2) ? ebo->keep : EINA_FALSE;
- }
+ for (j = 0; j < request; ++j)
+ {
+ ebo = malloc(sizeof (Eina_Bench_Object));
+ if (!ebo)
+ continue;
+
+ ebo->keep = rand() < (RAND_MAX / 2) ? EINA_TRUE : EINA_FALSE;
+
+ list = g_list_prepend(list, ebo);
+ }
+
+ if (i == 500)
+ while (list)
+ {
+ free(list->data);
+ list = g_list_delete_link(list, list);
+ }
+ else if (i % 30 == 0)
+ {
+ tmp = list;
+ while (tmp)
+ {
+ GList *reminder = tmp;
+
+ ebo = reminder->data;
+ tmp = g_list_next(tmp);
+
+ if (ebo->keep == EINA_FALSE)
+ {
+ list = g_list_delete_link(list, reminder);
+ free(ebo);
+ }
+ }
+ }
+
+ for (tmp = list; tmp; tmp = g_list_next(tmp))
+ {
+ ebo = tmp->data;
+
+ ebo->keep = rand() < (RAND_MAX / 2) ? ebo->keep : EINA_FALSE;
+ }
}
while (list)
{
- free(list->data);
- list = g_list_delete_link(list, list);
+ free(list->data);
+ list = g_list_delete_link(list, list);
}
}
for (i = 0; i < 1000; ++i)
{
- for (j = 0; j < (unsigned int) request; ++j)
- {
- ebo = malloc(sizeof (Eina_Bench_Object));
- if (!ebo) continue ;
-
- ebo->keep = rand() < (RAND_MAX / 2) ? EINA_TRUE : EINA_FALSE;
-
- g_ptr_array_add(array, ebo);
- }
-
- if (i == 500)
- {
- for (j = 0; j < array->len; ++j)
- free(g_ptr_array_index(array, j));
- g_ptr_array_remove_range(array, 0, array->len);
- }
- else
- {
- if (i % 30 == 0)
- {
- for (j = 0; j < array->len; )
- {
- ebo = g_ptr_array_index(array, j);
-
- if (ebo->keep == EINA_FALSE)
- free(g_ptr_array_remove_index_fast(array, j));
- else
- j++;
- }
- }
- }
-
- for (j = 0; j < array->len; ++j)
- {
- ebo = g_ptr_array_index(array, j);
-
- ebo->keep = rand() < (RAND_MAX / 2) ? ebo->keep : EINA_FALSE;
- }
+ for (j = 0; j < (unsigned int)request; ++j)
+ {
+ ebo = malloc(sizeof (Eina_Bench_Object));
+ if (!ebo)
+ continue;
+
+ ebo->keep = rand() < (RAND_MAX / 2) ? EINA_TRUE : EINA_FALSE;
+
+ g_ptr_array_add(array, ebo);
+ }
+
+ if (i == 500)
+ {
+ for (j = 0; j < array->len; ++j)
+ free(g_ptr_array_index(array, j));
+ g_ptr_array_remove_range(array, 0, array->len);
+ }
+ else if (i % 30 == 0)
+ for (j = 0; j < array->len; )
+ {
+ ebo = g_ptr_array_index(array, j);
+
+ if (ebo->keep == EINA_FALSE)
+ free(g_ptr_array_remove_index_fast(array, j));
+ else
+ j++;
+ }
+
+ for (j = 0; j < array->len; ++j)
+ {
+ ebo = g_ptr_array_index(array, j);
+
+ ebo->keep = rand() < (RAND_MAX / 2) ? ebo->keep : EINA_FALSE;
+ }
}
for (j = 0; j < array->len; ++j)
- free(g_ptr_array_index(array, j));
- g_ptr_array_free(array, TRUE);
+ free(g_ptr_array_index(array, j));
+ g_ptr_array_free(array, TRUE);
}
#endif
for (i = 0; i < 1000; ++i)
{
- for (j = 0; j < request; ++j)
- {
- ebo = malloc(sizeof (Eina_Bench_Object));
- if (!ebo) continue ;
-
- ebo->keep = rand() < (RAND_MAX / 2) ? EINA_TRUE : EINA_FALSE;
-
- list = evas_list_prepend(list, ebo);
- }
-
- if (i == 500)
- {
- while (list)
- {
- free(evas_list_data(list));
- list = evas_list_remove_list(list, list);
- }
- }
- else
- {
- if (i % 30 == 0)
- {
- tmp = list;
- while (tmp)
- {
- Evas_List *reminder = tmp;
-
- ebo = evas_list_data(reminder);
- tmp = evas_list_next(tmp);
-
- if (ebo->keep == EINA_FALSE)
- {
- list = evas_list_remove_list(list, reminder);
- free(ebo);
- }
- }
- }
- }
-
- for (tmp = list; tmp; tmp = evas_list_next(tmp))
- {
- ebo = evas_list_data(tmp);
-
- ebo->keep = rand() < (RAND_MAX / 2) ? ebo->keep : EINA_FALSE;
- }
+ for (j = 0; j < request; ++j)
+ {
+ ebo = malloc(sizeof (Eina_Bench_Object));
+ if (!ebo)
+ continue;
+
+ ebo->keep = rand() < (RAND_MAX / 2) ? EINA_TRUE : EINA_FALSE;
+
+ list = evas_list_prepend(list, ebo);
+ }
+
+ if (i == 500)
+ while (list)
+ {
+ free(evas_list_data(list));
+ list = evas_list_remove_list(list, list);
+ }
+ else if (i % 30 == 0)
+ {
+ tmp = list;
+ while (tmp)
+ {
+ Evas_List *reminder = tmp;
+
+ ebo = evas_list_data(reminder);
+ tmp = evas_list_next(tmp);
+
+ if (ebo->keep == EINA_FALSE)
+ {
+ list = evas_list_remove_list(list, reminder);
+ free(ebo);
+ }
+ }
+ }
+
+ for (tmp = list; tmp; tmp = evas_list_next(tmp))
+ {
+ ebo = evas_list_data(tmp);
+
+ ebo->keep = rand() < (RAND_MAX / 2) ? ebo->keep : EINA_FALSE;
+ }
}
while (list)
{
- free(evas_list_data(list));
- list = evas_list_remove_list(list, list);
+ free(evas_list_data(list));
+ list = evas_list_remove_list(list, list);
}
}
Ecore_List *list = user_data;
if (ebo->keep == EINA_FALSE)
- ecore_list_remove_destroy(list);
+ ecore_list_remove_destroy(list);
}
static void
for (i = 0; i < 1000; ++i)
{
- for (j = 0; j < request; ++j)
- {
- ebo = malloc(sizeof (Eina_Bench_Object));
- if (!ebo) continue ;
-
- ebo->keep = rand() < (RAND_MAX / 2) ? EINA_TRUE : EINA_FALSE;
-
- ecore_list_prepend(list, ebo);
- }
-
- if (i == 500)
- {
- ecore_list_clear(list);
- }
- else
- {
- if (i % 30 == 0)
- {
- ecore_list_for_each(list, _eina_ecore_for_each_remove, list);
- }
- }
-
- ecore_list_for_each(list, _eina_ecore_for_each_rand, list);
+ for (j = 0; j < request; ++j)
+ {
+ ebo = malloc(sizeof (Eina_Bench_Object));
+ if (!ebo)
+ continue;
+
+ ebo->keep = rand() < (RAND_MAX / 2) ? EINA_TRUE : EINA_FALSE;
+
+ ecore_list_prepend(list, ebo);
+ }
+
+ if (i == 500)
+ ecore_list_clear(list);
+ else if (i % 30 == 0)
+ ecore_list_for_each(list, _eina_ecore_for_each_remove, list);
+
+ ecore_list_for_each(list, _eina_ecore_for_each_rand, list);
}
- ecore_list_destroy(list);
+ ecore_list_destroy(list);
}
void eina_bench_array(Eina_Benchmark *bench)
{
- eina_benchmark_register(bench, "array-inline", EINA_BENCHMARK(eina_bench_array_4evas_render_inline), 200, 4000, 100);
- eina_benchmark_register(bench, "array-iterator", EINA_BENCHMARK(eina_bench_array_4evas_render_iterator), 200, 4000, 100);
- eina_benchmark_register(bench, "list", EINA_BENCHMARK(eina_bench_list_4evas_render), 200, 4000, 100);
- eina_benchmark_register(bench, "list-iterator", EINA_BENCHMARK(eina_bench_list_4evas_render_iterator), 200, 4000, 100);
- eina_benchmark_register(bench, "inlist", EINA_BENCHMARK(eina_bench_inlist_4evas_render), 200, 4000, 100);
- eina_benchmark_register(bench, "inlist-iterator", EINA_BENCHMARK(eina_bench_inlist_4evas_render_iterator), 200, 4000, 100);
+ eina_benchmark_register(bench, "array-inline",
+ EINA_BENCHMARK(
+ eina_bench_array_4evas_render_inline), 200,
+ 4000, 100);
+ eina_benchmark_register(bench, "array-iterator",
+ EINA_BENCHMARK(
+ eina_bench_array_4evas_render_iterator), 200,
+ 4000, 100);
+ eina_benchmark_register(bench, "list",
+ EINA_BENCHMARK(
+ eina_bench_list_4evas_render), 200,
+ 4000, 100);
+ eina_benchmark_register(bench, "list-iterator",
+ EINA_BENCHMARK(
+ eina_bench_list_4evas_render_iterator), 200,
+ 4000, 100);
+ eina_benchmark_register(bench, "inlist",
+ EINA_BENCHMARK(
+ eina_bench_inlist_4evas_render), 200,
+ 4000, 100);
+ eina_benchmark_register(bench, "inlist-iterator",
+ EINA_BENCHMARK(
+ eina_bench_inlist_4evas_render_iterator), 200,
+ 4000, 100);
#ifdef EINA_BENCH_HAVE_GLIB
- eina_benchmark_register(bench, "glist", EINA_BENCHMARK(eina_bench_glist_4evas_render), 200, 4000, 100);
- eina_benchmark_register(bench, "gptrarray", EINA_BENCHMARK(eina_bench_gptrarray_4evas_render), 200, 4000, 100);
+ eina_benchmark_register(bench, "glist",
+ EINA_BENCHMARK(
+ eina_bench_glist_4evas_render), 200,
+ 4000, 100);
+ eina_benchmark_register(bench, "gptrarray",
+ EINA_BENCHMARK(
+ eina_bench_gptrarray_4evas_render), 200,
+ 4000, 100);
#endif
- eina_benchmark_register(bench, "evas", EINA_BENCHMARK(eina_bench_evas_list_4evas_render), 200, 4000, 100);
- eina_benchmark_register(bench, "ecore", EINA_BENCHMARK(eina_bench_ecore_list_4evas_render), 200, 1000, 100);
+ eina_benchmark_register(bench, "evas",
+ EINA_BENCHMARK(
+ eina_bench_evas_list_4evas_render), 200,
+ 4000, 100);
+ eina_benchmark_register(bench, "ecore",
+ EINA_BENCHMARK(
+ eina_bench_ecore_list_4evas_render), 200,
+ 1000, 100);
}
for (i = 0; i < request; ++i)
{
- eina_convert_itoa(rand(), tmp);
+ eina_convert_itoa(rand(), tmp);
}
}
for (i = 0; i < request; ++i)
{
- eina_convert_xtoa(rand(), tmp);
+ eina_convert_xtoa(rand(), tmp);
}
}
for (i = 0; i < request; ++i)
{
- snprintf(tmp, 128, "%i", rand());
+ snprintf(tmp, 128, "%i", rand());
}
}
for (i = 0; i < request; ++i)
{
- snprintf(tmp, 128, "%x", rand());
+ snprintf(tmp, 128, "%x", rand());
}
}
for (i = 0; i < request; ++i)
{
- r = 10000 * (rand() / ((double)RAND_MAX + 1));
- snprintf(tmp, 128, "%a", r);
- sscanf(tmp, "%la", &r);
+ r = 10000 * (rand() / ((double)RAND_MAX + 1));
+ snprintf(tmp, 128, "%a", r);
+ sscanf(tmp, "%la", &r);
}
}
for (i = 0; i < request; ++i)
{
- r = 10000 * (rand() / ((double)RAND_MAX + 1));
- eina_convert_dtoa(r, tmp);
- eina_convert_atod(tmp, 128, &m, &e);
- r = ldexp((double)m, e);
+ r = 10000 * (rand() / ((double)RAND_MAX + 1));
+ eina_convert_dtoa(r, tmp);
+ eina_convert_atod(tmp, 128, &m, &e);
+ r = ldexp((double)m, e);
}
}
for (i = 0; i < request; ++i)
{
- r = 10000 * (rand() / ((double)RAND_MAX + 1));
- g_ascii_dtostr(tmp, 128, r);
- r = g_ascii_strtod(tmp, NULL);
+ r = 10000 * (rand() / ((double)RAND_MAX + 1));
+ g_ascii_dtostr(tmp, 128, r);
+ r = g_ascii_strtod(tmp, NULL);
}
}
#endif
void eina_bench_convert(Eina_Benchmark *bench)
{
- eina_benchmark_register(bench, "itoa 10", EINA_BENCHMARK(eina_bench_convert_itoa_10), 1000, 200000, 500);
- eina_benchmark_register(bench, "itoa 16", EINA_BENCHMARK(eina_bench_convert_itoa_16), 1000, 200000, 500);
- eina_benchmark_register(bench, "snprintf 10", EINA_BENCHMARK(eina_bench_convert_snprintf_10), 1000, 200000, 500);
- eina_benchmark_register(bench, "snprintf 16", EINA_BENCHMARK(eina_bench_convert_snprintf_x), 1000, 200000, 500);
- eina_benchmark_register(bench, "snprintf a", EINA_BENCHMARK(eina_bench_convert_snprintf_a), 1000, 200000, 500);
- eina_benchmark_register(bench, "dtoa", EINA_BENCHMARK(eina_bench_convert_dtoa), 1000, 200000, 500);
+ eina_benchmark_register(bench, "itoa 10",
+ EINA_BENCHMARK(
+ eina_bench_convert_itoa_10), 1000, 200000,
+ 500);
+ eina_benchmark_register(bench, "itoa 16",
+ EINA_BENCHMARK(
+ eina_bench_convert_itoa_16), 1000, 200000,
+ 500);
+ eina_benchmark_register(bench, "snprintf 10",
+ EINA_BENCHMARK(
+ eina_bench_convert_snprintf_10), 1000, 200000,
+ 500);
+ eina_benchmark_register(bench, "snprintf 16",
+ EINA_BENCHMARK(
+ eina_bench_convert_snprintf_x), 1000, 200000,
+ 500);
+ eina_benchmark_register(bench, "snprintf a",
+ EINA_BENCHMARK(
+ eina_bench_convert_snprintf_a), 1000, 200000,
+ 500);
+ eina_benchmark_register(bench, "dtoa",
+ EINA_BENCHMARK(
+ eina_bench_convert_dtoa), 1000, 200000,
+ 500);
#ifdef EINA_BENCH_HAVE_GLIB
- eina_benchmark_register(bench, "gstrtod", EINA_BENCHMARK(eina_bench_convert_gstrtod), 1000, 200000, 500);
+ eina_benchmark_register(bench, "gstrtod",
+ EINA_BENCHMARK(
+ eina_bench_convert_gstrtod), 1000, 200000,
+ 500);
#endif
}
};
static Eina_Rbtree_Direction
-_eina_bench_rbtree_cmp(const Eina_Bench_Rbtree *left, const Eina_Bench_Rbtree *right, __UNUSED__ void *data)
+_eina_bench_rbtree_cmp(const Eina_Bench_Rbtree *left,
+ const Eina_Bench_Rbtree *right,
+ __UNUSED__ void *data)
{
- if (!left) return EINA_RBTREE_RIGHT;
- if (!right) return EINA_RBTREE_LEFT;
+ if (!left)
+ return EINA_RBTREE_RIGHT;
- return strcmp(left->key, right->key) < 0 ? EINA_RBTREE_LEFT : EINA_RBTREE_RIGHT;
+ if (!right)
+ return EINA_RBTREE_LEFT;
+
+ return strcmp(left->key,
+ right->key) < 0 ? EINA_RBTREE_LEFT : EINA_RBTREE_RIGHT;
}
static inline int
-_eina_bench_rbtree_key(const Eina_Bench_Rbtree *node, const char *key, int length, __UNUSED__ void *data)
+_eina_bench_rbtree_key(const Eina_Bench_Rbtree *node,
+ const char *key,
+ int length,
+ __UNUSED__ void *data)
{
return strncmp(node->key, key, length);
}
for (i = 0; i < request; ++i)
{
- Eina_Bench_Rbtree *tmp;
+ Eina_Bench_Rbtree *tmp;
- tmp = malloc(sizeof (Eina_Bench_Rbtree));
- if (!tmp) continue ;
+ tmp = malloc(sizeof (Eina_Bench_Rbtree));
+ if (!tmp)
+ continue;
- tmp->value = i;
- eina_convert_itoa(i, tmp->key);
+ tmp->value = i;
+ eina_convert_itoa(i, tmp->key);
- root = eina_rbtree_inline_insert(root, &tmp->node, EINA_RBTREE_CMP_NODE_CB(_eina_bench_rbtree_cmp), NULL);
+ root = eina_rbtree_inline_insert(root,
+ &tmp->node,
+ EINA_RBTREE_CMP_NODE_CB(
+ _eina_bench_rbtree_cmp),
+ NULL);
}
srand(time(NULL));
for (j = 0; j < 200; ++j)
- for (i = 0; i < request; ++i)
- {
- Eina_Rbtree *tmp;
- char tmp_key[10];
+ for (i = 0; i < request; ++i)
+ {
+ Eina_Rbtree *tmp;
+ char tmp_key[10];
- eina_convert_itoa(rand() % request, tmp_key);
+ eina_convert_itoa(rand() % request, tmp_key);
- tmp = eina_rbtree_inline_lookup(root, tmp_key, 10, EINA_RBTREE_CMP_KEY_CB(_eina_bench_rbtree_key), NULL);
- }
+ tmp = eina_rbtree_inline_lookup(root,
+ tmp_key,
+ 10,
+ EINA_RBTREE_CMP_KEY_CB(
+ _eina_bench_rbtree_key),
+ NULL);
+ }
eina_rbtree_delete(root, EINA_RBTREE_FREE_CB(_eina_bench_rbtree_free), NULL);
}
hash = eina_hash_string_superfast_new(free);
- for (i = 0; i < (unsigned int) request; ++i)
+ for (i = 0; i < (unsigned int)request; ++i)
{
- char tmp_key[10];
+ char tmp_key[10];
- tmp_val = malloc(sizeof (int));
+ tmp_val = malloc(sizeof (int));
- if (!tmp_val) continue ;
+ if (!tmp_val)
+ continue;
- eina_convert_itoa(i, tmp_key);
- *tmp_val = i;
+ eina_convert_itoa(i, tmp_key);
+ *tmp_val = i;
- eina_hash_add(hash, tmp_key, tmp_val);
+ eina_hash_add(hash, tmp_key, tmp_val);
}
srand(time(NULL));
for (j = 0; j < 200; ++j)
- for (i = 0; i < (unsigned int) request; ++i)
- {
- char tmp_key[10];
+ for (i = 0; i < (unsigned int)request; ++i)
+ {
+ char tmp_key[10];
- eina_convert_itoa(rand() % request, tmp_key);
- tmp_val = eina_hash_find(hash, tmp_key);
- }
+ eina_convert_itoa(rand() % request, tmp_key);
+ tmp_val = eina_hash_find(hash, tmp_key);
+ }
eina_hash_free(hash);
}
hash = eina_hash_string_djb2_new(free);
- for (i = 0; i < (unsigned int) request; ++i)
+ for (i = 0; i < (unsigned int)request; ++i)
{
- char tmp_key[10];
+ char tmp_key[10];
- tmp_val = malloc(sizeof (int));
+ tmp_val = malloc(sizeof (int));
- if (!tmp_val) continue ;
+ if (!tmp_val)
+ continue;
- eina_convert_itoa(i, tmp_key);
- *tmp_val = i;
+ eina_convert_itoa(i, tmp_key);
+ *tmp_val = i;
- eina_hash_add(hash, tmp_key, tmp_val);
+ eina_hash_add(hash, tmp_key, tmp_val);
}
srand(time(NULL));
for (j = 0; j < 200; ++j)
- for (i = 0; i < (unsigned int) request; ++i)
- {
- char tmp_key[10];
+ for (i = 0; i < (unsigned int)request; ++i)
+ {
+ char tmp_key[10];
- eina_convert_itoa(rand() % request, tmp_key);
+ eina_convert_itoa(rand() % request, tmp_key);
- tmp_val = eina_hash_find(hash, tmp_key);
- }
+ tmp_val = eina_hash_find(hash, tmp_key);
+ }
eina_hash_free(hash);
}
hash = eina_hash_string_djb2_new(free);
- for (i = 0; i < (unsigned int) request; ++i)
+ for (i = 0; i < (unsigned int)request; ++i)
{
- int length;
+ int length;
- elm = malloc(sizeof (Eina_Bench_DJB2) + 10);
- if (!elm) continue ;
+ elm = malloc(sizeof (Eina_Bench_DJB2) + 10);
+ if (!elm)
+ continue;
- elm->key = (char*) (elm + 1);
+ elm->key = (char *)(elm + 1);
- length = eina_convert_itoa(i, elm->key) + 1;
- elm->value = i;
+ length = eina_convert_itoa(i, elm->key) + 1;
+ elm->value = i;
- eina_hash_direct_add_by_hash(hash, elm->key, length, eina_hash_djb2(elm->key, length), elm);
+ eina_hash_direct_add_by_hash(hash, elm->key, length,
+ eina_hash_djb2(elm->key, length), elm);
}
srand(time(NULL));
for (j = 0; j < 200; ++j)
- for (i = 0; i < (unsigned int) request; ++i)
- {
- char tmp_key[10];
- int length = 6;
+ for (i = 0; i < (unsigned int)request; ++i)
+ {
+ char tmp_key[10];
+ int length = 6;
- length = eina_convert_itoa(rand() % request, tmp_key) + 1;
+ length = eina_convert_itoa(rand() % request, tmp_key) + 1;
- elm = eina_hash_find_by_hash(hash, tmp_key, length, eina_hash_djb2(tmp_key, length));
- }
+ elm =
+ eina_hash_find_by_hash(hash, tmp_key, length,
+ eina_hash_djb2(tmp_key, length));
+ }
eina_hash_free(hash);
}
hash = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, free);
- for (i = 0; i < (unsigned int) request; ++i)
+ for (i = 0; i < (unsigned int)request; ++i)
{
- elm = malloc(sizeof (Eina_Bench_Glib) + 10);
- if (!elm) continue ;
+ elm = malloc(sizeof (Eina_Bench_Glib) + 10);
+ if (!elm)
+ continue;
- elm->key = (char*) (elm + 1);
+ elm->key = (char *)(elm + 1);
- eina_convert_itoa(i, elm->key);
- elm->value = i;
+ eina_convert_itoa(i, elm->key);
+ elm->value = i;
- g_hash_table_insert(hash, elm->key, elm);
+ g_hash_table_insert(hash, elm->key, elm);
}
srand(time(NULL));
for (j = 0; j < 200; ++j)
- for (i = 0; i < (unsigned int) request; ++i)
- {
- char tmp_key[10];
+ for (i = 0; i < (unsigned int)request; ++i)
+ {
+ char tmp_key[10];
- eina_convert_itoa(rand() % request, tmp_key);
+ eina_convert_itoa(rand() % request, tmp_key);
- elm = g_hash_table_lookup(hash, tmp_key);
- }
+ elm = g_hash_table_lookup(hash, tmp_key);
+ }
g_hash_table_destroy(hash);
}
array = eina_array_new(1000);
- for (i = 0; i < (unsigned int) request; ++i)
+ for (i = 0; i < (unsigned int)request; ++i)
{
- char tmp_key[10];
+ char tmp_key[10];
- tmp_val = malloc(sizeof (int));
+ tmp_val = malloc(sizeof (int));
- if (!tmp_val) continue ;
+ if (!tmp_val)
+ continue;
- eina_convert_itoa(i, tmp_key);
- *tmp_val = i;
+ eina_convert_itoa(i, tmp_key);
+ *tmp_val = i;
- hash = evas_hash_add(hash, tmp_key, tmp_val);
+ hash = evas_hash_add(hash, tmp_key, tmp_val);
- eina_array_push(array, tmp_val);
+ eina_array_push(array, tmp_val);
}
srand(time(NULL));
for (j = 0; j < 200; ++j)
- for (i = 0; i < (unsigned int) request; ++i)
- {
- char tmp_key[10];
+ for (i = 0; i < (unsigned int)request; ++i)
+ {
+ char tmp_key[10];
- eina_convert_itoa(rand() % request, tmp_key);
+ eina_convert_itoa(rand() % request, tmp_key);
- tmp_val = evas_hash_find(hash, tmp_key);
- }
+ tmp_val = evas_hash_find(hash, tmp_key);
+ }
evas_hash_free(hash);
EINA_ARRAY_ITER_NEXT(array, i, tmp_val, it)
- free(tmp_val);
+ free(tmp_val);
eina_array_free(array);
}
ecore_hash_free_key_cb_set(hash, NULL);
ecore_hash_free_value_cb_set(hash, free);
- for (i = 0; i < (unsigned int) request; ++i)
+ for (i = 0; i < (unsigned int)request; ++i)
{
- elm = malloc(sizeof (Eina_Bench_Ecore) + 10);
- if (!elm) continue;
+ elm = malloc(sizeof (Eina_Bench_Ecore) + 10);
+ if (!elm)
+ continue;
- elm->key = (char*) (elm + 1);
- eina_convert_itoa(i, elm->key);
- elm->value = i;
+ elm->key = (char *)(elm + 1);
+ eina_convert_itoa(i, elm->key);
+ elm->value = i;
- ecore_hash_set(hash, elm->key, elm);
+ ecore_hash_set(hash, elm->key, elm);
}
srand(time(NULL));
for (j = 0; j < 200; ++j)
- for (i = 0; i < (unsigned int) request; ++i)
- {
- char tmp_key[10];
+ for (i = 0; i < (unsigned int)request; ++i)
+ {
+ char tmp_key[10];
- eina_convert_itoa(rand() % request, tmp_key);
+ eina_convert_itoa(rand() % request, tmp_key);
- elm = ecore_hash_get(hash, tmp_key);
- }
+ elm = ecore_hash_get(hash, tmp_key);
+ }
ecore_hash_destroy(hash);
}
void eina_bench_hash(Eina_Benchmark *bench)
{
- eina_benchmark_register(bench, "superfast-lookup", EINA_BENCHMARK(eina_bench_lookup_superfast), 10, 3000, 10);
- eina_benchmark_register(bench, "djb2-lookup", EINA_BENCHMARK(eina_bench_lookup_djb2), 10, 3000, 10);
- eina_benchmark_register(bench, "djb2-lookup-inline", EINA_BENCHMARK(eina_bench_lookup_djb2_inline), 10, 3000, 10);
- eina_benchmark_register(bench, "rbtree", EINA_BENCHMARK(eina_bench_lookup_rbtree), 10, 3000, 10);
+ eina_benchmark_register(bench, "superfast-lookup",
+ EINA_BENCHMARK(
+ eina_bench_lookup_superfast), 10, 3000, 10);
+ eina_benchmark_register(bench, "djb2-lookup",
+ EINA_BENCHMARK(
+ eina_bench_lookup_djb2), 10, 3000, 10);
+ eina_benchmark_register(bench, "djb2-lookup-inline",
+ EINA_BENCHMARK(
+ eina_bench_lookup_djb2_inline), 10, 3000, 10);
+ eina_benchmark_register(bench, "rbtree",
+ EINA_BENCHMARK(
+ eina_bench_lookup_rbtree), 10, 3000, 10);
#ifdef EINA_BENCH_HAVE_GLIB
- eina_benchmark_register(bench, "ghash-lookup", EINA_BENCHMARK(eina_bench_lookup_ghash), 10, 3000, 10);
+ eina_benchmark_register(bench, "ghash-lookup",
+ EINA_BENCHMARK(
+ eina_bench_lookup_ghash), 10, 3000, 10);
#endif
- eina_benchmark_register(bench, "evas-lookup", EINA_BENCHMARK(eina_bench_lookup_evas), 10, 3000, 10);
- eina_benchmark_register(bench, "ecore-lookup", EINA_BENCHMARK(eina_bench_lookup_ecore), 10, 3000, 10);
+ eina_benchmark_register(bench, "evas-lookup",
+ EINA_BENCHMARK(
+ eina_bench_lookup_evas), 10, 3000, 10);
+ eina_benchmark_register(bench, "ecore-lookup",
+ EINA_BENCHMARK(
+ eina_bench_lookup_ecore), 10, 3000, 10);
}
for (i = 0; i < 100; ++i)
{
- for (j = 0; j < request; ++j)
- {
- eina_array_push(array, eina_mempool_malloc(mp, sizeof (int)));
- }
-
- for (j = 0; j < request; ++j)
- {
- eina_mempool_free(mp, eina_array_pop(array));
- }
+ for (j = 0; j < request; ++j)
+ {
+ eina_array_push(array, eina_mempool_malloc(mp, sizeof (int)));
+ }
+
+ for (j = 0; j < request; ++j)
+ {
+ eina_mempool_free(mp, eina_array_pop(array));
+ }
}
eina_array_free(array);
{
Eina_Mempool *mp;
- mp = eina_mempool_add("ememoa_unknown", "test", NULL, 0, 2, sizeof (int), 8, sizeof (int) * 2, 8);
+ mp = eina_mempool_add("ememoa_unknown",
+ "test",
+ NULL,
+ 0,
+ 2,
+ sizeof (int),
+ 8,
+ sizeof (int) * 2,
+ 8);
_eina_mempool_bench(mp, request);
eina_mempool_del(mp);
}
for (i = 0; i < 100; ++i)
{
- for (j = 0; j < request; ++j)
- {
- eina_array_push(array, g_slice_alloc(sizeof (int)));
- }
-
- for (j = 0; j < request; ++j)
- {
- g_slice_free1(sizeof (int), eina_array_pop(array));
- }
+ for (j = 0; j < request; ++j)
+ {
+ eina_array_push(array, g_slice_alloc(sizeof (int)));
+ }
+
+ for (j = 0; j < request; ++j)
+ {
+ g_slice_free1(sizeof (int), eina_array_pop(array));
+ }
}
eina_array_free(array);
eina_bench_mempool(Eina_Benchmark *bench)
{
#ifdef EINA_BUILD_CHAINED_POOL
- eina_benchmark_register(bench, "chained mempool", EINA_BENCHMARK(eina_mempool_chained_mempool), 10, 1000, 10);
+ eina_benchmark_register(bench, "chained mempool",
+ EINA_BENCHMARK(
+ eina_mempool_chained_mempool), 10, 1000, 10);
#endif
#ifdef EINA_BUILD_PASS_THROUGH
- eina_benchmark_register(bench, "pass through", EINA_BENCHMARK(eina_mempool_pass_through), 10, 1000, 10);
+ eina_benchmark_register(bench, "pass through",
+ EINA_BENCHMARK(
+ eina_mempool_pass_through), 10, 1000, 10);
#endif
#ifdef EINA_BUILD_FIXED_BITMAP
- eina_benchmark_register(bench, "fixed bitmap", EINA_BENCHMARK(eina_mempool_fixed_bitmap), 10, 1000, 10);
+ eina_benchmark_register(bench, "fixed bitmap",
+ EINA_BENCHMARK(
+ eina_mempool_fixed_bitmap), 10, 1000, 10);
#endif
#ifdef EINA_BUILD_EMEMOA_FIXED
- eina_benchmark_register(bench, "ememoa fixed", EINA_BENCHMARK(eina_mempool_ememoa_fixed), 10, 1000, 10);
+ eina_benchmark_register(bench, "ememoa fixed",
+ EINA_BENCHMARK(
+ eina_mempool_ememoa_fixed), 10, 1000, 10);
#endif
#ifdef EINA_BUILD_EMEMOA_UNKNOWN
- eina_benchmark_register(bench, "ememoa unknown", EINA_BENCHMARK(eina_mempool_ememoa_unknown), 10, 1000, 10);
+ eina_benchmark_register(bench, "ememoa unknown",
+ EINA_BENCHMARK(
+ eina_mempool_ememoa_unknown), 10, 1000, 10);
#endif
#ifdef EINA_BENCH_HAVE_GLIB
- eina_benchmark_register(bench, "gslice", EINA_BENCHMARK(eina_mempool_glib), 10, 1000, 10);
+ eina_benchmark_register(bench, "gslice",
+ EINA_BENCHMARK(
+ eina_mempool_glib), 10, 1000, 10);
#endif
}
eina_init();
for (i = 0; i < request; ++i)
- objects = eina_list_append(objects,
- eina_rectangle_new((rand() * WIDTH) / RAND_MAX,
- (rand() * HEIGHT) / RAND_MAX,
- (rand() * WIDTH / 2) / RAND_MAX,
- (rand() * HEIGHT / 2) / RAND_MAX));
+ objects = eina_list_append(objects,
+ eina_rectangle_new((rand() * WIDTH) / RAND_MAX,
+ (rand() *
+ HEIGHT) / RAND_MAX,
+ (rand() * WIDTH /
+ 2) / RAND_MAX,
+ (rand() * HEIGHT /
+ 2) / RAND_MAX));
for (j = 0; j < 100; ++j)
{
- Eina_Rectangle *collide;
- Eina_List *collided = NULL;
- Eina_List *changed = NULL;
- Eina_List *l;
-
- /* Delete 25% of all objects */
- i = request * 25 / 100;
- for (; i > 0; --i)
- {
- eina_rectangle_free(eina_list_data_get(objects));
- objects = eina_list_remove_list(objects, objects);
- }
-
- /* Add them back */
- i = request * 25 / 100;
- for (; i > 0; --i)
- {
- r = eina_rectangle_new((rand() * WIDTH) / RAND_MAX,
- (rand() * HEIGHT) / RAND_MAX,
- (rand() * WIDTH / 3) / RAND_MAX,
- (rand() * HEIGHT / 3) / RAND_MAX);
- objects = eina_list_prepend(objects, r);
- changed = eina_list_append(changed, r);
- }
-
- /* Do one collide search */
- collide = eina_rectangle_new((rand() * WIDTH) / RAND_MAX,
- (rand() * HEIGHT) / RAND_MAX,
- (rand() * WIDTH / 4) / RAND_MAX,
- (rand() * HEIGHT / 4) / RAND_MAX);
- EINA_LIST_FOREACH(objects, l, r)
- if (eina_rectangles_intersect(r, collide))
- collided = eina_list_append(collided, r);
- collided = eina_list_free(collided);
- eina_rectangle_free(collide);
-
- /* Modify 50% of all objects */
- i = request * 50 / 100;
- for (; i > 0; --i)
- {
- r = eina_list_data_get(eina_list_last(objects));
- objects = eina_list_remove_list(objects, eina_list_last(objects));
-
- r->x = (rand() * WIDTH) / RAND_MAX;
- r->y = (rand() * HEIGHT) / RAND_MAX;
- r->w = (rand() * WIDTH / 3) / RAND_MAX;
- r->h = (rand() * HEIGHT / 3) / RAND_MAX;
-
- objects = eina_list_prepend(objects, r);
- changed = eina_list_append(changed, r);
- }
-
- /* Emulating the render loop by colliding all modified
- object with all intersecting object */
- EINA_LIST_FREE(changed, r)
- {
- EINA_LIST_FOREACH(objects, l, collide)
- if (r != collide && eina_rectangles_intersect(collide, r))
- collided = eina_list_append(collided, collide);
-
- collided = eina_list_append(collided, r);
- }
-
- /* Ok, we compute it, now it's done */
- collided = eina_list_free(collided);
+ Eina_Rectangle *collide;
+ Eina_List *collided = NULL;
+ Eina_List *changed = NULL;
+ Eina_List *l;
+
+ /* Delete 25% of all objects */
+ i = request * 25 / 100;
+ for (; i > 0; --i)
+ {
+ eina_rectangle_free(eina_list_data_get(objects));
+ objects = eina_list_remove_list(objects, objects);
+ }
+
+ /* Add them back */
+ i = request * 25 / 100;
+ for (; i > 0; --i)
+ {
+ r = eina_rectangle_new((rand() * WIDTH) / RAND_MAX,
+ (rand() * HEIGHT) / RAND_MAX,
+ (rand() * WIDTH / 3) / RAND_MAX,
+ (rand() * HEIGHT / 3) / RAND_MAX);
+ objects = eina_list_prepend(objects, r);
+ changed = eina_list_append(changed, r);
+ }
+
+ /* Do one collide search */
+ collide = eina_rectangle_new((rand() * WIDTH) / RAND_MAX,
+ (rand() * HEIGHT) / RAND_MAX,
+ (rand() * WIDTH / 4) / RAND_MAX,
+ (rand() * HEIGHT / 4) / RAND_MAX);
+ EINA_LIST_FOREACH(objects, l, r)
+ if (eina_rectangles_intersect(r, collide))
+ collided = eina_list_append(collided, r);
+
+ collided = eina_list_free(collided);
+ eina_rectangle_free(collide);
+
+ /* Modify 50% of all objects */
+ i = request * 50 / 100;
+ for (; i > 0; --i)
+ {
+ r = eina_list_data_get(eina_list_last(objects));
+ objects = eina_list_remove_list(objects, eina_list_last(objects));
+
+ r->x = (rand() * WIDTH) / RAND_MAX;
+ r->y = (rand() * HEIGHT) / RAND_MAX;
+ r->w = (rand() * WIDTH / 3) / RAND_MAX;
+ r->h = (rand() * HEIGHT / 3) / RAND_MAX;
+
+ objects = eina_list_prepend(objects, r);
+ changed = eina_list_append(changed, r);
+ }
+
+ /* Emulating the render loop by colliding all modified
+ object with all intersecting object */
+ EINA_LIST_FREE(changed, r)
+ {
+ EINA_LIST_FOREACH(objects, l, collide)
+ if (r != collide && eina_rectangles_intersect(collide, r))
+ collided = eina_list_append(collided, collide);
+
+ collided = eina_list_append(collided, r);
+ }
+
+ /* Ok, we compute it, now it's done */
+ collided = eina_list_free(collided);
}
EINA_LIST_FREE(objects, r)
- eina_rectangle_free(r);
+ eina_rectangle_free(r);
eina_shutdown();
}
const Eina_Bench_Quad *b = object;
size_t y;
- y = b->r.y < 0 ? 0 : (size_t) b->r.y;
+ y = b->r.y < 0 ? 0 : (size_t)b->r.y;
if (y + b->r.h < middle)
- return EINA_QUAD_LEFT;
+ return EINA_QUAD_LEFT;
+
if (y > middle)
- return EINA_QUAD_RIGHT;
+ return EINA_QUAD_RIGHT;
+
return EINA_QUAD_BOTH;
}
const Eina_Bench_Quad *b = object;
size_t x;
- x = b->r.x < 0 ? 0 : (size_t) b->r.x;
+ x = b->r.x < 0 ? 0 : (size_t)b->r.x;
if (x + b->r.w < middle)
- return EINA_QUAD_LEFT;
+ return EINA_QUAD_LEFT;
+
if (x > middle)
- return EINA_QUAD_RIGHT;
+ return EINA_QUAD_RIGHT;
+
return EINA_QUAD_BOTH;
}
eina_init();
mp = eina_mempool_add("chained_mempool", "bench-quad", NULL,
- sizeof (Eina_Bench_Quad), 320);
+ sizeof (Eina_Bench_Quad), 320);
q = eina_quadtree_new(WIDTH, HEIGHT,
- _eina_bench_quadtree_vertical,
- _eina_bench_quadtree_horizontal);
+ _eina_bench_quadtree_vertical,
+ _eina_bench_quadtree_horizontal);
/* Create requested object */
for (i = 0; i < request; ++i)
{
- b = eina_mempool_malloc(mp, sizeof (Eina_Bench_Quad));
- EINA_RECTANGLE_SET(&b->r,
- (rand() * WIDTH) / RAND_MAX,
- (rand() * HEIGHT) / RAND_MAX,
- (rand() * WIDTH / 2) / RAND_MAX,
- (rand() * HEIGHT / 2) / RAND_MAX);
- b->item = eina_quadtree_add(q, b);
-
- objects = eina_list_append(objects, b);
+ b = eina_mempool_malloc(mp, sizeof (Eina_Bench_Quad));
+ EINA_RECTANGLE_SET(&b->r,
+ (rand() * WIDTH) / RAND_MAX,
+ (rand() * HEIGHT) / RAND_MAX,
+ (rand() * WIDTH / 2) / RAND_MAX,
+ (rand() * HEIGHT / 2) / RAND_MAX);
+ b->item = eina_quadtree_add(q, b);
+
+ objects = eina_list_append(objects, b);
}
for (j = 0; j < 100; ++j)
{
- Eina_Bench_Quad *collide;
- Eina_List *changed = NULL;
- Eina_List *collided = NULL;
-
- /* Delete 25% of all objects */
- i = request * 25 / 100;
- for (; i > 0; --i)
- {
- b = eina_list_data_get(objects);
- eina_quadtree_del(b->item);
- eina_mempool_free(mp, b);
-
- objects = eina_list_remove_list(objects, objects);
- }
-
- /* Add them back */
- i = request * 25 / 100;
- for (; i > 0; --i)
- {
- b = eina_mempool_malloc(mp, sizeof (Eina_Bench_Quad));
- EINA_RECTANGLE_SET(&b->r,
- (rand() * WIDTH) / RAND_MAX,
- (rand() * HEIGHT) / RAND_MAX,
- (rand() * WIDTH / 3) / RAND_MAX,
- (rand() * HEIGHT / 3) / RAND_MAX);
- b->item = eina_quadtree_add(q, b);
-
- objects = eina_list_prepend(objects, b);
- changed = eina_list_append(changed, b);
- }
-
- /* Do one collide search */
- collide = eina_mempool_malloc(mp, sizeof (Eina_Bench_Quad));
- EINA_RECTANGLE_SET(&collide->r,
- (rand() * WIDTH) / RAND_MAX,
- (rand() * HEIGHT) / RAND_MAX,
- (rand() * WIDTH / 4) / RAND_MAX,
- (rand() * HEIGHT / 4) / RAND_MAX);
- possibility = eina_quadtree_collide(q,
- collide->r.x, collide->r.y,
- collide->r.w, collide->r.h);
- while (possibility)
- {
- b = eina_quadtree_object(possibility);
- possibility = possibility->next;
-
- if (eina_rectangles_intersect(&b->r, &collide->r))
- collided = eina_list_append(collided, b);
- }
-
- collided = eina_list_free(collided);
- eina_mempool_free(mp, collide);
-
- /* Modify 50% of all objects */
- i = request * 50 / 100;
- for (; i > 0; --i)
- {
- b = eina_list_data_get(eina_list_last(objects));
- objects = eina_list_remove_list(objects, eina_list_last(objects));
-
- b->r.x = (rand() * WIDTH) / RAND_MAX;
- b->r.y = (rand() * HEIGHT) / RAND_MAX;
- b->r.w = (rand() * WIDTH / 3) / RAND_MAX;
- b->r.h = (rand() * HEIGHT / 3) / RAND_MAX;
-
- eina_quadtree_change(b->item);
-
- objects = eina_list_prepend(objects, b);
- changed = eina_list_append(changed, b);
- }
-
- /* Emulating the render loop by colliding all modified
- object with all intersecting object */
- EINA_LIST_FREE(changed, b)
- {
- possibility = eina_quadtree_collide(q,
- b->r.x, b->r.y, b->r.w, b->r.h);
- while (possibility)
- {
- collide = eina_quadtree_object(possibility);
- possibility = possibility->next;
-
- if (collide != b && eina_rectangles_intersect(&b->r, &collide->r))
- collided = eina_list_append(collided, collide);
- }
-
- collided = eina_list_append(collided, b);
- }
-
- /* Ok, we compute it, now it's done */
- collided = eina_list_free(collided);
+ Eina_Bench_Quad *collide;
+ Eina_List *changed = NULL;
+ Eina_List *collided = NULL;
+
+ /* Delete 25% of all objects */
+ i = request * 25 / 100;
+ for (; i > 0; --i)
+ {
+ b = eina_list_data_get(objects);
+ eina_quadtree_del(b->item);
+ eina_mempool_free(mp, b);
+
+ objects = eina_list_remove_list(objects, objects);
+ }
+
+ /* Add them back */
+ i = request * 25 / 100;
+ for (; i > 0; --i)
+ {
+ b = eina_mempool_malloc(mp, sizeof (Eina_Bench_Quad));
+ EINA_RECTANGLE_SET(&b->r,
+ (rand() * WIDTH) / RAND_MAX,
+ (rand() * HEIGHT) / RAND_MAX,
+ (rand() * WIDTH / 3) / RAND_MAX,
+ (rand() * HEIGHT / 3) / RAND_MAX);
+ b->item = eina_quadtree_add(q, b);
+
+ objects = eina_list_prepend(objects, b);
+ changed = eina_list_append(changed, b);
+ }
+
+ /* Do one collide search */
+ collide = eina_mempool_malloc(mp, sizeof (Eina_Bench_Quad));
+ EINA_RECTANGLE_SET(&collide->r,
+ (rand() * WIDTH) / RAND_MAX,
+ (rand() * HEIGHT) / RAND_MAX,
+ (rand() * WIDTH / 4) / RAND_MAX,
+ (rand() * HEIGHT / 4) / RAND_MAX);
+ possibility = eina_quadtree_collide(q,
+ collide->r.x, collide->r.y,
+ collide->r.w, collide->r.h);
+ while (possibility)
+ {
+ b = eina_quadtree_object(possibility);
+ possibility = possibility->next;
+
+ if (eina_rectangles_intersect(&b->r, &collide->r))
+ collided = eina_list_append(collided, b);
+ }
+
+ collided = eina_list_free(collided);
+ eina_mempool_free(mp, collide);
+
+ /* Modify 50% of all objects */
+ i = request * 50 / 100;
+ for (; i > 0; --i)
+ {
+ b = eina_list_data_get(eina_list_last(objects));
+ objects = eina_list_remove_list(objects, eina_list_last(objects));
+
+ b->r.x = (rand() * WIDTH) / RAND_MAX;
+ b->r.y = (rand() * HEIGHT) / RAND_MAX;
+ b->r.w = (rand() * WIDTH / 3) / RAND_MAX;
+ b->r.h = (rand() * HEIGHT / 3) / RAND_MAX;
+
+ eina_quadtree_change(b->item);
+
+ objects = eina_list_prepend(objects, b);
+ changed = eina_list_append(changed, b);
+ }
+
+ /* Emulating the render loop by colliding all modified
+ object with all intersecting object */
+ EINA_LIST_FREE(changed, b)
+ {
+ possibility = eina_quadtree_collide(q,
+ b->r.x, b->r.y, b->r.w, b->r.h);
+ while (possibility)
+ {
+ collide = eina_quadtree_object(possibility);
+ possibility = possibility->next;
+
+ if (collide != b &&
+ eina_rectangles_intersect(&b->r, &collide->r))
+ collided = eina_list_append(collided, collide);
+ }
+
+ collided = eina_list_append(collided, b);
+ }
+
+ /* Ok, we compute it, now it's done */
+ collided = eina_list_free(collided);
}
EINA_LIST_FREE(objects, b)
- {
- eina_quadtree_del(b->item);
- eina_mempool_free(mp, b);
- }
+ {
+ eina_quadtree_del(b->item);
+ eina_mempool_free(mp, b);
+ }
eina_mempool_del(mp);
eina_bench_quadtree(Eina_Benchmark *bench)
{
eina_benchmark_register(bench, "collide-all",
- EINA_BENCHMARK(eina_bench_render_loop),
- 100, 1500, 50);
+ EINA_BENCHMARK(eina_bench_render_loop),
+ 100, 1500, 50);
eina_benchmark_register(bench, "collide-quad-tree",
- EINA_BENCHMARK(eina_bench_quadtree_render_loop),
- 100, 1500, 50);
+ EINA_BENCHMARK(eina_bench_quadtree_render_loop),
+ 100, 1500, 50);
}
eina_init();
pool = eina_rectangle_pool_new(2048, 2048);
- if (!pool) return ;
-
+ if (!pool)
+ return;
for (i = 0; i < request; ++i)
{
- rect = NULL;
+ rect = NULL;
+
+ while (!rect)
+ {
+ rect = eina_rectangle_pool_request(pool, i & 0xFF, 256 - (i & 0xFF));
+ if (!rect)
+ {
+ rect = eina_list_data_get(list);
+ list = eina_list_remove_list(list, list);
+ if (rect)
+ eina_rectangle_pool_release(rect);
+ }
+ else
+ list = eina_list_append(list, rect);
- while (!rect)
- {
- rect = eina_rectangle_pool_request(pool, i & 0xFF, 256 - (i & 0xFF));
- if (!rect)
- {
- rect = eina_list_data_get(list);
- list = eina_list_remove_list(list, list);
- if (rect) eina_rectangle_pool_release(rect);
- }
- else
- {
- list = eina_list_append(list, rect);
- }
- if (!(i & 0xFF)) break;
- }
+ if (!(i & 0xFF))
+ break;
+ }
}
eina_rectangle_pool_free(pool);
void eina_bench_rectangle_pool(Eina_Benchmark *bench)
{
- eina_benchmark_register(bench, "eina", EINA_BENCHMARK(eina_bench_eina_rectangle_pool), 10, 4000, 100);
+ eina_benchmark_register(bench, "eina",
+ EINA_BENCHMARK(
+ eina_bench_eina_rectangle_pool), 10, 4000, 100);
}
for (i = 0; i < request; ++i)
{
- char buffer[10];
+ char buffer[10];
- eina_convert_itoa(rand() % request, buffer);
+ eina_convert_itoa(rand() % request, buffer);
- list = eina_list_prepend(list, strdup(buffer));
+ list = eina_list_prepend(list, strdup(buffer));
}
list = eina_list_sort(list, -1, EINA_COMPARE_CB(_eina_cmp_str));
while (list)
{
- free(eina_list_data_get(list));
- list = eina_list_remove_list(list, list);
+ free(eina_list_data_get(list));
+ list = eina_list_remove_list(list, list);
}
eina_shutdown();
for (i = 0; i < request; ++i)
{
- char buffer[10];
+ char buffer[10];
- eina_convert_itoa(rand() % request, buffer);
+ eina_convert_itoa(rand() % request, buffer);
- list = evas_list_prepend(list, strdup(buffer));
+ list = evas_list_prepend(list, strdup(buffer));
}
- list = evas_list_sort(list, -1, (void*) _eina_cmp_str);
+ list = evas_list_sort(list, -1, (void *)_eina_cmp_str);
while (list)
{
- free(evas_list_data(list));
- list = evas_list_remove_list(list, list);
+ free(evas_list_data(list));
+ list = evas_list_remove_list(list, list);
}
}
for (i = 0; i < request; ++i)
{
- char buffer[10];
+ char buffer[10];
- eina_convert_itoa(rand() % request, buffer);
+ eina_convert_itoa(rand() % request, buffer);
- list = g_list_prepend(list, strdup(buffer));
+ list = g_list_prepend(list, strdup(buffer));
}
- list = g_list_sort(list, (void*) _eina_cmp_str);
+ list = g_list_sort(list, (void *)_eina_cmp_str);
while (list)
{
- free(list->data);
- list = g_list_delete_link(list, list);
+ free(list->data);
+ list = g_list_delete_link(list, list);
}
}
#endif
for (i = 0; i < request; ++i)
{
- char buffer[10];
+ char buffer[10];
- eina_convert_itoa(rand() % request, buffer);
+ eina_convert_itoa(rand() % request, buffer);
- ecore_list_prepend(list, strdup(buffer));
+ ecore_list_prepend(list, strdup(buffer));
}
ecore_list_sort(list, ECORE_COMPARE_CB(_eina_cmp_str), 0);
for (i = 0; i < request; ++i)
{
- char buffer[10];
+ char buffer[10];
- eina_convert_itoa(rand() % request, buffer);
+ eina_convert_itoa(rand() % request, buffer);
- ecore_list_prepend(list, strdup(buffer));
+ ecore_list_prepend(list, strdup(buffer));
}
ecore_list_mergesort(list, ECORE_COMPARE_CB(_eina_cmp_str), 0);
for (i = 0; i < request; ++i)
{
- char buffer[10];
+ char buffer[10];
- eina_convert_itoa(rand() % request, buffer);
+ eina_convert_itoa(rand() % request, buffer);
- ecore_list_prepend(list, strdup(buffer));
+ ecore_list_prepend(list, strdup(buffer));
}
ecore_list_heapsort(list, ECORE_COMPARE_CB(_eina_cmp_str), 0);
void eina_bench_sort(Eina_Benchmark *bench)
{
- eina_benchmark_register(bench, "eina", EINA_BENCHMARK(eina_bench_sort_eina), 10, 10000, 100);
+ eina_benchmark_register(bench, "eina",
+ EINA_BENCHMARK(
+ eina_bench_sort_eina), 10, 10000, 100);
#ifdef EINA_BENCH_HAVE_GLIB
- eina_benchmark_register(bench, "glist", EINA_BENCHMARK(eina_bench_sort_glist), 10, 10000, 100);
+ eina_benchmark_register(bench, "glist",
+ EINA_BENCHMARK(
+ eina_bench_sort_glist), 10, 10000, 100);
#endif
- eina_benchmark_register(bench, "ecore", EINA_BENCHMARK(eina_bench_sort_ecore_default), 10, 10000, 100);
- eina_benchmark_register(bench, "ecore-merge", EINA_BENCHMARK(eina_bench_sort_ecore_merge), 10, 10000, 100);
- eina_benchmark_register(bench, "ecore-heap", EINA_BENCHMARK(eina_bench_sort_ecore_heap), 10, 10000, 100);
- eina_benchmark_register(bench, "evas", EINA_BENCHMARK(eina_bench_sort_evas), 10, 10000, 100);
+ eina_benchmark_register(bench, "ecore",
+ EINA_BENCHMARK(
+ eina_bench_sort_ecore_default), 10, 10000, 100);
+ eina_benchmark_register(bench, "ecore-merge",
+ EINA_BENCHMARK(
+ eina_bench_sort_ecore_merge), 10, 10000, 100);
+ eina_benchmark_register(bench, "ecore-heap",
+ EINA_BENCHMARK(
+ eina_bench_sort_ecore_heap), 10, 10000, 100);
+ eina_benchmark_register(bench, "evas",
+ EINA_BENCHMARK(
+ eina_bench_sort_evas), 10, 10000, 100);
}
for (i = 0; i < request; ++i)
{
- char build[64] = "string_";
+ char build[64] = "string_";
- eina_convert_xtoa(i, build + 7);
- tmp = eina_stringshare_add(build);
+ eina_convert_xtoa(i, build + 7);
+ tmp = eina_stringshare_add(build);
}
srand(time(NULL));
for (j = 0; j < 200; ++j)
- for (i = 0; i < request; ++i)
- {
- char build[64] = "string_";
+ for (i = 0; i < request; ++i)
+ {
+ char build[64] = "string_";
- eina_convert_xtoa(rand() % request, build + 7);
- tmp = eina_stringshare_add(build);
- }
+ eina_convert_xtoa(rand() % request, build + 7);
+ tmp = eina_stringshare_add(build);
+ }
eina_shutdown();
}
for (i = 0; i < request; ++i)
{
- char build[64] = "string_";
+ char build[64] = "string_";
- eina_convert_xtoa(i, build + 7);
- g_string_chunk_insert_const(chunk, build);
+ eina_convert_xtoa(i, build + 7);
+ g_string_chunk_insert_const(chunk, build);
}
srand(time(NULL));
for (j = 0; j < 200; ++j)
- for (i = 0; i < request; ++i)
- {
- char build[64] = "string_";
+ for (i = 0; i < request; ++i)
+ {
+ char build[64] = "string_";
- eina_convert_xtoa(rand() % request, build + 7);
- g_string_chunk_insert_const(chunk, build);
- }
+ eina_convert_xtoa(rand() % request, build + 7);
+ g_string_chunk_insert_const(chunk, build);
+ }
g_string_chunk_free(chunk);
}
for (i = 0; i < request; ++i)
{
- char build[64] = "string_";
+ char build[64] = "string_";
- eina_convert_xtoa(i, build + 7);
- tmp = evas_stringshare_add(build);
+ eina_convert_xtoa(i, build + 7);
+ tmp = evas_stringshare_add(build);
}
srand(time(NULL));
for (j = 0; j < 200; ++j)
- for (i = 0; i < request; ++i)
- {
- char build[64] = "string_";
+ for (i = 0; i < request; ++i)
+ {
+ char build[64] = "string_";
- eina_convert_xtoa(rand() % request, build + 7);
- tmp = evas_stringshare_add(build);
- }
+ eina_convert_xtoa(rand() % request, build + 7);
+ tmp = evas_stringshare_add(build);
+ }
}
static void
for (i = 0; i < request; ++i)
{
- char build[64] = "string_";
+ char build[64] = "string_";
- eina_convert_xtoa(i, build + 7);
- tmp = ecore_string_instance(build);
+ eina_convert_xtoa(i, build + 7);
+ tmp = ecore_string_instance(build);
}
srand(time(NULL));
for (j = 0; j < 200; ++j)
- for (i = 0; i < request; ++i)
- {
- char build[64] = "string_";
+ for (i = 0; i < request; ++i)
+ {
+ char build[64] = "string_";
- eina_convert_xtoa(rand() % request, build + 7);
- tmp = ecore_string_instance(build);
- }
+ eina_convert_xtoa(rand() % request, build + 7);
+ tmp = ecore_string_instance(build);
+ }
ecore_string_shutdown();
}
void eina_bench_stringshare(Eina_Benchmark *bench)
{
- eina_benchmark_register(bench, "stringshare", EINA_BENCHMARK(eina_bench_stringshare_job), 100, 20100, 500);
+ eina_benchmark_register(bench, "stringshare",
+ EINA_BENCHMARK(
+ eina_bench_stringshare_job), 100, 20100, 500);
#ifdef EINA_BENCH_HAVE_GLIB
- eina_benchmark_register(bench, "stringchunk (glib)", EINA_BENCHMARK(eina_bench_stringchunk_job), 100, 20100, 500);
+ eina_benchmark_register(bench, "stringchunk (glib)",
+ EINA_BENCHMARK(
+ eina_bench_stringchunk_job), 100, 20100, 500);
#endif
- eina_benchmark_register(bench, "stringshare (evas)", EINA_BENCHMARK(eina_bench_evas_job), 100, 20100, 500);
- eina_benchmark_register(bench, "stringshare (ecore)", EINA_BENCHMARK(eina_bench_ecore_job), 100, 20100, 500);
+ eina_benchmark_register(bench, "stringshare (evas)",
+ EINA_BENCHMARK(
+ eina_bench_evas_job), 100, 20100, 500);
+ eina_benchmark_register(bench, "stringshare (ecore)",
+ EINA_BENCHMARK(
+ eina_bench_ecore_job), 100, 20100, 500);
}
const char *name;
int (*init)(void);
- const char *(*add)(const char* str);
- void (*del)(const char* str);
+ const char *(*add)(const char *str);
+ void (*del)(const char *str);
int (*shutdown)(void);
};
static const char *strings[30000];
static Eina_Stringshare_Test eina_str = {
- "eina",
- eina_init,
- eina_stringshare_add,
- eina_stringshare_del,
- eina_shutdown
+ "eina",
+ eina_init,
+ eina_stringshare_add,
+ eina_stringshare_del,
+ eina_shutdown
};
static Eina_Stringshare_Test evas_str = {
- "evas",
+ "evas",
/* evas_stringshare_init, */
- evas_stringshare_add,
- evas_stringshare_del
+ evas_stringshare_add,
+ evas_stringshare_del
/* evas_stringshare_shutdown */
};
static Eina_Stringshare_Test ecore_str = {
- "ecore",
- ecore_string_init,
- ecore_string_instance,
- ecore_string_release,
- ecore_string_shutdown
+ "ecore",
+ ecore_string_init,
+ ecore_string_instance,
+ ecore_string_release,
+ ecore_string_shutdown
};
-static Eina_Stringshare_Test* str[] = {
- &eina_str,
- &evas_str,
- &ecore_str,
- NULL
+static Eina_Stringshare_Test *str[] = {
+ &eina_str,
+ &evas_str,
+ &ecore_str,
+ NULL
};
static void
eina_init();
for (i = 0; str[i]; ++i)
- eina_bench_e17_stringshare(str[i]);
+ eina_bench_e17_stringshare(str[i]);
eina_shutdown();
#endif
};
static const Eina_Test_Case etc[] = {
- { "FixedPoint", eina_test_fp },
- { "Array", eina_test_array },
- { "Binary Share", eina_test_binshare },
- { "String Share", eina_test_stringshare },
- { "UString Share", eina_test_ustringshare },
- { "Log", eina_test_log },
- { "Error", eina_test_error },
- { "Magic", eina_test_magic },
- { "Inlist", eina_test_inlist },
- { "Lazy alloc", eina_test_lalloc },
- { "Main", eina_test_main },
- { "Counter", eina_test_counter },
- { "Hash", eina_test_hash },
- { "List", eina_test_list },
- { "Iterator", eina_test_iterator },
- { "Accessor", eina_test_accessor },
- { "Module", eina_test_module },
- { "Convert", eina_test_convert },
- { "Rbtree", eina_test_rbtree },
- { "File", eina_test_file },
- { "Benchmark", eina_test_benchmark },
- { "Mempool", eina_test_mempool },
- { "Rectangle", eina_test_rectangle },
- { "Matrix Sparse", eina_test_matrixsparse },
- { "Eina Tiler", eina_test_tiler },
- { "Eina Strbuf", eina_test_strbuf },
- { "String", eina_test_str },
- { "QuadTree", eina_test_quadtree },
- { NULL, NULL }
+ { "FixedPoint", eina_test_fp },
+ { "Array", eina_test_array },
+ { "Binary Share", eina_test_binshare },
+ { "String Share", eina_test_stringshare },
+ { "UString Share", eina_test_ustringshare },
+ { "Log", eina_test_log },
+ { "Error", eina_test_error },
+ { "Magic", eina_test_magic },
+ { "Inlist", eina_test_inlist },
+ { "Lazy alloc", eina_test_lalloc },
+ { "Main", eina_test_main },
+ { "Counter", eina_test_counter },
+ { "Hash", eina_test_hash },
+ { "List", eina_test_list },
+ { "Iterator", eina_test_iterator },
+ { "Accessor", eina_test_accessor },
+ { "Module", eina_test_module },
+ { "Convert", eina_test_convert },
+ { "Rbtree", eina_test_rbtree },
+ { "File", eina_test_file },
+ { "Benchmark", eina_test_benchmark },
+ { "Mempool", eina_test_mempool },
+ { "Rectangle", eina_test_rectangle },
+ { "Matrix Sparse", eina_test_matrixsparse },
+ { "Eina Tiler", eina_test_tiler },
+ { "Eina Strbuf", eina_test_strbuf },
+ { "String", eina_test_str },
+ { "QuadTree", eina_test_quadtree },
+ { NULL, NULL }
};
static void
_list_tests(void)
{
const Eina_Test_Case *itr = etc;
- fputs("Available Test Cases:\n", stderr);
+ fputs("Available Test Cases:\n", stderr);
for (; itr->test_case != NULL; itr++)
- fprintf(stderr, "\t%s\n", itr->test_case);
+ fprintf(stderr, "\t%s\n", itr->test_case);
}
static Eina_Bool
_use_test(int argc, const char **argv, const char *test_case)
{
if (argc < 1)
- return 1;
+ return 1;
for (; argc > 0; argc--, argv++)
- if (strcmp(test_case, *argv) == 0)
- return 1;
+ if (strcmp(test_case, *argv) == 0)
+ return 1;
+
return 0;
}
for (i = 0; etc[i].test_case != NULL; ++i)
{
- if (!_use_test(argc, argv, etc[i].test_case)) continue;
- tc = tcase_create(etc[i].test_case);
+ if (!_use_test(argc, argv, etc[i].test_case))
+ continue;
+
+ tc = tcase_create(etc[i].test_case);
- etc[i].build(tc);
+ etc[i].build(tc);
- suite_add_tcase(s, tc);
- tcase_set_timeout(tc, 0);
+ suite_add_tcase(s, tc);
+ tcase_set_timeout(tc, 0);
}
return s;
static Eina_Array *_modules;
static void _mempool_init(void)
{
- 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_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);
}
static void _mempool_shutdown(void)
int i, failed_count;
for (i = 1; i < argc; i++)
- if ((strcmp(argv[i], "-h") == 0) ||
- (strcmp(argv[i], "--help") == 0))
- {
- fprintf(stderr, "Usage:\n\t%s [test_case1 .. [test_caseN]]\n",
- argv[0]);
- _list_tests();
- return 0;
- }
- else if ((strcmp(argv[i], "-l") == 0) ||
- (strcmp(argv[i], "--list") == 0))
- {
- _list_tests();
- return 0;
- }
+ if ((strcmp(argv[i], "-h") == 0) ||
+ (strcmp(argv[i], "--help") == 0))
+ {
+ fprintf(stderr, "Usage:\n\t%s [test_case1 .. [test_caseN]]\n",
+ argv[0]);
+ _list_tests();
+ return 0;
+ }
+ else if ((strcmp(argv[i], "-l") == 0) ||
+ (strcmp(argv[i], "--list") == 0))
+ {
+ _list_tests();
+ return 0;
+ }
s = eina_build_suite(argc - 1, (const char **)argv + 1);
sr = srunner_create(s);
static Eina_Bool
eina_accessor_check(__UNUSED__ const Eina_Array *array,
- int *data, int *fdata)
+ int *data, int *fdata)
{
fail_if(*fdata > *data);
*fdata = *data;
eina_init();
ea = eina_array_new(11);
- fail_if(!ea);
+ fail_if(!ea);
for (i = 0; i < 200; ++i)
{
- tmp = malloc(sizeof(int));
- fail_if(!tmp);
- *tmp = i;
+ tmp = malloc(sizeof(int));
+ fail_if(!tmp);
+ *tmp = i;
- eina_array_push(ea, tmp);
+ eina_array_push(ea, tmp);
}
it = eina_array_accessor_new(ea);
fail_if(!it);
- fail_if(eina_accessor_data_get(it, 100, (void**) &tmp) != EINA_TRUE);
+ fail_if(eina_accessor_data_get(it, 100, (void **)&tmp) != EINA_TRUE);
fail_if(!tmp);
fail_if(*tmp != 100);
int i;
};
-static Eina_Test_Inlist*
+static Eina_Test_Inlist *
_eina_test_inlist_build(int i)
{
Eina_Test_Inlist *tmp;
}
static Eina_Bool
-eina_accessor_inlist_data_check(__UNUSED__ const Eina_Inlist *in_list, Eina_Test_Inlist *data, int *fdata)
+eina_accessor_inlist_data_check(__UNUSED__ const Eina_Inlist *in_list,
+ Eina_Test_Inlist *data,
+ int *fdata)
{
switch (*fdata)
{
case 0: fail_if(data->i != 3227); break;
+
case 1: fail_if(data->i != 1664); break;
}
tmp = _eina_test_inlist_build(1664);
lst = eina_inlist_append_relative(lst, EINA_INLIST_GET(tmp), lst);
fail_if(!lst);
- fail_if(((Eina_Test_Inlist*)lst)->i != 42);
+ fail_if(((Eina_Test_Inlist *)lst)->i != 42);
prev = tmp;
tmp = _eina_test_inlist_build(3227);
- lst = eina_inlist_prepend_relative(lst, EINA_INLIST_GET(tmp), EINA_INLIST_GET(prev));
+ lst = eina_inlist_prepend_relative(lst, EINA_INLIST_GET(
+ tmp), EINA_INLIST_GET(prev));
fail_if(!lst);
- fail_if(((Eina_Test_Inlist*)lst)->i != 42);
+ fail_if(((Eina_Test_Inlist *)lst)->i != 42);
tmp = _eina_test_inlist_build(27);
lst = eina_inlist_prepend_relative(lst, EINA_INLIST_GET(tmp), NULL);
eina_accessor_over(it, EINA_EACH(eina_accessor_inlist_data_check), 2, 4, &i);
- fail_if(eina_accessor_data_get(it, 5, (void**) &tmp) != EINA_TRUE);
- fail_if(eina_accessor_data_get(it, 3, (void**) &tmp) != EINA_TRUE);
+ fail_if(eina_accessor_data_get(it, 5, (void **)&tmp) != EINA_TRUE);
+ fail_if(eina_accessor_data_get(it, 3, (void **)&tmp) != EINA_TRUE);
fail_if(tmp->i != 1664);
- fail_if(eina_accessor_data_get(it, 3, (void**) &tmp) != EINA_TRUE);
+ fail_if(eina_accessor_data_get(it, 3, (void **)&tmp) != EINA_TRUE);
fail_if(tmp->i != 1664);
- fail_if(eina_accessor_data_get(it, 1, (void**) &tmp) != EINA_TRUE);
+ fail_if(eina_accessor_data_get(it, 1, (void **)&tmp) != EINA_TRUE);
fail_if(tmp->i != 42);
eina_accessor_free(it);
END_TEST
static Eina_Bool
-eina_iterator_list_data_check(__UNUSED__ const Eina_List *list, int *data, int *fdata)
+eina_iterator_list_data_check(__UNUSED__ const Eina_List *list,
+ int *data,
+ int *fdata)
{
switch (*fdata)
{
case 0: fail_if(*data != 9); break;
+
case 1: fail_if(*data != 6); break;
}
eina_accessor_over(it, EINA_EACH(eina_iterator_list_data_check), 2, 4, &i);
- fail_if(eina_accessor_data_get(it, 5, (void**) &j) != EINA_TRUE);
+ fail_if(eina_accessor_data_get(it, 5, (void **)&j) != EINA_TRUE);
fail_if(*j != 1);
- fail_if(eina_accessor_data_get(it, 3, (void**) &j) != EINA_TRUE);
+ fail_if(eina_accessor_data_get(it, 3, (void **)&j) != EINA_TRUE);
fail_if(*j != 6);
- fail_if(eina_accessor_data_get(it, 3, (void**) &j) != EINA_TRUE);
+ fail_if(eina_accessor_data_get(it, 3, (void **)&j) != EINA_TRUE);
fail_if(*j != 6);
- fail_if(eina_accessor_data_get(it, 1, (void**) &j) != EINA_TRUE);
+ fail_if(eina_accessor_data_get(it, 1, (void **)&j) != EINA_TRUE);
fail_if(*j != 7);
- fail_if(eina_accessor_data_get(it, 5, (void**) &j) != EINA_TRUE);
+ fail_if(eina_accessor_data_get(it, 5, (void **)&j) != EINA_TRUE);
fail_if(*j != 1);
eina_accessor_free(it);
eina_init();
ea = eina_array_new(11);
- fail_if(!ea);
+ fail_if(!ea);
for (i = 0; i < 201; ++i)
{
- tmp = malloc(sizeof(char) * 10);
- fail_if(!tmp);
- eina_convert_itoa(i, tmp);
+ tmp = malloc(sizeof(char) * 10);
+ fail_if(!tmp);
+ eina_convert_itoa(i, tmp);
- eina_array_push(ea, tmp);
+ eina_array_push(ea, tmp);
}
fail_if(eina_array_data_get(ea, 10) == NULL);
free(tmp);
EINA_ARRAY_ITER_NEXT(ea, i, tmp, it)
- {
- fail_if((unsigned int) atoi(tmp) != i);
- free(tmp);
- }
+ {
+ fail_if((unsigned int)atoi(tmp) != i);
+ free(tmp);
+ }
fail_if(i != 200);
for (i = 0; i < 200; ++i)
{
- tmp = malloc(sizeof(char) * 10);
- fail_if(!tmp);
- eina_convert_itoa(i, tmp);
+ tmp = malloc(sizeof(char) * 10);
+ fail_if(!tmp);
+ eina_convert_itoa(i, tmp);
- eina_array_push(&sea, tmp);
+ eina_array_push(&sea, tmp);
}
fail_if(eina_array_data_get(&sea, 10) == NULL);
fail_if(atoi(eina_array_data_get(&sea, 10)) != 10);
EINA_ARRAY_ITER_NEXT(&sea, i, tmp, it)
- {
- fail_if((unsigned int) atoi(tmp) != i);
- free(tmp);
- }
+ {
+ fail_if((unsigned int)atoi(tmp) != i);
+ free(tmp);
+ }
fail_if(i != 200);
fail_if(gdata);
fail_if(!tmp);
- if (*tmp == 0) return EINA_FALSE;
+ if (*tmp == 0)
+ return EINA_FALSE;
+
return EINA_TRUE;
}
eina_init();
ea = eina_array_new(64);
- fail_if(!ea);
+ fail_if(!ea);
for (i = 0; i < 1000; ++i)
{
- tmp = malloc(sizeof(int));
- fail_if(!tmp);
- *tmp = i;
+ tmp = malloc(sizeof(int));
+ fail_if(!tmp);
+ *tmp = i;
- eina_array_push(ea, tmp);
+ eina_array_push(ea, tmp);
}
// Remove the first 10 items
for (i = 0; i < 10; ++i)
{
- tmp = eina_array_data_get(ea, i);
- fail_if(!tmp);
- *tmp = 0;
+ tmp = eina_array_data_get(ea, i);
+ fail_if(!tmp);
+ *tmp = 0;
}
- fail_if(eina_array_remove(ea, keep_int, NULL) != EINA_TRUE);
+ fail_if(eina_array_remove(ea, keep_int, NULL) != EINA_TRUE);
- fail_if(eina_array_count_get(ea) != 990);
- EINA_ARRAY_ITER_NEXT(ea, i, tmp, it)
- fail_if(*tmp == 0);
+ fail_if(eina_array_count_get(ea) != 990);
+ EINA_ARRAY_ITER_NEXT(ea, i, tmp, it)
+ fail_if(*tmp == 0);
// Remove the last items
for (i = 980; i < 990; ++i)
{
- tmp = eina_array_data_get(ea, i);
- fail_if(!tmp);
- *tmp = 0;
+ tmp = eina_array_data_get(ea, i);
+ fail_if(!tmp);
+ *tmp = 0;
}
- eina_array_remove(ea, keep_int, NULL);
+ eina_array_remove(ea, keep_int, NULL);
// Remove all items
fail_if(eina_array_count_get(ea) != 980);
EINA_ARRAY_ITER_NEXT(ea, i, tmp, it)
- {
- fail_if(*tmp == 0);
- *tmp = 0;
- }
+ {
+ fail_if(*tmp == 0);
+ *tmp = 0;
+ }
eina_array_remove(ea, keep_int, NULL);
int a = 0;
for (i = 0; i < request; ++i)
- a += i;
+ a += i;
global_test = a;
}
eb = eina_benchmark_new("benchmark", "test");
fail_if(!eb);
- eina_benchmark_register(eb, "specimens_check", EINA_BENCHMARK(_eina_benchmark_specimens), 1000, 1100, 100);
+ eina_benchmark_register(eb, "specimens_check",
+ EINA_BENCHMARK(
+ _eina_benchmark_specimens), 1000, 1100, 100);
ea = eina_benchmark_run(eb);
fail_if(!ea);
EINA_ARRAY_ITER_NEXT(ea, i, tmp, it)
- {
- fail_if(!tmp);
- fail_if(unlink(tmp));
- }
+ {
+ fail_if(!tmp);
+ fail_if(unlink(tmp));
+ }
- fail_if(global_test != 499500);
+ fail_if(global_test != 499500);
- eina_benchmark_free(eb);
+ eina_benchmark_free(eb);
}
END_TEST
for (i = 1; i < 3; i++)
{
- const char *t0, *t1;
- int j;
-
- for (j = 0; j < i; j++)
- {
- char c;
- for (c = 'a'; c <= 'z'; c++)
- buf[j] = c;
- }
- buf[i] = '\0';
- t0 = eina_binshare_add_length(buf, i);
- t1 = eina_binshare_add_length(buf, i);
-
- fail_if(t0 == NULL);
- fail_if(t1 == NULL);
- fail_if(t0 != t1);
- fail_if(memcmp(t0, buf, i) != 0);
-
- eina_binshare_del(t0);
- eina_binshare_del(t1);
+ const char *t0, *t1;
+ int j;
+
+ for (j = 0; j < i; j++)
+ {
+ char c;
+ for (c = 'a'; c <= 'z'; c++)
+ buf[j] = c;
+ }
+ buf[i] = '\0';
+ t0 = eina_binshare_add_length(buf, i);
+ t1 = eina_binshare_add_length(buf, i);
+
+ fail_if(t0 == NULL);
+ fail_if(t1 == NULL);
+ fail_if(t0 != t1);
+ fail_if(memcmp(t0, buf, i) != 0);
+
+ eina_binshare_del(t0);
+ eina_binshare_del(t1);
}
- eina_binshare_shutdown();
+ eina_binshare_shutdown();
eina_shutdown();
}
END_TEST
eina_init();
eina_binshare_init();
-
+
for (i = 10000; i > 0; --i)
{
- char build[64] = "string_";
+ char build[64] = "string_";
- eina_convert_xtoa(i, build + 7);
- tmp = eina_binshare_add_length(build, strlen(build));
- fail_if(tmp != eina_binshare_add_length(build, strlen(build)));
- fail_if((int) strlen(build) != eina_binshare_length(tmp));
+ eina_convert_xtoa(i, build + 7);
+ tmp = eina_binshare_add_length(build, strlen(build));
+ fail_if(tmp != eina_binshare_add_length(build, strlen(build)));
+ fail_if((int)strlen(build) != eina_binshare_length(tmp));
}
- eina_binshare_shutdown();
+ eina_binshare_shutdown();
eina_shutdown();
}
END_TEST
for (i = 0; i < 10000; ++i)
{
- eina_convert_itoa(rand(), buffer);
- eina_array_push(ea, (void*) eina_binshare_add_length(buffer, strlen(buffer)));
- if (rand() > RAND_MAX / 2)
- {
- const char *r = eina_binshare_add_length(buffer, strlen(buffer));
- fail_if(r == NULL);
- }
+ eina_convert_itoa(rand(), buffer);
+ eina_array_push(ea,
+ (void *)eina_binshare_add_length(buffer, strlen(buffer)));
+ if (rand() > RAND_MAX / 2)
+ {
+ const char *r = eina_binshare_add_length(buffer, strlen(buffer));
+ fail_if(r == NULL);
+ }
}
for (i = 0; i < 10000; ++i)
{
- const char *r;
-
- eina_convert_itoa(60000 - i, buffer);
- eina_array_push(ea, (void*) eina_binshare_add_length(buffer, strlen(buffer)));
- r = eina_binshare_add_length(buffer, strlen(buffer));
- fail_if(r == NULL);
- r = eina_binshare_add_length(buffer, strlen(buffer));
- fail_if(r == NULL);
+ const char *r;
+
+ eina_convert_itoa(60000 - i, buffer);
+ eina_array_push(ea,
+ (void *)eina_binshare_add_length(buffer, strlen(buffer)));
+ r = eina_binshare_add_length(buffer, strlen(buffer));
+ fail_if(r == NULL);
+ r = eina_binshare_add_length(buffer, strlen(buffer));
+ fail_if(r == NULL);
}
for (i = 0; i < 200; ++i)
- eina_binshare_del(eina_array_data_get(ea, i));
+ eina_binshare_del(eina_array_data_get(ea, i));
for (i = 0; i < 1000; ++i)
- eina_binshare_del(eina_array_pop(ea));
+ eina_binshare_del(eina_array_pop(ea));
- eina_binshare_shutdown();
+ eina_binshare_shutdown();
eina_shutdown();
eina_array_free(ea);
fail_if(fabs(r - test) > DBL_MIN);
}
-START_TEST(eina_convert_double)
+ START_TEST(eina_convert_double)
{
long long int m = 0;
long e = 0;
eina_init();
- _eina_convert_check(EET_TEST_DOUBLE0, 20);
+ _eina_convert_check(EET_TEST_DOUBLE0, 20);
_eina_convert_check(-EET_TEST_DOUBLE0, 21);
- _eina_convert_check(EET_TEST_DOUBLE1, 6);
- _eina_convert_check(EET_TEST_DOUBLE2, 6);
- _eina_convert_check(EET_TEST_DOUBLE3, 21);
- _eina_convert_check(EET_TEST_DOUBLE4, 21);
+ _eina_convert_check(EET_TEST_DOUBLE1, 6);
+ _eina_convert_check(EET_TEST_DOUBLE2, 6);
+ _eina_convert_check(EET_TEST_DOUBLE3, 21);
+ _eina_convert_check(EET_TEST_DOUBLE4, 21);
fail_if(eina_convert_atod("ah ah ah", 8, &m, &e) != EINA_FALSE);
fail_if(eina_convert_atod("0xjo", 8, &m, &e) != EINA_FALSE);
fail_if(fabs(fpd - d) > DBL_MIN);
}
-START_TEST(eina_convert_fp)
+ START_TEST(eina_convert_fp)
{
- _eina_convert_fp_check(1.0, 0x0000000100000000, 6);
- _eina_convert_fp_check(0.5, 0x0000000080000000, 8);
- _eina_convert_fp_check(0.625, 0x00000000a0000000, 8);
- _eina_convert_fp_check(256.0, 0x0000010000000000, 6);
- _eina_convert_fp_check(0.5, 0x0000000080000000, 8);
+ _eina_convert_fp_check(1.0, 0x0000000100000000, 6);
+ _eina_convert_fp_check(0.5, 0x0000000080000000, 8);
+ _eina_convert_fp_check(0.625, 0x00000000a0000000, 8);
+ _eina_convert_fp_check(256.0, 0x0000010000000000, 6);
+ _eina_convert_fp_check(0.5, 0x0000000080000000, 8);
_eina_convert_fp_check(128.625, 0x00000080a0000000, 10);
}
END_TEST
{
tcase_add_test(tc, eina_convert_simple);
tcase_add_test(tc, eina_convert_double);
- tcase_add_test(tc, eina_convert_fp);
+ tcase_add_test(tc, eina_convert_fp);
}
for (i = 0; i < 100000; ++i)
{
- void *tmp = malloc(sizeof(long int));
- free(tmp);
+ void *tmp = malloc(sizeof(long int));
+ free(tmp);
}
eina_counter_stop(cnt, i);
for (i = 0; i < 200000; ++i)
{
- void *tmp = malloc(sizeof(long int));
- free(tmp);
+ void *tmp = malloc(sizeof(long int));
+ free(tmp);
}
eina_counter_stop(cnt, i);
eina_array_free(ea);
#ifdef _WIN32
- ea = eina_file_split(strdup("this\\\\is\\\\\\a \\more\\complex\\\\\\case\\\\\\"));
+ ea =
+ eina_file_split(strdup(
+ "this\\\\is\\\\\\a \\more\\complex\\\\\\case\\\\\\"));
#else
ea = eina_file_split(strdup("this//is///a /more/complex///case///"));
#endif
double dresult;
double delta;
- fail_if(!eina_init());
+ fail_if(!eina_init());
fl = eina_f32p32_scale(EINA_F32P32_PI, 4);
step = eina_f32p32_div(fl, eina_f32p32_int_from(2048));
for (fc = 0; fc < fl; fc += step)
{
- fresult = eina_f32p32_cos(fc);
- dc = eina_f32p32_double_to(fc);
- dresult = cos(dc);
+ fresult = eina_f32p32_cos(fc);
+ dc = eina_f32p32_double_to(fc);
+ dresult = cos(dc);
- delta = fabs(dresult - eina_f32p32_double_to(fresult));
- fail_if(delta > 0.005);
+ delta = fabs(dresult - eina_f32p32_double_to(fresult));
+ fail_if(delta > 0.005);
}
- eina_shutdown();
+ eina_shutdown();
}
END_TEST
double dresult;
double delta;
- fail_if(!eina_init());
+ fail_if(!eina_init());
fl = eina_f32p32_scale(EINA_F32P32_PI, 4);
step = eina_f32p32_div(fl, eina_f32p32_int_from(2048));
for (fc = 0; fc < fl; fc += step)
{
- fresult = eina_f32p32_sin(fc);
- dc = eina_f32p32_double_to(fc);
- dresult = sin(dc);
+ fresult = eina_f32p32_sin(fc);
+ dc = eina_f32p32_double_to(fc);
+ dresult = sin(dc);
- delta = fabs(dresult - eina_f32p32_double_to(fresult));
- fail_if(delta > 0.005);
+ delta = fabs(dresult - eina_f32p32_double_to(fresult));
+ fail_if(delta > 0.005);
}
#include "Eina.h"
static Eina_Bool
-eina_foreach_check(__UNUSED__ const Eina_Hash *hash, const void *key, void *data, __UNUSED__ void *fdata)
+eina_foreach_check(__UNUSED__ const Eina_Hash *hash,
+ const void *key,
+ void *data,
+ __UNUSED__ void *fdata)
{
int *j = data;
int i;
- if (strlen(key) <= 0) return EINA_TRUE;
+ if (strlen(key) <= 0)
+ return EINA_TRUE;
i = atoi(key);
fail_if(i != *j);
eina_hash_free(hash);
/* Same comment as eina_init */
- fail_if(eina_shutdown() != 1);
+ fail_if(eina_shutdown() != 1);
}
END_TEST
Eina_Hash *hash = NULL;
int i;
- fail_if(eina_init() != 2);
+ fail_if(eina_init() != 2);
hash = eina_hash_string_djb2_new(NULL);
- fail_if(hash == NULL);
+ fail_if(hash == NULL);
- fail_if(eina_hash_direct_add(hash, "42", "42") != EINA_TRUE);
+ fail_if(eina_hash_direct_add(hash, "42", "42") != EINA_TRUE);
for (i = 43; i < 3043; ++i)
{
- char *tmp = malloc(10);
- fail_if(!tmp);
- eina_convert_itoa(i, tmp);
- fail_if(eina_hash_direct_add(hash, tmp, tmp) != EINA_TRUE);
+ char *tmp = malloc(10);
+ fail_if(!tmp);
+ eina_convert_itoa(i, tmp);
+ fail_if(eina_hash_direct_add(hash, tmp, tmp) != EINA_TRUE);
}
- fail_if(eina_hash_find(hash, "42") == NULL);
+ fail_if(eina_hash_find(hash, "42") == NULL);
- eina_hash_free(hash);
+ eina_hash_free(hash);
fail_if(eina_shutdown() != 1);
}
eina_hash_free(hash);
- fail_if(eina_shutdown() != 1);
+ fail_if(eina_shutdown() != 1);
}
END_TEST
int *test;
int it;
- fail_if(eina_init() != 2);
+ fail_if(eina_init() != 2);
hash = eina_hash_int32_new(NULL);
- fail_if(hash == NULL);
+ fail_if(hash == NULL);
for (it = 0; it < 4; ++it)
- fail_if(eina_hash_add(hash, &i[it], &i[it]) != EINA_TRUE);
+ fail_if(eina_hash_add(hash, &i[it], &i[it]) != EINA_TRUE);
- fail_if(eina_hash_del(hash, &i[1], &i[1]) != EINA_TRUE);
+ fail_if(eina_hash_del(hash, &i[1], &i[1]) != EINA_TRUE);
test = eina_hash_find(hash, &i[2]);
- fail_if(test != &i[2]);
+ fail_if(test != &i[2]);
test = eina_hash_find(hash, &i[3]);
- fail_if(test != &i[3]);
+ fail_if(test != &i[3]);
- eina_hash_free(hash);
+ eina_hash_free(hash);
hash = eina_hash_int64_new(NULL);
- fail_if(hash == NULL);
+ fail_if(hash == NULL);
for (it = 0; it < 4; ++it)
- fail_if(eina_hash_add(hash, &j[it], &j[it]) != EINA_TRUE);
+ fail_if(eina_hash_add(hash, &j[it], &j[it]) != EINA_TRUE);
- fail_if(eina_hash_del(hash, &j[1], &j[1]) != EINA_TRUE);
+ fail_if(eina_hash_del(hash, &j[1], &j[1]) != EINA_TRUE);
test2 = eina_hash_find(hash, &j[0]);
- fail_if(test2 != &j[0]);
+ fail_if(test2 != &j[0]);
- eina_hash_free(hash);
+ eina_hash_free(hash);
fail_if(eina_shutdown() != 1);
}
EINA_INLIST;
};
-static Eina_Test_Inlist*
+static Eina_Test_Inlist *
_eina_test_inlist_build(int i)
{
Eina_Test_Inlist *tmp;
prev = tmp;
tmp = _eina_test_inlist_build(3227);
- lst = eina_inlist_prepend_relative(lst, EINA_INLIST_GET(tmp), EINA_INLIST_GET(prev));
+ lst = eina_inlist_prepend_relative(lst, EINA_INLIST_GET(
+ tmp), EINA_INLIST_GET(prev));
fail_if(!lst);
fail_if(EINA_INLIST_CONTAINER_GET(lst, Eina_Test_Inlist)->i != 42);
lst = eina_inlist_append_relative(lst, EINA_INLIST_GET(tmp), NULL);
EINA_INLIST_FOREACH(lst, tmp)
- {
- switch (i)
- {
- case 0: fail_if(tmp->i != 27); break;
- case 1: fail_if(tmp->i != 3227); break;
- case 2: fail_if(tmp->i != 42); break;
- case 3: fail_if(tmp->i != 1664); break;
- case 4: fail_if(tmp->i != 81); break;
- }
-
- ++i;
- }
+ {
+ switch (i)
+ {
+ case 0: fail_if(tmp->i != 27); break;
+
+ case 1: fail_if(tmp->i != 3227); break;
+
+ case 2: fail_if(tmp->i != 42); break;
+
+ case 3: fail_if(tmp->i != 1664); break;
+
+ case 4: fail_if(tmp->i != 81); break;
+ }
+
+ ++i;
+ }
#ifdef EINA_SAFETY_CHECKS
fprintf(stderr, "you should have a safety check failure below:\n");
fail_if(eina_error_get() != EINA_ERROR_SAFETY_FAILED);
}
- fprintf(stderr, "you should have a safety check failure below:\n");
+ fprintf(stderr, "you should have a safety check failure below:\n");
lst = eina_inlist_remove(lst, NULL);
fail_if(eina_error_get() != EINA_ERROR_SAFETY_FAILED);
#endif
lst = eina_inlist_promote(lst, EINA_INLIST_GET(tmp));
fail_if(lst != EINA_INLIST_GET(tmp));
- tmp = EINA_INLIST_CONTAINER_GET(eina_inlist_find(lst, EINA_INLIST_GET(prev)), Eina_Test_Inlist);
+ tmp = EINA_INLIST_CONTAINER_GET(eina_inlist_find(lst, EINA_INLIST_GET(
+ prev)), Eina_Test_Inlist);
lst = eina_inlist_remove(lst, EINA_INLIST_GET(tmp));
prev = (Eina_Test_Inlist *)eina_inlist_find(lst, EINA_INLIST_GET(tmp));
tmp = prev ? EINA_INLIST_CONTAINER_GET(prev, Eina_Test_Inlist) : NULL;
fail_if(tmp != NULL);
while (lst)
- lst = eina_inlist_remove(lst, lst);
+ lst = eina_inlist_remove(lst, lst);
}
END_TEST
static Eina_Bool
eina_iterator_array_check(__UNUSED__ const Eina_Array *array,
- int *data, int *fdata)
+ int *data, int *fdata)
{
fail_if(*fdata > *data);
*fdata = *data;
eina_init();
ea = eina_array_new(11);
- fail_if(!ea);
+ fail_if(!ea);
for (i = 0; i < 200; ++i)
{
- tmp = malloc(sizeof(int));
- fail_if(!tmp);
- *tmp = i;
+ tmp = malloc(sizeof(int));
+ fail_if(!tmp);
+ *tmp = i;
- eina_array_push(ea, tmp);
+ eina_array_push(ea, tmp);
}
it = eina_array_iterator_new(ea);
fail_if(i != 199);
fail_if(eina_iterator_container_get(it) != ea);
- fail_if(eina_iterator_next(it, (void**) &tmp) != EINA_FALSE);
+ fail_if(eina_iterator_next(it, (void **)&tmp) != EINA_FALSE);
eina_iterator_free(it);
END_TEST
static Eina_Bool
-eina_iterator_hash_key_check(const Eina_Hash *hash, const char *key, __UNUSED__ void *fdata)
+eina_iterator_hash_key_check(const Eina_Hash *hash,
+ const char *key,
+ __UNUSED__ void *fdata)
{
fail_if(eina_hash_find(hash, key) == NULL);
return EINA_TRUE;
}
static Eina_Bool
-eina_iterator_hash_data_check(const Eina_Hash *hash, int *data, __UNUSED__ void *fdata)
+eina_iterator_hash_data_check(const Eina_Hash *hash,
+ int *data,
+ __UNUSED__ void *fdata)
{
char tmp[10];
return EINA_TRUE;
}
static Eina_Bool
-eina_iterator_hash_tuple_check(__UNUSED__ const Eina_Hash *hash, Eina_Hash_Tuple *tuple, __UNUSED__ void *fdata)
+eina_iterator_hash_tuple_check(__UNUSED__ const Eina_Hash *hash,
+ Eina_Hash_Tuple *tuple,
+ __UNUSED__ void *fdata)
{
- fail_if(atoi((char*) tuple->key) != *((int*) tuple->data));
+ fail_if(atoi((char *)tuple->key) != *((int *)tuple->data));
return EINA_TRUE;
}
int i;
};
-static Eina_Test_Inlist*
+static Eina_Test_Inlist *
_eina_test_inlist_build(int i)
{
Eina_Test_Inlist *tmp;
}
static Eina_Bool
-eina_iterator_inlist_data_check(__UNUSED__ const Eina_Inlist *in_list, Eina_Test_Inlist *data, int *fdata)
+eina_iterator_inlist_data_check(__UNUSED__ const Eina_Inlist *in_list,
+ Eina_Test_Inlist *data,
+ int *fdata)
{
switch (*fdata)
{
case 0: fail_if(data->i != 27); break;
+
case 1: fail_if(data->i != 42); break;
+
case 2: fail_if(data->i != 3227); break;
+
case 3: fail_if(data->i != 1664); break;
+
case 4: fail_if(data->i != 81); break;
}
tmp = _eina_test_inlist_build(1664);
lst = eina_inlist_append_relative(lst, EINA_INLIST_GET(tmp), lst);
fail_if(!lst);
- fail_if(((Eina_Test_Inlist*)lst)->i != 42);
+ fail_if(((Eina_Test_Inlist *)lst)->i != 42);
prev = tmp;
tmp = _eina_test_inlist_build(3227);
- lst = eina_inlist_prepend_relative(lst, EINA_INLIST_GET(tmp), EINA_INLIST_GET(prev));
+ lst = eina_inlist_prepend_relative(lst, EINA_INLIST_GET(
+ tmp), EINA_INLIST_GET(prev));
fail_if(!lst);
- fail_if(((Eina_Test_Inlist*)lst)->i != 42);
+ fail_if(((Eina_Test_Inlist *)lst)->i != 42);
tmp = _eina_test_inlist_build(27);
lst = eina_inlist_prepend_relative(lst, EINA_INLIST_GET(tmp), NULL);
END_TEST
static Eina_Bool
-eina_iterator_list_data_check(__UNUSED__ const Eina_List *list, int *data, int *fdata)
+eina_iterator_list_data_check(__UNUSED__ const Eina_List *list,
+ int *data,
+ int *fdata)
{
switch (*fdata)
{
case 0: fail_if(*data != 81); break;
+
case 1: fail_if(*data != 7); break;
+
case 2: fail_if(*data != 9); break;
+
case 3: fail_if(*data != 6); break;
+
case 4: fail_if(*data != 42); break;
+
case 5: fail_if(*data != 1); break;
+
case 6: fail_if(*data != 1337); break;
}
fail_if(!left);
fail_if(!right);
- if (left->value < right->value) return EINA_RBTREE_LEFT;
+ if (left->value < right->value)
+ return EINA_RBTREE_LEFT;
+
return EINA_RBTREE_RIGHT;
}
}
static Eina_Bool
-eina_iterator_rbtree_data_check_sorted(__UNUSED__ const Eina_List *list, Eina_Rbtree_Int *data, int *fdata)
+eina_iterator_rbtree_data_check_sorted(__UNUSED__ const Eina_List *list,
+ Eina_Rbtree_Int *data,
+ int *fdata)
{
switch (*fdata)
{
case 0: fail_if(data->value != 10); break;
+
case 1: fail_if(data->value != 27); break;
+
case 2: fail_if(data->value != 42); break;
+
case 3: fail_if(data->value != 69); break;
+
case 4: fail_if(data->value != 1337); break;
}
}
static Eina_Bool
-eina_iterator_rbtree_data_check_prefix(__UNUSED__ const Eina_List *list, Eina_Rbtree_Int *data, int *fdata)
+eina_iterator_rbtree_data_check_prefix(__UNUSED__ const Eina_List *list,
+ Eina_Rbtree_Int *data,
+ int *fdata)
{
switch (*fdata)
{
case 0: fail_if(data->value != 27); break;
+
case 1: fail_if(data->value != 10); break;
+
case 2: fail_if(data->value != 69); break;
+
case 3: fail_if(data->value != 42); break;
+
case 4: fail_if(data->value != 1337); break;
}
}
static Eina_Bool
-eina_iterator_rbtree_data_check_postfix(__UNUSED__ const Eina_List *list, Eina_Rbtree_Int *data, int *fdata)
+eina_iterator_rbtree_data_check_postfix(__UNUSED__ const Eina_List *list,
+ Eina_Rbtree_Int *data,
+ int *fdata)
{
switch (*fdata)
{
case 0: fail_if(data->value != 10); break;
+
case 1: fail_if(data->value != 42); break;
+
case 2: fail_if(data->value != 1337); break;
+
case 3: fail_if(data->value != 69); break;
+
case 4: fail_if(data->value != 27); break;
}
Eina_Iterator *it;
int i;
- root = eina_rbtree_inline_insert(NULL, _eina_rbtree_int_new(10), EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp), NULL);
+ root = eina_rbtree_inline_insert(NULL, _eina_rbtree_int_new(
+ 10),
+ EINA_RBTREE_CMP_NODE_CB(
+ eina_rbtree_int_cmp), NULL);
fail_if(!root);
- root = eina_rbtree_inline_insert(root, _eina_rbtree_int_new(1337), EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp), NULL);
+ root = eina_rbtree_inline_insert(root, _eina_rbtree_int_new(
+ 1337),
+ EINA_RBTREE_CMP_NODE_CB(
+ eina_rbtree_int_cmp), NULL);
fail_if(!root);
- root = eina_rbtree_inline_insert(root, _eina_rbtree_int_new(27), EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp), NULL);
+ root = eina_rbtree_inline_insert(root, _eina_rbtree_int_new(
+ 27),
+ EINA_RBTREE_CMP_NODE_CB(
+ eina_rbtree_int_cmp), NULL);
fail_if(!root);
- root = eina_rbtree_inline_insert(root, _eina_rbtree_int_new(69), EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp), NULL);
+ root = eina_rbtree_inline_insert(root, _eina_rbtree_int_new(
+ 69),
+ EINA_RBTREE_CMP_NODE_CB(
+ eina_rbtree_int_cmp), NULL);
fail_if(!root);
- root = eina_rbtree_inline_insert(root, _eina_rbtree_int_new(42), EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp), NULL);
+ root = eina_rbtree_inline_insert(root, _eina_rbtree_int_new(
+ 42),
+ EINA_RBTREE_CMP_NODE_CB(
+ eina_rbtree_int_cmp), NULL);
fail_if(!root);
i = 0;
it = eina_rbtree_iterator_prefix(root);
fail_if(!it);
- eina_iterator_foreach(it, EINA_EACH(eina_iterator_rbtree_data_check_prefix), &i);
+ eina_iterator_foreach(it, EINA_EACH(
+ eina_iterator_rbtree_data_check_prefix), &i);
eina_iterator_free(it);
/* This will return the item sorted. */
it = eina_rbtree_iterator_infix(root);
fail_if(!it);
- eina_iterator_foreach(it, EINA_EACH(eina_iterator_rbtree_data_check_sorted), &i);
+ eina_iterator_foreach(it, EINA_EACH(
+ eina_iterator_rbtree_data_check_sorted), &i);
eina_iterator_free(it);
i = 0;
it = eina_rbtree_iterator_postfix(root);
fail_if(!it);
- eina_iterator_foreach(it, EINA_EACH(eina_iterator_rbtree_data_check_postfix), &i);
+ eina_iterator_foreach(it, EINA_EACH(
+ eina_iterator_rbtree_data_check_postfix), &i);
eina_iterator_free(it);
}
END_TEST
static Eina_Bool
_test_alloc(Eina_Lazy_Allocator_Test *elat, int num)
{
- if (elat->num == 10 && num == 1) return EINA_FALSE;
- if (elat->num == 122 && num == 128) return EINA_FALSE;
+ if (elat->num == 10 && num == 1)
+ return EINA_FALSE;
+
+ if (elat->num == 122 && num == 128)
+ return EINA_FALSE;
elat->num += num;
elat->data = realloc(elat->data, elat->num);
int i;
elat = calloc(1, sizeof (Eina_Lazy_Allocator_Test));
- fail_if(!elat);
+ fail_if(!elat);
- test = eina_lalloc_new(elat, EINA_LALLOC_ALLOC(_test_alloc), EINA_LALLOC_FREE(_test_free), 10);
- fail_if(!test);
+ test = eina_lalloc_new(elat, EINA_LALLOC_ALLOC(
+ _test_alloc), EINA_LALLOC_FREE(_test_free), 10);
+ fail_if(!test);
for (i = 0; i < 10; ++i)
- fail_if(eina_lalloc_element_add(test) != EINA_TRUE);
- fail_if(eina_lalloc_element_add(test) != EINA_FALSE);
- fail_if(eina_lalloc_elements_add(test, 5) != EINA_TRUE);
+ fail_if(eina_lalloc_element_add(test) != EINA_TRUE);
+ fail_if(eina_lalloc_element_add(test) != EINA_FALSE);
+ fail_if(eina_lalloc_elements_add(test, 5) != EINA_TRUE);
for (i = 0; i < 21; ++i)
- fail_if(eina_lalloc_element_add(test) != EINA_TRUE);
+ fail_if(eina_lalloc_element_add(test) != EINA_TRUE);
- fail_if(eina_lalloc_elements_add(test, 50) != EINA_FALSE);
+ fail_if(eina_lalloc_elements_add(test, 50) != EINA_FALSE);
- eina_lalloc_free(test);
+ eina_lalloc_free(test);
}
END_TEST
int last = *(int *)list->data;
EINA_LIST_FOREACH(list->next, n, d)
- {
- int current = *(int *)d;
- if (last > current)
- {
- fprintf(stderr, "list is not sorted: last=%d, current=%d\n",
- last, current);
- return 0;
- }
- last = current;
- }
+ {
+ int current = *(int *)d;
+ if (last > current)
+ {
+ fprintf(stderr, "list is not sorted: last=%d, current=%d\n",
+ last, current);
+ return 0;
+ }
+
+ last = current;
+ }
return 1;
}
eina_init();
list = eina_list_append(list, &data[0]);
- fail_if(list == NULL);
+ fail_if(list == NULL);
list = eina_list_prepend(list, &data[1]);
- fail_if(list == NULL);
+ fail_if(list == NULL);
list = eina_list_append(list, &data[2]);
- fail_if(list == NULL);
+ fail_if(list == NULL);
list = eina_list_remove(list, &data[0]);
- fail_if(list == NULL);
+ fail_if(list == NULL);
list = eina_list_remove(list, &data[0]);
- fail_if(list == NULL);
+ fail_if(list == NULL);
tmp = eina_list_data_find_list(list, &data[2]);
- fail_if(tmp == NULL);
+ fail_if(tmp == NULL);
list = eina_list_append_relative_list(list, &data[3], tmp);
- fail_if(list == NULL);
+ fail_if(list == NULL);
list = eina_list_prepend_relative_list(list, &data[4], tmp);
- fail_if(list == NULL);
+ fail_if(list == NULL);
list = eina_list_promote_list(list, tmp);
- fail_if(list == NULL);
+ fail_if(list == NULL);
list = eina_list_append_relative(list, &data[5], &data[2]);
- fail_if(list == NULL);
+ fail_if(list == NULL);
list = eina_list_prepend_relative(list, &data[6], &data[2]);
- fail_if(list == NULL);
+ fail_if(list == NULL);
list = eina_list_remove_list(list, tmp);
- fail_if(list == NULL);
+ fail_if(list == NULL);
- fail_if(eina_list_data_find_list(list, &data[2]) != NULL);
- fail_if(eina_list_data_find(list, &data[2]) != NULL);
- fail_if(eina_list_data_find(list, &data[5]) != &data[5]);
+ fail_if(eina_list_data_find_list(list, &data[2]) != NULL);
+ fail_if(eina_list_data_find(list, &data[2]) != NULL);
+ fail_if(eina_list_data_find(list, &data[5]) != &data[5]);
- fail_if(eina_list_count(list) != 5);
- fail_if(eina_list_nth(list, 4) != &data[3]);
- fail_if(eina_list_nth(list, 10) != NULL);
- fail_if(eina_list_nth_list(list, 10) != NULL);
+ fail_if(eina_list_count(list) != 5);
+ fail_if(eina_list_nth(list, 4) != &data[3]);
+ fail_if(eina_list_nth(list, 10) != NULL);
+ fail_if(eina_list_nth_list(list, 10) != NULL);
for (tmp = list, i = 0; tmp != NULL; tmp = eina_list_next(tmp), ++i)
{
- int *d = eina_list_data_get(tmp);
- fail_if(d == NULL);
- fail_if(*d != result[i]);
+ int *d = eina_list_data_get(tmp);
+ fail_if(d == NULL);
+ fail_if(*d != result[i]);
}
list = eina_list_reverse(list);
for (tmp = list; tmp != NULL; tmp = eina_list_next(tmp), --i)
{
- int *d = eina_list_data_get(tmp);
- fail_if(d == NULL);
- fail_if(*d != result[i - 1]);
+ int *d = eina_list_data_get(tmp);
+ fail_if(d == NULL);
+ fail_if(*d != result[i - 1]);
}
list = eina_list_append_relative(list, &data[7], &data[7]);
- fail_if(list == NULL);
+ fail_if(list == NULL);
list = eina_list_prepend_relative(list, &data[8], &data[8]);
- fail_if(list == NULL);
+ fail_if(list == NULL);
list = eina_list_sort(list, 2, eina_int_cmp);
test2 = eina_list_nth(list, 1);
test3 = eina_list_nth(list, 2);
- fail_if(test1 == NULL || test2 == NULL || test3 == NULL);
- fail_if(*test1 > *test2);
- fail_if(*test3 == *test2);
+ fail_if(test1 == NULL || test2 == NULL || test3 == NULL);
+ fail_if(*test1 > *test2);
+ fail_if(*test3 == *test2);
list = eina_list_sort(list, 5, eina_int_cmp);
test2 = eina_list_nth(list, 4);
test3 = eina_list_nth(list, 5);
- fail_if(test1 == NULL || test2 == NULL || test3 == NULL);
- fail_if(*test1 > *test2);
- fail_if(*test3 > *test2);
+ fail_if(test1 == NULL || test2 == NULL || test3 == NULL);
+ fail_if(*test1 > *test2);
+ fail_if(*test3 > *test2);
list = eina_list_append(list, &data[8]);
- fail_if(list == NULL);
+ fail_if(list == NULL);
list = eina_list_append(list, &data[7]);
- fail_if(list == NULL);
+ fail_if(list == NULL);
list = eina_list_sort(list, -1, eina_int_cmp);
test1 = eina_list_nth(list, 0);
for (tmp = list; tmp != NULL; tmp = eina_list_next(tmp))
{
- int *d = eina_list_data_get(tmp);
- fail_if(*test1 > *d);
+ int *d = eina_list_data_get(tmp);
+ fail_if(*test1 > *d);
- test1 = d;
+ test1 = d;
}
test3 = eina_list_nth(list, 5);
- fail_if(test3 == NULL);
+ fail_if(test3 == NULL);
list = eina_list_promote_list(list, list);
- fail_if(list == NULL);
+ fail_if(list == NULL);
list = eina_list_promote_list(list, eina_list_last(list));
- fail_if(list == NULL);
+ fail_if(list == NULL);
test1 = eina_list_nth(list, 0);
test2 = eina_list_nth(list, 1);
list = eina_list_promote_list(eina_list_next(list), list);
- fail_if(list == NULL);
- fail_if(eina_list_data_get(list) != test1);
- fail_if(eina_list_data_get(eina_list_next(list)) != test2);
+ fail_if(list == NULL);
+ fail_if(eina_list_data_get(list) != test1);
+ fail_if(eina_list_data_get(eina_list_next(list)) != test2);
list = eina_list_remove_list(list, list);
- fail_if(list == NULL);
+ fail_if(list == NULL);
list = eina_list_remove_list(list, eina_list_last(list));
- fail_if(list == NULL);
+ fail_if(list == NULL);
list = eina_list_free(list);
- fail_if(list != NULL);
+ fail_if(list != NULL);
- eina_shutdown();
+ eina_shutdown();
}
END_TEST
l1 = eina_list_append(l1, &data[1]);
l1 = eina_list_append(l1, &data[2]);
l1 = eina_list_append(l1, &data[3]);
- fail_if(l1 == NULL);
+ fail_if(l1 == NULL);
l2 = eina_list_append(NULL, &data[4]);
l2 = eina_list_append(l2, &data[5]);
- fail_if(l2 == NULL);
+ fail_if(l2 == NULL);
l1 = eina_list_merge(l1, l2);
- fail_if(l1 == NULL);
- fail_if(eina_list_count(l1) != 6);
+ fail_if(l1 == NULL);
+ fail_if(eina_list_count(l1) != 6);
for (i = 0, l2 = l1; ((l2 != NULL) && (i < 6)); ++i, l2 = l2->next)
- fail_if(l2->data != &data[i]);
- fail_if(i != 6);
- fail_if(l2 != NULL);
+ fail_if(l2->data != &data[i]);
+ fail_if(i != 6);
+ fail_if(l2 != NULL);
- eina_list_free(l1);
+ eina_list_free(l1);
l1 = eina_list_append(NULL, &data[0]);
l1 = eina_list_append(l1, &data[1]);
- fail_if(l1 == NULL);
+ fail_if(l1 == NULL);
l2 = eina_list_append(NULL, &data[2]);
l2 = eina_list_append(l2, &data[3]);
l2 = eina_list_append(l2, &data[4]);
l2 = eina_list_append(l2, &data[5]);
- fail_if(l2 == NULL);
+ fail_if(l2 == NULL);
l1 = eina_list_merge(l1, l2);
- fail_if(l1 == NULL);
- fail_if(eina_list_count(l1) != 6);
+ fail_if(l1 == NULL);
+ fail_if(eina_list_count(l1) != 6);
for (i = 0, l2 = l1; ((l2 != NULL) && (i < 6)); ++i, l2 = l2->next)
- fail_if(l2->data != &data[i]);
- fail_if(i != 6);
- fail_if(l2 != NULL);
+ fail_if(l2->data != &data[i]);
+ fail_if(i != 6);
+ fail_if(l2 != NULL);
l3 = eina_list_append(NULL, &data[6]);
l3 = eina_list_append(l3, &data[7]);
l5 = eina_list_sort(l5, -1, eina_int_cmp);
l1 = eina_list_sorted_merge(l1, l3, eina_int_cmp);
- fail_if(l1 == NULL);
- fail_if(eina_list_count(l1) != 9);
+ fail_if(l1 == NULL);
+ fail_if(eina_list_count(l1) != 9);
l1 = eina_list_sorted_merge(l1, l4, eina_int_cmp);
- fail_if(l1 == NULL);
- fail_if(eina_list_count(l1) != 12);
+ fail_if(l1 == NULL);
+ fail_if(eina_list_count(l1) != 12);
l1 = eina_list_sorted_merge(l1, l5, eina_int_cmp);
- fail_if(l1 == NULL);
- fail_if(eina_list_count(l1) != 15);
+ fail_if(l1 == NULL);
+ fail_if(eina_list_count(l1) != 15);
- fail_if(!eina_list_sorted_check(l1));
+ fail_if(!eina_list_sorted_check(l1));
- eina_shutdown();
+ eina_shutdown();
}
END_TEST
eina_init();
- count = sizeof(data)/sizeof(data[0]);
+ count = sizeof(data) / sizeof(data[0]);
l1 = NULL;
for (i = 0; i < count; i++)
- l1 = eina_list_sorted_insert(l1, eina_int_cmp, data + i);
+ l1 = eina_list_sorted_insert(l1, eina_int_cmp, data + i);
fail_if(l1 == NULL);
fail_if(!eina_list_sorted_check(l1));
l2 = NULL;
EINA_LIST_FOREACH(l1, itr, d)
- l2 = eina_list_sorted_insert(l2, eina_int_cmp, d);
+ l2 = eina_list_sorted_insert(l2, eina_int_cmp, d);
fail_if(l2 == NULL);
fail_if(!eina_list_sorted_check(l2));
l2 = NULL;
EINA_LIST_REVERSE_FOREACH(l1, itr, d)
- l2 = eina_list_sorted_insert(l2, eina_int_cmp, d);
+ l2 = eina_list_sorted_insert(l2, eina_int_cmp, d);
fail_if(l2 == NULL);
fail_if(!eina_list_sorted_check(l2));
eina_list_free(l2);
eina_list_free(l1);
- count = sizeof(data2)/sizeof(data2[0]);
+ count = sizeof(data2) / sizeof(data2[0]);
l1 = NULL;
for (i = 0; i < count; i++)
- l1 = eina_list_sorted_insert(l1, eina_int_cmp, data2 + i);
+ l1 = eina_list_sorted_insert(l1, eina_int_cmp, data2 + i);
fail_if(l1 == NULL);
fail_if(!eina_list_sorted_check(l1));
#include "eina_suite.h"
#include "Eina.h"
-START_TEST(eina_log_macro)
+ START_TEST(eina_log_macro)
{
fail_if(!eina_init());
START_TEST(eina_log_domains_registry)
{
- fail_if(!eina_init());
+ fail_if(!eina_init());
int i;
int d[50];
for (i = 0; i < 50; i++)
{
- d[i] = eina_log_domain_register("Test", EINA_COLOR_GREEN);
- fail_if(d[i] < 0);
+ d[i] = eina_log_domain_register("Test", EINA_COLOR_GREEN);
+ fail_if(d[i] < 0);
}
for (i = 0; i < 50; i++)
START_TEST(eina_log_domains_slot_reuse)
{
- fail_if(!eina_init());
- fail_if(!eina_threads_init());
+ fail_if(!eina_init());
+ fail_if(!eina_threads_init());
// Create 9 domains
int idx[9];
for (i = 0; i < 9; i++)
{
- idx[i] = eina_log_domain_register("Test1", EINA_COLOR_GREEN);
- fail_if(idx[i] < 0);
+ idx[i] = eina_log_domain_register("Test1", EINA_COLOR_GREEN);
+ fail_if(idx[i] < 0);
}
// Slot 0 by default contains the global logger. The above code created
EINA_LOG(d, -1, "Negative index message\n");
// Displayed only if user sets level 6 or higher
- EINA_LOG(d, 6, "Higher level debug\n");
+ EINA_LOG(d, 6, "Higher level debug\n");
eina_threads_shutdown();
eina_threads_shutdown();
fail_if(!eina_init());
-#define test_set_get(func, val) \
- eina_log_##func##_set(val); \
- fail_if(eina_log_##func##_get() != val)
+#define test_set_get(func, val) \
+ eina_log_ ## func ## _set(val); \
+ fail_if(eina_log_ ## func ## _get() != val)
test_set_get(level, -1234);
test_set_get(level, 4567);
-#define test_set_get_bool(func) \
- test_set_get(func, EINA_FALSE); \
- test_set_get(func, EINA_TRUE)
+#define test_set_get_bool(func) \
+ test_set_get(func, EINA_FALSE); \
+ test_set_get(func, EINA_TRUE)
test_set_get_bool(color_disable);
test_set_get_bool(file_disable);
eina_log_domain_unregister(d);
fputs("NOTE: You should see a failed safety check or "
- "a crash if compiled without safety checks support.\n",
- stderr);
+ "a crash if compiled without safety checks support.\n",
+ stderr);
eina_log_abort_on_critical_set(EINA_FALSE);
fail_if(eina_log_domain_registered_level_get(d) != EINA_LOG_LEVEL_UNKNOWN);
fail_if(!eina_init());
-#define tst(level, str) \
- eina_log_level_name_get(level, name); \
+#define tst(level, str) \
+ eina_log_level_name_get(level, name); \
fail_if(strcmp(name, str) != 0)
- tst(0, "CRI");
- tst(1, "ERR");
- tst(2, "WRN");
- tst(3, "INF");
- tst(4, "DBG");
- tst(5, "005");
- tst(12, "012");
+ tst(0, "CRI");
+ tst(1, "ERR");
+ tst(2, "WRN");
+ tst(3, "INF");
+ tst(4, "DBG");
+ tst(5, "005");
+ tst(12, "012");
tst(369, "369");
- tst(-1, "-01");
+ tst(-1, "-01");
tst(-48, "-48");
#undef tst
eina_magic_string_set(EINA_MAGIC_TEST2, EINA_MAGIC_STRING);
fail_if(eina_magic_string_get(EINA_MAGIC_TEST) == NULL);
- fail_if(strcmp(eina_magic_string_get(EINA_MAGIC_TEST), EINA_MAGIC_STRING) != 0);
+ fail_if(strcmp(eina_magic_string_get(
+ EINA_MAGIC_TEST), EINA_MAGIC_STRING) != 0);
#ifdef EINA_MAGIC_DEBUG
fail_if(EINA_MAGIC_CHECK(ems, EINA_MAGIC_TEST));
fail_if(!EINA_MAGIC_CHECK(ems, EINA_MAGIC_TEST));
EINA_MAGIC_SET(ems, EINA_MAGIC_NONE);
- fprintf(stderr, "you should see 'Input handle has already been freed' below\n");
+ fprintf(stderr,
+ "you should see 'Input handle has already been freed' below\n");
EINA_MAGIC_FAIL(ems, EINA_MAGIC_TEST);
EINA_MAGIC_SET(ems, 42424242);
#include "eina_suite.h"
#include "Eina.h"
-START_TEST(eina_simple)
+ START_TEST(eina_simple)
{
fail_if(eina_init() != 2); /* one init by test suite */
fail_if(eina_shutdown() != 1);
#define MAX_ROWS 10
#define MAX_COLS 10
-static void eina_matrixsparse_free_cell_cb(void *user_data __UNUSED__, void *cell_data __UNUSED__)
+static void eina_matrixsparse_free_cell_cb(void *user_data __UNUSED__,
+ void *cell_data __UNUSED__)
{
}
-static void matrixsparse_initialize(Eina_Matrixsparse *matrix, long data[MAX_ROWS][MAX_COLS], unsigned long nrows, unsigned long ncols)
+static void matrixsparse_initialize(Eina_Matrixsparse *matrix,
+ long data[MAX_ROWS][MAX_COLS],
+ unsigned long nrows,
+ unsigned long ncols)
{
unsigned long i, j;
Eina_Bool r;
for (i = 0; i < nrows; i++)
- for (j = 0; j < ncols; j++)
- if (data[i][j] != 0)
- {
- r = eina_matrixsparse_data_idx_set(matrix, i, j, &data[i][j]);
- fail_if(r == EINA_FALSE);
- }
+ for (j = 0; j < ncols; j++)
+ if (data[i][j] != 0)
+ {
+ r = eina_matrixsparse_data_idx_set(matrix, i, j, &data[i][j]);
+ fail_if(r == EINA_FALSE);
+ }
+
}
-static void matrixsparse_check(Eina_Matrixsparse *matrix, long data[MAX_ROWS][MAX_COLS], unsigned long nrows __UNUSED__, unsigned long ncols __UNUSED__)
+static void matrixsparse_check(Eina_Matrixsparse *matrix,
+ long data[MAX_ROWS][MAX_COLS],
+ unsigned long nrows __UNUSED__,
+ unsigned long ncols __UNUSED__)
{
unsigned long i, j;
long *test1;
for (i = 0; i < MAX_ROWS; i++)
- for (j = 0; j < MAX_COLS; j++)
- {
- if (data[i][j] != 0)
- {
- test1 = eina_matrixsparse_data_idx_get(matrix, i, j);
- fail_if(test1 == NULL || *test1 != data[i][j]);
- }
- else
- {
- test1 = eina_matrixsparse_data_idx_get(matrix, i, j);
- fail_if(test1 != NULL);
- }
- }
+ for (j = 0; j < MAX_COLS; j++)
+ {
+ if (data[i][j] != 0)
+ {
+ test1 = eina_matrixsparse_data_idx_get(matrix, i, j);
+ fail_if(test1 == NULL || *test1 != data[i][j]);
+ }
+ else
+ {
+ test1 = eina_matrixsparse_data_idx_get(matrix, i, j);
+ fail_if(test1 != NULL);
+ }
+ }
}
START_TEST(eina_test_simple)
long data[MAX_ROWS][MAX_COLS];
for (i = 0; i < MAX_ROWS; i++)
- for (j = 0; j < MAX_COLS; j++)
- data[i][j] = 0;
+ for (j = 0; j < MAX_COLS; j++)
+ data[i][j] = 0;
data[0][3] = 3;
data[1][3] = 13;
eina_init();
matrix = eina_matrixsparse_new(MAX_ROWS, MAX_COLS,
- eina_matrixsparse_free_cell_cb, data);
+ eina_matrixsparse_free_cell_cb, data);
fail_if(matrix == NULL);
r = eina_matrixsparse_cell_idx_get(matrix, 3, 5, &cell);
r = eina_matrixsparse_data_idx_set(matrix, 1, 9, &data[1][9]);
fail_if(r == EINA_FALSE);
- r = eina_matrixsparse_data_idx_replace(matrix, 4, 3, &value, (void**)&test1);
+ r = eina_matrixsparse_data_idx_replace(matrix, 4, 3, &value, (void **)&test1);
fail_if(r == EINA_FALSE);
fail_if(test1 == NULL);
fail_if(*test1 != data[4][3]);
test1 = eina_matrixsparse_data_idx_get(matrix, 4, 3);
fail_if(test1 == NULL || *test1 != value);
- r = eina_matrixsparse_cell_data_replace(cell, &value2, (void**)&test1);
+ r = eina_matrixsparse_cell_data_replace(cell, &value2, (void **)&test1);
fail_if(r == EINA_FALSE);
fail_if(test1 == NULL);
fail_if(*test1 != data[3][5]);
test1 = eina_matrixsparse_data_idx_get(matrix, 4, 2);
fail_if(test1 == NULL || *test1 != value3);
- r = eina_matrixsparse_data_idx_replace(matrix, 6, 5, &value4, (void**)&test1);
+ r = eina_matrixsparse_data_idx_replace(matrix,
+ 6,
+ 5,
+ &value4,
+ (void **)&test1);
fail_if(r == EINA_FALSE || test1 != NULL);
data[6][5] = value4;
long data[MAX_ROWS][MAX_COLS];
for (i = 0; i < MAX_ROWS; i++)
- for (j = 0; j < MAX_COLS; j++)
- data[i][j] = 0;
+ for (j = 0; j < MAX_COLS; j++)
+ data[i][j] = 0;
eina_init();
matrix = eina_matrixsparse_new(MAX_ROWS, MAX_COLS,
- eina_matrixsparse_free_cell_cb, data);
+ eina_matrixsparse_free_cell_cb, data);
fail_if(matrix == NULL);
/* cell insertion */
value = 0;
for (i = 0; i < MAX_ROWS; i++)
{
- for (j = 0; j < MAX_COLS; j++)
- {
- data[i][j] = value++;
- printf("%4ld ", data[i][j]);
- }
- printf("\n");
+ for (j = 0; j < MAX_COLS; j++)
+ {
+ data[i][j] = value++;
+ printf("%4ld ", data[i][j]);
+ }
+ printf("\n");
}
- eina_init();
+ eina_init();
matrix = eina_matrixsparse_new(MAX_ROWS, MAX_COLS,
- eina_matrixsparse_free_cell_cb, data);
+ eina_matrixsparse_free_cell_cb, data);
fail_if(matrix == NULL);
r = eina_matrixsparse_data_idx_set(matrix, 3, 5, &data[3][5]);
it = eina_matrixsparse_iterator_new(matrix);
fail_if(it == NULL);
EINA_ITERATOR_FOREACH(it, cell)
- {
- fail_if(cell == NULL);
- r = eina_matrixsparse_cell_position_get(cell, &row, &col);
- fail_if(r == EINA_FALSE);
+ {
+ fail_if(cell == NULL);
+ r = eina_matrixsparse_cell_position_get(cell, &row, &col);
+ fail_if(r == EINA_FALSE);
- test1 = eina_matrixsparse_cell_data_get(cell);
- fail_if(test1 == NULL || *test1 != data[row][col]);
- }
- eina_iterator_free(it);
+ test1 = eina_matrixsparse_cell_data_get(cell);
+ fail_if(test1 == NULL || *test1 != data[row][col]);
+ }
+ eina_iterator_free(it);
it = eina_matrixsparse_iterator_complete_new(matrix);
fail_if(it == NULL);
EINA_ITERATOR_FOREACH(it, cell)
- {
- fail_if(cell == NULL);
- r = eina_matrixsparse_cell_position_get(cell, &row, &col);
- fail_if(r == EINA_FALSE);
+ {
+ fail_if(cell == NULL);
+ r = eina_matrixsparse_cell_position_get(cell, &row, &col);
+ fail_if(r == EINA_FALSE);
- test1 = eina_matrixsparse_cell_data_get(cell);
- if (test1)
- fail_if(*test1 != data[row][col]);
- }
- eina_iterator_free(it);
+ test1 = eina_matrixsparse_cell_data_get(cell);
+ if (test1)
+ fail_if(*test1 != data[row][col]);
+ }
+ eina_iterator_free(it);
eina_matrixsparse_free(matrix);
void
eina_test_matrixsparse(TCase *tc)
{
- tcase_add_test(tc, eina_test_simple);
- tcase_add_test(tc, eina_test_resize);
- tcase_add_test(tc, eina_test_iterators);
+ tcase_add_test(tc, eina_test_simple);
+ tcase_add_test(tc, eina_test_resize);
+ tcase_add_test(tc, eina_test_iterators);
}
static void
_mempool_init(void)
{
- 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_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);
}
static void
int *tbl[512];
int i;
- fail_if(!mp);
+ fail_if(!mp);
for (i = 0; i < 512; ++i)
{
- tbl[i] = eina_mempool_malloc(mp, sizeof (int));
- fail_if(!tbl[i]);
- *tbl[i] = i;
+ tbl[i] = eina_mempool_malloc(mp, sizeof (int));
+ fail_if(!tbl[i]);
+ *tbl[i] = i;
}
for (i = 0; i < 512; ++i)
- fail_if(*tbl[i] != i);
+ fail_if(*tbl[i] != i);
for (i = 0; i < 256; ++i)
- eina_mempool_free(mp, tbl[i]);
+ eina_mempool_free(mp, tbl[i]);
if (with_realloc)
- fail_if(eina_mempool_realloc(mp, tbl[500], 25) == NULL);
+ fail_if(eina_mempool_realloc(mp, tbl[500], 25) == NULL);
else
- fail_if(eina_mempool_realloc(mp, tbl[500], 25) != NULL);
+ fail_if(eina_mempool_realloc(mp, tbl[500], 25) != NULL);
if (with_gc)
{
- eina_mempool_gc(mp);
- eina_mempool_statistics(mp);
+ eina_mempool_gc(mp);
+ eina_mempool_statistics(mp);
}
eina_mempool_del(mp);
_mempool_init();
- mp = eina_mempool_add("ememoa_unknown", "test", NULL, 0, 2, sizeof (int), 8, sizeof (int) * 2, 8);
+ mp = eina_mempool_add("ememoa_unknown",
+ "test",
+ NULL,
+ 0,
+ 2,
+ sizeof (int),
+ 8,
+ sizeof (int) * 2,
+ 8);
_eina_mempool_test(mp, EINA_TRUE, EINA_TRUE);
_mempool_shutdown();
Eina_Array *_modules;
eina_init();
- _modules = eina_module_list_get(NULL, PACKAGE_BUILD_DIR"/src/tests/", 1, &list_cb, NULL);
+ _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_Bool dummy_module_init(void)
{
- return EINA_TRUE;
+ return EINA_TRUE;
}
void dummy_module_shutdown(void)
{
-
+
}
EAPI int dummy_symbol = 0xbad;
{
const Eina_Rectangle *r = object;
- if (r->y + r->h < (int) middle)
- return EINA_QUAD_LEFT;
- if (r->y > (int) middle)
- return EINA_QUAD_RIGHT;
+ if (r->y + r->h < (int)middle)
+ return EINA_QUAD_LEFT;
+
+ if (r->y > (int)middle)
+ return EINA_QUAD_RIGHT;
+
return EINA_QUAD_BOTH;
}
{
const Eina_Rectangle *r = object;
- if (r->x + r->w < (int) middle)
- return EINA_QUAD_LEFT;
- if (r->x > (int) middle)
- return EINA_QUAD_RIGHT;
+ if (r->x + r->w < (int)middle)
+ return EINA_QUAD_LEFT;
+
+ if (r->x > (int)middle)
+ return EINA_QUAD_RIGHT;
+
return EINA_QUAD_BOTH;
}
START_TEST(eina_quadtree_collision)
{
- struct {
+ struct
+ {
Eina_Rectangle r;
Eina_QuadTree_Item *item;
} objects[] = {
- { { 10, 10, 30, 30 }, NULL },
- { { 20, 20, 30, 30 }, NULL },
- { { 5, 30, 30, 30 }, NULL },
- { { 70, 130, 100, 100 }, NULL },
- { { 10, 220, 50, 40 }, NULL },
- { { 310, 20, 50, 30 }, NULL },
- { { 300, 220, 40, 40 }, NULL },
- { { 500, 150, 40, 40 }, NULL },
- { { 500, 220, 40, 40 }, NULL },
- { { 330, 250, 40, 40 }, NULL },
- { { 300, 400, 40, 40 }, NULL },
- { { 10, 400, 40, 40 }, NULL },
- { { 0, 0, 0, 0 }, NULL }
- };
- struct {
+ { { 10, 10, 30, 30 }, NULL },
+ { { 20, 20, 30, 30 }, NULL },
+ { { 5, 30, 30, 30 }, NULL },
+ { { 70, 130, 100, 100 }, NULL },
+ { { 10, 220, 50, 40 }, NULL },
+ { { 310, 20, 50, 30 }, NULL },
+ { { 300, 220, 40, 40 }, NULL },
+ { { 500, 150, 40, 40 }, NULL },
+ { { 500, 220, 40, 40 }, NULL },
+ { { 330, 250, 40, 40 }, NULL },
+ { { 300, 400, 40, 40 }, NULL },
+ { { 10, 400, 40, 40 }, NULL },
+ { { 0, 0, 0, 0 }, NULL }
+ };
+ struct
+ {
Eina_Rectangle r;
int count;
int result[20];
} tests [] = {
- { { 600, 400, 40, 40 }, 4, { 4, 6, 8, 10 } },
- { { 20, 30, 10, 10 }, 7, { 0, 1, 2, 4, 5, 6, 8 } },
- { { 0, 0, 0, 0 }, -1, {} },
+ { { 600, 400, 40, 40 }, 4, { 4, 6, 8, 10 } },
+ { { 20, 30, 10, 10 }, 7, { 0, 1, 2, 4, 5, 6, 8 } },
+ { { 0, 0, 0, 0 }, -1, {} },
};
int hidden[] = { 4, 5, 6, 8, 10 };
int show[] = { 0, 1, 2 };
int count;
int i;
- fail_if(!eina_init());
+ fail_if(!eina_init());
q = eina_quadtree_new(640, 480,
- _eina_quadtree_rectangle_vert,
- _eina_quadtree_rectangle_hort);
+ _eina_quadtree_rectangle_vert,
+ _eina_quadtree_rectangle_hort);
- fail_if(!q);
+ fail_if(!q);
for (i = 0; objects[i].r.w != 0 && objects[i].r.h != 0; ++i)
{
- objects[i].item = eina_quadtree_add(q, &objects[i].r);
- fail_if(!objects[i].item);
- fail_if(!eina_quadtree_show(objects[i].item));
+ objects[i].item = eina_quadtree_add(q, &objects[i].r);
+ fail_if(!objects[i].item);
+ fail_if(!eina_quadtree_show(objects[i].item));
}
- eina_quadtree_resize(q, 640, 480);
+ eina_quadtree_resize(q, 640, 480);
for (i = 0; tests[i].count != -1; ++i)
{
- head = eina_quadtree_collide(q,
- tests[i].r.x, tests[i].r.y,
- tests[i].r.w, tests[i].r.h);
-
- count = 0;
- while (head)
- {
- int k;
-
- r = eina_quadtree_object(head);
-
- for (k = 0; k < tests[i].count; ++k)
- {
- if (&objects[tests[i].result[k]].r == r)
- break;
- }
- fail_if(k == tests[i].count);
-
- head = head->next;
- count++;
- }
- fail_if(count != tests[i].count);
+ head = eina_quadtree_collide(q,
+ tests[i].r.x, tests[i].r.y,
+ tests[i].r.w, tests[i].r.h);
+
+ count = 0;
+ while (head)
+ {
+ int k;
+
+ r = eina_quadtree_object(head);
+
+ for (k = 0; k < tests[i].count; ++k)
+ {
+ if (&objects[tests[i].result[k]].r == r)
+ break;
+ }
+ fail_if(k == tests[i].count);
+
+ head = head->next;
+ count++;
+ }
+ fail_if(count != tests[i].count);
}
- for (i = 0; i < (int) (sizeof (hidden) / sizeof (int)); ++i)
- eina_quadtree_hide(objects[hidden[i]].item);
- for (i = 0; i < (int) (sizeof (show) / sizeof (int)); ++i)
- eina_quadtree_show(objects[show[i]].item);
+ for (i = 0; i < (int)(sizeof (hidden) / sizeof (int)); ++i)
+ eina_quadtree_hide(objects[hidden[i]].item);
+ for (i = 0; i < (int)(sizeof (show) / sizeof (int)); ++i)
+ eina_quadtree_show(objects[show[i]].item);
head = eina_quadtree_collide(q,
- tests[1].r.x, tests[1].r.y,
- tests[1].r.w, tests[1].r.h);
+ tests[1].r.x, tests[1].r.y,
+ tests[1].r.w, tests[1].r.h);
count = 0;
while (head)
{
- r = eina_quadtree_object(head);
+ r = eina_quadtree_object(head);
- fail_if(r != &objects[tests[1].result[show[count]]].r);
+ fail_if(r != &objects[tests[1].result[show[count]]].r);
- head = head->next;
- count++;
+ head = head->next;
+ count++;
}
- fail_if(count != 3);
+ fail_if(count != 3);
- eina_quadtree_cycle(q);
+ eina_quadtree_cycle(q);
eina_quadtree_show(objects[4].item);
eina_quadtree_increase(objects[4].item);
eina_quadtree_show(objects[5].item);
eina_quadtree_resize(q, 641, 480);
head = eina_quadtree_collide(q,
- tests[0].r.x, tests[0].r.y,
- tests[0].r.w, tests[0].r.h);
+ tests[0].r.x, tests[0].r.y,
+ tests[0].r.w, tests[0].r.h);
count = 0;
while (head)
{
- r = eina_quadtree_object(head);
+ r = eina_quadtree_object(head);
- head = head->next;
- count++;
+ head = head->next;
+ count++;
}
fail_if(count != 1);
int left_height;
int right_height;
- if (!tree) return 1;
+ if (!tree)
+ return 1;
left = tree->son[EINA_RBTREE_LEFT];
right = tree->son[EINA_RBTREE_RIGHT];
/* Consecutive red links. */
- fail_if(_eina_rbtree_is_red(tree) && (_eina_rbtree_is_red(left) || _eina_rbtree_is_red(right)));
+ fail_if(_eina_rbtree_is_red(tree) &&
+ (_eina_rbtree_is_red(left) || _eina_rbtree_is_red(right)));
left_height = _eina_rbtree_black_height(left, cmp);
right_height = _eina_rbtree_black_height(right, cmp);
/* Check binary search tree. */
if (left)
{
- dir = cmp(tree, left, NULL);
- fail_if(dir != EINA_RBTREE_LEFT);
+ dir = cmp(tree, left, NULL);
+ fail_if(dir != EINA_RBTREE_LEFT);
}
if (right)
{
- dir = cmp(tree, right, NULL);
- fail_if(dir != EINA_RBTREE_RIGHT);
+ dir = cmp(tree, right, NULL);
+ fail_if(dir != EINA_RBTREE_RIGHT);
}
/* Check black height */
if (left_height != right_height)
- fprintf(stderr, "%i != %i\n", left_height, right_height);
+ fprintf(stderr, "%i != %i\n", left_height, right_height);
+
fail_if(left_height != right_height);
return _eina_rbtree_is_red(tree) ? left_height : left_height + 1;
};
static Eina_Rbtree_Direction
-eina_rbtree_int_cmp(const Eina_Rbtree_Int *left, const Eina_Rbtree_Int *right, __UNUSED__ void *data)
+eina_rbtree_int_cmp(const Eina_Rbtree_Int *left,
+ const Eina_Rbtree_Int *right,
+ __UNUSED__ void *data)
{
fail_if(!left);
fail_if(!right);
- if (left->value < right->value) return EINA_RBTREE_LEFT;
+ if (left->value < right->value)
+ return EINA_RBTREE_LEFT;
+
return EINA_RBTREE_RIGHT;
}
static int
-eina_rbtree_int_key(const Eina_Rbtree_Int *node, const int *key, __UNUSED__ int length, __UNUSED__ void *data)
+eina_rbtree_int_key(const Eina_Rbtree_Int *node,
+ const int *key,
+ __UNUSED__ int length,
+ __UNUSED__ void *data)
{
fail_if(!node);
return node->value - *key;
for (i = 0; i < 500; ++i)
{
- item = _eina_rbtree_int_new(rand());
- root = (Eina_Rbtree_Int*) eina_rbtree_inline_insert(&root->node, &item->node, EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp), NULL);
+ item = _eina_rbtree_int_new(rand());
+ root = (Eina_Rbtree_Int *)eina_rbtree_inline_insert(
+ &root->node,
+ &item->node,
+ EINA_RBTREE_CMP_NODE_CB(
+ eina_rbtree_int_cmp),
+ NULL);
}
- _eina_rbtree_black_height(&root->node, EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp));
+ _eina_rbtree_black_height(&root->node,
+ EINA_RBTREE_CMP_NODE_CB(
+ eina_rbtree_int_cmp));
}
END_TEST
for (i = 0; i < sizeof (list) / sizeof (int); ++i)
{
- item = _eina_rbtree_int_new(list[i]);
- root = (Eina_Rbtree_Int*) eina_rbtree_inline_insert(&root->node, &item->node, EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp), NULL);
+ item = _eina_rbtree_int_new(list[i]);
+ root = (Eina_Rbtree_Int *)eina_rbtree_inline_insert(
+ &root->node,
+ &item->node,
+ EINA_RBTREE_CMP_NODE_CB(
+ eina_rbtree_int_cmp),
+ NULL);
}
- item = (Eina_Rbtree_Int*) eina_rbtree_inline_lookup(&root->node, &list[0], sizeof(int), EINA_RBTREE_CMP_KEY_CB(eina_rbtree_int_key), NULL);
+ item = (Eina_Rbtree_Int *)eina_rbtree_inline_lookup(&root->node,
+ &list[0],
+ sizeof(int),
+ EINA_RBTREE_CMP_KEY_CB(
+ eina_rbtree_int_key),
+ NULL);
fail_if(!item);
i = 42;
- item = (Eina_Rbtree_Int*) eina_rbtree_inline_lookup(&root->node, &i, sizeof(int), EINA_RBTREE_CMP_KEY_CB(eina_rbtree_int_key), NULL);
+ item =
+ (Eina_Rbtree_Int *)eina_rbtree_inline_lookup(&root->node,
+ &i,
+ sizeof(int),
+ EINA_RBTREE_CMP_KEY_CB(
+ eina_rbtree_int_key),
+ NULL);
fail_if(item);
}
END_TEST
eina_init();
- ea = eina_array_new(11);
+ ea = eina_array_new(11);
fail_if(!ea);
srand(time(NULL));
for (i = 0; i < 500; ++i)
{
- item = _eina_rbtree_int_new(rand());
- eina_array_push(ea, item);
- root = (Eina_Rbtree_Int*) eina_rbtree_inline_insert(&root->node, &item->node, EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp), NULL);
+ item = _eina_rbtree_int_new(rand());
+ eina_array_push(ea, item);
+ root = (Eina_Rbtree_Int *)eina_rbtree_inline_insert(
+ &root->node,
+ &item->node,
+ EINA_RBTREE_CMP_NODE_CB(
+ eina_rbtree_int_cmp),
+ NULL);
}
- _eina_rbtree_black_height(&root->node, EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp));
+ _eina_rbtree_black_height(&root->node,
+ EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp));
EINA_ARRAY_ITER_NEXT(ea, i, item, it)
- {
- root = (Eina_Rbtree_Int*) eina_rbtree_inline_remove(&root->node, &item->node, EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp), NULL);
- _eina_rbtree_black_height(&root->node, EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp));
- }
+ {
+ root = (Eina_Rbtree_Int *)eina_rbtree_inline_remove(
+ &root->node,
+ &item->node,
+ EINA_RBTREE_CMP_NODE_CB(
+ eina_rbtree_int_cmp),
+ NULL);
+ _eina_rbtree_black_height(&root->node,
+ EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp));
+ }
fail_if(root != NULL);
Eina_Rbtree *lookup;
int i;
- root = eina_rbtree_inline_insert(root, (Eina_Rbtree*) _eina_rbtree_int_new(10), EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp), NULL);
- root = eina_rbtree_inline_insert(root, (Eina_Rbtree*) _eina_rbtree_int_new(42), EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp), NULL);
- root = eina_rbtree_inline_insert(root, (Eina_Rbtree*) _eina_rbtree_int_new(69), EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp), NULL);
- root = eina_rbtree_inline_insert(root, (Eina_Rbtree*) _eina_rbtree_int_new(1337), EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp), NULL);
- _eina_rbtree_black_height(root, EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp));
+ root =
+ eina_rbtree_inline_insert(root, (Eina_Rbtree *)_eina_rbtree_int_new(
+ 10),
+ EINA_RBTREE_CMP_NODE_CB(
+ eina_rbtree_int_cmp), NULL);
+ root =
+ eina_rbtree_inline_insert(root, (Eina_Rbtree *)_eina_rbtree_int_new(
+ 42),
+ EINA_RBTREE_CMP_NODE_CB(
+ eina_rbtree_int_cmp), NULL);
+ root =
+ eina_rbtree_inline_insert(root, (Eina_Rbtree *)_eina_rbtree_int_new(
+ 69),
+ EINA_RBTREE_CMP_NODE_CB(
+ eina_rbtree_int_cmp), NULL);
+ root =
+ eina_rbtree_inline_insert(root, (Eina_Rbtree *)_eina_rbtree_int_new(
+ 1337),
+ EINA_RBTREE_CMP_NODE_CB(
+ eina_rbtree_int_cmp), NULL);
+ _eina_rbtree_black_height(root,
+ EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp));
fail_if(root == NULL);
i = 69;
- lookup = eina_rbtree_inline_lookup(root, &i, sizeof (int), EINA_RBTREE_CMP_KEY_CB(eina_rbtree_int_key), NULL);
+ lookup = eina_rbtree_inline_lookup(root,
+ &i,
+ sizeof (int),
+ EINA_RBTREE_CMP_KEY_CB(
+ eina_rbtree_int_key),
+ NULL);
_eina_rbtree_black_height(root, EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp));
fail_if(lookup == NULL);
- root = eina_rbtree_inline_remove(root, lookup, EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp), NULL);
+ root =
+ eina_rbtree_inline_remove(root, lookup, EINA_RBTREE_CMP_NODE_CB(
+ eina_rbtree_int_cmp), NULL);
_eina_rbtree_black_height(root, EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp));
}
Eina_Rbtree *lookup;
int i;
- root = eina_rbtree_inline_insert(root, (Eina_Rbtree*) _eina_rbtree_int_new(10), EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp), NULL);
- root = eina_rbtree_inline_insert(root, (Eina_Rbtree*) _eina_rbtree_int_new(42), EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp), NULL);
- root = eina_rbtree_inline_insert(root, (Eina_Rbtree*) _eina_rbtree_int_new(69), EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp), NULL);
- root = eina_rbtree_inline_insert(root, (Eina_Rbtree*) _eina_rbtree_int_new(1337), EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp), NULL);
- root = eina_rbtree_inline_insert(root, (Eina_Rbtree*) _eina_rbtree_int_new(77), EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp), NULL);
- root = eina_rbtree_inline_insert(root, (Eina_Rbtree*) _eina_rbtree_int_new(75), EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp), NULL);
- root = eina_rbtree_inline_insert(root, (Eina_Rbtree*) _eina_rbtree_int_new(81), EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp), NULL);
- _eina_rbtree_black_height(root, EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp));
+ root =
+ eina_rbtree_inline_insert(root, (Eina_Rbtree *)_eina_rbtree_int_new(
+ 10),
+ EINA_RBTREE_CMP_NODE_CB(
+ eina_rbtree_int_cmp), NULL);
+ root =
+ eina_rbtree_inline_insert(root, (Eina_Rbtree *)_eina_rbtree_int_new(
+ 42),
+ EINA_RBTREE_CMP_NODE_CB(
+ eina_rbtree_int_cmp), NULL);
+ root =
+ eina_rbtree_inline_insert(root, (Eina_Rbtree *)_eina_rbtree_int_new(
+ 69),
+ EINA_RBTREE_CMP_NODE_CB(
+ eina_rbtree_int_cmp), NULL);
+ root =
+ eina_rbtree_inline_insert(root, (Eina_Rbtree *)_eina_rbtree_int_new(
+ 1337),
+ EINA_RBTREE_CMP_NODE_CB(
+ eina_rbtree_int_cmp), NULL);
+ root =
+ eina_rbtree_inline_insert(root, (Eina_Rbtree *)_eina_rbtree_int_new(
+ 77),
+ EINA_RBTREE_CMP_NODE_CB(
+ eina_rbtree_int_cmp), NULL);
+ root =
+ eina_rbtree_inline_insert(root, (Eina_Rbtree *)_eina_rbtree_int_new(
+ 75),
+ EINA_RBTREE_CMP_NODE_CB(
+ eina_rbtree_int_cmp), NULL);
+ root =
+ eina_rbtree_inline_insert(root, (Eina_Rbtree *)_eina_rbtree_int_new(
+ 81),
+ EINA_RBTREE_CMP_NODE_CB(
+ eina_rbtree_int_cmp), NULL);
+ _eina_rbtree_black_height(root,
+ EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp));
fail_if(root == NULL);
i = 69;
- lookup = eina_rbtree_inline_lookup(root, &i, sizeof (int), EINA_RBTREE_CMP_KEY_CB(eina_rbtree_int_key), NULL);
+ lookup = eina_rbtree_inline_lookup(root,
+ &i,
+ sizeof (int),
+ EINA_RBTREE_CMP_KEY_CB(
+ eina_rbtree_int_key),
+ NULL);
_eina_rbtree_black_height(root, EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp));
fail_if(lookup == NULL);
- root = eina_rbtree_inline_remove(root, lookup, EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp), NULL);
+ root =
+ eina_rbtree_inline_remove(root, lookup, EINA_RBTREE_CMP_NODE_CB(
+ eina_rbtree_int_cmp), NULL);
_eina_rbtree_black_height(root, EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp));
}
Eina_Rbtree *lookup;
int i;
- root = eina_rbtree_inline_insert(root, (Eina_Rbtree*) _eina_rbtree_int_new(1113497590), EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp), NULL);
- root = eina_rbtree_inline_insert(root, (Eina_Rbtree*) _eina_rbtree_int_new(499187507), EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp), NULL);
- root = eina_rbtree_inline_insert(root, (Eina_Rbtree*) _eina_rbtree_int_new(1693860487), EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp), NULL);
- root = eina_rbtree_inline_insert(root, (Eina_Rbtree*) _eina_rbtree_int_new(26211080), EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp), NULL);
- root = eina_rbtree_inline_insert(root, (Eina_Rbtree*) _eina_rbtree_int_new(797272577), EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp), NULL);
- root = eina_rbtree_inline_insert(root, (Eina_Rbtree*) _eina_rbtree_int_new(1252184882), EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp), NULL);
- root = eina_rbtree_inline_insert(root, (Eina_Rbtree*) _eina_rbtree_int_new(1448158229), EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp), NULL);
- root = eina_rbtree_inline_insert(root, (Eina_Rbtree*) _eina_rbtree_int_new(1821884856), EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp), NULL);
- root = eina_rbtree_inline_insert(root, (Eina_Rbtree*) _eina_rbtree_int_new(346086006), EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp), NULL);
- root = eina_rbtree_inline_insert(root, (Eina_Rbtree*) _eina_rbtree_int_new(936357333), EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp), NULL);
- root = eina_rbtree_inline_insert(root, (Eina_Rbtree*) _eina_rbtree_int_new(1462073936), EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp), NULL);
- root = eina_rbtree_inline_insert(root, (Eina_Rbtree*) _eina_rbtree_int_new(1717320055), EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp), NULL);
- root = eina_rbtree_inline_insert(root, (Eina_Rbtree*) _eina_rbtree_int_new(1845524606), EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp), NULL);
- _eina_rbtree_black_height(root, EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp));
+ root =
+ eina_rbtree_inline_insert(root, (Eina_Rbtree *)_eina_rbtree_int_new(
+ 1113497590),
+ EINA_RBTREE_CMP_NODE_CB(
+ eina_rbtree_int_cmp), NULL);
+ root =
+ eina_rbtree_inline_insert(root, (Eina_Rbtree *)_eina_rbtree_int_new(
+ 499187507),
+ EINA_RBTREE_CMP_NODE_CB(
+ eina_rbtree_int_cmp), NULL);
+ root =
+ eina_rbtree_inline_insert(root, (Eina_Rbtree *)_eina_rbtree_int_new(
+ 1693860487),
+ EINA_RBTREE_CMP_NODE_CB(
+ eina_rbtree_int_cmp), NULL);
+ root =
+ eina_rbtree_inline_insert(root, (Eina_Rbtree *)_eina_rbtree_int_new(
+ 26211080),
+ EINA_RBTREE_CMP_NODE_CB(
+ eina_rbtree_int_cmp), NULL);
+ root =
+ eina_rbtree_inline_insert(root, (Eina_Rbtree *)_eina_rbtree_int_new(
+ 797272577),
+ EINA_RBTREE_CMP_NODE_CB(
+ eina_rbtree_int_cmp), NULL);
+ root =
+ eina_rbtree_inline_insert(root, (Eina_Rbtree *)_eina_rbtree_int_new(
+ 1252184882),
+ EINA_RBTREE_CMP_NODE_CB(
+ eina_rbtree_int_cmp), NULL);
+ root =
+ eina_rbtree_inline_insert(root, (Eina_Rbtree *)_eina_rbtree_int_new(
+ 1448158229),
+ EINA_RBTREE_CMP_NODE_CB(
+ eina_rbtree_int_cmp), NULL);
+ root =
+ eina_rbtree_inline_insert(root, (Eina_Rbtree *)_eina_rbtree_int_new(
+ 1821884856),
+ EINA_RBTREE_CMP_NODE_CB(
+ eina_rbtree_int_cmp), NULL);
+ root =
+ eina_rbtree_inline_insert(root, (Eina_Rbtree *)_eina_rbtree_int_new(
+ 346086006),
+ EINA_RBTREE_CMP_NODE_CB(
+ eina_rbtree_int_cmp), NULL);
+ root =
+ eina_rbtree_inline_insert(root, (Eina_Rbtree *)_eina_rbtree_int_new(
+ 936357333),
+ EINA_RBTREE_CMP_NODE_CB(
+ eina_rbtree_int_cmp), NULL);
+ root =
+ eina_rbtree_inline_insert(root, (Eina_Rbtree *)_eina_rbtree_int_new(
+ 1462073936),
+ EINA_RBTREE_CMP_NODE_CB(
+ eina_rbtree_int_cmp), NULL);
+ root =
+ eina_rbtree_inline_insert(root, (Eina_Rbtree *)_eina_rbtree_int_new(
+ 1717320055),
+ EINA_RBTREE_CMP_NODE_CB(
+ eina_rbtree_int_cmp), NULL);
+ root =
+ eina_rbtree_inline_insert(root, (Eina_Rbtree *)_eina_rbtree_int_new(
+ 1845524606),
+ EINA_RBTREE_CMP_NODE_CB(
+ eina_rbtree_int_cmp), NULL);
+ _eina_rbtree_black_height(root,
+ EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp));
fail_if(root == NULL);
i = 1113497590;
- lookup = eina_rbtree_inline_lookup(root, &i, sizeof (int), EINA_RBTREE_CMP_KEY_CB(eina_rbtree_int_key), NULL);
+ lookup = eina_rbtree_inline_lookup(root,
+ &i,
+ sizeof (int),
+ EINA_RBTREE_CMP_KEY_CB(
+ eina_rbtree_int_key),
+ NULL);
_eina_rbtree_black_height(root, EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp));
fail_if(lookup == NULL);
- root = eina_rbtree_inline_remove(root, lookup, EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp), NULL);
+ root =
+ eina_rbtree_inline_remove(root, lookup, EINA_RBTREE_CMP_NODE_CB(
+ eina_rbtree_int_cmp), NULL);
_eina_rbtree_black_height(root, EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp));
}
fail_if(pool == NULL);
eina_rectangle_pool_data_set(pool, rects);
- fail_if(eina_rectangle_pool_data_get(pool) != rects);
+ fail_if(eina_rectangle_pool_data_get(pool) != rects);
- fail_if(eina_rectangle_pool_request(pool, 1024, 1024) != NULL);
+ fail_if(eina_rectangle_pool_request(pool, 1024, 1024) != NULL);
for (x = 0; x < 8; x++)
- for (y = 0; y < 8; y++)
- {
- rects[x][y] = eina_rectangle_pool_request(pool, 32, 32);
- fail_if(rects[x][y] == NULL);
- }
+ for (y = 0; y < 8; y++)
+ {
+ rects[x][y] = eina_rectangle_pool_request(pool, 32, 32);
+ fail_if(rects[x][y] == NULL);
+ }
- fail_if(eina_rectangle_pool_count(pool) != 64);
+ fail_if(eina_rectangle_pool_count(pool) != 64);
- fail_if(eina_rectangle_pool_get(rects[0][0]) != pool);
+ fail_if(eina_rectangle_pool_get(rects[0][0]) != pool);
- fail_if(eina_rectangle_pool_geometry_get(pool, &w, &h) != EINA_TRUE);
- fail_if(w != 256 || h != 256);
+ fail_if(eina_rectangle_pool_geometry_get(pool, &w, &h) != EINA_TRUE);
+ fail_if(w != 256 || h != 256);
- fail_if(eina_rectangle_pool_request(pool, 32, 32) != NULL);
- fail_if(eina_rectangle_pool_request(pool, 1024, 1024) != NULL);
+ fail_if(eina_rectangle_pool_request(pool, 32, 32) != NULL);
+ fail_if(eina_rectangle_pool_request(pool, 1024, 1024) != NULL);
for (x = 0; x < 8; x++)
- eina_rectangle_pool_release(rects[0][x]);
+ eina_rectangle_pool_release(rects[0][x]);
fail_if(eina_rectangle_pool_request(pool, 16, 16) == NULL);
EINA_RECTANGLE_SET(&r1, 10, 10, 50, 50);
EINA_RECTANGLE_SET(&r2, 20, 20, 20, 20);
- EINA_RECTANGLE_SET(&r3, 0, 0, 10, 10);
+ EINA_RECTANGLE_SET(&r3, 0, 0, 10, 10);
EINA_RECTANGLE_SET(&r4, 30, 30, 50, 50);
rd = r1;
fail_if(!eina_rectangle_intersection(&rd, &r2));
fail_if(rd.x != r2.x
- || rd.y != r2.y
- || rd.w != r2.w
- || rd.h != r2.h);
+ || rd.y != r2.y
+ || rd.w != r2.w
+ || rd.h != r2.h);
rd = r1;
fail_if(!eina_rectangle_intersection(&rd, &r4));
fail_if(rd.x != 30
- || rd.y != 30
- || rd.w != 30
- || rd.h != 30);
+ || rd.y != 30
+ || rd.w != 30
+ || rd.h != 30);
eina_shutdown();
}
#include "eina_suite.h"
#include "Eina.h"
-START_TEST(str_simple)
+ START_TEST(str_simple)
{
eina_init();
eina_init();
result = eina_str_split_full("nomatch", "", -1, &elements);
- fail_if(result != NULL);
- fail_if(elements != 0);
+ fail_if(result != NULL);
+ fail_if(elements != 0);
result = eina_str_split_full("nomatch", "x", -1, &elements);
- fail_if(result == NULL);
- fail_if(elements != 1);
- fail_if(strcmp(result[0], "nomatch") != 0);
- free(result[0]);
- free(result);
+ fail_if(result == NULL);
+ fail_if(elements != 1);
+ fail_if(strcmp(result[0], "nomatch") != 0);
+ free(result[0]);
+ free(result);
result = eina_str_split_full("nomatch", "xyz", -1, &elements);
- fail_if(result == NULL);
- fail_if(elements != 1);
- fail_if(strcmp(result[0], "nomatch") != 0);
- free(result[0]);
- free(result);
+ fail_if(result == NULL);
+ fail_if(elements != 1);
+ fail_if(strcmp(result[0], "nomatch") != 0);
+ free(result[0]);
+ free(result);
result = eina_str_split_full("match:match:match", ":", -1, &elements);
- fail_if(result == NULL);
- fail_if(elements != 3);
+ fail_if(result == NULL);
+ fail_if(elements != 3);
while (elements >= 1)
{
- elements--;
- fail_if(strcmp(result[elements], "match") != 0);
+ elements--;
+ fail_if(strcmp(result[elements], "match") != 0);
}
- free(result[0]);
- free(result);
+ free(result[0]);
+ free(result);
result = eina_str_split_full("a:b:c", ":", -1, &elements);
- fail_if(result == NULL);
- fail_if(elements != 3);
- fail_if(strcmp(result[0], "a") != 0);
- fail_if(strcmp(result[1], "b") != 0);
- fail_if(strcmp(result[2], "c") != 0);
- free(result[0]);
- free(result);
+ fail_if(result == NULL);
+ fail_if(elements != 3);
+ fail_if(strcmp(result[0], "a") != 0);
+ fail_if(strcmp(result[1], "b") != 0);
+ fail_if(strcmp(result[2], "c") != 0);
+ free(result[0]);
+ free(result);
result = eina_str_split_full("a:b:", ":", -1, &elements);
- fail_if(result == NULL);
- fail_if(elements != 3);
- fail_if(strcmp(result[0], "a") != 0);
- fail_if(strcmp(result[1], "b") != 0);
- fail_if(strcmp(result[2], "") != 0);
- free(result[0]);
- free(result);
+ fail_if(result == NULL);
+ fail_if(elements != 3);
+ fail_if(strcmp(result[0], "a") != 0);
+ fail_if(strcmp(result[1], "b") != 0);
+ fail_if(strcmp(result[2], "") != 0);
+ free(result[0]);
+ free(result);
result = eina_str_split_full(":b:c", ":", -1, &elements);
- fail_if(result == NULL);
- fail_if(elements != 3);
- fail_if(strcmp(result[0], "") != 0);
- fail_if(strcmp(result[1], "b") != 0);
- fail_if(strcmp(result[2], "c") != 0);
- free(result[0]);
- free(result);
+ fail_if(result == NULL);
+ fail_if(elements != 3);
+ fail_if(strcmp(result[0], "") != 0);
+ fail_if(strcmp(result[1], "b") != 0);
+ fail_if(strcmp(result[2], "c") != 0);
+ free(result[0]);
+ free(result);
result = eina_str_split_full(":", ":", -1, &elements);
- fail_if(result == NULL);
- fail_if(elements != 2);
- fail_if(strcmp(result[0], "") != 0);
- fail_if(strcmp(result[1], "") != 0);
- free(result[0]);
- free(result);
+ fail_if(result == NULL);
+ fail_if(elements != 2);
+ fail_if(strcmp(result[0], "") != 0);
+ fail_if(strcmp(result[1], "") != 0);
+ free(result[0]);
+ free(result);
result = eina_str_split_full("a", "!!!!!!!!!", -1, &elements);
- fail_if(result == NULL);
- fail_if(elements != 1);
- fail_if(strcmp(result[0], "a") != 0);
- free(result[0]);
- free(result);
+ fail_if(result == NULL);
+ fail_if(elements != 1);
+ fail_if(strcmp(result[0], "a") != 0);
+ free(result[0]);
+ free(result);
result = eina_str_split_full("aaba", "ab", -1, &elements);
- fail_if(result == NULL);
- fail_if(elements != 2);
- fail_if(strcmp(result[0], "a") != 0);
- fail_if(strcmp(result[1], "a") != 0);
- free(result[0]);
- free(result);
-
- eina_shutdown();
+ fail_if(result == NULL);
+ fail_if(elements != 2);
+ fail_if(strcmp(result[0], "a") != 0);
+ fail_if(strcmp(result[1], "a") != 0);
+ free(result[0]);
+ free(result);
+
+ eina_shutdown();
}
END_TEST
{
Eina_Strbuf *buf;
char *txt;
-#define TEXT "This test should be so long that it is longer than the initial size of strbuf"
+#define TEXT \
+ "This test should be so long that it is longer than the initial size of strbuf"
eina_init();
fail_if(strlen(eina_strbuf_string_get(buf)) != eina_strbuf_length_get(buf));
fail_if(strcmp(eina_strbuf_string_get(buf), ""));
-#define TEXT "This test should be so long that it is longer than the initial size of strbuf"
+#define TEXT \
+ "This test should be so long that it is longer than the initial size of strbuf"
eina_strbuf_append(buf, TEXT TEXT);
fail_if(strlen(eina_strbuf_string_get(buf)) != eina_strbuf_length_get(buf));
eina_strbuf_remove(buf, 0, eina_strbuf_length_get(buf) - 1);
fail_if(strncmp(eina_strbuf_string_get(buf) + 3, "678", 3));
eina_strbuf_insert_escaped(buf, "089 '\\", 9);
- fail_if(strlen(eina_strbuf_string_get(buf)) != eina_strbuf_length_get(buf));
- fail_if(strncmp(eina_strbuf_string_get(buf) + 9, "089\\ \\'\\\\",
- strlen("089\\ \\'\\\\")));
+ fail_if(strlen(eina_strbuf_string_get(
+ buf)) != eina_strbuf_length_get(buf));
+ fail_if(strncmp(eina_strbuf_string_get(buf) + 9,
+ "089\\ \\'\\\\",
+ strlen("089\\ \\'\\\\")));
eina_strbuf_reset(buf);
eina_strbuf_free(buf);
size_t sz;
for (i = 0; i < sizeof(pattern) - 1; i++)
- pattern[i] = 'a' + (i % 26);
+ pattern[i] = 'a' + (i % 26);
pattern[i] = '\0';
eina_init();
eina_strbuf_append_length(buf, pattern, sizeof(pattern) - 1);
fail_if(eina_strbuf_length_get(buf) != sz + sizeof(pattern) - 1);
- fail_if(memcmp(eina_strbuf_string_get(buf) + sz, pattern, sizeof(pattern) - 1));
+ fail_if(memcmp(eina_strbuf_string_get(buf) + sz, pattern, sizeof(pattern) -
+ 1));
sz += sizeof(pattern) - 1;
eina_init();
buf = eina_strbuf_new();
- fail_if(!buf);
+ fail_if(!buf);
for (i = 0; i < runs; i++)
{
- fail_if(!eina_strbuf_append(buf, "string"));
- fail_if(!eina_strbuf_append_n(buf, "string", 3));
- fail_if(!eina_strbuf_append_char(buf, 's'));
- fail_if(!eina_strbuf_append_length(buf, "string", 3));
+ fail_if(!eina_strbuf_append(buf, "string"));
+ fail_if(!eina_strbuf_append_n(buf, "string", 3));
+ fail_if(!eina_strbuf_append_char(buf, 's'));
+ fail_if(!eina_strbuf_append_length(buf, "string", 3));
}
target_pattern_size = strlen(target_pattern);
- fail_if(eina_strbuf_length_get(buf) != (runs * target_pattern_size));
+ fail_if(eina_strbuf_length_get(buf) != (runs * target_pattern_size));
str = eina_strbuf_string_get(buf);
- fail_if(str == NULL);
+ fail_if(str == NULL);
for (i = 0; i < runs; i++, str += target_pattern_size)
- fail_if(memcmp(str, target_pattern, target_pattern_size));
+ fail_if(memcmp(str, target_pattern, target_pattern_size));
- eina_strbuf_free(buf);
+ eina_strbuf_free(buf);
eina_shutdown();
}
eina_init();
buf = eina_strbuf_new();
- fail_if(!buf);
+ fail_if(!buf);
for (i = 0; i < runs; i++)
{
- fail_if(!eina_strbuf_prepend(buf, "string"));
- fail_if(!eina_strbuf_prepend_n(buf, "string", 3));
- fail_if(!eina_strbuf_prepend_char(buf, 's'));
- fail_if(!eina_strbuf_prepend_length(buf, "string", 3));
+ fail_if(!eina_strbuf_prepend(buf, "string"));
+ fail_if(!eina_strbuf_prepend_n(buf, "string", 3));
+ fail_if(!eina_strbuf_prepend_char(buf, 's'));
+ fail_if(!eina_strbuf_prepend_length(buf, "string", 3));
}
target_pattern_size = strlen(target_pattern);
- fail_if(eina_strbuf_length_get(buf) != (runs * target_pattern_size));
+ fail_if(eina_strbuf_length_get(buf) != (runs * target_pattern_size));
str = eina_strbuf_string_get(buf);
- fail_if(str == NULL);
+ fail_if(str == NULL);
for (i = 0; i < runs; i++, str += target_pattern_size)
- fail_if(memcmp(str, target_pattern, target_pattern_size));
+ fail_if(memcmp(str, target_pattern, target_pattern_size));
- eina_strbuf_free(buf);
+ eina_strbuf_free(buf);
eina_shutdown();
}
fail_if(t1 == NULL);
fail_if(strcmp(t0, TEST0) != 0);
fail_if(strcmp(t1, TEST1) != 0);
- fail_if((int) strlen(TEST0) != eina_stringshare_strlen(t0));
- fail_if((int) strlen(TEST1) != eina_stringshare_strlen(t1));
+ fail_if((int)strlen(TEST0) != eina_stringshare_strlen(t0));
+ fail_if((int)strlen(TEST1) != eina_stringshare_strlen(t1));
t0 = eina_stringshare_ref(t0);
fail_if(t0 == NULL);
- fail_if((int) strlen(TEST0) != eina_stringshare_strlen(t0));
+ fail_if((int)strlen(TEST0) != eina_stringshare_strlen(t0));
eina_stringshare_del(t0);
eina_stringshare_del(t0);
for (i = 0; i < 3; i++)
{
- const char *t0, *t1;
- int j;
-
- for (j = 0; j < i; j++)
- {
- char c;
- for (c = 'a'; c <= 'z'; c++)
- buf[j] = c;
- }
- buf[i] = '\0';
- t0 = eina_stringshare_add(buf);
- t1 = eina_stringshare_add(buf);
-
- fail_if(t0 == NULL);
- fail_if(t1 == NULL);
- fail_if(t0 != t1);
- fail_if(strcmp(t0, buf) != 0);
- fail_if((int) strlen(buf) != eina_stringshare_strlen(t0));
- fail_if((int) strlen(buf) != eina_stringshare_strlen(t1));
-
- eina_stringshare_del(t0);
- eina_stringshare_del(t1);
+ const char *t0, *t1;
+ int j;
+
+ for (j = 0; j < i; j++)
+ {
+ char c;
+ for (c = 'a'; c <= 'z'; c++)
+ buf[j] = c;
+ }
+ buf[i] = '\0';
+ t0 = eina_stringshare_add(buf);
+ t1 = eina_stringshare_add(buf);
+
+ fail_if(t0 == NULL);
+ fail_if(t1 == NULL);
+ fail_if(t0 != t1);
+ fail_if(strcmp(t0, buf) != 0);
+ fail_if((int)strlen(buf) != eina_stringshare_strlen(t0));
+ fail_if((int)strlen(buf) != eina_stringshare_strlen(t1));
+
+ eina_stringshare_del(t0);
+ eina_stringshare_del(t1);
}
- eina_shutdown();
+ eina_shutdown();
}
END_TEST
fail_if(strcmp(t0, TEST0) != 0);
fail_if(strcmp(t1, TEST0) != 0);
fail_if(t0 != t1);
- fail_if((int) strlen(t0) != eina_stringshare_strlen(t0));
+ fail_if((int)strlen(t0) != eina_stringshare_strlen(t0));
eina_stringshare_del(t0);
eina_stringshare_del(t1);
for (i = 10000; i > 0; --i)
{
- char build[64] = "string_";
+ char build[64] = "string_";
- eina_convert_xtoa(i, build + 7);
- tmp = eina_stringshare_add(build);
- fail_if(tmp != eina_stringshare_add(build));
+ eina_convert_xtoa(i, build + 7);
+ tmp = eina_stringshare_add(build);
+ fail_if(tmp != eina_stringshare_add(build));
}
eina_shutdown();
for (i = 0; i < 10000; ++i)
{
- eina_convert_itoa(rand(), buffer);
- eina_array_push(ea, (void*) eina_stringshare_add(buffer));
- if (rand() > RAND_MAX / 2)
- {
- const char *r = eina_stringshare_add(buffer);
- fail_if(r == NULL);
- }
+ eina_convert_itoa(rand(), buffer);
+ eina_array_push(ea, (void *)eina_stringshare_add(buffer));
+ if (rand() > RAND_MAX / 2)
+ {
+ const char *r = eina_stringshare_add(buffer);
+ fail_if(r == NULL);
+ }
}
for (i = 0; i < 10000; ++i)
{
- const char *r;
-
- eina_convert_itoa(60000 - i, buffer);
- eina_array_push(ea, (void*) eina_stringshare_add(buffer));
- r = eina_stringshare_add(buffer);
- fail_if(r == NULL);
- r = eina_stringshare_add(buffer);
- fail_if(r == NULL);
+ const char *r;
+
+ eina_convert_itoa(60000 - i, buffer);
+ eina_array_push(ea, (void *)eina_stringshare_add(buffer));
+ r = eina_stringshare_add(buffer);
+ fail_if(r == NULL);
+ r = eina_stringshare_add(buffer);
+ fail_if(r == NULL);
}
for (i = 0; i < 200; ++i)
- eina_stringshare_del(eina_array_data_get(ea, i));
+ eina_stringshare_del(eina_array_data_get(ea, i));
for (i = 0; i < 1000; ++i)
- eina_stringshare_del(eina_array_pop(ea));
+ eina_stringshare_del(eina_array_pop(ea));
- eina_shutdown();
+ eina_shutdown();
eina_array_free(ea);
}
#include "eina_suite.h"
#include "Eina.h"
-struct test_rect {
- unsigned long col, row;
- int x, y, w, h;
- Eina_Bool full;
+struct test_rect
+{
+ unsigned long col, row;
+ int x, y, w, h;
+ Eina_Bool full;
};
static void
unsigned int i = 0;
struct Eina_Tile_Grid_Info *tile;
- EINA_ITERATOR_FOREACH(it, tile) {
+ EINA_ITERATOR_FOREACH(it, tile) {
fail_if(cur_test[i].col != tile->col ||
- cur_test[i].row != tile->row ||
- cur_test[i].x != tile->rect.x ||
- cur_test[i].y != tile->rect.y ||
- cur_test[i].w != tile->rect.w ||
- cur_test[i].h != tile->rect.h ||
- cur_test[i].full != tile->full);
+ cur_test[i].row != tile->row ||
+ cur_test[i].x != tile->rect.x ||
+ cur_test[i].y != tile->rect.y ||
+ cur_test[i].w != tile->rect.w ||
+ cur_test[i].h != tile->rect.h ||
+ cur_test[i].full != tile->full);
i++;
}
- fail_if(i == 0);
+ fail_if(i == 0);
}
-START_TEST(eina_test_tile_grid_slicer_iterator)
+ START_TEST(eina_test_tile_grid_slicer_iterator)
{
Eina_Iterator *it;
struct test_rect *cur_test;
struct test_rect test1[] = {{1, 1, 72, 82, 10, 15, 0}};
struct test_rect test2[] =
- {{1, 1, 72, 82, 56, 15, 0},
- {2, 1, 0, 82, 128, 15, 0},
- {3, 1, 0, 82, 116, 15, 0}};
+ {{1, 1, 72, 82, 56, 15, 0},
+ {2, 1, 0, 82, 128, 15, 0},
+ {3, 1, 0, 82, 116, 15, 0}};
struct test_rect test3[] =
- {{1, 1, 72, 82, 10, 46, 0},
- {1, 2, 72, 0, 10, 128, 0},
- {1, 3, 72, 0, 10, 126, 0}};
+ {{1, 1, 72, 82, 10, 46, 0},
+ {1, 2, 72, 0, 10, 128, 0},
+ {1, 3, 72, 0, 10, 126, 0}};
struct test_rect test4[] =
- {{1, 1, 72, 82, 56, 46, 0},
- {2, 1, 0, 82, 128, 46, 0},
- {3, 1, 0, 82, 128, 46, 0},
- {4, 1, 0, 82, 88, 46, 0},
- {1, 2, 72, 0, 56, 128, 0},
- {2, 2, 0, 0, 128, 128, 1},
- {3, 2, 0, 0, 128, 128, 1},
- {4, 2, 0, 0, 88, 128, 0},
- {1, 3, 72, 0, 56, 126, 0},
- {2, 3, 0, 0, 128, 126, 0},
- {3, 3, 0, 0, 128, 126, 0},
- {4, 3, 0, 0, 88, 126, 0}};
+ {{1, 1, 72, 82, 56, 46, 0},
+ {2, 1, 0, 82, 128, 46, 0},
+ {3, 1, 0, 82, 128, 46, 0},
+ {4, 1, 0, 82, 88, 46, 0},
+ {1, 2, 72, 0, 56, 128, 0},
+ {2, 2, 0, 0, 128, 128, 1},
+ {3, 2, 0, 0, 128, 128, 1},
+ {4, 2, 0, 0, 88, 128, 0},
+ {1, 3, 72, 0, 56, 126, 0},
+ {2, 3, 0, 0, 128, 126, 0},
+ {3, 3, 0, 0, 128, 126, 0},
+ {4, 3, 0, 0, 88, 126, 0}};
struct test_rect test5[] = {{1, 1, 0, 0, 128, 128, 1}};
struct test_rect test6[] = {{1, 1, 0, 0, 1, 1, 0}};
struct test_rect test7[] =
- {{1, 1, 0, 0, 128, 128, 1},
- {2, 1, 0, 0, 1, 128, 0},
- {1, 2, 0, 0, 128, 1, 0},
- {2, 2, 0, 0, 1, 1, 0}};
+ {{1, 1, 0, 0, 128, 128, 1},
+ {2, 1, 0, 0, 1, 128, 0},
+ {1, 2, 0, 0, 128, 1, 0},
+ {2, 2, 0, 0, 1, 1, 0}};
eina_init();
EINA_RECTANGLE_SET(&r, 40, 40, 20, 20);
eina_tiler_rect_del(tl, &r);
-
+
it = eina_tiler_iterator_new(tl);
fail_if(!it);
EINA_ITERATOR_FOREACH(it, r)
- {
- fail_if(r.w <= 0);
- fail_if(r.h <= 0);
- fail_if(r.x < 0 || r.x + r.w > 640);
- fail_if(r.y < 0 || r.y + r.h > 480);
- ++i;
- }
+ {
+ fail_if(r.w <= 0);
+ fail_if(r.h <= 0);
+ fail_if(r.x < 0 || r.x + r.w > 640);
+ fail_if(r.y < 0 || r.y + r.h > 480);
+ ++i;
+ }
- fail_if(eina_iterator_container_get(it) != tl);
+ fail_if(eina_iterator_container_get(it) != tl);
- eina_iterator_free(it);
+ eina_iterator_free(it);
fail_if(i == 0);
fail_if(t1 == NULL);
fail_if(eina_unicode_strcmp(t0, TEST0) != 0);
fail_if(eina_unicode_strcmp(t1, TEST1) != 0);
- fail_if((int) eina_unicode_strlen(TEST0) != eina_ustringshare_strlen(t0));
- fail_if((int) eina_unicode_strlen(TEST1) != eina_ustringshare_strlen(t1));
+ fail_if((int)eina_unicode_strlen(TEST0) != eina_ustringshare_strlen(t0));
+ fail_if((int)eina_unicode_strlen(TEST1) != eina_ustringshare_strlen(t1));
t0 = eina_ustringshare_ref(t0);
fail_if(t0 == NULL);
- fail_if((int) strlen(TEST0) != eina_stringshare_strlen(t0));
+ fail_if((int)strlen(TEST0) != eina_stringshare_strlen(t0));
eina_ustringshare_del(t0);
eina_ustringshare_del(t0);
fail_if(eina_unicode_strcmp(t0, TEST0) != 0);
fail_if(eina_unicode_strcmp(t1, TEST0) != 0);
fail_if(t0 != t1);
- fail_if((int) eina_unicode_strlen(TEST0) != eina_ustringshare_strlen(t0));
- fail_if((int) eina_unicode_strlen(TEST0) != eina_ustringshare_strlen(t1));
+ fail_if((int)eina_unicode_strlen(TEST0) != eina_ustringshare_strlen(t0));
+ fail_if((int)eina_unicode_strlen(TEST0) != eina_ustringshare_strlen(t1));
eina_ustringshare_del(t0);
eina_ustringshare_del(t1);
for (i = 10000; i > 0; --i)
{
Eina_Unicode string_[] = {'s', 't', 'r', 'i', 'n', 'g', '_', 0};
- Eina_Unicode build[64];
+ Eina_Unicode build[64];
eina_unicode_strcpy(build, string_);
- build[7] = i;
+ build[7] = i;
build[8] = 0;
- tmp = eina_ustringshare_add(build);
- fail_if(tmp != eina_ustringshare_add(build));
- fail_if((int) eina_unicode_strlen(build) != eina_ustringshare_strlen(tmp));
+ tmp = eina_ustringshare_add(build);
+ fail_if(tmp != eina_ustringshare_add(build));
+ fail_if((int)eina_unicode_strlen(build) != eina_ustringshare_strlen(tmp));
}
- eina_shutdown();
+ eina_shutdown();
}
END_TEST
struct _Evas_Hash_El
{
- Evas_Object_List _list_data;
- const char *key;
- void *data;
+ Evas_Object_List _list_data;
+ const char *key;
+ void *data;
};
static inline int _evas_hash_gen(const char *key);
{
unsigned int hash_num = 5381;
const unsigned char *ptr;
-
- if (!key) return 0;
+
+ if (!key)
+ return 0;
+
for (ptr = (unsigned char *)key; *ptr; ptr++)
- hash_num = (hash_num * 33) ^ *ptr;
-
+ hash_num = (hash_num * 33) ^ *ptr;
+
hash_num &= 0xff;
return (int)hash_num;
}
int hash_num;
Evas_Hash_El *el;
- if ((!key) || (!data)) return hash;
+ if ((!key) || (!data))
+ return hash;
+
_evas_hash_alloc_error = 0;
if (!hash)
{
- hash = calloc(1, sizeof(struct _Evas_Hash));
- if (!hash)
- {
- _evas_hash_alloc_error = 1;
- return NULL;
- }
+ hash = calloc(1, sizeof(struct _Evas_Hash));
+ if (!hash)
+ {
+ _evas_hash_alloc_error = 1;
+ return NULL;
+ }
}
+
if (!(el = malloc(sizeof(struct _Evas_Hash_El) + strlen(key) + 1)))
{
if (hash->population <= 0)
- {
- free(hash);
- hash = NULL;
- }
- _evas_hash_alloc_error = 1;
- return hash;
- };
+ {
+ free(hash);
+ hash = NULL;
+ }
+
+ _evas_hash_alloc_error = 1;
+ return hash;
+ }
+
el->key = ((char *)el) + sizeof(struct _Evas_Hash_El);
- strcpy((char *) el->key, key);
+ strcpy((char *)el->key, key);
el->data = (void *)data;
hash_num = _evas_hash_gen(key);
- hash->buckets[hash_num] = evas_object_list_prepend(hash->buckets[hash_num], el);
+ hash->buckets[hash_num] = evas_object_list_prepend(hash->buckets[hash_num],
+ el);
hash->population++;
return hash;
}
int hash_num;
Evas_Hash_El *el;
- if ((!key) || (!data)) return hash;
+ if ((!key) || (!data))
+ return hash;
+
_evas_hash_alloc_error = 0;
if (!hash)
{
- hash = calloc(1, sizeof(struct _Evas_Hash));
- if (!hash)
- {
- _evas_hash_alloc_error = 1;
- return NULL;
- }
+ hash = calloc(1, sizeof(struct _Evas_Hash));
+ if (!hash)
+ {
+ _evas_hash_alloc_error = 1;
+ return NULL;
+ }
}
+
if (!(el = malloc(sizeof(struct _Evas_Hash_El))))
{
if (hash->population <= 0)
- {
- free(hash);
- hash = NULL;
- }
- _evas_hash_alloc_error = 1;
- return hash;
- };
+ {
+ free(hash);
+ hash = NULL;
+ }
+
+ _evas_hash_alloc_error = 1;
+ return hash;
+ }
+
el->key = key;
el->data = (void *)data;
hash_num = _evas_hash_gen(key);
- hash->buckets[hash_num] = evas_object_list_prepend(hash->buckets[hash_num], el);
+ hash->buckets[hash_num] = evas_object_list_prepend(hash->buckets[hash_num],
+ el);
hash->population++;
return hash;
}
Evas_Hash_El *el;
Evas_Object_List *l;
- if (!hash) return NULL;
+ if (!hash)
+ return NULL;
+
if (!key)
- {
- for (hash_num = 0; hash_num < 256; hash_num++)
- {
- for (l = hash->buckets[hash_num]; l; l = l->next)
- {
- el = (Evas_Hash_El *)l;
- if (el->data == data)
- {
- hash->buckets[hash_num] = evas_object_list_remove(hash->buckets[hash_num], el);
- free(el);
- hash->population--;
- if (hash->population <= 0)
- {
- free(hash);
- hash = NULL;
- }
- return hash;
- }
- }
- }
- }
+ for (hash_num = 0; hash_num < 256; hash_num++)
+ {
+ for (l = hash->buckets[hash_num]; l; l = l->next)
+ {
+ el = (Evas_Hash_El *)l;
+ if (el->data == data)
+ {
+ hash->buckets[hash_num] = evas_object_list_remove(
+ hash->buckets[hash_num],
+ el);
+ free(el);
+ hash->population--;
+ if (hash->population <= 0)
+ {
+ free(hash);
+ hash = NULL;
+ }
+
+ return hash;
+ }
+ }
+ }
else
{
- hash_num = _evas_hash_gen(key);
- for (l = hash->buckets[hash_num]; l; l = l->next)
- {
- el = (Evas_Hash_El *)l;
- if (!strcmp(el->key, key))
- {
- if ((!data) || (el->data == data))
- {
- hash->buckets[hash_num] = evas_object_list_remove(hash->buckets[hash_num], el);
- free(el);
- hash->population--;
- if (hash->population <= 0)
- {
- free(hash);
- hash = NULL;
- }
- return hash;
- }
- }
- }
+ hash_num = _evas_hash_gen(key);
+ for (l = hash->buckets[hash_num]; l; l = l->next)
+ {
+ el = (Evas_Hash_El *)l;
+ if (!strcmp(el->key, key))
+ if ((!data) || (el->data == data))
+ {
+ hash->buckets[hash_num] = evas_object_list_remove(
+ hash->buckets[hash_num],
+ el);
+ free(el);
+ hash->population--;
+ if (hash->population <= 0)
+ {
+ free(hash);
+ hash = NULL;
+ }
+
+ return hash;
+ }
+
+ }
}
+
return hash;
}
Evas_Object_List *l;
_evas_hash_alloc_error = 0;
- if ((!hash) || (!key)) return NULL;
+ if ((!hash) || (!key))
+ return NULL;
+
hash_num = _evas_hash_gen(key);
for (l = hash->buckets[hash_num]; l; l = l->next)
{
- el = (Evas_Hash_El *)l;
- if (!strcmp(el->key, key))
- {
- if (l != hash->buckets[hash_num])
- {
- Evas_Object_List *bucket;
-
- bucket = hash->buckets[hash_num];
- bucket = evas_object_list_remove(bucket, el);
- bucket = evas_object_list_prepend(bucket, el);
- ((Evas_Hash *)hash)->buckets[hash_num] = bucket;
- }
- return el->data;
- }
+ el = (Evas_Hash_El *)l;
+ if (!strcmp(el->key, key))
+ {
+ if (l != hash->buckets[hash_num])
+ {
+ Evas_Object_List *bucket;
+
+ bucket = hash->buckets[hash_num];
+ bucket = evas_object_list_remove(bucket, el);
+ bucket = evas_object_list_prepend(bucket, el);
+ ((Evas_Hash *)hash)->buckets[hash_num] = bucket;
+ }
+
+ return el->data;
+ }
}
return NULL;
}
Evas_Object_List *l;
_evas_hash_alloc_error = 0;
- if (!hash) return NULL;
+ if (!hash)
+ return NULL;
+
hash_num = _evas_hash_gen(key);
for (l = hash->buckets[hash_num]; l; l = l->next)
{
- el = (Evas_Hash_El *)l;
- if ((key) && (!strcmp(el->key, key)))
- {
- void *old_data;
-
- if (l != hash->buckets[hash_num])
- {
- hash->buckets[hash_num] = evas_object_list_remove(hash->buckets[hash_num], el);
- hash->buckets[hash_num] = evas_object_list_prepend(hash->buckets[hash_num], el);
- }
- old_data = el->data;
- el->data = (void *) data;
- return old_data;
- }
+ el = (Evas_Hash_El *)l;
+ if ((key) && (!strcmp(el->key, key)))
+ {
+ void *old_data;
+
+ if (l != hash->buckets[hash_num])
+ {
+ hash->buckets[hash_num] = evas_object_list_remove(
+ hash->buckets[hash_num],
+ el);
+ hash->buckets[hash_num] = evas_object_list_prepend(
+ hash->buckets[hash_num],
+ el);
+ }
+
+ old_data = el->data;
+ el->data = (void *)data;
+ return old_data;
+ }
}
return NULL;
}
EAPI int
evas_hash_size(const Evas_Hash *hash)
{
- if (!hash) return 0;
+ if (!hash)
+ return 0;
+
return 256;
}
{
int i, size;
- if (!hash) return;
+ if (!hash)
+ return;
+
size = evas_hash_size(hash);
for (i = 0; i < size; i++)
{
- while (hash->buckets[i])
- {
- Evas_Hash_El *el;
-
- el = (Evas_Hash_El *)hash->buckets[i];
- hash->buckets[i] = evas_object_list_remove(hash->buckets[i], el);
- free(el);
- }
+ while (hash->buckets[i])
+ {
+ Evas_Hash_El *el;
+
+ el = (Evas_Hash_El *)hash->buckets[i];
+ hash->buckets[i] = evas_object_list_remove(hash->buckets[i], el);
+ free(el);
+ }
}
- free(hash);
+ free(hash);
}
/**
* @ingroup Evas_Hash_General_Group
*/
EAPI void
-evas_hash_foreach(const Evas_Hash *hash, Evas_Bool (*func) (const Evas_Hash *hash, const char *key, void *data, void *fdata), const void *fdata)
+evas_hash_foreach(const Evas_Hash *hash, Evas_Bool (*func)(
+ const Evas_Hash *hash,
+ const char *key,
+ void *data,
+ void *fdata), const void *fdata)
{
int i, size;
- if (!hash) return;
+ if (!hash)
+ return;
+
size = evas_hash_size(hash);
for (i = 0; i < size; i++)
{
- Evas_Object_List *l, *next_l;
+ Evas_Object_List *l, *next_l;
+
+ for (l = hash->buckets[i]; l; )
+ {
+ Evas_Hash_El *el;
- for (l = hash->buckets[i]; l;)
- {
- Evas_Hash_El *el;
+ next_l = l->next;
+ el = (Evas_Hash_El *)l;
+ if (!func(hash, el->key, el->data, (void *)fdata))
+ return;
- next_l = l->next;
- el = (Evas_Hash_El *)l;
- if (!func(hash, el->key, el->data, (void *)fdata)) return;
- l = next_l;
- }
+ l = next_l;
+ }
}
}
struct _Evas_List_Accounting
{
Evas_List *last;
- int count;
+ int count;
};
static int _evas_list_alloc_error = 0;
new_l = evas_mempool_malloc(&_evas_list_mempool, sizeof(Evas_List));
if (!new_l)
{
- _evas_list_alloc_error = 1;
- return list;
+ _evas_list_alloc_error = 1;
+ return list;
}
+
new_l->next = NULL;
new_l->data = (void *)data;
if (!list)
{
- new_l->prev = NULL;
- new_l->accounting = evas_mempool_malloc(&_evas_list_accounting_mempool, sizeof(Evas_List_Accounting));
- if (!new_l->accounting)
- {
- _evas_list_alloc_error = 1;
- evas_mempool_free(&_evas_list_mempool, new_l);
- return list;
- }
- new_l->accounting->last = new_l;
- new_l->accounting->count = 1;
- return new_l;
+ new_l->prev = NULL;
+ new_l->accounting = evas_mempool_malloc(&_evas_list_accounting_mempool,
+ sizeof(Evas_List_Accounting));
+ if (!new_l->accounting)
+ {
+ _evas_list_alloc_error = 1;
+ evas_mempool_free(&_evas_list_mempool, new_l);
+ return list;
+ }
+
+ new_l->accounting->last = new_l;
+ new_l->accounting->count = 1;
+ return new_l;
}
+
l = list->accounting->last;
l->next = new_l;
new_l->prev = l;
new_l = evas_mempool_malloc(&_evas_list_mempool, sizeof(Evas_List));
if (!new_l)
{
- _evas_list_alloc_error = 1;
- return list;
+ _evas_list_alloc_error = 1;
+ return list;
}
+
new_l->prev = NULL;
new_l->data = (void *)data;
if (!list)
{
- new_l->next = NULL;
- new_l->accounting = evas_mempool_malloc(&_evas_list_accounting_mempool, sizeof(Evas_List_Accounting));
- if (!new_l->accounting)
- {
- _evas_list_alloc_error = 1;
- evas_mempool_free(&_evas_list_mempool, new_l);
- return list;
- }
- new_l->accounting->last = new_l;
- new_l->accounting->count = 1;
- return new_l;
+ new_l->next = NULL;
+ new_l->accounting = evas_mempool_malloc(&_evas_list_accounting_mempool,
+ sizeof(Evas_List_Accounting));
+ if (!new_l->accounting)
+ {
+ _evas_list_alloc_error = 1;
+ evas_mempool_free(&_evas_list_mempool, new_l);
+ return list;
+ }
+
+ new_l->accounting->last = new_l;
+ new_l->accounting->count = 1;
+ return new_l;
}
+
new_l->next = list;
list->prev = new_l;
new_l->accounting = list->accounting;
* @ingroup Evas_List_Data_Group
*/
EAPI Evas_List *
-evas_list_append_relative(Evas_List *list, const void *data, const void *relative)
+evas_list_append_relative(Evas_List *list,
+ const void *data,
+ const void *relative)
{
Evas_List *l;
for (l = list; l; l = l->next)
{
- if (l->data == relative)
- return evas_list_append_relative_list(list, data, l);
+ if (l->data == relative)
+ return evas_list_append_relative_list(list, data, l);
}
return evas_list_append(list, data);
}
EAPI Evas_List *
-evas_list_append_relative_list(Evas_List *list, const void *data, Evas_List *relative)
+evas_list_append_relative_list(Evas_List *list,
+ const void *data,
+ Evas_List *relative)
{
Evas_List *new_l;
- if ((!list) || (!relative)) return evas_list_append(list, data);
+ if ((!list) || (!relative))
+ return evas_list_append(list, data);
+
_evas_list_alloc_error = 0;
new_l = evas_mempool_malloc(&_evas_list_mempool, sizeof(Evas_List));
if (!new_l)
{
- _evas_list_alloc_error = 1;
- return list;
+ _evas_list_alloc_error = 1;
+ return list;
}
+
new_l->data = (void *)data;
if (relative->next)
{
- new_l->next = relative->next;
- relative->next->prev = new_l;
+ new_l->next = relative->next;
+ relative->next->prev = new_l;
}
else
- new_l->next = NULL;
+ new_l->next = NULL;
relative->next = new_l;
new_l->prev = relative;
new_l->accounting = list->accounting;
list->accounting->count++;
if (!new_l->next)
- new_l->accounting->last = new_l;
+ new_l->accounting->last = new_l;
+
return list;
}
* @ingroup Evas_List_Data_Group
*/
EAPI Evas_List *
-evas_list_prepend_relative(Evas_List *list, const void *data, const void *relative)
+evas_list_prepend_relative(Evas_List *list,
+ const void *data,
+ const void *relative)
{
Evas_List *l;
_evas_list_alloc_error = 0;
for (l = list; l; l = l->next)
{
- if (l->data == relative)
- return evas_list_prepend_relative_list(list, data, l);
+ if (l->data == relative)
+ return evas_list_prepend_relative_list(list, data, l);
}
return evas_list_prepend(list, data);
}
EAPI Evas_List *
-evas_list_prepend_relative_list(Evas_List *list, const void *data, Evas_List *relative)
+evas_list_prepend_relative_list(Evas_List *list,
+ const void *data,
+ Evas_List *relative)
{
Evas_List *new_l;
- if ((!list) || (!relative)) return evas_list_prepend(list, data);
+ if ((!list) || (!relative))
+ return evas_list_prepend(list, data);
+
_evas_list_alloc_error = 0;
new_l = evas_mempool_malloc(&_evas_list_mempool, sizeof(Evas_List));
if (!new_l)
{
- _evas_list_alloc_error = 1;
- return list;
+ _evas_list_alloc_error = 1;
+ return list;
}
+
new_l->data = (void *)data;
new_l->prev = relative->prev;
new_l->next = relative;
- if (relative->prev) relative->prev->next = new_l;
+ if (relative->prev)
+ relative->prev->next = new_l;
+
relative->prev = new_l;
new_l->accounting = list->accounting;
list->accounting->count++;
if (new_l->prev)
- return list;
+ return list;
+
return new_l;
}
for (l = list; l; l = l->next)
{
- if (l->data == data)
- return evas_list_remove_list(list, l);
+ if (l->data == data)
+ return evas_list_remove_list(list, l);
}
return list;
}
{
Evas_List *return_l;
- if (!list) return NULL;
- if (!remove_list) return list;
- if (remove_list->next) remove_list->next->prev = remove_list->prev;
+ if (!list)
+ return NULL;
+
+ if (!remove_list)
+ return list;
+
+ if (remove_list->next)
+ remove_list->next->prev = remove_list->prev;
+
if (remove_list->prev)
{
- remove_list->prev->next = remove_list->next;
- return_l = list;
+ remove_list->prev->next = remove_list->next;
+ return_l = list;
}
else
- return_l = remove_list->next;
+ return_l = remove_list->next;
+
if (remove_list == list->accounting->last)
- list->accounting->last = remove_list->prev;
+ list->accounting->last = remove_list->prev;
+
list->accounting->count--;
if (list->accounting->count == 0)
- evas_mempool_free(&_evas_list_accounting_mempool, list->accounting);
- evas_mempool_free(&_evas_list_mempool, remove_list);
+ evas_mempool_free(&_evas_list_accounting_mempool, list->accounting);
+
+ evas_mempool_free(&_evas_list_mempool, remove_list);
return return_l;
}
{
Evas_List *return_l;
- if (!list) return NULL;
- if (!move_list) return list;
- if (move_list == list) return list;
- if (move_list->next) move_list->next->prev = move_list->prev;
+ if (!list)
+ return NULL;
+
+ if (!move_list)
+ return list;
+
+ if (move_list == list)
+ return list;
+
+ if (move_list->next)
+ move_list->next->prev = move_list->prev;
+
if (move_list->prev)
{
- move_list->prev->next = move_list->next;
- return_l = list;
+ move_list->prev->next = move_list->next;
+ return_l = list;
}
else
- return_l = move_list->next;
+ return_l = move_list->next;
+
if (move_list == list->accounting->last)
- list->accounting->last = move_list->prev;
+ list->accounting->last = move_list->prev;
+
move_list->prev = return_l->prev;
if (return_l->prev)
- return_l->prev->next = move_list;
+ return_l->prev->next = move_list;
+
return_l->prev = move_list;
move_list->next = return_l;
return move_list;
for (l = list; l; l = l->next)
{
- if (l->data == data) return (void *)data;
+ if (l->data == data)
+ return (void *)data;
}
return NULL;
}
for (l = list; l; l = l->next)
{
- if (l->data == data) return (Evas_List *)l;
+ if (l->data == data)
+ return (Evas_List *)l;
}
return NULL;
}
{
Evas_List *l, *free_l;
- if (!list) return NULL;
- evas_mempool_free(&_evas_list_accounting_mempool, list->accounting);
- for (l = list; l;)
+ if (!list)
+ return NULL;
+
+ evas_mempool_free(&_evas_list_accounting_mempool, list->accounting);
+ for (l = list; l; )
{
- free_l = l;
- l = l->next;
- evas_mempool_free(&_evas_list_mempool, free_l);
+ free_l = l;
+ l = l->next;
+ evas_mempool_free(&_evas_list_mempool, free_l);
}
return NULL;
}
EAPI Evas_List *
evas_list_last(const Evas_List *list)
{
- if (!list) return NULL;
+ if (!list)
+ return NULL;
+
return list->accounting->last;
}
EAPI Evas_List *
evas_list_next(const Evas_List *list)
{
- if (!list) return NULL;
+ if (!list)
+ return NULL;
+
return list->next;
}
EAPI Evas_List *
evas_list_prev(const Evas_List *list)
{
- if (!list) return NULL;
+ if (!list)
+ return NULL;
+
return list->prev;
}
EAPI void *
evas_list_data(const Evas_List *list)
{
- if (!list) return NULL;
+ if (!list)
+ return NULL;
+
return list->data;
}
EAPI int
evas_list_count(const Evas_List *list)
{
- if (!list) return 0;
+ if (!list)
+ return 0;
+
return list->accounting->count;
}
/* check for non-existing nodes */
if ((!list) || (n < 0) ||
(n > (list->accounting->count - 1)))
- return NULL;
+ return NULL;
/* if the node is in the 2nd half of the list, search from the end
* else, search from the beginning.
*/
if (n > (list->accounting->count / 2))
- {
- for (i = list->accounting->count - 1,
- l = list->accounting->last;
- l;
- l = l->prev, i--)
- {
- if (i == n) return (Evas_List *)l;
- }
- }
+ for (i = list->accounting->count - 1,
+ l = list->accounting->last;
+ l;
+ l = l->prev, i--)
+ {
+ if (i == n)
+ return (Evas_List *)l;
+ }
else
- {
- for (i = 0, l = list; l; l = l->next, i++)
- {
- if (i == n) return (Evas_List *)l;
- }
- }
+ for (i = 0, l = list; l; l = l->next, i++)
+ {
+ if (i == n)
+ return (Evas_List *)l;
+ }
+
return NULL;
}
{
Evas_List *l1, *l2;
- if (!list) return NULL;
+ if (!list)
+ return NULL;
+
l1 = list;
l2 = list->accounting->last;
while (l1 != l2)
{
- void *data;
-
- data = l1->data;
- l1->data = l2->data;
- l2->data = data;
- l1 = l1->next;
- if (l1 == l2) break;
- l2 = l2->prev;
+ void *data;
+
+ data = l1->data;
+ l1->data = l2->data;
+ l2->data = data;
+ l1 = l1->next;
+ if (l1 == l2)
+ break;
+
+ l2 = l2->prev;
}
return list;
EAPI Evas_List *
evas_list_sort(Evas_List *list, int size, int (*func)(void *, void *))
{
- Evas_List* last;
- unsigned int list_number;
- unsigned int middle;
- int list_size;
+ Evas_List *last;
+ unsigned int list_number;
+ unsigned int middle;
+ int list_size;
if (!list || !func)
- return NULL;
+ return NULL;
/* if the caller specified an invalid size, sort the whole list */
if ((size <= 0) ||
(size > list->accounting->count))
- size = list->accounting->count;
+ size = list->accounting->count;
last = list->accounting->last;
middle = size - size / 2;
for (list_number = middle, list_size = 1;
- list_size < middle * 2;
- list_number >>= 1, list_size <<= 1)
+ list_size < middle * 2;
+ list_number >>= 1, list_size <<= 1)
{
- Evas_List *head1 = list;
- unsigned int limit = size;
- unsigned int process_list;
- unsigned int pass_number;
- unsigned int split_size = list_size;
-
- for (process_list = 0; process_list < list_number + 1; ++process_list)
- {
- Evas_List *head2;
- unsigned int size_sum;
- int size1, size2;
- int i;
-
- size1 = limit < split_size ? limit : split_size;
- limit -= size1;
-
- size2 = limit < split_size ? limit : split_size;
- limit -= size2;
-
- size_sum = size1 + size2;
-
- for (head2 = head1, i = 0; i < size1; ++i)
- head2 = evas_list_next (head2);
-
- for (pass_number = 0; pass_number < size_sum; ++pass_number)
- {
- Evas_List *next;
- Evas_List *prev1;
- Evas_List *prev2;
-
- if (size1 == 0 || head1 == NULL) /* List1 is empty, head1 is already at the end of the list. So only need to update head2 */
- {
- for (; pass_number < size_sum; ++pass_number)
- head2 = evas_list_next (head2);
- break;
- }
- else
- if (size2 == 0 || head2 == NULL) /* List2 is empty, just leave */
- break;
- else
- if (func (head1->data, head2->data) < 0)
- {
- head1 = evas_list_next (head1);
- --size1;
- }
- else
- {
- next = evas_list_next (head2);
- prev1 = evas_list_prev (head1);
- prev2 = evas_list_prev (head2);
-
- if (next)
- next->prev = prev2;
- if (prev1)
- prev1->next = head2;
- if (prev2)
- prev2->next = next;
-
- head2->prev = prev1;
- head2->next = head1;
- head1->prev = head2;
-
- --size2;
-
- if (head1 == list)
- list = head2;
- if (head2 == last)
- last = prev2;
-
- head2 = next;
- }
- }
- head1 = head2;
- }
+ Evas_List *head1 = list;
+ unsigned int limit = size;
+ unsigned int process_list;
+ unsigned int pass_number;
+ unsigned int split_size = list_size;
+
+ for (process_list = 0; process_list < list_number + 1; ++process_list)
+ {
+ Evas_List *head2;
+ unsigned int size_sum;
+ int size1, size2;
+ int i;
+
+ size1 = limit < split_size ? limit : split_size;
+ limit -= size1;
+
+ size2 = limit < split_size ? limit : split_size;
+ limit -= size2;
+
+ size_sum = size1 + size2;
+
+ for (head2 = head1, i = 0; i < size1; ++i)
+ head2 = evas_list_next (head2);
+
+ for (pass_number = 0; pass_number < size_sum; ++pass_number)
+ {
+ Evas_List *next;
+ Evas_List *prev1;
+ Evas_List *prev2;
+
+ if (size1 == 0 || head1 == NULL) /* List1 is empty, head1 is already at the end of the list. So only need to update head2 */
+ {
+ for (; pass_number < size_sum; ++pass_number)
+ head2 = evas_list_next (head2);
+ break;
+ }
+ else
+ if (size2 == 0 || head2 == NULL) /* List2 is empty, just leave */
+ break;
+ else
+ if (func (head1->data, head2->data) < 0)
+ {
+ head1 = evas_list_next (head1);
+ --size1;
+ }
+ else
+ {
+ next = evas_list_next (head2);
+ prev1 = evas_list_prev (head1);
+ prev2 = evas_list_prev (head2);
+
+ if (next)
+ next->prev = prev2;
+
+ if (prev1)
+ prev1->next = head2;
+
+ if (prev2)
+ prev2->next = next;
+
+ head2->prev = prev1;
+ head2->next = head1;
+ head1->prev = head2;
+
+ --size2;
+
+ if (head1 == list)
+ list = head2;
+
+ if (head2 == last)
+ last = prev2;
+
+ head2 = next;
+ }
+ }
+ head1 = head2;
+ }
}
list->accounting->last = last;
struct _Pool
{
- int usage;
+ int usage;
void *base;
Pool *prev, *next;
};
void **ptr;
int item_alloc, i;
- item_alloc = ((pool->item_size + sizeof(void *) - 1) / sizeof(void *)) * sizeof(void *);
+ item_alloc =
+ ((pool->item_size + sizeof(void *) - 1) / sizeof(void *)) * sizeof(void *);
p = malloc(sizeof(Pool) + (pool->pool_size * item_alloc));
ptr = (void **)(((unsigned char *)p) + sizeof(Pool));
p->usage = 0;
p->base = ptr;
for (i = 0; i < pool->pool_size - 1; i++)
{
- *ptr = (void **)(((unsigned char *)ptr) + item_alloc);
- ptr = *ptr;
+ *ptr = (void **)(((unsigned char *)ptr) + item_alloc);
+ ptr = *ptr;
}
*ptr = NULL;
return p;
for (p = pool->first; p; p = p->next) // look 4 pool from 2nd bucket on
{
- if (p->base) // base is not NULL - has a free slot
- {
- if (p->prev)
- {
- if (pool->last == p) pool->last = p->prev;
- p->prev->next = p->next;
- p->prev = NULL;
- p->next = pool->first;
- p->next->prev = p;
- pool->first = p;
- }
- break;
- }
+ if (p->base) // base is not NULL - has a free slot
+ {
+ if (p->prev)
+ {
+ if (pool->last == p)
+ pool->last = p->prev;
+
+ p->prev->next = p->next;
+ p->prev = NULL;
+ p->next = pool->first;
+ p->next->prev = p;
+ pool->first = p;
+ }
+
+ break;
+ }
}
if (!p) // we have reached the end of the list - no free pools
{
- p = _evas_mp_pool_new(pool);
- if (!p) return NULL;
- p->prev = NULL;
- p->next = pool->first;
- if (p->next) p->next->prev = p;
- if (!pool->last) pool->last = p;
- pool->first = p;
+ p = _evas_mp_pool_new(pool);
+ if (!p)
+ return NULL;
+
+ p->prev = NULL;
+ p->next = pool->first;
+ if (p->next)
+ p->next->prev = p;
+
+ if (!pool->last)
+ pool->last = p;
+
+ pool->first = p;
}
+
mem = p->base; // this points to the next free block - so take it
p->base = *((void **)mem); // base now points to the next free block
if (!p->base) // move to end - it just filled up
- {
- if (p->next)
- {
- if (p->prev) p->prev->next = p->next;
- else pool->first = p->next;
- p->next->prev = p->prev;
- ((Pool *)pool->last)->next = p;
- p->prev = pool->last;
- p->next = NULL;
- pool->last = p;
- }
- }
+ if (p->next)
+ {
+ if (p->prev)
+ p->prev->next = p->next;
+ else
+ pool->first = p->next;
+
+ p->next->prev = p->prev;
+ ((Pool *)pool->last)->next = p;
+ p->prev = pool->last;
+ p->next = NULL;
+ pool->last = p;
+ }
+
p->usage++;
pool->usage++;
return mem;
void *pmem;
int item_alloc, psize;
- item_alloc = ((pool->item_size + sizeof(void *) - 1) / sizeof(void *)) * sizeof(void *);
+ item_alloc =
+ ((pool->item_size + sizeof(void *) - 1) / sizeof(void *)) * sizeof(void *);
psize = item_alloc * pool->pool_size;
for (p = (Pool *)(pool->first); p; p = p->next) // look 4 pool
{
- pmem = (void *)(((unsigned char *)p) + sizeof(Pool)); // pool mem base
- if ((ptr >= pmem) && ((unsigned char *)ptr < (((unsigned char *)pmem) + psize))) // is it in pool mem?
- {
- *((void **)ptr) = p->base; // freed node points to prev free node
- p->base = ptr; // next free node is now the one we freed
- p->usage--;
- pool->usage--;
- if (p->usage == 0) // free bucket
- {
- if (p->prev) p->prev->next = p->next;
- if (p->next) p->next->prev = p->prev;
- if (pool->last == p) pool->last = p->prev;
- if (pool->first == p) pool->first = p->next;
- _evas_mp_pool_free(p);
- }
- else
- {
- if (p->prev) // if not the first - move to front
- {
- p->prev->next = p->next;
- if (p->next) p->next->prev = p->prev;
- if (pool->last == p) pool->last = p->prev;
- p->prev = NULL;
- p->next = pool->first;
- p->next->prev = p;
- pool->first = p;
- }
- }
- break;
- }
+ pmem = (void *)(((unsigned char *)p) + sizeof(Pool)); // pool mem base
+ if ((ptr >= pmem) &&
+ ((unsigned char *)ptr < (((unsigned char *)pmem) + psize))) // is it in pool mem?
+ {
+ *((void **)ptr) = p->base; // freed node points to prev free node
+ p->base = ptr; // next free node is now the one we freed
+ p->usage--;
+ pool->usage--;
+ if (p->usage == 0) // free bucket
+ {
+ if (p->prev)
+ p->prev->next = p->next;
+
+ if (p->next)
+ p->next->prev = p->prev;
+
+ if (pool->last == p)
+ pool->last = p->prev;
+
+ if (pool->first == p)
+ pool->first = p->next;
+
+ _evas_mp_pool_free(p);
+ }
+ else if (p->prev) // if not the first - move to front
+ {
+ p->prev->next = p->next;
+ if (p->next)
+ p->next->prev = p->prev;
+
+ if (pool->last == p)
+ pool->last = p->prev;
+
+ p->prev = NULL;
+ p->next = pool->first;
+ p->next->prev = p;
+ pool->first = p;
+ }
+
+ break;
+ }
}
#endif
}
struct _Evas_Mempool
{
- int item_size;
- int pool_size;
- int usage;
- void *first, *last;
+ int item_size;
+ int pool_size;
+ int usage;
+ void *first, *last;
};
new_l->next = NULL;
if (!list)
{
- new_l->prev = NULL;
- new_l->last = new_l;
- return new_l;
+ new_l->prev = NULL;
+ new_l->last = new_l;
+ return new_l;
}
- if (list->last) l = list->last;
- else for (l = list; (l) && (l->next); l = l->next);
+
+ if (list->last)
+ l = list->last;
+ else
+ for (l = list; (l) && (l->next); l = l->next) ;
+
l->next = new_l;
new_l->prev = l;
list->last = new_l;
new_l->prev = NULL;
if (!list)
{
- new_l->next = NULL;
- new_l->last = new_l;
- return new_l;
+ new_l->next = NULL;
+ new_l->last = new_l;
+ return new_l;
}
+
new_l->next = list;
list->prev = new_l;
new_l->last = list->last;
}
void *
-evas_object_list_append_relative(void *in_list, void *in_item, void *in_relative)
+evas_object_list_append_relative(void *in_list,
+ void *in_item,
+ void *in_relative)
{
Evas_Object_List *list, *relative, *new_l;
relative = in_relative;
if (relative)
{
- if (relative->next)
- {
- new_l->next = relative->next;
- relative->next->prev = new_l;
- }
- else new_l->next = NULL;
- relative->next = new_l;
- new_l->prev = relative;
- if (!new_l->next) list->last = new_l;
- return list;
+ if (relative->next)
+ {
+ new_l->next = relative->next;
+ relative->next->prev = new_l;
+ }
+ else
+ new_l->next = NULL;
+
+ relative->next = new_l;
+ new_l->prev = relative;
+ if (!new_l->next)
+ list->last = new_l;
+
+ return list;
}
+
return evas_object_list_append(list, new_l);
}
void *
-evas_object_list_prepend_relative(void *in_list, void *in_item, void *in_relative)
+evas_object_list_prepend_relative(void *in_list,
+ void *in_item,
+ void *in_relative)
{
Evas_Object_List *list, *relative, *new_l;
relative = in_relative;
if (relative)
{
- new_l->prev = relative->prev;
- new_l->next = relative;
- relative->prev = new_l;
- if (new_l->prev)
- {
- new_l->prev->next = new_l;
- if (!new_l->next)
- list->last = new_l;
- return list;
- }
- else
- {
- if (!new_l->next)
- new_l->last = new_l;
- else
- {
- new_l->last = list->last;
- list->last = NULL;
- }
- return new_l;
- }
+ new_l->prev = relative->prev;
+ new_l->next = relative;
+ relative->prev = new_l;
+ if (new_l->prev)
+ {
+ new_l->prev->next = new_l;
+ if (!new_l->next)
+ list->last = new_l;
+
+ return list;
+ }
+ else
+ {
+ if (!new_l->next)
+ new_l->last = new_l;
+ else
+ {
+ new_l->last = list->last;
+ list->last = NULL;
+ }
+
+ return new_l;
+ }
}
+
return evas_object_list_prepend(list, new_l);
}
/* checkme */
if(!in_list)
- return in_list;
+ return in_list;
list = in_list;
item = in_item;
- if (!item) return list;
+ if (!item)
+ return list;
+
if (item->next)
- item->next->prev = item->prev;
+ item->next->prev = item->prev;
+
if (item->prev)
{
- item->prev->next = item->next;
- return_l = list;
+ item->prev->next = item->next;
+ return_l = list;
}
else
{
- return_l = item->next;
- if (return_l)
- return_l->last = list->last;
+ return_l = item->next;
+ if (return_l)
+ return_l->last = list->last;
}
+
if (item == list->last)
- list->last = item->prev;
+ list->last = item->prev;
+
item->next = NULL;
item->prev = NULL;
return return_l;
item = in_item;
for (l = list; l; l = l->next)
{
- if (l == item) return item;
+ if (l == item)
+ return item;
}
return NULL;
}
#include "Evas_Data.h"
-typedef struct _Evas_Stringshare Evas_Stringshare;
-typedef struct _Evas_Stringshare_El Evas_Stringshare_El;
+typedef struct _Evas_Stringshare Evas_Stringshare;
+typedef struct _Evas_Stringshare_El Evas_Stringshare_El;
struct _Evas_Stringshare
{
{
Evas_Stringshare_El *next;
// int op;
- int references;
+ int references;
};
static Evas_Stringshare share =
{
- {
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
- }
+ {
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL,
+
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL,
+
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL,
+
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL
+ }
};
//static int op = 0;
for (ptr = (const unsigned char *)str; *ptr; ptr++)
{
- hash_num = (hash_num * 33) ^ *ptr;
+ hash_num = (hash_num * 33) ^ *ptr;
}
hash_num &= 0x3ff;
char *el_str;
Evas_Stringshare_El *el, *pel = NULL;
- if (!str) return NULL;
-// if (!f)
+ if (!str)
+ return NULL; // if (!f)
+
// {
// char bf[256];
// snprintf(bf, sizeof(bf), "strlog-%i", getpid());
hash_num = _evas_stringshare_hash_gen(str, &slen);
for (el = share.buckets[hash_num]; el; pel = el, el = el->next)
{
- el_str = ((char *)el) + sizeof(Evas_Stringshare_El);
- if (!strcmp(el_str, str))
- {
- if (pel)
- {
- pel->next = el->next;
- el->next = share.buckets[hash_num];
- share.buckets[hash_num] = el;
- }
- el->references++;
+ el_str = ((char *)el) + sizeof(Evas_Stringshare_El);
+ if (!strcmp(el_str, str))
+ {
+ if (pel)
+ {
+ pel->next = el->next;
+ el->next = share.buckets[hash_num];
+ share.buckets[hash_num] = el;
+ }
+
+ el->references++;
// fprintf(f, "strings[%i] = str->add(strings[%i]);\n", el->op, el->op);
// fflush(f);
- return el_str;
- }
+ return el_str;
+ }
}
- if (!(el = malloc(sizeof(Evas_Stringshare_El) + slen + 1))) return NULL;
+ if (!(el = malloc(sizeof(Evas_Stringshare_El) + slen + 1)))
+ return NULL;
+
el_str = ((char *)el) + sizeof(Evas_Stringshare_El);
strcpy(el_str, str);
el->references = 1;
char *el_str;
Evas_Stringshare_El *el, *pel = NULL;
- if (!str) return;
+ if (!str)
+ return;
+
hash_num = _evas_stringshare_hash_gen(str, &slen);
for (el = share.buckets[hash_num]; el; pel = el, el = el->next)
{
- el_str = ((char *)el) + sizeof(Evas_Stringshare_El);
- if (el_str == str)
- {
- el->references--;
+ el_str = ((char *)el) + sizeof(Evas_Stringshare_El);
+ if (el_str == str)
+ {
+ el->references--;
// fprintf(f, "str->del(strings[%i]);\n", el->op);
// fflush(f);
- if (el->references == 0)
- {
- if (pel) pel->next = el->next;
- else share.buckets[hash_num] = el->next;
- free(el);
- }
- else
- {
- if (pel)
- {
- pel->next = el->next;
- el->next = share.buckets[hash_num];
- share.buckets[hash_num] = el;
- }
- }
- return;
- }
+ if (el->references == 0)
+ {
+ if (pel)
+ pel->next = el->next;
+ else
+ share.buckets[hash_num] = el->next;
+
+ free(el);
+ }
+ else if (pel)
+ {
+ pel->next = el->next;
+ el->next = share.buckets[hash_num];
+ share.buckets[hash_num] = el;
+ }
+
+ return;
+ }
}
printf("EEEK trying to del non-shared stringshare \"%s\"\n", str);
abort();