Commit 78ef95a3 authored by Simon Morlat's avatar Simon Morlat

fix multiple compilation warnings and memory corruptions in recent commits.

parent 70552041
......@@ -289,7 +289,7 @@ const LinphoneAddress * linphone_friend_get_address(const LinphoneFriend *lf) {
int linphone_friend_set_address(LinphoneFriend *lf, const LinphoneAddress *addr) {
LinphoneAddress *fr = linphone_address_clone(addr);
char *address;
LinphoneAddress *mAddr = linphone_friend_get_address(lf);
const LinphoneAddress *mAddr = linphone_friend_get_address(lf);
if(mAddr && lf->friend_list) {
char *mainAddress = linphone_address_as_string_uri_only(mAddr);
bctbx_iterator_t *it = bctbx_map_cchar_find_key(lf->friend_list->friends_map_uri, mainAddress);
......@@ -324,7 +324,7 @@ int linphone_friend_set_address(LinphoneFriend *lf, const LinphoneAddress *addr)
void linphone_friend_add_address(LinphoneFriend *lf, const LinphoneAddress *addr) {
LinphoneAddress *fr;
const char *uri;
char *uri;
if (!lf || !addr) return;
fr = linphone_address_clone(addr);
......@@ -387,7 +387,6 @@ void linphone_friend_add_phone_number(LinphoneFriend *lf, const char *phone) {
if(uri) {
bctbx_pair_t *pair = (bctbx_pair_t*) bctbx_pair_cchar_new(uri, linphone_friend_ref(lf));
bctbx_map_cchar_insert_and_delete(lf->friend_list->friends_map_uri, pair);
ms_free(uri);
}
}
......@@ -420,7 +419,6 @@ void linphone_friend_remove_phone_number(LinphoneFriend *lf, const char *phone)
bctbx_map_cchar_erase(lf->friend_list->friends_map_uri, it);
}
bctbx_iterator_cchar_delete(it);
ms_free(uri);
}
}
......@@ -534,7 +532,7 @@ static void _linphone_friend_destroy(LinphoneFriend *lf){
if (lf->phone_number_sip_uri_map) bctbx_list_free_with_data(lf->phone_number_sip_uri_map, (bctbx_list_free_func)free_phone_number_sip_uri);
if (lf->uri!=NULL) linphone_address_unref(lf->uri);
if (lf->info!=NULL) buddy_info_free(lf->info);
if (lf->vcard != NULL) linphone_vcard_free(lf->vcard);
if (lf->vcard != NULL) linphone_vcard_unref(lf->vcard);
if (lf->refkey != NULL) ms_free(lf->refkey);
}
......@@ -1111,7 +1109,7 @@ LinphoneVcard* linphone_friend_get_vcard(LinphoneFriend *fr) {
void linphone_friend_set_vcard(LinphoneFriend *fr, LinphoneVcard *vcard) {
if (!fr || !linphone_core_vcard_supported()) return;
if (fr->vcard) linphone_vcard_free(fr->vcard);
if (fr->vcard) linphone_vcard_unref(fr->vcard);
fr->vcard = vcard;
linphone_friend_save(fr, fr->lc);
}
......@@ -1134,7 +1132,7 @@ bool_t linphone_friend_create_vcard(LinphoneFriend *fr, const char *name) {
return FALSE;
}
vcard = linphone_vcard_new();
vcard = linphone_factory_create_vcard(linphone_factory_get());
lc = fr->lc;
if (!lc && fr->friend_list) {
......@@ -1608,7 +1606,6 @@ bctbx_list_t* linphone_core_fetch_friends_from_db(LinphoneCore *lc, LinphoneFrie
if(uri) {
bctbx_pair_t *pair = (bctbx_pair_t*) bctbx_pair_cchar_new(uri, linphone_friend_ref(lf));
bctbx_map_cchar_insert_and_delete(list->friends_map_uri, pair);
ms_free(uri);
}
iterator = bctbx_list_next(iterator);
}
......
......@@ -548,7 +548,6 @@ LinphoneFriendListStatus linphone_friend_list_import_friend(LinphoneFriendList *
if(uri) {
bctbx_pair_t *pair = (bctbx_pair_t*) bctbx_pair_cchar_new(uri, linphone_friend_ref(lf));
bctbx_map_cchar_insert_and_delete(list->friends_map_uri, pair);
ms_free(uri);
}
iterator = bctbx_list_next(iterator);
}
......@@ -628,7 +627,6 @@ static LinphoneFriendListStatus _linphone_friend_list_remove_friend(LinphoneFrie
bctbx_map_cchar_erase(list->friends_map_uri, it);
}
bctbx_iterator_cchar_delete(it);
ms_free(uri);
}
iterator = bctbx_list_next(iterator);
}
......@@ -761,7 +759,7 @@ LinphoneFriend * linphone_friend_list_find_friend_by_address(const LinphoneFrien
LinphoneFriend * linphone_friend_list_find_friend_by_uri(const LinphoneFriendList *list, const char *uri) {
LinphoneAddress *address = linphone_address_new(uri);
LinphoneFriend *result = linphone_friend_list_find_friend_by_address(list, address);
linphone_address_destroy(address);
linphone_address_unref(address);
return result;
}
......
oRTP @ 60cf1e2a
Subproject commit 2335fdf54906cc4e71a22b573f99ff472979eeac
Subproject commit 60cf1e2ae376d22d6813d06fb09a9511abec7c89
......@@ -381,7 +381,6 @@ static void friends_sqlite_store_lot_of_friends(void) {
sqlite3 *db;
int i;
char* errmsg = NULL;
char *key;
int ret;
char *buf;
......@@ -450,7 +449,6 @@ static void friends_sqlite_find_friend_in_lot_of_friends(void) {
sqlite3 *db;
int i;
char* errmsg = NULL;
char *key;
int ret;
char *buf;
bctoolboxTimeSpec t1;
......@@ -969,17 +967,16 @@ end:
static void insert_lot_of_friends_map_test(void) {
int i;
bctbx_map_t *friends_map = bctbx_mmap_cchar_new();
bctbx_pair_t *pair;
bctbx_iterator_t *it;
char *key[64];
ms_message("Départ\n");
bctbx_pair_cchar_t *pair;
char key[64];
ms_message("Start\n");
for(i = 0; i < 20000; i++) {
snprintf(key, sizeof(key),"key_%i",i);
pair = bctbx_pair_cchar_new(key,i);
bctbx_map_cchar_insert_and_delete(friends_map, pair);
pair = bctbx_pair_cchar_new(key,(void*)(uintptr_t)i);
bctbx_map_cchar_insert_and_delete(friends_map, (bctbx_pair_t*)pair);
}
ms_message("Fin\n");
bctbx_iterator_cchar_delete(it);
ms_message("End\n");
bctbx_mmap_cchar_delete(friends_map);
}
......@@ -987,27 +984,27 @@ static void find_friend_by_ref_key_in_lot_of_friends_test(void) {
int i;
int j;
bctbx_map_t *friends_map = bctbx_mmap_cchar_new();
bctbx_pair_t *pair;
bctbx_pair_cchar_t *pair;
bctbx_iterator_t *it;
bctoolboxTimeSpec t1;
bctoolboxTimeSpec t2;
char *key[64];
char key[64];
for(i = 0; i < 20000; i++) {
snprintf(key, sizeof(key),"key_%i",i);
pair = bctbx_pair_cchar_new(key,i);
bctbx_map_cchar_insert_and_delete(friends_map, pair);
pair = bctbx_pair_cchar_new(key,(void*)(uintptr_t)i);
bctbx_map_cchar_insert_and_delete(friends_map, (bctbx_pair_t*)pair);
}
bctbx_get_cur_time(&t1);
ms_message("Départ : %li : %li\n",t1.tv_sec, t1.tv_nsec);
ms_message("Start : %li : %li\n",t1.tv_sec, t1.tv_nsec);
for(i = 0; i < 20000; i++) {
snprintf(key, sizeof(key),"key_%i",i);
it = bctbx_map_cchar_find_key(friends_map, key);
j = (int)bctbx_pair_cchar_get_second(bctbx_iterator_cchar_get_pair(it));
j = (int)(uintptr_t)bctbx_pair_cchar_get_second(bctbx_iterator_cchar_get_pair(it));
BC_ASSERT_TRUE(i == j);
bctbx_iterator_cchar_delete(it);
}
bctbx_get_cur_time(&t2);
ms_message("Fin : %li : %li\n", t2.tv_sec, t2.tv_nsec);
ms_message("End : %li : %li\n", t2.tv_sec, t2.tv_nsec);
bctbx_mmap_cchar_delete(friends_map);
}
......
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