Commit 5d1efd57 authored by Ghislain MARY's avatar Ghislain MARY
Browse files

Deprecate MSList and use bctbx_list_t instead.

parent e73957fb
......@@ -20,6 +20,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define mscommon_h
#include <bctoolbox/port.h>
#include <bctoolbox/list.h>
#include <ortp/logging.h>
#include <ortp/port.h>
#include <ortp/str_utils.h>
......@@ -127,19 +128,7 @@ typedef ortpTimeSpec MSTimeSpec;
#define ms_get_cur_time ortp_get_cur_time
#define ms_get_cur_time_ms ortp_get_cur_time_ms
struct _MSList {
struct _MSList *next;
struct _MSList *prev;
void *data;
};
typedef struct _MSList MSList;
#define ms_list_next(elem) ((elem)->next)
typedef int (*MSCompareFunc)(const void *a, const void *b);
typedef bctbx_compare_func MSCompareFunc;
typedef void (*MSIterateFunc)(void *a);
typedef void (*MSIterate2Func)(void *a, void *b);
typedef void (*MSIterate3Func)(void *a, void *b, void *c);
......@@ -153,6 +142,9 @@ typedef struct { unsigned char octet[16]; } UInt128;
MS2_PUBLIC void ms_thread_exit(void* ret_val);
#define MSList bctbx_list_t
/**
* @addtogroup ms_list
* @{
......@@ -162,153 +154,178 @@ MS2_PUBLIC void ms_thread_exit(void* ret_val);
* @param list list where data should be added. If NULL, a new list will be created.
* @param data data to insert into the list
* @return first element of the list
* @deprecated Use bctbx_list_append() instead
**/
MS2_PUBLIC MSList * ms_list_append(MSList *list, void * data);
MS2_PUBLIC MS2_DEPRECATED MSList * ms_list_append(MSList *list, void * data);
/** Inserts given element to the end of a given list
* @param list list where data should be added. If NULL, a new list will be created.
* @param new_elem element to append
* @return first element of the list
* @deprecated Use bctbx_list_append_link() instead
**/
MS2_PUBLIC MSList *ms_list_append_link(MSList *list, MSList *new_elem);
MS2_PUBLIC MS2_DEPRECATED MSList *ms_list_append_link(MSList *list, MSList *new_elem);
/** Inserts a new element containing data to the start of a given list
* @param list list where data should be added. If NULL, a new list will be created.
* @param data data to insert into the list
* @return first element of the list - the one which was just created.
* @deprecated Use bctbx_list_prepend() instead
**/
MS2_PUBLIC MSList * ms_list_prepend(MSList *list, void * data);
MS2_PUBLIC MS2_DEPRECATED MSList * ms_list_prepend(MSList *list, void * data);
/** Frees all elements of a given list
* Note that data contained in each element will not be freed. If you need to clean
* them, consider using @ms_list_free_with_data
* @param list object to free.
* @return NULL
* @deprecated Use bctbx_list_free() instead
**/
MS2_PUBLIC MSList * ms_list_free(MSList *list);
MS2_PUBLIC MS2_DEPRECATED MSList * ms_list_free(MSList *list);
/** Frees all elements of a given list after having called freefunc on each element
* @param list object to free.
* @param freefunc function to invoke on each element data before destroying the element
* @return NULL
* @deprecated Use bctbx_list_free_with_data() instead
**/
MS2_PUBLIC MSList * ms_list_free_with_data(MSList *list, void (*freefunc)(void*));
MS2_PUBLIC MS2_DEPRECATED MSList * ms_list_free_with_data(MSList *list, void (*freefunc)(void*));
/** Concatenates second list to the end of first list
* @param first First list
* @param second Second list to append at the end of first list.
* @return first element of the merged list
* @deprecated Use bctbx_list_concat() instead
**/
MS2_PUBLIC MSList * ms_list_concat(MSList *first, MSList *second);
MS2_PUBLIC MS2_DEPRECATED MSList * ms_list_concat(MSList *first, MSList *second);
/** Finds and remove the first element containing the given data. Nothing is done if element is not found.
* @param list List in which data must be removed
* @param data Data to remove
* @return first element of the modified list
* @deprecated Use bctbx_list_remove() instead
**/
MS2_PUBLIC MSList * ms_list_remove(MSList *list, void *data);
MS2_PUBLIC MS2_DEPRECATED MSList * ms_list_remove(MSList *list, void *data);
/** Finds and remove any elements according to the given predicate function
* @param list List in which data must be removed
* @param compare_func Function to invoke on each element. If it returns TRUE, the given element will be deleted.
* @param user_data User data to pass to compare_func function
* @return first element of the modified list
* @deprecated Use bctbx_list_remove_custom() instead
**/
MS2_PUBLIC MSList * ms_list_remove_custom(MSList *list, MSCompareFunc compare_func, const void *user_data);
MS2_PUBLIC MS2_DEPRECATED MSList * ms_list_remove_custom(MSList *list, MSCompareFunc compare_func, const void *user_data);
/** Returns size of a given list
* @param list List to measure
* @return Size of list
* @deprecated Use bctbx_list_size() instead
**/
MS2_PUBLIC size_t ms_list_size(const MSList *list);
MS2_PUBLIC MS2_DEPRECATED int ms_list_size(const MSList *list);
/** Invoke function on each element of the list
* @param list List object
* @param iterate_func Function to invoke on each element.
* @deprecated Use bctbx_list_for_each() instead
**/
MS2_PUBLIC void ms_list_for_each(const MSList *list, MSIterateFunc iterate_func);
MS2_PUBLIC MS2_DEPRECATED void ms_list_for_each(const MSList *list, MSIterateFunc iterate_func);
/** Invoke function on each element of the list
* @param list List object
* @param iterate_func Function to invoke on each element.
* @param user_data User data to pass to iterate_func function.
*
* @deprecated Use bctbx_list_for_each2() instead
**/
MS2_PUBLIC void ms_list_for_each2(const MSList *list, MSIterate2Func iterate_func, void *user_data);
MS2_PUBLIC MS2_DEPRECATED void ms_list_for_each2(const MSList *list, MSIterate2Func iterate_func, void *user_data);
MS2_PUBLIC void ms_list_for_each3(const MSList *list, MSIterate3Func iterate_func, void *user_data, void *factory);
MS2_PUBLIC MS2_DEPRECATED void ms_list_for_each3(const MSList *list, MSIterate3Func iterate_func, void *user_data, void *factory);
/** Finds and remove given element in list.
* @param list List in which element must be removed
* @param element element to remove
* @return first element of the modified list
* @deprecated Use bctbx_list_remove_link() instead
**/
MS2_PUBLIC MSList *ms_list_remove_link(MSList *list, MSList *elem);
MS2_PUBLIC MS2_DEPRECATED MSList *ms_list_remove_link(MSList *list, MSList *elem);
/** Finds first element containing data in the given list.
* @param list List in which element must be found
* @param data data to find
* @return element containing data, or NULL if not found
* @deprecated Use bctbx_list_find() instead
**/
MS2_PUBLIC MSList *ms_list_find(MSList *list, void *data);
MS2_PUBLIC MS2_DEPRECATED MSList *ms_list_find(MSList *list, void *data);
/** Finds first element according to the given predicate function
* @param list List in which element must be found
* @param compare_func Function to invoke on each element. If it returns TRUE, the given element will be returned.
* @param user_data User data to pass to compare_func function
* @return Element matching the predicate, or NULL if none is found.
* @deprecated Use bctbx_list_find_custom() instead
**/
MS2_PUBLIC MSList *ms_list_find_custom(MSList *list, MSCompareFunc compare_func, const void *user_data);
MS2_PUBLIC MS2_DEPRECATED MSList *ms_list_find_custom(MSList *list, MSCompareFunc compare_func, const void *user_data);
/** Returns the nth element data of the list
* @param list List object
* @param index data index which must be returned.
* @return Element at the given index. NULL if index is invalid (negative or greater or equal to ms_list_size).
* @deprecated Use bctbx_list_nth_data() instead
**/
MS2_PUBLIC void * ms_list_nth_data(const MSList *list, int index);
MS2_PUBLIC MS2_DEPRECATED void * ms_list_nth_data(const MSList *list, int index);
/** Returns the index of the given element
* @param list List object
* @param elem Element to search for.
* @return Index of the given element. -1 if not found.
* @deprecated Use bctbx_list_position() instead
**/
MS2_PUBLIC int ms_list_position(const MSList *list, MSList *elem);
MS2_PUBLIC MS2_DEPRECATED int ms_list_position(const MSList *list, MSList *elem);
/** Returns the index of the first element containing data
* @param list List object
* @param data Data to search for.
* @return Index of the element containing data. -1 if not found.
* @deprecated Use bctbx_list_index() instead
**/
MS2_PUBLIC int ms_list_index(const MSList *list, void *data);
MS2_PUBLIC MS2_DEPRECATED int ms_list_index(const MSList *list, void *data);
/** Inserts a new element containing data at the place given by compare_func
* @param list list where data should be added. If NULL, a new list will be created.
* @param data data to insert into the list
* @param compare_func function determining where should the new element be placed
* @return first element of the list.
* @deprecated Use bctbx_list_insert_sorted() instead
**/
MS2_PUBLIC MSList *ms_list_insert_sorted(MSList *list, void *data, MSCompareFunc compare_func);
MS2_PUBLIC MS2_DEPRECATED MSList *ms_list_insert_sorted(MSList *list, void *data, MSCompareFunc compare_func);
/** Inserts a new element containing data before the given element
* @param list list where data should be added. If NULL, a new list will be created.
* @param before element parent to the one we will insert.
* @param data data to insert into the list
* @return first element of the modified list.
* @deprecated Use bctbx_list_insert() instead
**/
MS2_PUBLIC MSList *ms_list_insert(MSList *list, MSList *before, void *data);
MS2_PUBLIC MS2_DEPRECATED MSList *ms_list_insert(MSList *list, MSList *before, void *data);
/** Copies a list in another one, duplicating elements but not data
* @param list list to copy
* @return Newly created list
* @deprecated Use bctbx_list_copy() instead
**/
MS2_PUBLIC MSList *ms_list_copy(const MSList *list);
MS2_PUBLIC MS2_DEPRECATED MSList *ms_list_copy(const MSList *list);
/** Copies a list in another one, duplicating elements according to the given function
* @param list list to copy
* @param copyfunc function to invoke on each element which will return the new list data value
* @return Newly created list
* @deprecated Use bctbx_list_copy_with_data() instead
**/
MS2_PUBLIC MSList *ms_list_copy_with_data(const MSList *list, void *(*copyfunc)(void *));
MS2_PUBLIC MS2_DEPRECATED MSList *ms_list_copy_with_data(const MSList *list, void *(*copyfunc)(void *));
/**
* @deprecated @deprecated Use bctbx_list_next() instead
*/
MS2_PUBLIC MS2_DEPRECATED MSList* ms_list_next(const MSList *list);
/** @} */
......
......@@ -166,7 +166,7 @@ SoundDeviceDescription genericSoundDeviceDescriptor={"Generic", "Generic", "Gene
#endif
static MSList *sound_device_descriptions;
static bctbx_list_t *sound_device_descriptions;
static bool_t sound_device_match(SoundDeviceDescription *d, const char *manufacturer, const char* model, const char *platform){
if (strcasecmp(d->manufacturer, manufacturer) == 0
......@@ -181,7 +181,7 @@ static bool_t sound_device_match(SoundDeviceDescription *d, const char *manufact
}
static SoundDeviceDescription *lookup_sound_device(const char *manufacturer, const char* model, const char *platform) {
MSList *list = sound_device_descriptions;
bctbx_list_t *list = sound_device_descriptions;
SoundDeviceDescription *d;
for(; list != NULL; list = list->next) {
d = (SoundDeviceDescription*) list->data;
......@@ -213,7 +213,7 @@ void ms_sound_device_description_add(const char *manufacturer, const char *model
new_sound_device_description->delay = delay;
new_sound_device_description->recommended_rate = recommended_rate;
sound_device_descriptions = ms_list_append(sound_device_descriptions, new_sound_device_description);
sound_device_descriptions = bctbx_list_append(sound_device_descriptions, new_sound_device_description);
}
#ifndef PROP_VALUE_MAX
......@@ -307,7 +307,7 @@ MSDevicesInfo *ms_devices_info_new(void) {
}
void ms_devices_info_free(MSDevicesInfo *devices_info) {
ms_list_free(devices_info->sound_devices_descriptions);
bctbx_list_free(devices_info->sound_devices_descriptions);
ms_free(devices_info);
}
......@@ -320,11 +320,11 @@ void ms_devices_info_add(MSDevicesInfo *devices_info, const char *manufacturer,
new_sound_device_description->delay = delay;
new_sound_device_description->recommended_rate = recommended_rate;
devices_info->sound_devices_descriptions = ms_list_append(devices_info->sound_devices_descriptions, new_sound_device_description);
devices_info->sound_devices_descriptions = bctbx_list_append(devices_info->sound_devices_descriptions, new_sound_device_description);
}
SoundDeviceDescription* ms_devices_info_lookup_device(MSDevicesInfo *devices_info, const char *manufacturer, const char* model, const char *platform) {
MSList *list = devices_info->sound_devices_descriptions;
bctbx_list_t *list = devices_info->sound_devices_descriptions;
SoundDeviceDescription *d = NULL;
while(list) {
......@@ -332,7 +332,7 @@ SoundDeviceDescription* ms_devices_info_lookup_device(MSDevicesInfo *devices_inf
if (sound_device_match(d, manufacturer, model, platform)) {
return d;
}
list = ms_list_next(list);
list = bctbx_list_next(list);
}
if (platform) {
......
......@@ -382,15 +382,15 @@ MSFilterDesc ms_equalizer_desc={
#endif
MSList *ms_parse_equalizer_string(const char *str) {
MSList *eq_list = NULL;
bctbx_list_t *ms_parse_equalizer_string(const char *str) {
bctbx_list_t *eq_list = NULL;
do {
int bytes;
MSEqualizerGain g;
if (sscanf(str, "%f:%f:%f %n", &g.frequency, &g.gain, &g.width, &bytes) == 3) {
MSEqualizerGain *gain = ms_new(MSEqualizerGain, 1);
*gain = g;
eq_list = ms_list_append(eq_list, gain);
eq_list = bctbx_list_append(eq_list, gain);
str += bytes;
} else break;
} while (1);
......
......@@ -142,7 +142,7 @@ MSSndCardDesc pulse_card_desc={
};
void pa_sinklist_cb(pa_context *c, const pa_sink_info *l, int eol, void *userdata) {
MSList **pa_devicelist = userdata;
bctbx_list_t **pa_devicelist = userdata;
pa_device_t *pa_device;
/* when eol is set to a positive number : end of the list */
......@@ -154,13 +154,13 @@ void pa_sinklist_cb(pa_context *c, const pa_sink_info *l, int eol, void *userdat
strncpy(pa_device->name, l->name, PA_STRING_SIZE-1);
strncpy(pa_device->description, l->description, PA_STRING_SIZE-1);
*pa_devicelist = ms_list_append(*pa_devicelist, pa_device);
*pa_devicelist = bctbx_list_append(*pa_devicelist, pa_device);
end:
pa_threaded_mainloop_signal(the_pa_loop, FALSE);
}
void pa_sourcelist_cb(pa_context *c, const pa_source_info *l, int eol, void *userdata) {
MSList **pa_devicelist = userdata;
bctbx_list_t **pa_devicelist = userdata;
pa_device_t *pa_device;
if (eol > 0) {
......@@ -175,7 +175,7 @@ void pa_sourcelist_cb(pa_context *c, const pa_source_info *l, int eol, void *use
strncpy(pa_device->name, l->name, PA_STRING_SIZE -1);
strncpy(pa_device->description, l->description, PA_STRING_SIZE -1);
*pa_devicelist = ms_list_append(*pa_devicelist, pa_device);
*pa_devicelist = bctbx_list_append(*pa_devicelist, pa_device);
end:
pa_threaded_mainloop_signal(the_pa_loop, FALSE);
}
......@@ -227,13 +227,13 @@ int pulse_card_compare(pa_device_t *sink, pa_device_t *source) {
return strncmp(sink->description, source->description, 512);
}
static void pulse_card_merge_lists(pa_device_t *pa_device, MSList **pa_source_list) {
MSList *sourceCard = ms_list_find_custom(*pa_source_list, (MSCompareFunc)pulse_card_compare, pa_device);
static void pulse_card_merge_lists(pa_device_t *pa_device, bctbx_list_t **pa_source_list) {
bctbx_list_t *sourceCard = bctbx_list_find_custom(*pa_source_list, (bctbx_compare_func)pulse_card_compare, pa_device);
if (sourceCard!= NULL) {
pa_device_t *sourceCard_data = (pa_device_t *)sourceCard->data;
pa_device->bidirectionnal = 1;
strncpy(pa_device->source_name,sourceCard_data->name, PA_STRING_SIZE -1);
*pa_source_list = ms_list_remove(*pa_source_list, sourceCard->data);
*pa_source_list = bctbx_list_remove(*pa_source_list, sourceCard->data);
ms_free(sourceCard_data);
}
}
......@@ -246,8 +246,8 @@ static void pulse_card_merge_lists(pa_device_t *pa_device, MSList **pa_source_li
**/
static void pulse_card_detect(MSSndCardManager *m){
pa_operation *pa_op;
MSList *pa_sink_list=NULL;
MSList *pa_source_list=NULL;
bctbx_list_t *pa_sink_list=NULL;
bctbx_list_t *pa_source_list=NULL;
/* connect to pulse server */
init_pulse_context();
......@@ -279,14 +279,14 @@ static void pulse_card_detect(MSSndCardManager *m){
pa_threaded_mainloop_unlock(the_pa_loop);
/* merge source list into sink list for dual capabilities cards */
ms_list_for_each2(pa_sink_list, (MSIterate2Func)pulse_card_merge_lists, &pa_source_list);
bctbx_list_for_each2(pa_sink_list, (MSIterate2Func)pulse_card_merge_lists, &pa_source_list);
/* create sink and souce cards */
ms_list_for_each2(pa_sink_list, (MSIterate2Func)pulse_card_sink_create, m);
ms_list_for_each2(pa_source_list, (MSIterate2Func)pulse_card_source_create, m);
bctbx_list_for_each2(pa_sink_list, (MSIterate2Func)pulse_card_sink_create, m);
bctbx_list_for_each2(pa_source_list, (MSIterate2Func)pulse_card_source_create, m);
ms_list_free_with_data(pa_sink_list, ms_free);
ms_list_free_with_data(pa_source_list, ms_free);
bctbx_list_free_with_data(pa_sink_list, ms_free);
bctbx_list_free_with_data(pa_source_list, ms_free);
}
typedef enum _StreamType {
......
......@@ -939,7 +939,7 @@ static MSSndCard *winsnddscard_new(const char *name, LPGUID lpguid, int in_dev,
static void add_or_update_card(MSSndCardManager *m, const char *name, LPGUID lpguid, int indev, int outdev, unsigned int capability){
MSSndCard *card;
const MSList *elem=ms_snd_card_manager_get_list(m);
const bctbx_list_t *elem=ms_snd_card_manager_get_list(m);
for(;elem!=NULL;elem=elem->next){
card=(MSSndCard*)elem->data;
if (strcmp(card->desc->driver_type, winsndds_card_desc.driver_type)==0
......@@ -1092,7 +1092,7 @@ static void _winsnddscard_detect(MSSndCardManager *m){
static void deactivate_removed_cards(MSSndCardManager *m){
MSSndCard *card;
const MSList *elem=ms_snd_card_manager_get_list(m);
const bctbx_list_t *elem=ms_snd_card_manager_get_list(m);
for(;elem!=NULL;elem=elem->next){
card=(MSSndCard*)elem->data;
if (strcmp(card->desc->driver_type, winsndds_card_desc.driver_type)==0){
......@@ -1105,7 +1105,7 @@ static void deactivate_removed_cards(MSSndCardManager *m){
static void mark_as_removed(MSSndCardManager *m){
MSSndCard *card;
const MSList *elem=ms_snd_card_manager_get_list(m);
const bctbx_list_t *elem=ms_snd_card_manager_get_list(m);
for(;elem!=NULL;elem=elem->next){
card=(MSSndCard*)elem->data;
if (strcmp(card->desc->driver_type, winsndds_card_desc.driver_type)==0){
......@@ -1424,14 +1424,14 @@ static void winsndds_write_preprocess(MSFilter *f){
unsigned char* pDSBuffData;
DWORD outputBufferWriteOffsetBytes;
MSList *filters=NULL;
bctbx_list_t *filters=NULL;
MSFilter *f_capture_filter=NULL;
WinSndDs *d_capture_filter=NULL;
filters=ms_filter_find_neighbours(f);
if (filters!=NULL)
{
MSList *it;
bctbx_list_t *it;
/* search for another winsndds filter */
for(it=filters;it!=NULL;it=it->next)
{
......@@ -1444,7 +1444,7 @@ static void winsndds_write_preprocess(MSFilter *f){
}
f_capture_filter=NULL;
}
ms_list_free(filters);
bctbx_list_free(filters);
}
d->stat_input=0;
......
......@@ -229,12 +229,12 @@ static void ms_notify_context_destroy(MSNotifyContext *obj){
}
void ms_filter_add_notify_callback(MSFilter *f, MSFilterNotifyFunc fn, void *ud, bool_t synchronous){
f->notify_callbacks=ms_list_append(f->notify_callbacks,ms_notify_context_new(fn,ud,synchronous));
f->notify_callbacks=bctbx_list_append(f->notify_callbacks,ms_notify_context_new(fn,ud,synchronous));
}
void ms_filter_remove_notify_callback(MSFilter *f, MSFilterNotifyFunc fn, void *ud){
MSList *elem;
MSList *found=NULL;
bctbx_list_t *elem;
bctbx_list_t *found=NULL;
for(elem=f->notify_callbacks;elem!=NULL;elem=elem->next){
MSNotifyContext *ctx=(MSNotifyContext*)elem->data;
if (ctx->fn==fn && ctx->ud==ud){
......@@ -244,16 +244,16 @@ void ms_filter_remove_notify_callback(MSFilter *f, MSFilterNotifyFunc fn, void *
}
if (found){
ms_notify_context_destroy((MSNotifyContext*)found->data);
f->notify_callbacks=ms_list_remove_link(f->notify_callbacks,found);
f->notify_callbacks=bctbx_list_remove_link(f->notify_callbacks,found);
}else ms_warning("ms_filter_remove_notify_callback(filter=%p): no registered callback with fn=%p and ud=%p",f,fn,ud);
}
void ms_filter_clear_notify_callback(MSFilter *f){
f->notify_callbacks=ms_list_free_with_data(f->notify_callbacks,(void (*)(void*))ms_notify_context_destroy);
f->notify_callbacks=bctbx_list_free_with_data(f->notify_callbacks,(void (*)(void*))ms_notify_context_destroy);
}
static void ms_filter_invoke_callbacks(MSFilter **f, unsigned int id, void *arg, InvocationMode synchronous_mode){
MSList *elem;
bctbx_list_t *elem;
for (elem=(*f)->notify_callbacks;elem!=NULL;elem=elem->next){
MSNotifyContext *ctx=(MSNotifyContext*)elem->data;
if (synchronous_mode==Both || (synchronous_mode==OnlyAsynchronous && !ctx->synchronous)
......
......@@ -58,103 +58,51 @@ void ms_set_cpu_count(unsigned int c) {
}
MSList *ms_list_new(void *data){
MSList *new_elem=(MSList *)ms_new0(MSList,1);
new_elem->data=data;
return new_elem;
return bctbx_list_new(data);
}
MSList *ms_list_append_link(MSList *elem, MSList *new_elem){
MSList *it=elem;
if (elem==NULL) return new_elem;
while (it->next!=NULL) it=ms_list_next(it);
it->next=new_elem;
new_elem->prev=it;
return elem;
return bctbx_list_append_link(elem, new_elem);
}
MSList * ms_list_append(MSList *elem, void * data){
MSList *new_elem=ms_list_new(data);
return ms_list_append_link(elem,new_elem);
return bctbx_list_append(elem, data);
}
MSList * ms_list_prepend(MSList *elem, void *data){
MSList *new_elem=ms_list_new(data);
if (elem!=NULL) {
new_elem->next=elem;
elem->prev=new_elem;
}
return new_elem;
return bctbx_list_prepend(elem, data);
}
MSList * ms_list_concat(MSList *first, MSList *second){
MSList *it=first;
if (it==NULL) return second;
while(it->next!=NULL) it=ms_list_next(it);
it->next=second;
second->prev=it;
return first;
return bctbx_list_concat(first, second);
}
MSList * ms_list_free_with_data(MSList *list, void (*freefunc)(void*)){
MSList *elem;
MSList *tmp;
for (elem=list;elem!=NULL;){
tmp=elem->next;
if (freefunc) freefunc(elem->data);
ms_free(elem);
elem=tmp;
}
return NULL;
return bctbx_list_free_with_data(list, freefunc);
}
MSList * ms_list_free(MSList *elem){
return ms_list_free_with_data(elem,NULL);
return bctbx_list_free(elem);
}
MSList * ms_list_remove(MSList *first, void *data){
MSList *it;
it=ms_list_find(first,data);
if (it) return ms_list_remove_link(first,it);
else {
ms_warning("ms_list_remove: no element with %p data was in the list", data);
return first;
}
return bctbx_list_remove(first, data);
}
MSList * ms_list_remove_custom(MSList *first, MSCompareFunc compare_func, const void *user_data) {
MSList *cur;
MSList *elem = first;
while (elem != NULL) {
cur = elem;
elem = elem->next;
if (compare_func(cur->data, user_data) == 0) {
first = ms_list_remove(first, cur->data);
}
}
return first;
return bctbx_list_remove_custom(first, compare_func, user_data);
}
size_t ms_list_size(const MSList *first){
size_t n=0;
while(first!=NULL){
++n;
first=first->next;
}
return n;
int ms_list_size(const MSList *first){
return (int)bctbx_list_size(first);
}
void ms_list_for_each(const MSList *list, void (*func)(void *)){
for(;list!=NULL;list=list->next){
func(list->data);
}
bctbx_list_for_each(list, func);
}
void ms_list_for_each2(const MSList *list, void (*func)(void *, void *y), void *user_data){
for(;list!=NULL;list=list->next){
func(list->data,user_data);
}
bctbx_list_for_each2(list, func, user_data);
}