API BREAK: fix Eina API so that it is more consistent with the other EFL

what is modified:

eina_counter_add -> eina_counter_new
eina_counter_delete -> eina_counter_free
eina_lalloc_delete -> eina_lalloc_free
eina_mempool_new -> eina_mempool_add
eina_mempool_delete -> eina_mempool_del
eina_mempool_alloc -> eina_mempool_malloc
eina_tiler_del -> eina_tiler_free

It remains some questions: have the following API a good name:

eina_module_list_delete
eina_list_free
eina_rbtree_delete

(see ticket #286)

If you find any problem, please report in that thread


SVN revision: 41187
This commit is contained in:
Vincent Torri 2009-06-24 16:56:49 +00:00
parent 3b384b323c
commit ebc20c2236
20 changed files with 67 additions and 67 deletions

View File

@ -42,8 +42,8 @@ typedef struct _Eina_Counter Eina_Counter;
EAPI int eina_counter_init(void);
EAPI int eina_counter_shutdown(void);
EAPI Eina_Counter *eina_counter_add(const char *name) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
EAPI void eina_counter_delete(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);

View File

@ -45,7 +45,7 @@ eina_mempool_realloc(Eina_Mempool *mp, void *element, unsigned int size)
}
static inline void *
eina_mempool_alloc(Eina_Mempool *mp, unsigned int size)
eina_mempool_malloc(Eina_Mempool *mp, unsigned int size)
{
return mp->backend.alloc(mp->backend_data, size);
}

View File

@ -41,7 +41,7 @@ typedef void (*Eina_Lalloc_Free) (void *user_data);
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_delete(Eina_Lalloc *a) EINA_ARG_NONNULL(1);
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);

View File

@ -43,11 +43,11 @@ EAPI extern Eina_Error EINA_ERROR_NOT_MEMPOOL_MODULE;
EAPI int eina_mempool_init(void);
EAPI int eina_mempool_shutdown(void);
EAPI Eina_Mempool * eina_mempool_new(const char *module, const char *context, const char *options, ...) EINA_MALLOC EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
EAPI void eina_mempool_delete(Eina_Mempool *mp) EINA_ARG_NONNULL(1);
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_alloc(Eina_Mempool *mp, unsigned int size) EINA_MALLOC EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
static inline void * eina_mempool_malloc(Eina_Mempool *mp, unsigned int size) EINA_MALLOC EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
static inline void eina_mempool_free(Eina_Mempool *mp, void *element) EINA_ARG_NONNULL(1);
EAPI void eina_mempool_gc(Eina_Mempool *mp) EINA_ARG_NONNULL(1);

View File

@ -51,7 +51,7 @@ EAPI int eina_module_init(void);
EAPI int eina_module_shutdown(void);
EAPI Eina_Module * eina_module_new(const char *file) EINA_MALLOC EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
EAPI Eina_Bool eina_module_delete(Eina_Module *m) 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(Eina_Module *module, const char *symbol) EINA_PURE EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;

View File

@ -26,7 +26,7 @@
typedef struct _Eina_Tiler Eina_Tiler;
EAPI Eina_Tiler *eina_tiler_new(int w, int h);
EAPI void eina_tiler_del(Eina_Tiler *t);
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, Eina_Rectangle *r);
EAPI void eina_tiler_rect_del(Eina_Tiler *t, Eina_Rectangle *r);

View File

@ -405,7 +405,7 @@ eina_benchmark_run(Eina_Benchmark *bench)
eina_array_push(ea, strdup(buffer));
counter = eina_counter_add(run->name);
counter = eina_counter_new(run->name);
for (i = run->start; i < run->end; i += run->step)
{
@ -424,7 +424,7 @@ eina_benchmark_run(Eina_Benchmark *bench)
free(result);
}
eina_counter_delete(counter);
eina_counter_free(counter);
fclose(current_data);

View File

@ -153,7 +153,7 @@ _eina_counter_asiprintf(char *base, int *position, const char *format, ...)
*
* The counter system must be initialized with eina_counter_init() and
* shut down with eina_counter_shutdown(). The create a counter, use
* eina_counter_add(). To free it, use eina_counter_delete().
* eina_counter_new(). To free it, use eina_counter_free().
*
* To time a part of a code, call eina_counter_start() just before it,
* and eina_counter_stop() just after it. Each time you start to time
@ -193,7 +193,7 @@ _eina_counter_asiprintf(char *base, int *position, const char *format, ...)
* return EXIT_FAILURE;
* }
*
* counter = eina_counter_add("malloc");
* counter = eina_counter_new("malloc");
*
* eina_counter_start(counter);
* test_malloc();
@ -201,7 +201,7 @@ _eina_counter_asiprintf(char *base, int *position, const char *format, ...)
*
* eina_counter_dump(counter);
*
* eina_counter_delete(counter);
* eina_counter_free(counter);
* eina_counter_shutdown();
*
* return EXIT_SUCCESS;
@ -306,7 +306,7 @@ eina_counter_shutdown(void)
* error is set to #EINA_ERROR_OUT_OF_MEMORY.
*/
EAPI Eina_Counter *
eina_counter_add(const char *name)
eina_counter_new(const char *name)
{
Eina_Counter *counter;
size_t length;
@ -340,7 +340,7 @@ eina_counter_add(const char *name)
* immediatly.
*/
EAPI void
eina_counter_delete(Eina_Counter *counter)
eina_counter_free(Eina_Counter *counter)
{
EINA_SAFETY_ON_NULL_RETURN(counter);

View File

@ -81,7 +81,7 @@ EAPI Eina_Lalloc * eina_lalloc_new(void *data, Eina_Lalloc_Alloc alloc_cb, Eina_
return a;
}
EAPI void eina_lalloc_delete(Eina_Lalloc *a)
EAPI void eina_lalloc_free(Eina_Lalloc *a)
{
EINA_SAFETY_ON_NULL_RETURN(a);
EINA_SAFETY_ON_NULL_RETURN(a->free_cb);

View File

@ -160,7 +160,7 @@ _eina_list_mempool_accounting_new(__UNUSED__ Eina_List *list)
{
Eina_List_Accounting *tmp;
tmp = eina_mempool_alloc(_eina_list_accounting_mp, sizeof (Eina_List_Accounting));
tmp = eina_mempool_malloc(_eina_list_accounting_mp, sizeof (Eina_List_Accounting));
if (!tmp) return NULL;
EINA_MAGIC_SET(tmp, EINA_MAGIC_LIST_ACCOUNTING);
@ -181,7 +181,7 @@ _eina_list_mempool_list_new(__UNUSED__ Eina_List *list)
{
Eina_List *tmp;
tmp = eina_mempool_alloc(_eina_list_mp, sizeof (Eina_List));
tmp = eina_mempool_malloc(_eina_list_mp, sizeof (Eina_List));
if (!tmp) return NULL;
EINA_MAGIC_SET(tmp, EINA_MAGIC_LIST);
@ -487,19 +487,19 @@ eina_list_init(void)
choice = "chained_mempool";
#endif
_eina_list_mp = eina_mempool_new(choice, "list", NULL,
_eina_list_mp = eina_mempool_add(choice, "list", NULL,
sizeof (Eina_List), 320);
if (!_eina_list_mp)
{
EINA_ERROR_PERR("ERROR: Mempool for list cannot be allocated in list init.\n");
goto on_init_fail;
}
_eina_list_accounting_mp = eina_mempool_new(choice, "list_accounting", NULL,
_eina_list_accounting_mp = eina_mempool_add(choice, "list_accounting", NULL,
sizeof (Eina_List_Accounting), 80);
if (!_eina_list_accounting_mp)
{
EINA_ERROR_PERR("ERROR: Mempool for list accounting cannot be allocated in list init.\n");
eina_mempool_delete(_eina_list_mp);
eina_mempool_del(_eina_list_mp);
goto on_init_fail;
}
@ -546,8 +546,8 @@ eina_list_shutdown(void)
if (!_eina_list_init_count)
{
eina_mempool_delete(_eina_list_accounting_mp);
eina_mempool_delete(_eina_list_mp);
eina_mempool_del(_eina_list_accounting_mp);
eina_mempool_del(_eina_list_mp);
eina_mempool_shutdown();
eina_magic_string_shutdown();

View File

@ -231,7 +231,7 @@ eina_mempool_shutdown(void)
}
EAPI Eina_Mempool *
eina_mempool_new(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;
@ -245,7 +245,7 @@ eina_mempool_new(const char *name, const char *context, const char *options, ...
return mp;
}
EAPI void eina_mempool_delete(Eina_Mempool *mp)
EAPI void eina_mempool_del(Eina_Mempool *mp)
{
EINA_SAFETY_ON_NULL_RETURN(mp);
EINA_SAFETY_ON_NULL_RETURN(mp->backend.shutdown);

View File

@ -140,7 +140,7 @@ static void _dir_list_cb(const char *name, const char *path, void *data)
return;
/* call the user provided cb on this module */
if (!cb_data->cb(m, cb_data->data))
eina_module_delete(m);
eina_module_free(m);
}
}
static int _eina_module_count = 0;
@ -269,7 +269,7 @@ EAPI Eina_Module * eina_module_new(const char *file)
return m;
}
EAPI Eina_Bool eina_module_delete(Eina_Module *m)
EAPI Eina_Bool eina_module_free(Eina_Module *m)
{
EINA_SAFETY_ON_NULL_RETURN_VAL(m, EINA_FALSE);
@ -422,7 +422,7 @@ EAPI void eina_module_list_unload(Eina_Array *array)
/**
* Helper function that iterates over the list of modules and calls
* eina_module_delete on each
* eina_module_free on each
*/
EAPI void eina_module_list_delete(Eina_Array *array)
{
@ -433,7 +433,7 @@ EAPI void eina_module_list_delete(Eina_Array *array)
EINA_SAFETY_ON_NULL_RETURN(array);
EINA_ARRAY_ITER_NEXT(array, i, m, iterator)
eina_module_delete(m);
eina_module_free(m);
eina_array_flush(array);
}

View File

@ -217,7 +217,7 @@ eina_rectangle_new(int x, int y, int w, int h)
{
Eina_Rectangle *rect;
rect = eina_mempool_alloc(_eina_rectangle_mp, sizeof (Eina_Rectangle));
rect = eina_mempool_malloc(_eina_rectangle_mp, sizeof (Eina_Rectangle));
if (!rect) return NULL;
EINA_RECTANGLE_SET(rect, x, y, w, h);
@ -301,8 +301,8 @@ eina_rectangle_pool_request(Eina_Rectangle_Pool *pool, int w, int h)
if (x == -1) return NULL;
pool->sorted = EINA_FALSE;
new = eina_mempool_alloc(_eina_rectangle_alloc_mp,
sizeof (Eina_Rectangle_Alloc) + sizeof (Eina_Rectangle));
new = eina_mempool_malloc(_eina_rectangle_alloc_mp,
sizeof (Eina_Rectangle_Alloc) + sizeof (Eina_Rectangle));
if (!new) return NULL;
rect = (Eina_Rectangle*) (new + 1);
@ -415,7 +415,7 @@ eina_rectangle_init(void)
choice = "chained_mempool";
#endif
_eina_rectangle_alloc_mp = eina_mempool_new(choice, "rectangle-alloc", NULL,
_eina_rectangle_alloc_mp = eina_mempool_add(choice, "rectangle-alloc", NULL,
sizeof (Eina_Rectangle_Alloc) + sizeof (Eina_Rectangle), 42);
if (!_eina_rectangle_alloc_mp)
{
@ -423,7 +423,7 @@ eina_rectangle_init(void)
goto init_error;
}
_eina_rectangle_mp = eina_mempool_new(choice, "rectangle", NULL, sizeof (Eina_Rectangle), 256);
_eina_rectangle_mp = eina_mempool_add(choice, "rectangle", NULL, sizeof (Eina_Rectangle), 256);
if (!_eina_rectangle_mp)
{
EINA_ERROR_PERR("ERROR: Mempool for rectangle cannot be allocated in list init.\n");
@ -447,8 +447,8 @@ eina_rectangle_shutdown(void)
if (_eina_rectangle_init_count) return _eina_rectangle_init_count;
eina_mempool_delete(_eina_rectangle_alloc_mp);
eina_mempool_delete(_eina_rectangle_mp);
eina_mempool_del(_eina_rectangle_alloc_mp);
eina_mempool_del(_eina_rectangle_mp);
eina_mempool_shutdown();
eina_error_shutdown();

View File

@ -1111,7 +1111,7 @@ EAPI Eina_Tiler *eina_tiler_new(int w, int h)
* To be documented
* FIXME: To be fixed
*/
EAPI void eina_tiler_del(Eina_Tiler *t)
EAPI void eina_tiler_free(Eina_Tiler *t)
{
EINA_MAGIC_CHECK_TILER(t);
_splitter_del(t);

View File

@ -42,7 +42,7 @@ _eina_mempool_bench(Eina_Mempool *mp, int request)
{
for (j = 0; j < request; ++j)
{
eina_array_push(array, eina_mempool_alloc(mp, sizeof (int)));
eina_array_push(array, eina_mempool_malloc(mp, sizeof (int)));
}
for (j = 0; j < request; ++j)
@ -60,9 +60,9 @@ eina_mempool_chained_mempool(int request)
{
Eina_Mempool *mp;
mp = eina_mempool_new("chained_mempool", "test", NULL, sizeof (int), 256);
mp = eina_mempool_add("chained_mempool", "test", NULL, sizeof (int), 256);
_eina_mempool_bench(mp, request);
eina_mempool_delete(mp);
eina_mempool_del(mp);
}
static void
@ -70,9 +70,9 @@ eina_mempool_pass_through(int request)
{
Eina_Mempool *mp;
mp = eina_mempool_new("pass_through", "test", NULL, sizeof (int), 8, 0);
mp = eina_mempool_add("pass_through", "test", NULL, sizeof (int), 8, 0);
_eina_mempool_bench(mp, request);
eina_mempool_delete(mp);
eina_mempool_del(mp);
}
static void
@ -80,9 +80,9 @@ eina_mempool_fixed_bitmap(int request)
{
Eina_Mempool *mp;
mp = eina_mempool_new("fixed_bitmap", "test", NULL, sizeof (int));
mp = eina_mempool_add("fixed_bitmap", "test", NULL, sizeof (int));
_eina_mempool_bench(mp, request);
eina_mempool_delete(mp);
eina_mempool_del(mp);
}
#ifdef EINA_EMEMOA_SUPPORT
@ -91,9 +91,9 @@ eina_mempool_ememoa_fixed(int request)
{
Eina_Mempool *mp;
mp = eina_mempool_new("ememoa_fixed", "test", NULL, sizeof (int), 8, 0);
mp = eina_mempool_add("ememoa_fixed", "test", NULL, sizeof (int), 8, 0);
_eina_mempool_bench(mp, request);
eina_mempool_delete(mp);
eina_mempool_del(mp);
}
static void
@ -101,9 +101,9 @@ eina_mempool_ememoa_unknown(int request)
{
Eina_Mempool *mp;
mp = eina_mempool_new("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_delete(mp);
eina_mempool_del(mp);
}
#endif

View File

@ -97,7 +97,7 @@ eina_bench_e17_stringshare(Eina_Stringshare_Test *str)
{
Eina_Counter *cnt;
cnt = eina_counter_add(str->name);
cnt = eina_counter_new(str->name);
eina_counter_start(cnt);
@ -112,7 +112,7 @@ eina_bench_e17_stringshare(Eina_Stringshare_Test *str)
fprintf(stderr, "For `%s`:\n", str->name);
eina_counter_dump(cnt);
eina_counter_delete(cnt);
eina_counter_free(cnt);
}
#endif

View File

@ -47,7 +47,7 @@ START_TEST(eina_counter_simple)
eina_counter_init();
cnt = eina_counter_add("eina_test");
cnt = eina_counter_new("eina_test");
fail_if(!cnt);
eina_counter_start(cnt);
@ -71,7 +71,7 @@ START_TEST(eina_counter_simple)
free(dump);
eina_counter_delete(cnt);
eina_counter_free(cnt);
eina_counter_shutdown();
}
@ -84,12 +84,12 @@ START_TEST(eina_counter_break)
eina_counter_init();
cnt = eina_counter_add("eina_test");
cnt = eina_counter_new("eina_test");
fail_if(!cnt);
eina_counter_stop(cnt, 10);
eina_counter_delete(cnt);
eina_counter_free(cnt);
dump = eina_counter_dump(NULL);
fail_if(dump);

View File

@ -74,7 +74,7 @@ START_TEST(eina_lalloc_simple)
fail_if(eina_lalloc_elements_add(test, 50) != EINA_FALSE);
eina_lalloc_delete(test);
eina_lalloc_free(test);
}
END_TEST

View File

@ -52,7 +52,7 @@ _eina_mempool_test(Eina_Mempool *mp, Eina_Bool with_realloc, Eina_Bool with_gc)
for (i = 0; i < 512; ++i)
{
tbl[i] = eina_mempool_alloc(mp, sizeof (int));
tbl[i] = eina_mempool_malloc(mp, sizeof (int));
fail_if(!tbl[i]);
*tbl[i] = i;
}
@ -74,7 +74,7 @@ _eina_mempool_test(Eina_Mempool *mp, Eina_Bool with_realloc, Eina_Bool with_gc)
eina_mempool_statistics(mp);
}
eina_mempool_delete(mp);
eina_mempool_del(mp);
}
START_TEST(eina_mempool_init_shutdown)
@ -83,7 +83,7 @@ START_TEST(eina_mempool_init_shutdown)
_mempool_init();
mp = eina_mempool_new("test", "test", NULL);
mp = eina_mempool_add("test", "test", NULL);
fail_if(mp != NULL);
_mempool_shutdown();
@ -96,7 +96,7 @@ START_TEST(eina_mempool_chained_mempool)
_mempool_init();
mp = eina_mempool_new("chained_mempool", "test", NULL, sizeof (int), 256);
mp = eina_mempool_add("chained_mempool", "test", NULL, sizeof (int), 256);
_eina_mempool_test(mp, EINA_FALSE, EINA_FALSE);
_mempool_shutdown();
@ -109,7 +109,7 @@ START_TEST(eina_mempool_pass_through)
_mempool_init();
mp = eina_mempool_new("pass_through", "test", NULL, sizeof (int), 8, 0);
mp = eina_mempool_add("pass_through", "test", NULL, sizeof (int), 8, 0);
_eina_mempool_test(mp, EINA_TRUE, EINA_FALSE);
_mempool_shutdown();
@ -122,7 +122,7 @@ START_TEST(eina_mempool_fixed_bitmap)
_mempool_init();
mp = eina_mempool_new("fixed_bitmap", "test", NULL, sizeof (int));
mp = eina_mempool_add("fixed_bitmap", "test", NULL, sizeof (int));
_eina_mempool_test(mp, EINA_FALSE, EINA_FALSE);
_mempool_shutdown();
@ -136,7 +136,7 @@ START_TEST(eina_mempool_ememoa_fixed)
_mempool_init();
mp = eina_mempool_new("ememoa_fixed", "test", NULL, sizeof (int), 8, 0);
mp = eina_mempool_add("ememoa_fixed", "test", NULL, sizeof (int), 8, 0);
_eina_mempool_test(mp, EINA_FALSE, EINA_TRUE);
_mempool_shutdown();
@ -149,7 +149,7 @@ START_TEST(eina_mempool_ememoa_unknown)
_mempool_init();
mp = eina_mempool_new("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();

View File

@ -339,7 +339,7 @@ evas_module_find_type(Evas_Module_Type type, const char *name)
if (!eina_module_load(en))
{
eina_module_delete(en);
eina_module_free(en);
continue;
}
@ -350,7 +350,7 @@ evas_module_find_type(Evas_Module_Type type, const char *name)
return em;
}
eina_module_delete(en);
eina_module_free(en);
}
return NULL;
@ -496,7 +496,7 @@ evas_module_shutdown(void)
evas_static_module[i].shutdown();
EINA_LIST_FREE(eina_evas_modules, en)
eina_module_delete(en);
eina_module_free(en);
eina_hash_free(evas_modules[EVAS_MODULE_TYPE_ENGINE]);
eina_hash_free(evas_modules[EVAS_MODULE_TYPE_IMAGE_LOADER]);