From: Benjamin Auder Date: Fri, 15 May 2015 10:00:39 +0000 (+0200) Subject: fixed mistake in test/makemain.sh ; still vector_pop_first to fix in src/Vector.c X-Git-Url: https://git.auder.net/%7B%7B%20asset%28%27mixstore/images/assets/doc/img/%3C?a=commitdiff_plain;h=6860e3738006ac605540c4f7bd9b7a8bb75383ac;p=cgds.git fixed mistake in test/makemain.sh ; still vector_pop_first to fix in src/Vector.c --- diff --git a/src/Vector.c b/src/Vector.c index a303d54..cf45cb9 100644 --- a/src/Vector.c +++ b/src/Vector.c @@ -85,9 +85,17 @@ void vector_pop(Vector* vector) void vector_pop_first(Vector* vector) { safe_free(vector->datas[0]); - vector->datas++; + + + //HACK: next 3 lines move vector head + void** nextDatas = vector->datas + 1; + safe_free(vector->datas); + vector->datas = nextDatas; +//but memory can then be reallocated : TODO + + vector->size--; - if (vector_size(vector) <= (vector->capacity >> 1)) + if (vector->size <= (vector->capacity >> 1)) _vector_realloc(vector, vector->capacity >> 1); } diff --git a/test/main.c b/test/main.c index a6e926c..7b8f5ff 100644 --- a/test/main.c +++ b/test/main.c @@ -3,60 +3,60 @@ int main(int argc, char** argv) { //file ./t.Vector.c : - void t_vector_clear(); - void t_vector_size(); - void t_vector_push_pop_basic(); - void t_vector_push_pop_evolved(); - void t_vector_copy(); + t_vector_clear(); + t_vector_size(); + t_vector_push_pop_basic(); + t_vector_push_pop_evolved(); + t_vector_copy(); //file ./t.BufferTop.c : - void t_buffertop_clear(); - void t_buffertop_size(); - void t_buffertop_push_pop_basic(); - void t_buffertop_push_pop_evolved(); - void t_buffertop_copy(); + t_buffertop_clear(); + t_buffertop_size(); + t_buffertop_push_pop_basic(); + t_buffertop_push_pop_evolved(); + t_buffertop_copy(); //file ./t.Tree.c : - void t_tree_clear(); - void t_tree_size(); - void t_tree_add_remove(); - void t_tree_iterate(); - void t_tree_copy(); + t_tree_clear(); + t_tree_size(); + t_tree_add_remove(); + t_tree_iterate(); + t_tree_copy(); //file ./t.Heap.c : - void t_heap_clear(); - void t_heap_size(); - void t_heap_push_pop_basic(); - void t_heap_push_pop_evolved(); - void t_heap_copy(); + t_heap_clear(); + t_heap_size(); + t_heap_push_pop_basic(); + t_heap_push_pop_evolved(); + t_heap_copy(); //file ./t.List.c : - void t_list_clear(); - void t_list_size(); - void t_list_push_pop_basic(); - void t_list_push_pop_evolved(); - void t_list_copy(); + t_list_clear(); + t_list_size(); + t_list_push_pop_basic(); + t_list_push_pop_evolved(); + t_list_copy(); //file ./t.Queue.c : - void t_queue_clear(); - void t_queue_size(); - void t_queue_push_pop_basic(); - void t_queue_push_pop_evolved(); - void t_queue_copy(); + t_queue_clear(); + t_queue_size(); + t_queue_push_pop_basic(); + t_queue_push_pop_evolved(); + t_queue_copy(); //file ./t.Stack.c : - void t_stack_clear(); - void t_stack_size(); - void t_stack_push_pop_basic(); - void t_stack_push_pop_evolved(); - void t_stack_copy(); + t_stack_clear(); + t_stack_size(); + t_stack_push_pop_basic(); + t_stack_push_pop_evolved(); + t_stack_copy(); //file ./t.PriorityQueue.c : - void t_priorityqueue_clear(); - void t_priorityqueue_size(); - void t_priorityqueue_push_pop_basic(); - void t_priorityqueue_push_pop_evolved(); - void t_priorityqueue_copy(); + t_priorityqueue_clear(); + t_priorityqueue_size(); + t_priorityqueue_push_pop_basic(); + t_priorityqueue_push_pop_evolved(); + t_priorityqueue_copy(); return 0; } diff --git a/test/makeMain.sh b/test/makeMain.sh index 19bb852..69ac68c 100644 --- a/test/makeMain.sh +++ b/test/makeMain.sh @@ -10,7 +10,7 @@ printf '{\n' >> main.c #add functions for file in `find . -type f -name \*.c ! -name main.c`; do printf "\t//file $file :\n" >> main.c - functions=`grep '^ *void t_' $file | sed 's/^ *\(void [^(]*\).*/\t\1();/g'` + functions=`grep '^ *void t_' $file | sed 's/^ *void \([^(]*\).*/\t\1();/g'` printf "$functions" >> main.c printf '\n\n' >> main.c done