list: debug purge_list_ptr
This commit is contained in:
+106
-37
@@ -25,11 +25,12 @@
|
|||||||
struct main_list_##type *create_var_list_##type();\
|
struct main_list_##type *create_var_list_##type();\
|
||||||
void push_back_list_##type(struct main_list_##type *var_list, type value);\
|
void push_back_list_##type(struct main_list_##type *var_list, type value);\
|
||||||
void push_front_list_##type(struct main_list_##type *var_list, type value);\
|
void push_front_list_##type(struct main_list_##type *var_list, type value);\
|
||||||
size_t move_current_to_index_list_##type(struct main_list_##type *var_list, size_t index);\
|
size_t move_current_to_index_list_##type(struct main_list_##type *var_list, size_t index, struct list_##type **list_in_index);\
|
||||||
size_t move_current_to_begin_list_##type(struct main_list_##type *var_list);\
|
size_t move_current_to_begin_list_##type(struct main_list_##type *var_list);\
|
||||||
size_t move_current_to_end_list_##type(struct main_list_##type *var_list);\
|
size_t move_current_to_end_list_##type(struct main_list_##type *var_list);\
|
||||||
void insert_into_list_##type(struct main_list_##type *var_list, size_t index, type value );\
|
size_t insert_into_list_##type(struct main_list_##type *var_list, size_t index, type value );\
|
||||||
void remove_index_from_list_##type(struct main_list_##type *var_list, size_t index );\
|
void remove_index_from_list_##type(struct main_list_##type *var_list, size_t index );\
|
||||||
|
struct list_##type* pull_index_from_list_##type(struct main_list_##type *var_list, size_t index );\
|
||||||
void free_all_var_list_##type(struct main_list_##type *var_list);\
|
void free_all_var_list_##type(struct main_list_##type *var_list);\
|
||||||
void remove_all_list_in_##type(struct main_list_##type *var_list);\
|
void remove_all_list_in_##type(struct main_list_##type *var_list);\
|
||||||
void increment_list_##type(struct main_list_##type * var_list);\
|
void increment_list_##type(struct main_list_##type * var_list);\
|
||||||
@@ -118,27 +119,37 @@ GENERATE_LIST_ALL(TYPE_PTR)
|
|||||||
}\
|
}\
|
||||||
pthread_mutex_unlock(var_list->mut_list);\
|
pthread_mutex_unlock(var_list->mut_list);\
|
||||||
}\
|
}\
|
||||||
size_t move_current_to_index_list_##type(struct main_list_##type *var_list, size_t index){\
|
size_t move_current_to_index_list_##type(struct main_list_##type *var_list, size_t index, struct list_##type **list_in_index){\
|
||||||
pthread_mutex_lock(var_list->mut_list);\
|
pthread_mutex_lock(var_list->mut_list);\
|
||||||
if(index == var_list->current_index){\
|
if(var_list->current_list==NULL) {;\
|
||||||
|
if(index <= var_list->size - 1 - index){\
|
||||||
|
var_list->current_list = var_list->begin_list;\
|
||||||
|
}else{\
|
||||||
|
var_list->current_list = var_list->end_list;\
|
||||||
|
}\
|
||||||
|
}\
|
||||||
|
if(index == var_list->current_list->index){\
|
||||||
|
if(list_in_index) *list_in_index = var_list->current_list;\
|
||||||
pthread_mutex_unlock(var_list->mut_list);\
|
pthread_mutex_unlock(var_list->mut_list);\
|
||||||
return index;\
|
return index;\
|
||||||
}\
|
}\
|
||||||
if(var_list->begin_list == NULL){\
|
if(var_list->begin_list == NULL){\
|
||||||
|
if(list_in_index) *list_in_index=NULL;\
|
||||||
pthread_mutex_unlock(var_list->mut_list);\
|
pthread_mutex_unlock(var_list->mut_list);\
|
||||||
return 0;\
|
return 0;\
|
||||||
}\
|
}\
|
||||||
if(index >= var_list->size){\
|
if(index >= var_list->size){\
|
||||||
var_list->current_list = var_list->end_list;\
|
var_list->current_list = var_list->end_list;\
|
||||||
var_list->current_index = var_list->size - 1;\
|
var_list->current_index = var_list->size - 1;\
|
||||||
|
if(list_in_index) *list_in_index = var_list->current_list;\
|
||||||
pthread_mutex_unlock(var_list->mut_list);\
|
pthread_mutex_unlock(var_list->mut_list);\
|
||||||
return var_list->size - 1;\
|
return var_list->current_list->index /*size - 1*/;\
|
||||||
}\
|
}\
|
||||||
if((var_list->current_index >= var_list->size) || !(var_list->current_list)){\
|
/*if((var_list->current_list->index >= var_list->size) || !(var_list->current_list)){\
|
||||||
var_list->current_list = var_list->end_list;\
|
var_list->current_list = var_list->end_list;\
|
||||||
var_list->current_index = var_list->size - 1;\
|
var_list->current_index = var_list->size - 1;\
|
||||||
}\
|
}*/\
|
||||||
long from_current_index = var_list->current_index - index; \
|
long from_current_index = var_list->current_list->index - index; \
|
||||||
size_t abs_cur_diff = abs(from_current_index); \
|
size_t abs_cur_diff = abs(from_current_index); \
|
||||||
size_t array_diff_index[3] = {index, abs_cur_diff , var_list->size - 1 - index}; \
|
size_t array_diff_index[3] = {index, abs_cur_diff , var_list->size - 1 - index}; \
|
||||||
size_t index_nearest = ARG_MIN_ARRAY_TYPE_SIZE_T(array_diff_index, 3);\
|
size_t index_nearest = ARG_MIN_ARRAY_TYPE_SIZE_T(array_diff_index, 3);\
|
||||||
@@ -155,6 +166,7 @@ GENERATE_LIST_ALL(TYPE_PTR)
|
|||||||
for(size_t i=0; i < array_diff_index[1]; ++i) var_list->current_list = (var_list->current_list)->next; \
|
for(size_t i=0; i < array_diff_index[1]; ++i) var_list->current_list = (var_list->current_list)->next; \
|
||||||
\
|
\
|
||||||
var_list->current_index = index;\
|
var_list->current_index = index;\
|
||||||
|
if(list_in_index) *list_in_index = var_list->current_list;\
|
||||||
pthread_mutex_unlock(var_list->mut_list);\
|
pthread_mutex_unlock(var_list->mut_list);\
|
||||||
return index;\
|
return index;\
|
||||||
}\
|
}\
|
||||||
@@ -180,51 +192,76 @@ GENERATE_LIST_ALL(TYPE_PTR)
|
|||||||
pthread_mutex_unlock(var_list->mut_list);\
|
pthread_mutex_unlock(var_list->mut_list);\
|
||||||
return var_list->current_index;\
|
return var_list->current_index;\
|
||||||
}\
|
}\
|
||||||
void insert_into_list_##type(struct main_list_##type *var_list, size_t index, type value ){\
|
size_t insert_into_list_##type(struct main_list_##type *var_list, size_t index, type value ){\
|
||||||
struct list_##type * list_to_add = malloc(sizeof(struct list_##type));\
|
struct list_##type * list_to_add = malloc(sizeof(struct list_##type));\
|
||||||
|
size_t ii=0;\
|
||||||
list_to_add->value = value;\
|
list_to_add->value = value;\
|
||||||
if(var_list->begin_list == NULL){\
|
if(var_list->begin_list == NULL){\
|
||||||
|
pthread_mutex_lock(var_list->mut_list);\
|
||||||
list_to_add->preview = NULL;\
|
list_to_add->preview = NULL;\
|
||||||
list_to_add->next = NULL;\
|
list_to_add->next = NULL;\
|
||||||
pthread_mutex_lock(var_list->mut_list);\
|
|
||||||
var_list->begin_list = list_to_add;\
|
var_list->begin_list = list_to_add;\
|
||||||
var_list->end_list = list_to_add;\
|
var_list->end_list = list_to_add;\
|
||||||
var_list->current_list = list_to_add;\
|
var_list->current_list = list_to_add;\
|
||||||
var_list->current_index = 0;\
|
var_list->current_index = 0;\
|
||||||
\
|
\
|
||||||
}else {\
|
}else {\
|
||||||
size_t ii = move_current_to_index_list_##type(var_list, index);\
|
struct list_##type *current_list;\
|
||||||
|
ii = move_current_to_index_list_##type(var_list, index, ¤t_list);\
|
||||||
pthread_mutex_lock(var_list->mut_list);\
|
pthread_mutex_lock(var_list->mut_list);\
|
||||||
if(index > ii)\
|
if(index > ii)\
|
||||||
printf("%ld out of range, we put the value at %ld index of the list \n",index, ii);\
|
printf("%ld out of range, we put the value at %ld index of the list \n",index, ii);\
|
||||||
if(var_list->current_list){\
|
if(current_list){\
|
||||||
list_to_add->preview = (var_list->current_list)->preview;\
|
struct list_##type *prev_list = (current_list)->preview;\
|
||||||
list_to_add->next = var_list->current_list;\
|
list_to_add->preview = prev_list;\
|
||||||
if(list_to_add->preview)\
|
list_to_add->next = current_list;\
|
||||||
(list_to_add->preview)->next = list_to_add;\
|
if(list_to_add->preview == NULL){\
|
||||||
else var_list->begin_list = list_to_add;\
|
var_list->begin_list = list_to_add;\
|
||||||
(var_list->current_list)->preview = list_to_add;\
|
}else\
|
||||||
|
prev_list->next = list_to_add;\
|
||||||
|
if(list_to_add->next == NULL)\
|
||||||
|
var_list->end_list = list_to_add;\
|
||||||
|
(current_list)->preview = list_to_add;\
|
||||||
var_list->current_list = list_to_add;\
|
var_list->current_list = list_to_add;\
|
||||||
|
var_list->current_index = ii;\
|
||||||
}\
|
}\
|
||||||
}\
|
}\
|
||||||
++(var_list->size);\
|
++(var_list->size);\
|
||||||
|
size_t local_ii = ii;\
|
||||||
while(list_to_add){\
|
while(list_to_add){\
|
||||||
list_to_add->index = index++;\
|
list_to_add->index = local_ii++;\
|
||||||
list_to_add = list_to_add->next;\
|
list_to_add = list_to_add->next;\
|
||||||
}\
|
}\
|
||||||
pthread_mutex_unlock(var_list->mut_list);\
|
pthread_mutex_unlock(var_list->mut_list);\
|
||||||
|
return ii;\
|
||||||
}\
|
}\
|
||||||
void remove_index_from_list_##type(struct main_list_##type *var_list, size_t index ){\
|
void remove_index_from_list_##type(struct main_list_##type *var_list, size_t index ){\
|
||||||
if( index == move_current_to_index_list_##type(var_list, index)) {\
|
struct list_##type *current_list;\
|
||||||
|
if( index == move_current_to_index_list_##type(var_list, index, ¤t_list)) {\
|
||||||
pthread_mutex_lock(var_list->mut_list);\
|
pthread_mutex_lock(var_list->mut_list);\
|
||||||
struct list_##type * list_tmp_prev = (var_list->current_list)->preview;\
|
struct list_##type * list_tmp_prev = (current_list)->preview;\
|
||||||
struct list_##type * list_tmp_next = (var_list->current_list)->next;\
|
struct list_##type * list_tmp_next = (current_list)->next;\
|
||||||
if(list_tmp_prev){\
|
if(list_tmp_prev){\
|
||||||
list_tmp_prev->next = list_tmp_next;\
|
list_tmp_prev->next = list_tmp_next;\
|
||||||
if(list_tmp_next) list_tmp_next->preview = list_tmp_prev;\
|
if(list_tmp_next){\
|
||||||
|
list_tmp_next->preview = list_tmp_prev;\
|
||||||
|
var_list->current_list = list_tmp_next;\
|
||||||
|
}\
|
||||||
|
else {\
|
||||||
|
var_list->end_list = list_tmp_prev;\
|
||||||
|
var_list->current_list = list_tmp_prev;\
|
||||||
|
}\
|
||||||
|
}else{\
|
||||||
|
var_list->begin_list = list_tmp_next;\
|
||||||
|
if(list_tmp_next) {\
|
||||||
|
list_tmp_next->preview = list_tmp_prev;\
|
||||||
|
}\
|
||||||
|
else{\
|
||||||
|
var_list->end_list = NULL;\
|
||||||
|
var_list->current_list = NULL;\
|
||||||
|
}\
|
||||||
}\
|
}\
|
||||||
free(var_list->current_list);\
|
free(current_list);\
|
||||||
var_list->current_list = list_tmp_next;\
|
|
||||||
--(var_list->size);\
|
--(var_list->size);\
|
||||||
while(list_tmp_next){\
|
while(list_tmp_next){\
|
||||||
list_tmp_next->index = index++;\
|
list_tmp_next->index = index++;\
|
||||||
@@ -233,6 +270,41 @@ GENERATE_LIST_ALL(TYPE_PTR)
|
|||||||
pthread_mutex_unlock(var_list->mut_list);\
|
pthread_mutex_unlock(var_list->mut_list);\
|
||||||
}\
|
}\
|
||||||
}\
|
}\
|
||||||
|
struct list_##type * pull_index_from_list_##type(struct main_list_##type *var_list, size_t index ){\
|
||||||
|
struct list_##type *current_list=NULL;\
|
||||||
|
if( index == move_current_to_index_list_##type(var_list, index, ¤t_list)) {\
|
||||||
|
pthread_mutex_lock(var_list->mut_list);\
|
||||||
|
struct list_##type * list_tmp_prev = (current_list)->preview;\
|
||||||
|
struct list_##type * list_tmp_next = (current_list)->next;\
|
||||||
|
if(list_tmp_prev){\
|
||||||
|
list_tmp_prev->next = list_tmp_next;\
|
||||||
|
if(list_tmp_next){\
|
||||||
|
list_tmp_next->preview = list_tmp_prev;\
|
||||||
|
var_list->current_list = list_tmp_next;\
|
||||||
|
}\
|
||||||
|
else {\
|
||||||
|
var_list->end_list = list_tmp_prev;\
|
||||||
|
var_list->current_list = list_tmp_prev;\
|
||||||
|
}\
|
||||||
|
}else{\
|
||||||
|
var_list->begin_list = list_tmp_next;\
|
||||||
|
if(list_tmp_next) {\
|
||||||
|
list_tmp_next->preview = list_tmp_prev;\
|
||||||
|
}\
|
||||||
|
else{\
|
||||||
|
var_list->end_list = NULL;\
|
||||||
|
var_list->current_list = NULL;\
|
||||||
|
}\
|
||||||
|
}\
|
||||||
|
--(var_list->size);\
|
||||||
|
while(list_tmp_next){\
|
||||||
|
list_tmp_next->index = index++;\
|
||||||
|
list_tmp_next=list_tmp_next->next;\
|
||||||
|
}\
|
||||||
|
pthread_mutex_unlock(var_list->mut_list);\
|
||||||
|
}\
|
||||||
|
return current_list;\
|
||||||
|
}\
|
||||||
void remove_all_list_in_##type(struct main_list_##type *var_list){\
|
void remove_all_list_in_##type(struct main_list_##type *var_list){\
|
||||||
pthread_mutex_lock(var_list->mut_list);\
|
pthread_mutex_lock(var_list->mut_list);\
|
||||||
struct list_##type *tmp = var_list->begin_list, *prec_tmp;\
|
struct list_##type *tmp = var_list->begin_list, *prec_tmp;\
|
||||||
@@ -286,6 +358,10 @@ GENERATE_LIST_ALL(TYPE_PTR)
|
|||||||
return NULL;\
|
return NULL;\
|
||||||
}\
|
}\
|
||||||
struct list_##type * search_first_occ_from_begin_in_list_##type(struct main_list_##type *var_list, type value, int (*funcCmp)(type, type)){\
|
struct list_##type * search_first_occ_from_begin_in_list_##type(struct main_list_##type *var_list, type value, int (*funcCmp)(type, type)){\
|
||||||
|
pthread_mutex_lock(var_list->mut_list);\
|
||||||
|
printf("debug: cur_index change to 0");\
|
||||||
|
var_list->current_list = var_list->begin_list;\
|
||||||
|
pthread_mutex_unlock(var_list->mut_list);\
|
||||||
return search_first_occ_with_mov_from_curr_in_list_##type(var_list, value, funcCmp, local_increment_list_##type);\
|
return search_first_occ_with_mov_from_curr_in_list_##type(var_list, value, funcCmp, local_increment_list_##type);\
|
||||||
}\
|
}\
|
||||||
struct list_##type * pull_end_from_list_##type(struct main_list_##type *var_list){\
|
struct list_##type * pull_end_from_list_##type(struct main_list_##type *var_list){\
|
||||||
@@ -356,6 +432,7 @@ GENERATE_LIST_ALL(TYPE_PTR)
|
|||||||
|
|
||||||
#define GEN_FUNC_PTR_LIST_FREE(type)\
|
#define GEN_FUNC_PTR_LIST_FREE(type)\
|
||||||
void remove_all_ptr_type_list_##type(struct main_list_##type *var_list){\
|
void remove_all_ptr_type_list_##type(struct main_list_##type *var_list){\
|
||||||
|
pthread_mutex_lock(var_list->mut_list);\
|
||||||
struct list_##type *tmp = var_list->begin_list, *prec_tmp;\
|
struct list_##type *tmp = var_list->begin_list, *prec_tmp;\
|
||||||
while(tmp){\
|
while(tmp){\
|
||||||
prec_tmp = tmp;\
|
prec_tmp = tmp;\
|
||||||
@@ -368,20 +445,12 @@ GENERATE_LIST_ALL(TYPE_PTR)
|
|||||||
var_list->end_list = NULL;\
|
var_list->end_list = NULL;\
|
||||||
var_list->size = 0;\
|
var_list->size = 0;\
|
||||||
var_list->current_index = 0;\
|
var_list->current_index = 0;\
|
||||||
|
pthread_mutex_unlock(var_list->mut_list);\
|
||||||
}\
|
}\
|
||||||
void purge_ptr_type_list_##type(struct main_list_##type *var_list){\
|
void purge_ptr_type_list_##type(struct main_list_##type *var_list){\
|
||||||
struct list_##type *tmp = var_list->begin_list, *prec_tmp;\
|
remove_all_ptr_type_list_##type(var_list);\
|
||||||
while(tmp){\
|
pthread_mutex_destroy(var_list->mut_list);\
|
||||||
prec_tmp = tmp;\
|
free(var_list->mut_list);\
|
||||||
tmp = tmp->next;\
|
|
||||||
free_##type(prec_tmp->value);\
|
|
||||||
free(prec_tmp);\
|
|
||||||
}\
|
|
||||||
var_list->begin_list = NULL;\
|
|
||||||
var_list->current_list = NULL;\
|
|
||||||
var_list->end_list = NULL;\
|
|
||||||
var_list->size = 0;\
|
|
||||||
var_list->current_index = 0;\
|
|
||||||
free(var_list);\
|
free(var_list);\
|
||||||
}\
|
}\
|
||||||
\
|
\
|
||||||
|
|||||||
+63
-18
@@ -12,14 +12,16 @@ TEST(list_create){
|
|||||||
push_back_list_TYPE_INT(var_list_int, -9);
|
push_back_list_TYPE_INT(var_list_int, -9);
|
||||||
push_back_list_TYPE_INT(var_list_int, 19);
|
push_back_list_TYPE_INT(var_list_int, 19);
|
||||||
|
|
||||||
move_current_to_index_list_TYPE_INT(var_list_int, 0);
|
LOG("move to 0 = %ld", move_current_to_index_list_TYPE_INT(var_list_int, 0,NULL));
|
||||||
while(var_list_int->current_list){
|
while(var_list_int->current_list){
|
||||||
LOG("cur %ld : %d : size :%ld \n", var_list_int->current_index, (var_list_int->current_list)->value, var_list_int->size);
|
LOG("cur %ld : %d : size :%ld \n", var_list_int->current_index, (var_list_int->current_list)->value, var_list_int->size);
|
||||||
increment_list_TYPE_INT(var_list_int);
|
increment_list_TYPE_INT(var_list_int);
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG("%s"," =============== \n");
|
LOG("%s"," =============== \n");
|
||||||
for(move_current_to_index_list_TYPE_INT(var_list_int, (var_list_int->size) - 1); var_list_int->current_list; decrement_list_TYPE_INT(var_list_int))
|
size_t size_li = (var_list_int->size);
|
||||||
|
LOG("move to %ld = %ld", move_current_to_index_list_TYPE_INT(var_list_int, size_li - 1,NULL), size_li);
|
||||||
|
for(/*move_current_to_index_list_TYPE_INT(var_list_int, (var_list_int->size) - 1, NULL)*/; var_list_int->current_list; decrement_list_TYPE_INT(var_list_int))
|
||||||
LOG("cur %ld : %d : size :%ld \n", var_list_int->current_index, (var_list_int->current_list)->value, var_list_int->size);
|
LOG("cur %ld : %d : size :%ld \n", var_list_int->current_index, (var_list_int->current_list)->value, var_list_int->size);
|
||||||
|
|
||||||
free_all_var_list_TYPE_INT(var_list_int);
|
free_all_var_list_TYPE_INT(var_list_int);
|
||||||
@@ -38,7 +40,7 @@ TEST(insert){
|
|||||||
for(int i=var_list_int->size; i< 25; ++i)
|
for(int i=var_list_int->size; i< 25; ++i)
|
||||||
insert_into_list_TYPE_INT(var_list_int, i, 3*i+1);
|
insert_into_list_TYPE_INT(var_list_int, i, 3*i+1);
|
||||||
|
|
||||||
for(move_current_to_index_list_TYPE_INT(var_list_int, 0); var_list_int->current_list; increment_list_TYPE_INT(var_list_int))
|
for(move_current_to_index_list_TYPE_INT(var_list_int, 0, NULL); var_list_int->current_list; increment_list_TYPE_INT(var_list_int))
|
||||||
LOG("cur %ld : %d : size :%ld \n", var_list_int->current_index, (var_list_int->current_list)->value, var_list_int->size);
|
LOG("cur %ld : %d : size :%ld \n", var_list_int->current_index, (var_list_int->current_list)->value, var_list_int->size);
|
||||||
|
|
||||||
free_all_var_list_TYPE_INT(var_list_int);
|
free_all_var_list_TYPE_INT(var_list_int);
|
||||||
@@ -49,7 +51,7 @@ TEST(insert){
|
|||||||
TEST(remove){
|
TEST(remove){
|
||||||
struct main_list_TYPE_INT * var_list_int = create_var_list_TYPE_INT();
|
struct main_list_TYPE_INT * var_list_int = create_var_list_TYPE_INT();
|
||||||
|
|
||||||
remove_all_list_in_TYPE_INT(var_list_int);
|
remove_all_list_in_TYPE_INT(var_list_int);
|
||||||
|
|
||||||
for(int i=0; i<5; ++i)
|
for(int i=0; i<5; ++i)
|
||||||
push_back_list_TYPE_INT(var_list_int, i);
|
push_back_list_TYPE_INT(var_list_int, i);
|
||||||
@@ -60,46 +62,89 @@ remove_all_list_in_TYPE_INT(var_list_int);
|
|||||||
for(int i=var_list_int->size; i< 25; ++i)
|
for(int i=var_list_int->size; i< 25; ++i)
|
||||||
insert_into_list_TYPE_INT(var_list_int, i, 3*i+1);
|
insert_into_list_TYPE_INT(var_list_int, i, 3*i+1);
|
||||||
|
|
||||||
for(move_current_to_index_list_TYPE_INT(var_list_int, 0); var_list_int->current_list; increment_list_TYPE_INT(var_list_int))
|
// for(move_current_to_index_list_TYPE_INT(var_list_int, 0,NULL); var_list_int->current_list; increment_list_TYPE_INT(var_list_int))
|
||||||
LOG("cur %ld : %d : size :%ld \n", var_list_int->current_index, (var_list_int->current_list)->value, var_list_int->size);
|
for(struct list_TYPE_INT *current_list = var_list_int->end_list; current_list; current_list = current_list->preview)
|
||||||
|
LOG("cur %ld : %d : size :%ld \n", current_list->index, (current_list)->value, var_list_int->size);
|
||||||
|
|
||||||
for(int i=1; i<var_list_int->size; i+= 3)
|
for(int i=1; i<var_list_int->size; i+= 3)
|
||||||
remove_index_from_list_TYPE_INT(var_list_int, i);
|
remove_index_from_list_TYPE_INT(var_list_int, i);
|
||||||
|
|
||||||
LOG("%s"," =============== \n");
|
LOG("%s"," =============== \n");
|
||||||
|
|
||||||
for(move_current_to_index_list_TYPE_INT(var_list_int, 0); var_list_int->current_list; increment_list_TYPE_INT(var_list_int))
|
for(struct list_TYPE_INT *current_list = var_list_int->begin_list; current_list; current_list = current_list->next)
|
||||||
|
LOG("cur %ld : %d : size :%ld \n", current_list->index, (current_list)->value, var_list_int->size);
|
||||||
|
/*
|
||||||
|
for(struct list_TYPE_INT *current_list = var_list_int->begin_list; current_list; current_list = current_list->next)
|
||||||
|
LOG("cur %ld : %d : size :%ld \n", current_list->index, (current_list)->value, var_list_int->size);
|
||||||
|
*/ /*for(move_current_to_index_list_TYPE_INT(var_list_int, 0,NULL); var_list_int->current_list; increment_list_TYPE_INT(var_list_int))
|
||||||
LOG("cur %ld : %d : size :%ld \n", var_list_int->current_index, (var_list_int->current_list)->value, var_list_int->size);
|
LOG("cur %ld : %d : size :%ld \n", var_list_int->current_index, (var_list_int->current_list)->value, var_list_int->size);
|
||||||
|
*/
|
||||||
|
|
||||||
free_all_var_list_TYPE_INT(var_list_int);
|
free_all_var_list_TYPE_INT(var_list_int);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(pull_index){
|
||||||
|
struct main_list_TYPE_INT * var_list_int = create_var_list_TYPE_INT();
|
||||||
|
|
||||||
|
remove_all_list_in_TYPE_INT(var_list_int);
|
||||||
|
|
||||||
|
for(int i=0; i<5; ++i)
|
||||||
|
push_back_list_TYPE_INT(var_list_int, i);
|
||||||
|
|
||||||
|
for(int i=0; i<10; ++i)
|
||||||
|
insert_into_list_TYPE_INT(var_list_int, i, -2*i+1);
|
||||||
|
|
||||||
|
for(int i=var_list_int->size; i< 25; ++i)
|
||||||
|
insert_into_list_TYPE_INT(var_list_int, i, 3*i+1);
|
||||||
|
|
||||||
|
// for(move_current_to_index_list_TYPE_INT(var_list_int, 0,NULL); var_list_int->current_list; increment_list_TYPE_INT(var_list_int))
|
||||||
|
for(struct list_TYPE_INT *current_list = var_list_int->end_list; current_list; current_list = current_list->preview)
|
||||||
|
LOG("cur %ld : %d : size :%ld \n", current_list->index, (current_list)->value, var_list_int->size);
|
||||||
|
|
||||||
|
for(int i=1; i<var_list_int->size; i+= 3){
|
||||||
|
struct list_TYPE_INT *current_list =pull_index_from_list_TYPE_INT(var_list_int, i);
|
||||||
|
if(current_list) free(current_list);
|
||||||
|
}
|
||||||
|
LOG("%s"," =============== \n");
|
||||||
|
|
||||||
|
for(struct list_TYPE_INT *current_list = var_list_int->begin_list; current_list; current_list = current_list->next)
|
||||||
|
LOG("cur %ld : %d : size :%ld \n", current_list->index, (current_list)->value, var_list_int->size);
|
||||||
|
/*
|
||||||
|
for(struct list_TYPE_INT *current_list = var_list_int->begin_list; current_list; current_list = current_list->next)
|
||||||
|
LOG("cur %ld : %d : size :%ld \n", current_list->index, (current_list)->value, var_list_int->size);
|
||||||
|
*/ /*for(move_current_to_index_list_TYPE_INT(var_list_int, 0,NULL); var_list_int->current_list; increment_list_TYPE_INT(var_list_int))
|
||||||
|
LOG("cur %ld : %d : size :%ld \n", var_list_int->current_index, (var_list_int->current_list)->value, var_list_int->size);
|
||||||
|
*/
|
||||||
|
|
||||||
|
free_all_var_list_TYPE_INT(var_list_int);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
TEST(remove_All){
|
TEST(remove_All){
|
||||||
struct main_list_TYPE_INT * var_list_int = create_var_list_TYPE_INT();
|
struct main_list_TYPE_INT * var_list_int = create_var_list_TYPE_INT();
|
||||||
|
|
||||||
for(int i=0; i<5; ++i)
|
for(int i=0; i<5; ++i)
|
||||||
push_back_list_TYPE_INT(var_list_int, i);
|
push_back_list_TYPE_INT(var_list_int, i);
|
||||||
|
|
||||||
for(int i=0; i<10; ++i)
|
for(int i=0; i<10; ++i)
|
||||||
insert_into_list_TYPE_INT(var_list_int, i, -2*i+1);
|
insert_into_list_TYPE_INT(var_list_int, i, -2*i+1);
|
||||||
|
|
||||||
|
#if 1
|
||||||
for(int i=var_list_int->size; i< 25; ++i)
|
for(int i=var_list_int->size; i< 25; ++i)
|
||||||
insert_into_list_TYPE_INT(var_list_int, i, 3*i+1);
|
insert_into_list_TYPE_INT(var_list_int, i, 3*i+1);
|
||||||
|
|
||||||
for(move_current_to_index_list_TYPE_INT(var_list_int, 0); var_list_int->current_list; increment_list_TYPE_INT(var_list_int))
|
for(move_current_to_index_list_TYPE_INT(var_list_int, 0,NULL); var_list_int->current_list; increment_list_TYPE_INT(var_list_int))
|
||||||
LOG("cur %ld : %d : size :%ld \n", var_list_int->current_index, (var_list_int->current_list)->value, var_list_int->size);
|
LOG("cur %ld : %d : size :%ld \n", var_list_int->current_index, (var_list_int->current_list)->value, var_list_int->size);
|
||||||
|
|
||||||
remove_all_list_in_TYPE_INT(var_list_int);
|
remove_all_list_in_TYPE_INT(var_list_int);
|
||||||
for(int i=0; i<5; ++i)
|
for(int i=0; i<5; ++i)
|
||||||
push_back_list_TYPE_INT(var_list_int, 10*i);
|
push_back_list_TYPE_INT(var_list_int, 10*i);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
LOG("%s"," =============== \n");
|
LOG("%s"," =============== \n");
|
||||||
|
|
||||||
for(move_current_to_index_list_TYPE_INT(var_list_int, 0); var_list_int->current_list; increment_list_TYPE_INT(var_list_int))
|
for(move_current_to_index_list_TYPE_INT(var_list_int, 0,NULL); var_list_int->current_list; increment_list_TYPE_INT(var_list_int))
|
||||||
LOG("cur %ld : %d : size :%ld \n", var_list_int->current_index, (var_list_int->current_list)->value, var_list_int->size);
|
LOG("cur %ld : %d : size :%ld \n", var_list_int->current_index, (var_list_int->current_list)->value, var_list_int->size);
|
||||||
|
|
||||||
free_all_var_list_TYPE_INT(var_list_int);
|
free_all_var_list_TYPE_INT(var_list_int);
|
||||||
@@ -141,7 +186,7 @@ TEST(list_TYPE_PTR){
|
|||||||
push_back_list_TYPE_PTR(var_list_ptr,t1);
|
push_back_list_TYPE_PTR(var_list_ptr,t1);
|
||||||
push_back_list_TYPE_PTR(var_list_ptr,t2);
|
push_back_list_TYPE_PTR(var_list_ptr,t2);
|
||||||
|
|
||||||
for(move_current_to_index_list_TYPE_PTR(var_list_ptr, 0); var_list_ptr->current_list; increment_list_TYPE_PTR(var_list_ptr))
|
for(move_current_to_index_list_TYPE_PTR(var_list_ptr, 0,NULL); var_list_ptr->current_list; increment_list_TYPE_PTR(var_list_ptr))
|
||||||
LOG("cur %ld : %d : size :%ld \n", var_list_ptr->current_index, ((test_c*)((var_list_ptr->current_list)->value))->value, var_list_ptr->size);
|
LOG("cur %ld : %d : size :%ld \n", var_list_ptr->current_index, ((test_c*)((var_list_ptr->current_list)->value))->value, var_list_ptr->size);
|
||||||
|
|
||||||
|
|
||||||
@@ -167,7 +212,7 @@ TEST(list_struct_test_c){
|
|||||||
push_back_list_test_c(var_list_ptr,t1);
|
push_back_list_test_c(var_list_ptr,t1);
|
||||||
push_back_list_test_c(var_list_ptr,t2);
|
push_back_list_test_c(var_list_ptr,t2);
|
||||||
|
|
||||||
for(move_current_to_index_list_test_c(var_list_ptr, 0); var_list_ptr->current_list; increment_list_test_c(var_list_ptr))
|
for(move_current_to_index_list_test_c(var_list_ptr, 0,NULL); var_list_ptr->current_list; increment_list_test_c(var_list_ptr))
|
||||||
LOG("cur %ld : %d : size :%ld \n", var_list_ptr->current_index, ((var_list_ptr->current_list)->value).value, var_list_ptr->size);
|
LOG("cur %ld : %d : size :%ld \n", var_list_ptr->current_index, ((var_list_ptr->current_list)->value).value, var_list_ptr->size);
|
||||||
|
|
||||||
|
|
||||||
@@ -189,7 +234,7 @@ TEST(index_list_struct_test_c){
|
|||||||
push_back_list_test_c(var_list_ptr,t1);
|
push_back_list_test_c(var_list_ptr,t1);
|
||||||
push_back_list_test_c(var_list_ptr,t2);
|
push_back_list_test_c(var_list_ptr,t2);
|
||||||
|
|
||||||
for(move_current_to_index_list_test_c(var_list_ptr, 0); var_list_ptr->current_list; increment_list_test_c(var_list_ptr))
|
for(move_current_to_index_list_test_c(var_list_ptr, 0,NULL); var_list_ptr->current_list; increment_list_test_c(var_list_ptr))
|
||||||
LOG("index=[%ld] cur %ld : %d : size :%ld \n", var_list_ptr->current_list->index, var_list_ptr->current_index, ((var_list_ptr->current_list)->value).value, var_list_ptr->size);
|
LOG("index=[%ld] cur %ld : %d : size :%ld \n", var_list_ptr->current_list->index, var_list_ptr->current_index, ((var_list_ptr->current_list)->value).value, var_list_ptr->size);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user