forked from enlightenment/efl
Add some type checking to Inlined List.
SVN revision: 36084
This commit is contained in:
parent
80e138df1b
commit
8bda22fced
|
@ -28,9 +28,7 @@
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* TODO change the prototype to use an Eina_Inlist */
|
|
||||||
typedef struct _Eina_Inlist Eina_Inlist;
|
typedef struct _Eina_Inlist Eina_Inlist;
|
||||||
|
|
||||||
struct _Eina_Inlist
|
struct _Eina_Inlist
|
||||||
{
|
{
|
||||||
Eina_Inlist *next;
|
Eina_Inlist *next;
|
||||||
|
@ -38,18 +36,21 @@ struct _Eina_Inlist
|
||||||
Eina_Inlist *last;
|
Eina_Inlist *last;
|
||||||
};
|
};
|
||||||
|
|
||||||
EAPI void * eina_inlist_append(void *in_list, void *in_item);
|
#define EINA_INLIST Eina_Inlist __in_list
|
||||||
EAPI void * eina_inlist_prepend(void *in_list, void *in_item);
|
#define EINA_INLIST_GET(Inlist) &(Inlist->__in_list)
|
||||||
EAPI void * eina_inlist_append_relative(void *in_list, void *in_item, void *in_relative);
|
|
||||||
EAPI void * eina_inlist_prepend_relative(void *in_list, void *in_item, void *in_relative);
|
|
||||||
EAPI void * eina_inlist_remove(void *in_list, void *in_item);
|
|
||||||
EAPI void * eina_inlist_find(void *in_list, void *in_item);
|
|
||||||
|
|
||||||
EAPI Eina_Iterator *eina_inlist_iterator_new(const void *in_list);
|
EAPI Eina_Inlist * eina_inlist_append(Eina_Inlist *in_list, Eina_Inlist *in_item);
|
||||||
EAPI Eina_Accessor *eina_inlist_accessor_new(const void *in_list);
|
EAPI Eina_Inlist * eina_inlist_prepend(Eina_Inlist *in_list, Eina_Inlist *in_item);
|
||||||
|
EAPI Eina_Inlist * eina_inlist_append_relative(Eina_Inlist *in_list, Eina_Inlist *in_item, Eina_Inlist *in_relative);
|
||||||
|
EAPI Eina_Inlist * eina_inlist_prepend_relative(Eina_Inlist *in_list, Eina_Inlist *in_item, Eina_Inlist *in_relative);
|
||||||
|
EAPI Eina_Inlist * eina_inlist_remove(Eina_Inlist *in_list, Eina_Inlist *in_item);
|
||||||
|
EAPI Eina_Inlist * eina_inlist_find(Eina_Inlist *in_list, Eina_Inlist *in_item);
|
||||||
|
|
||||||
#define EINA_INLIST_ITER_NEXT(list, l) for (l = (void*)(Eina_Inlist *)list; l; l = (void*)((Eina_Inlist *)l)->next)
|
EAPI Eina_Iterator *eina_inlist_iterator_new(const Eina_Inlist *in_list);
|
||||||
#define EINA_INLIST_ITER_LAST(list, l) for (l = (void*)((Eina_Inlist *)list)->last; l; l = (void*)((Eina_Inlist *)l)->prev)
|
EAPI Eina_Accessor *eina_inlist_accessor_new(const Eina_Inlist *in_list);
|
||||||
|
|
||||||
|
#define EINA_INLIST_ITER_NEXT(list, l) for (l = (void*)list; l; l = (void*)(l->__in_list.next))
|
||||||
|
#define EINA_INLIST_ITER_LAST(list, l) for (l = (void*)(list->last); l; l = (void*)(l->__in_list.prev))
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@
|
||||||
typedef struct _Eina_Run Eina_Run;
|
typedef struct _Eina_Run Eina_Run;
|
||||||
struct _Eina_Run
|
struct _Eina_Run
|
||||||
{
|
{
|
||||||
Eina_Inlist __list;
|
EINA_INLIST;
|
||||||
|
|
||||||
Eina_Benchmark_Specimens cb;
|
Eina_Benchmark_Specimens cb;
|
||||||
const char *name;
|
const char *name;
|
||||||
|
@ -176,7 +176,7 @@ eina_benchmark_register(Eina_Benchmark *bench, const char *name, Eina_Benchmark_
|
||||||
run->end = count_end;
|
run->end = count_end;
|
||||||
run->step = count_step;
|
run->step = count_step;
|
||||||
|
|
||||||
bench->runs = eina_inlist_append(bench->runs, run);
|
bench->runs = eina_inlist_append(bench->runs, EINA_INLIST_GET(run));
|
||||||
}
|
}
|
||||||
|
|
||||||
EAPI Eina_Array *
|
EAPI Eina_Array *
|
||||||
|
|
|
@ -61,7 +61,7 @@ typedef struct _Eina_Clock Eina_Clock;
|
||||||
|
|
||||||
struct _Eina_Counter
|
struct _Eina_Counter
|
||||||
{
|
{
|
||||||
Eina_Inlist __list;
|
EINA_INLIST;
|
||||||
|
|
||||||
Eina_Inlist *clocks;
|
Eina_Inlist *clocks;
|
||||||
const char *name;
|
const char *name;
|
||||||
|
@ -69,7 +69,7 @@ struct _Eina_Counter
|
||||||
|
|
||||||
struct _Eina_Clock
|
struct _Eina_Clock
|
||||||
{
|
{
|
||||||
Eina_Inlist __list;
|
EINA_INLIST;
|
||||||
|
|
||||||
Eina_Nano_Time start;
|
Eina_Nano_Time start;
|
||||||
Eina_Nano_Time end;
|
Eina_Nano_Time end;
|
||||||
|
@ -272,7 +272,7 @@ eina_counter_start(Eina_Counter *counter)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
counter->clocks = eina_inlist_prepend(counter->clocks, clk);
|
counter->clocks = eina_inlist_prepend(counter->clocks, EINA_INLIST_GET(clk));
|
||||||
|
|
||||||
clk->valid = EINA_FALSE;
|
clk->valid = EINA_FALSE;
|
||||||
clk->start = tp;
|
clk->start = tp;
|
||||||
|
|
|
@ -137,196 +137,189 @@ eina_inlist_accessor_free(Eina_Accessor_Inlist *it) {
|
||||||
* To be documented
|
* To be documented
|
||||||
* FIXME: To be fixed
|
* FIXME: To be fixed
|
||||||
*/
|
*/
|
||||||
EAPI void * eina_inlist_append(void *in_list, void *in_item) {
|
EAPI Eina_Inlist *
|
||||||
Eina_Inlist *l, *new_l;
|
eina_inlist_append(Eina_Inlist *list, Eina_Inlist *new_l)
|
||||||
Eina_Inlist *list;
|
{
|
||||||
|
Eina_Inlist *l;
|
||||||
|
|
||||||
list = in_list;
|
new_l->next = NULL;
|
||||||
new_l = in_item;
|
if (!list) {
|
||||||
|
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)
|
||||||
|
;
|
||||||
|
l->next = new_l;
|
||||||
|
new_l->prev = l;
|
||||||
|
list->last = new_l;
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* To be documented
|
||||||
|
* FIXME: To be fixed
|
||||||
|
*/
|
||||||
|
EAPI Eina_Inlist *
|
||||||
|
eina_inlist_prepend(Eina_Inlist *list, Eina_Inlist *new_l)
|
||||||
|
{
|
||||||
|
new_l->prev = NULL;
|
||||||
|
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;
|
||||||
|
list->last = NULL;
|
||||||
|
return new_l;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* To be documented
|
||||||
|
* FIXME: To be fixed
|
||||||
|
*/
|
||||||
|
EAPI Eina_Inlist *
|
||||||
|
eina_inlist_append_relative(Eina_Inlist *list,
|
||||||
|
Eina_Inlist *new_l,
|
||||||
|
Eina_Inlist *relative)
|
||||||
|
{
|
||||||
|
if (relative) {
|
||||||
|
if (relative->next) {
|
||||||
|
new_l->next = relative->next;
|
||||||
|
relative->next->prev = new_l;
|
||||||
|
} else
|
||||||
new_l->next = NULL;
|
new_l->next = NULL;
|
||||||
if (!list) {
|
relative->next = new_l;
|
||||||
new_l->prev = NULL;
|
new_l->prev = relative;
|
||||||
new_l->last = new_l;
|
if (!new_l->next)
|
||||||
return new_l;
|
|
||||||
}
|
|
||||||
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;
|
list->last = new_l;
|
||||||
return list;
|
return list;
|
||||||
|
}
|
||||||
|
return eina_inlist_append(list, new_l);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* To be documented
|
* To be documented
|
||||||
* FIXME: To be fixed
|
* FIXME: To be fixed
|
||||||
*/
|
*/
|
||||||
EAPI void * eina_inlist_prepend(void *in_list, void *in_item) {
|
EAPI Eina_Inlist *
|
||||||
Eina_Inlist *new_l;
|
eina_inlist_prepend_relative(Eina_Inlist *list,
|
||||||
Eina_Inlist *list;
|
Eina_Inlist *new_l,
|
||||||
|
Eina_Inlist *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;
|
||||||
|
/* 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);
|
||||||
|
|
||||||
list = in_list;
|
new_l->last = list->last;
|
||||||
new_l = in_item;
|
list->last = NULL;
|
||||||
new_l->prev = NULL;
|
return new_l;
|
||||||
if (!list) {
|
}
|
||||||
new_l->next = NULL;
|
}
|
||||||
new_l->last = new_l;
|
return eina_inlist_prepend(list, new_l);
|
||||||
return new_l;
|
|
||||||
}
|
|
||||||
new_l->next = list;
|
|
||||||
list->prev = new_l;
|
|
||||||
new_l->last = list->last;
|
|
||||||
list->last = NULL;
|
|
||||||
return new_l;
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* To be documented
|
* To be documented
|
||||||
* FIXME: To be fixed
|
* FIXME: To be fixed
|
||||||
*/
|
*/
|
||||||
EAPI void * eina_inlist_append_relative(void *in_list, void *in_item,
|
EAPI Eina_Inlist *
|
||||||
void *in_relative) {
|
eina_inlist_remove(Eina_Inlist *list, Eina_Inlist *item)
|
||||||
Eina_Inlist *list, *relative, *new_l;
|
{
|
||||||
|
Eina_Inlist *return_l;
|
||||||
|
|
||||||
list = in_list;
|
/* checkme */
|
||||||
new_l = in_item;
|
if (!list) return list;
|
||||||
relative = in_relative;
|
if (!item) return list;
|
||||||
if (relative) {
|
|
||||||
if (relative->next) {
|
if (item->next)
|
||||||
new_l->next = relative->next;
|
item->next->prev = item->prev;
|
||||||
relative->next->prev = new_l;
|
|
||||||
} else
|
if (item->prev) {
|
||||||
new_l->next = NULL;
|
item->prev->next = item->next;
|
||||||
relative->next = new_l;
|
return_l = list;
|
||||||
new_l->prev = relative;
|
} else {
|
||||||
if (!new_l->next)
|
return_l = item->next;
|
||||||
list->last = new_l;
|
if (return_l)
|
||||||
return list;
|
return_l->last = list->last;
|
||||||
}
|
}
|
||||||
return eina_inlist_append(list, new_l);
|
if (item == list->last)
|
||||||
|
list->last = item->prev;
|
||||||
|
item->next = NULL;
|
||||||
|
item->prev = NULL;
|
||||||
|
return return_l;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* To be documented
|
* To be documented
|
||||||
* FIXME: To be fixed
|
* FIXME: To be fixed
|
||||||
*/
|
*/
|
||||||
EAPI void * eina_inlist_prepend_relative(void *in_list, void *in_item,
|
EAPI Eina_Inlist *
|
||||||
void *in_relative) {
|
eina_inlist_find(Eina_Inlist *list, Eina_Inlist *item)
|
||||||
Eina_Inlist *list, *relative, *new_l;
|
{
|
||||||
|
Eina_Inlist *l;
|
||||||
|
|
||||||
list = in_list;
|
for (l = list; l; l = l->next) {
|
||||||
new_l = in_item;
|
if (l == item)
|
||||||
relative = in_relative;
|
return item;
|
||||||
if (relative) {
|
}
|
||||||
new_l->prev = relative->prev;
|
return NULL;
|
||||||
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);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* To be documented
|
|
||||||
* FIXME: To be fixed
|
|
||||||
*/
|
|
||||||
EAPI void * eina_inlist_remove(void *in_list, void *in_item) {
|
|
||||||
Eina_Inlist *return_l;
|
|
||||||
Eina_Inlist *list, *item;
|
|
||||||
|
|
||||||
/* checkme */
|
|
||||||
if (!in_list)
|
|
||||||
return in_list;
|
|
||||||
|
|
||||||
list = in_list;
|
|
||||||
item = in_item;
|
|
||||||
if (!item)
|
|
||||||
return list;
|
|
||||||
if (item->next)
|
|
||||||
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 == list->last)
|
|
||||||
list->last = item->prev;
|
|
||||||
item->next = NULL;
|
|
||||||
item->prev = NULL;
|
|
||||||
return return_l;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* To be documented
|
|
||||||
* FIXME: To be fixed
|
|
||||||
*/
|
|
||||||
EAPI void * eina_inlist_find(void *in_list, void *in_item) {
|
|
||||||
Eina_Inlist *l;
|
|
||||||
Eina_Inlist *list, *item;
|
|
||||||
|
|
||||||
list = in_list;
|
|
||||||
item = in_item;
|
|
||||||
for (l = list; l; l = l->next) {
|
|
||||||
if (l == item)
|
|
||||||
return item;
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EAPI Eina_Iterator *eina_inlist_iterator_new(const void *in_list) {
|
EAPI Eina_Iterator *
|
||||||
Eina_Iterator_Inlist *it;
|
eina_inlist_iterator_new(const Eina_Inlist *list)
|
||||||
|
{
|
||||||
|
Eina_Iterator_Inlist *it;
|
||||||
|
|
||||||
if (!in_list) return NULL;
|
if (!list) return NULL;
|
||||||
|
|
||||||
eina_error_set(0);
|
eina_error_set(0);
|
||||||
it = calloc(1, sizeof (Eina_Iterator_Inlist));
|
it = calloc(1, sizeof (Eina_Iterator_Inlist));
|
||||||
if (!it) {
|
if (!it) {
|
||||||
eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
|
eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
it->head = in_list;
|
it->head = list;
|
||||||
it->current = in_list;
|
it->current = list;
|
||||||
|
|
||||||
it->iterator.next = FUNC_ITERATOR_NEXT(eina_inlist_iterator_next);
|
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);
|
it->iterator.free = FUNC_ITERATOR_FREE(eina_inlist_iterator_free);
|
||||||
|
|
||||||
return &it->iterator;
|
return &it->iterator;
|
||||||
}
|
}
|
||||||
|
|
||||||
EAPI Eina_Accessor *eina_inlist_accessor_new(const void *in_list) {
|
EAPI Eina_Accessor *
|
||||||
Eina_Accessor_Inlist *it;
|
eina_inlist_accessor_new(const Eina_Inlist *list)
|
||||||
|
{
|
||||||
|
Eina_Accessor_Inlist *it;
|
||||||
|
|
||||||
if (!in_list) return NULL;
|
if (!list) return NULL;
|
||||||
|
|
||||||
eina_error_set(0);
|
eina_error_set(0);
|
||||||
it = calloc(1, sizeof (Eina_Accessor_Inlist));
|
it = calloc(1, sizeof (Eina_Accessor_Inlist));
|
||||||
if (!it) {
|
if (!it) {
|
||||||
eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
|
eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
it->head = in_list;
|
it->head = list;
|
||||||
it->current = in_list;
|
it->current = list;
|
||||||
it->index = 0;
|
it->index = 0;
|
||||||
|
|
||||||
it->accessor.get_at = FUNC_ACCESSOR_GET_AT(eina_inlist_accessor_get_at);
|
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);
|
it->accessor.free = FUNC_ACCESSOR_FREE(eina_inlist_accessor_free);
|
||||||
|
|
||||||
return &it->accessor;
|
return &it->accessor;
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,7 @@ typedef struct _Eina_App Eina_App;
|
||||||
|
|
||||||
struct _Eina_Module
|
struct _Eina_Module
|
||||||
{
|
{
|
||||||
Eina_Inlist __list;
|
EINA_INLIST;
|
||||||
|
|
||||||
const char * path;
|
const char * path;
|
||||||
const char * name;
|
const char * name;
|
||||||
|
@ -73,7 +73,7 @@ struct _Eina_Module
|
||||||
|
|
||||||
struct _Eina_Directory
|
struct _Eina_Directory
|
||||||
{
|
{
|
||||||
Eina_Inlist __list;
|
EINA_INLIST;
|
||||||
|
|
||||||
const char * path;
|
const char * path;
|
||||||
const char * extention;
|
const char * extention;
|
||||||
|
@ -90,7 +90,7 @@ struct _Eina_App
|
||||||
|
|
||||||
struct _Eina_Static
|
struct _Eina_Static
|
||||||
{
|
{
|
||||||
Eina_Inlist __list;
|
EINA_INLIST;
|
||||||
Eina_Module_Export static_desc;
|
Eina_Module_Export static_desc;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -106,7 +106,7 @@ struct _Eina_Module_Group
|
||||||
|
|
||||||
struct _Eina_Root_Directory
|
struct _Eina_Root_Directory
|
||||||
{
|
{
|
||||||
Eina_Inlist __list;
|
EINA_INLIST;
|
||||||
|
|
||||||
const char * path;
|
const char * path;
|
||||||
};
|
};
|
||||||
|
@ -134,7 +134,6 @@ _eina_module_build(Eina_Module_Group *modules, Eina_App *app,
|
||||||
void *handle;
|
void *handle;
|
||||||
|
|
||||||
handle = dlopen(path, RTLD_LAZY | RTLD_GLOBAL);
|
handle = dlopen(path, RTLD_LAZY | RTLD_GLOBAL);
|
||||||
fprintf(stderr, "b [%s] %p\n", path, handle);
|
|
||||||
if (!handle) return NULL;
|
if (!handle) return NULL;
|
||||||
|
|
||||||
module = calloc(1, sizeof (Eina_Module) + length_path + strlen(name) + 1);
|
module = calloc(1, sizeof (Eina_Module) + length_path + strlen(name) + 1);
|
||||||
|
@ -212,7 +211,7 @@ _eina_dir_module_cb(const char *name, const char *path, Eina_Dir_List *data)
|
||||||
{
|
{
|
||||||
if (data->cb(module, data->data) == EINA_TRUE)
|
if (data->cb(module, data->data) == EINA_TRUE)
|
||||||
{
|
{
|
||||||
data->modules->loaded_module = eina_inlist_prepend(data->modules->loaded_module, module);
|
data->modules->loaded_module = eina_inlist_prepend(data->modules->loaded_module, EINA_INLIST_GET(module));
|
||||||
data->list = eina_list_append(data->list, module);
|
data->list = eina_list_append(data->list, module);
|
||||||
|
|
||||||
return ;
|
return ;
|
||||||
|
@ -378,7 +377,7 @@ eina_module_root_add(const char *root_path)
|
||||||
root->path = (char*)(root + 1);
|
root->path = (char*)(root + 1);
|
||||||
memcpy((char*) root->path, root_path, length);
|
memcpy((char*) root->path, root_path, length);
|
||||||
|
|
||||||
root_directory = eina_inlist_prepend(root_directory, root);
|
root_directory = eina_inlist_prepend(root_directory, EINA_INLIST_GET(root));
|
||||||
}
|
}
|
||||||
|
|
||||||
EAPI Eina_Module_Group *
|
EAPI Eina_Module_Group *
|
||||||
|
@ -437,9 +436,9 @@ eina_module_path_register(Eina_Module_Group *modules, const char *path, Eina_Boo
|
||||||
memcpy((char*) dir->path, path, length);
|
memcpy((char*) dir->path, path, length);
|
||||||
|
|
||||||
if (recursive)
|
if (recursive)
|
||||||
modules->recursive_directory = eina_inlist_prepend(modules->recursive_directory, dir);
|
modules->recursive_directory = eina_inlist_prepend(modules->recursive_directory, EINA_INLIST_GET(dir));
|
||||||
else
|
else
|
||||||
modules->root_directory = eina_inlist_prepend(modules->root_directory, dir);
|
modules->root_directory = eina_inlist_prepend(modules->root_directory, EINA_INLIST_GET(dir));
|
||||||
}
|
}
|
||||||
|
|
||||||
EAPI void
|
EAPI void
|
||||||
|
@ -505,7 +504,7 @@ eina_module_app_register(Eina_Module_Group *modules, const char *app, const char
|
||||||
}
|
}
|
||||||
strcat((char*) dir->extention, MODULE_EXTENSION);
|
strcat((char*) dir->extention, MODULE_EXTENSION);
|
||||||
|
|
||||||
modules->lookup_directory = eina_inlist_prepend(modules->lookup_directory, dir);
|
modules->lookup_directory = eina_inlist_prepend(modules->lookup_directory, EINA_INLIST_GET(dir));
|
||||||
}
|
}
|
||||||
|
|
||||||
EAPI void
|
EAPI void
|
||||||
|
@ -520,7 +519,7 @@ eina_module_register(Eina_Module_Group *modules, const Eina_Module_Export *stati
|
||||||
|
|
||||||
library->static_desc = *static_module;
|
library->static_desc = *static_module;
|
||||||
|
|
||||||
modules->static_libraries = eina_inlist_prepend(modules->static_libraries, library);
|
modules->static_libraries = eina_inlist_prepend(modules->static_libraries, EINA_INLIST_GET(library));
|
||||||
}
|
}
|
||||||
|
|
||||||
EAPI Eina_Module *
|
EAPI Eina_Module *
|
||||||
|
@ -560,7 +559,7 @@ eina_module_new(Eina_Module_Group *modules, const char *name)
|
||||||
module->references = 1;
|
module->references = 1;
|
||||||
module->is_static_library = EINA_TRUE;
|
module->is_static_library = EINA_TRUE;
|
||||||
|
|
||||||
modules->loaded_module = eina_inlist_prepend(modules->loaded_module, module);
|
modules->loaded_module = eina_inlist_prepend(modules->loaded_module, EINA_INLIST_GET(module));
|
||||||
|
|
||||||
return module;
|
return module;
|
||||||
}
|
}
|
||||||
|
@ -578,7 +577,7 @@ eina_module_new(Eina_Module_Group *modules, const char *name)
|
||||||
name);
|
name);
|
||||||
if (!module) continue ;
|
if (!module) continue ;
|
||||||
|
|
||||||
modules->loaded_module = eina_inlist_prepend(modules->loaded_module, module);
|
modules->loaded_module = eina_inlist_prepend(modules->loaded_module, EINA_INLIST_GET(module));
|
||||||
return module;
|
return module;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -600,7 +599,7 @@ eina_module_new(Eina_Module_Group *modules, const char *name)
|
||||||
continue ;
|
continue ;
|
||||||
}
|
}
|
||||||
|
|
||||||
modules->loaded_module = eina_inlist_prepend(modules->loaded_module, module);
|
modules->loaded_module = eina_inlist_prepend(modules->loaded_module, EINA_INLIST_GET(module));
|
||||||
return module;
|
return module;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -626,7 +625,7 @@ eina_module_delete(Eina_Module *module)
|
||||||
|
|
||||||
if (module->references != 0) return ;
|
if (module->references != 0) return ;
|
||||||
|
|
||||||
module->group->loaded_module = eina_inlist_remove(module->group->loaded_module, module);
|
module->group->loaded_module = eina_inlist_remove(module->group->loaded_module, EINA_INLIST_GET(module));
|
||||||
|
|
||||||
if (module->handle) dlclose(module->handle);
|
if (module->handle) dlclose(module->handle);
|
||||||
free(module);
|
free(module);
|
||||||
|
@ -671,7 +670,7 @@ eina_module_list_new(Eina_Module_Group *modules, Eina_Module_Cb cb, void *data)
|
||||||
|
|
||||||
if (cb(module, data) == EINA_TRUE)
|
if (cb(module, data) == EINA_TRUE)
|
||||||
{
|
{
|
||||||
modules->loaded_module = eina_inlist_prepend(modules->loaded_module, module);
|
modules->loaded_module = eina_inlist_prepend(modules->loaded_module, EINA_INLIST_GET(module));
|
||||||
list = eina_list_append(list, module);
|
list = eina_list_append(list, module);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -706,7 +705,7 @@ eina_module_list_new(Eina_Module_Group *modules, Eina_Module_Cb cb, void *data)
|
||||||
|
|
||||||
if (cb(module, data) == EINA_TRUE)
|
if (cb(module, data) == EINA_TRUE)
|
||||||
{
|
{
|
||||||
modules->loaded_module = eina_inlist_prepend(modules->loaded_module, module);
|
modules->loaded_module = eina_inlist_prepend(modules->loaded_module, EINA_INLIST_GET(module));
|
||||||
list = eina_list_append(list, module);
|
list = eina_list_append(list, module);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#include "eina_inlist.h"
|
#include "eina_inlist.h"
|
||||||
#include "eina_error.h"
|
#include "eina_error.h"
|
||||||
#include "eina_module.h"
|
#include "eina_module.h"
|
||||||
|
#include "eina_mempool.h"
|
||||||
|
|
||||||
#include "eina_private.h"
|
#include "eina_private.h"
|
||||||
|
|
||||||
|
@ -45,7 +46,7 @@ struct _Chained_Mempool
|
||||||
typedef struct _Chained_Pool Chained_Pool;
|
typedef struct _Chained_Pool Chained_Pool;
|
||||||
struct _Chained_Pool
|
struct _Chained_Pool
|
||||||
{
|
{
|
||||||
Eina_Inlist _list_data;
|
EINA_INLIST;
|
||||||
void *base;
|
void *base;
|
||||||
int usage;
|
int usage;
|
||||||
};
|
};
|
||||||
|
@ -82,18 +83,15 @@ eina_chained_mempool_malloc(void *data, __UNUSED__ unsigned int size)
|
||||||
{
|
{
|
||||||
Chained_Mempool *pool = data;
|
Chained_Mempool *pool = data;
|
||||||
Chained_Pool *p = NULL;
|
Chained_Pool *p = NULL;
|
||||||
Eina_Inlist *item;
|
|
||||||
void *mem;
|
void *mem;
|
||||||
|
|
||||||
// look 4 pool from 2nd bucket on
|
// look 4 pool from 2nd bucket on
|
||||||
EINA_INLIST_ITER_NEXT(pool->first, item)
|
EINA_INLIST_ITER_NEXT(pool->first, p)
|
||||||
{
|
{
|
||||||
p = (Chained_Pool*) item;
|
|
||||||
|
|
||||||
// base is not NULL - has a free slot
|
// base is not NULL - has a free slot
|
||||||
if (p->base)
|
if (p->base)
|
||||||
{
|
{
|
||||||
pool->first = eina_inlist_remove(pool->first, item);
|
pool->first = eina_inlist_remove(pool->first, EINA_INLIST_GET(p));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -102,7 +100,7 @@ eina_chained_mempool_malloc(void *data, __UNUSED__ unsigned int size)
|
||||||
{
|
{
|
||||||
p = _eina_chained_mp_pool_new(pool);
|
p = _eina_chained_mp_pool_new(pool);
|
||||||
if (!p) return NULL;
|
if (!p) return NULL;
|
||||||
pool->first = eina_inlist_prepend(pool->first, p);
|
pool->first = eina_inlist_prepend(pool->first, EINA_INLIST_GET(p));
|
||||||
}
|
}
|
||||||
// this points to the next free block - so take it
|
// this points to the next free block - so take it
|
||||||
mem = p->base;
|
mem = p->base;
|
||||||
|
@ -111,8 +109,8 @@ eina_chained_mempool_malloc(void *data, __UNUSED__ unsigned int size)
|
||||||
// move to end - it just filled up
|
// move to end - it just filled up
|
||||||
if (!p->base)
|
if (!p->base)
|
||||||
{
|
{
|
||||||
pool->first = eina_inlist_remove(pool->first, p);
|
pool->first = eina_inlist_remove(pool->first, EINA_INLIST_GET(p));
|
||||||
pool->first = eina_inlist_append(pool->first, p);
|
pool->first = eina_inlist_append(pool->first, EINA_INLIST_GET(p));
|
||||||
}
|
}
|
||||||
p->usage++;
|
p->usage++;
|
||||||
pool->usage++;
|
pool->usage++;
|
||||||
|
@ -124,17 +122,14 @@ eina_chained_mempool_free(void *data, void *ptr)
|
||||||
{
|
{
|
||||||
Chained_Mempool *pool = data;
|
Chained_Mempool *pool = data;
|
||||||
Chained_Pool *p;
|
Chained_Pool *p;
|
||||||
Eina_Inlist *item;
|
|
||||||
void *pmem;
|
void *pmem;
|
||||||
int item_alloc, psize;
|
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;
|
psize = item_alloc * pool->pool_size;
|
||||||
// look 4 pool
|
// look 4 pool
|
||||||
EINA_INLIST_ITER_NEXT(pool->first, item)
|
EINA_INLIST_ITER_NEXT(pool->first, p)
|
||||||
{
|
{
|
||||||
p = (Chained_Pool*) item;
|
|
||||||
|
|
||||||
// pool mem base
|
// pool mem base
|
||||||
pmem = (void *)(((unsigned char *)p) + sizeof(Chained_Pool));
|
pmem = (void *)(((unsigned char *)p) + sizeof(Chained_Pool));
|
||||||
// is it in pool mem?
|
// is it in pool mem?
|
||||||
|
@ -146,13 +141,13 @@ eina_chained_mempool_free(void *data, void *ptr)
|
||||||
p->base = ptr;
|
p->base = ptr;
|
||||||
p->usage--;
|
p->usage--;
|
||||||
pool->usage--;
|
pool->usage--;
|
||||||
pool->first = eina_inlist_remove(pool->first, p);
|
pool->first = eina_inlist_remove(pool->first, EINA_INLIST_GET(p));
|
||||||
if (p->usage == 0)
|
if (p->usage == 0)
|
||||||
// free bucket
|
// free bucket
|
||||||
_eina_chained_mp_pool_free(p);
|
_eina_chained_mp_pool_free(p);
|
||||||
else
|
else
|
||||||
// move to front
|
// move to front
|
||||||
pool->first = eina_inlist_prepend(pool->first, p);
|
pool->first = eina_inlist_prepend(pool->first, EINA_INLIST_GET(p));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
typedef struct _Eina_Test_Inlist Eina_Test_Inlist;
|
typedef struct _Eina_Test_Inlist Eina_Test_Inlist;
|
||||||
struct _Eina_Test_Inlist
|
struct _Eina_Test_Inlist
|
||||||
{
|
{
|
||||||
Eina_Inlist list;
|
EINA_INLIST;
|
||||||
int i;
|
int i;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -42,41 +42,41 @@ _eina_test_inlist_build(int i)
|
||||||
|
|
||||||
START_TEST(eina_inlist_simple)
|
START_TEST(eina_inlist_simple)
|
||||||
{
|
{
|
||||||
Eina_Test_Inlist *lst = NULL;
|
Eina_Inlist *lst = NULL;
|
||||||
Eina_Test_Inlist *tmp;
|
Eina_Test_Inlist *tmp;
|
||||||
Eina_Test_Inlist *prev;
|
Eina_Test_Inlist *prev;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
tmp = _eina_test_inlist_build(42);
|
tmp = _eina_test_inlist_build(42);
|
||||||
lst = eina_inlist_append(lst, tmp);
|
lst = eina_inlist_append(lst, EINA_INLIST_GET(tmp));
|
||||||
fail_if(!lst);
|
fail_if(!lst);
|
||||||
|
|
||||||
lst = eina_inlist_remove(lst, tmp);
|
lst = eina_inlist_remove(lst, EINA_INLIST_GET(tmp));
|
||||||
lst = eina_inlist_prepend(lst, tmp);
|
lst = eina_inlist_prepend(lst, EINA_INLIST_GET(tmp));
|
||||||
|
|
||||||
tmp = _eina_test_inlist_build(1664);
|
tmp = _eina_test_inlist_build(1664);
|
||||||
lst = eina_inlist_append_relative(lst, tmp, lst);
|
lst = eina_inlist_append_relative(lst, EINA_INLIST_GET(tmp), lst);
|
||||||
fail_if(!lst);
|
fail_if(!lst);
|
||||||
fail_if(lst->i != 42);
|
fail_if(((Eina_Test_Inlist*)lst)->i != 42);
|
||||||
|
|
||||||
prev = tmp;
|
prev = tmp;
|
||||||
tmp = _eina_test_inlist_build(3227);
|
tmp = _eina_test_inlist_build(3227);
|
||||||
lst = eina_inlist_prepend_relative(lst, tmp, prev);
|
lst = eina_inlist_prepend_relative(lst, EINA_INLIST_GET(tmp), EINA_INLIST_GET(prev));
|
||||||
fail_if(!lst);
|
fail_if(!lst);
|
||||||
fail_if(lst->i != 42);
|
fail_if(((Eina_Test_Inlist*)lst)->i != 42);
|
||||||
|
|
||||||
lst = eina_inlist_remove(lst, tmp);
|
lst = eina_inlist_remove(lst, EINA_INLIST_GET(tmp));
|
||||||
|
|
||||||
lst = eina_inlist_append_relative(lst, tmp, lst);
|
lst = eina_inlist_append_relative(lst, EINA_INLIST_GET(tmp), lst);
|
||||||
lst = eina_inlist_remove(lst, tmp);
|
lst = eina_inlist_remove(lst, EINA_INLIST_GET(tmp));
|
||||||
|
|
||||||
lst = eina_inlist_prepend_relative(lst, tmp, lst);
|
lst = eina_inlist_prepend_relative(lst, EINA_INLIST_GET(tmp), lst);
|
||||||
|
|
||||||
tmp = _eina_test_inlist_build(27);
|
tmp = _eina_test_inlist_build(27);
|
||||||
lst = eina_inlist_prepend_relative(lst, tmp, NULL);
|
lst = eina_inlist_prepend_relative(lst, EINA_INLIST_GET(tmp), NULL);
|
||||||
|
|
||||||
tmp = _eina_test_inlist_build(81);
|
tmp = _eina_test_inlist_build(81);
|
||||||
lst = eina_inlist_append_relative(lst, tmp, NULL);
|
lst = eina_inlist_append_relative(lst, EINA_INLIST_GET(tmp), NULL);
|
||||||
|
|
||||||
EINA_INLIST_ITER_NEXT(lst, tmp)
|
EINA_INLIST_ITER_NEXT(lst, tmp)
|
||||||
{
|
{
|
||||||
|
@ -92,12 +92,12 @@ START_TEST(eina_inlist_simple)
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
|
|
||||||
eina_inlist_remove(NULL, tmp);
|
eina_inlist_remove(NULL, EINA_INLIST_GET(tmp));
|
||||||
lst = eina_inlist_remove(lst, NULL);
|
lst = eina_inlist_remove(lst, NULL);
|
||||||
|
|
||||||
tmp = eina_inlist_find(lst, prev);
|
tmp = (Eina_Test_Inlist*) eina_inlist_find(lst, EINA_INLIST_GET(prev));
|
||||||
eina_inlist_remove(lst, tmp);
|
eina_inlist_remove(lst, EINA_INLIST_GET(tmp));
|
||||||
tmp = eina_inlist_find(lst, tmp);
|
tmp = (Eina_Test_Inlist*) eina_inlist_find(lst, EINA_INLIST_GET(tmp));
|
||||||
fail_if(tmp != NULL);
|
fail_if(tmp != NULL);
|
||||||
|
|
||||||
while (lst)
|
while (lst)
|
||||||
|
|
Loading…
Reference in New Issue