Commit dd095f5c authored by Simon Morlat's avatar Simon Morlat
Browse files

Rename bctbx_list_remove_link() into bctbx_list_unlink() and...

Rename bctbx_list_remove_link() into bctbx_list_unlink() and bctbx_list_delete_link() into bctbx_list_erase_link().
Indeed, there was a confusion between these two methods when the MSList API was deprecated, resulting in thousands of small memory leaks.
bctbx_list_remove_link() is not freeing the list node, unlike bctbx_list_delete_link.
parent bc85d6a8
......@@ -27,7 +27,7 @@ set(CMAKE_MACOSX_RPATH ON) # Before cmake 3.0.0, MACOSX_RPATH was not set to ON
project(bctoolbox)
set(BCTOOLBOX_VERSION_MAJOR 0)
set(BCTOOLBOX_VERSION_MINOR 2)
set(BCTOOLBOX_VERSION_MINOR 3)
set(BCTOOLBOX_VERSION_PATCH 0)
set(BCTOOLBOX_SO_VERSION 0)
set(BCTOOLBOXTESTER_SO_VERSION 0)
......
......@@ -3,7 +3,7 @@
AC_PREREQ([2.63])
AC_INIT([bctoolbox],[0.2.0],[jehan.monnier@linphone.org])
AC_INIT([bctoolbox],[0.3.0],[jehan.monnier@linphone.org])
BCTOOLBOX_SO_CURRENT=0 dnl increment this number when you add/change/remove an interface
BCTOOLBOX_SO_REVISION=0 dnl increment this number when you change source code, without changing interfaces; set to 0 when incrementing CURRENT
......
......@@ -52,8 +52,16 @@ BCTBX_PUBLIC bctbx_list_t * bctbx_list_pop_front(bctbx_list_t *list, void **fron
BCTBX_PUBLIC size_t bctbx_list_size(const bctbx_list_t * first);
BCTBX_PUBLIC void bctbx_list_for_each(const bctbx_list_t * list, bctbx_list_iterate_func func);
BCTBX_PUBLIC void bctbx_list_for_each2(const bctbx_list_t * list, bctbx_list_iterate2_func func, void *user_data);
BCTBX_PUBLIC bctbx_list_t * bctbx_list_remove_link(bctbx_list_t * list, bctbx_list_t * elem);
BCTBX_PUBLIC bctbx_list_t * bctbx_list_delete_link(bctbx_list_t * list, bctbx_list_t * elem);
/**
* Removes the element pointed by elem from the list. The element itself is not freed, allowing
* to be chained in another list for example.
* Use bctbx_list_erase_link() if you simply want to delete an element of a list.
**/
BCTBX_PUBLIC bctbx_list_t * bctbx_list_unlink(bctbx_list_t * list, bctbx_list_t * elem);
/**
* Delete the element pointed by 'elem' from the list.
**/
BCTBX_PUBLIC bctbx_list_t * bctbx_list_erase_link(bctbx_list_t * list, bctbx_list_t * elem);
BCTBX_PUBLIC bctbx_list_t * bctbx_list_find(bctbx_list_t * list, void *data);
BCTBX_PUBLIC bctbx_list_t * bctbx_list_free(bctbx_list_t *list);
/*frees list elements and associated data, using the supplied function pointer*/
......
......@@ -130,7 +130,7 @@ bctbx_list_t * bctbx_list_free_with_data(bctbx_list_t *list, bctbx_list_free_fun
bctbx_list_t* _bctbx_list_remove(bctbx_list_t* first, void *data, int warn_if_not_found){
bctbx_list_t* it;
it=bctbx_list_find(first,data);
if (it) return bctbx_list_delete_link(first,it);
if (it) return bctbx_list_erase_link(first,it);
else if (warn_if_not_found){
bctbx_warning("bctbx_list_remove: no element with %p data was in the list", data);
}
......@@ -182,12 +182,12 @@ bctbx_list_t * bctbx_list_pop_front(bctbx_list_t *list, void **front_data){
return NULL;
}
*front_data=front_elem->data;
list=bctbx_list_remove_link(list,front_elem);
list=bctbx_list_unlink(list,front_elem);
bctbx_free(front_elem);
return list;
}
bctbx_list_t* bctbx_list_remove_link(bctbx_list_t* list, bctbx_list_t* elem){
bctbx_list_t* bctbx_list_unlink(bctbx_list_t* list, bctbx_list_t* elem){
bctbx_list_t* ret;
if (elem==list){
ret=elem->next;
......@@ -203,8 +203,8 @@ bctbx_list_t* bctbx_list_remove_link(bctbx_list_t* list, bctbx_list_t* elem){
return list;
}
bctbx_list_t * bctbx_list_delete_link(bctbx_list_t* list, bctbx_list_t* elem){
bctbx_list_t *ret=bctbx_list_remove_link(list,elem);
bctbx_list_t * bctbx_list_erase_link(bctbx_list_t* list, bctbx_list_t* elem){
bctbx_list_t *ret=bctbx_list_unlink(list,elem);
bctbx_free(elem);
return ret;
}
......@@ -226,7 +226,7 @@ bctbx_list_t* bctbx_list_find_custom(const bctbx_list_t* list, bctbx_compare_fun
bctbx_list_t *bctbx_list_delete_custom(bctbx_list_t *list, bctbx_compare_func compare_func, const void *user_data){
bctbx_list_t *elem=bctbx_list_find_custom(list,compare_func,user_data);
if (elem!=NULL){
list=bctbx_list_delete_link(list,elem);
list=bctbx_list_erase_link(list,elem);
}
return list;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment