diff --git a/coreapi/friend.c b/coreapi/friend.c index 82e28de704d0f8f6aeb7462d2a911b21349d2744..24960a7aaec782685d40b21a93f2aeaeb401f9f1 100644 --- a/coreapi/friend.c +++ b/coreapi/friend.c @@ -596,7 +596,7 @@ bool_t _linphone_friend_has_phone_number(const LinphoneFriend *lf, ms_free(normalized_value); } } - bctbx_list_free(numbers); + bctbx_list_free_with_data(numbers, bctbx_free); return found; } @@ -2305,4 +2305,4 @@ const char *linphone_friend_get_job_title(const LinphoneFriend *lf) { return linphone_vcard_get_job_title(lf->vcard); } return NULL; -} \ No newline at end of file +} diff --git a/tester/liblinphone_tester.h b/tester/liblinphone_tester.h index c508e8b8a0d9165d4afd4c4adb392b3f3c47f817..c5514f91c95af078e24d91aff20046621d2d4e29 100644 --- a/tester/liblinphone_tester.h +++ b/tester/liblinphone_tester.h @@ -1042,6 +1042,10 @@ void liblinphone_tester_add_grammar_loader_path(const char *path); void liblinphone_tester_add_soci_search_path(const char *path); #endif +/* Returns a unique path, useful for tests that need temporary files, so that they can have unique path + * to be robust to parallel execution*/ +char *liblinphone_tester_make_unique_file_path(const char *name, const char *extension); + #ifdef __cplusplus }; #endif diff --git a/tester/setup_tester.c b/tester/setup_tester.c index d08e364f36b628131bea757687f2499f896c5d03..d356900f908d48d31c0ddb9676b8e463b4dee74f 100644 --- a/tester/setup_tester.c +++ b/tester/setup_tester.c @@ -3305,8 +3305,8 @@ static void friend_list_db_storage_base(bool_t set_friends_db_path) { // Disable legacy friends storage linphone_config_set_int(config, "misc", "store_friends", 0); - char *friends_db = bc_tester_file("friends.db"); - unlink(friends_db); + char *friends_db = liblinphone_tester_make_unique_file_path("friends", "db"); + if (set_friends_db_path) { linphone_core_set_friends_database_path(core, friends_db); } @@ -3436,7 +3436,7 @@ static void friend_list_db_storage_base(bool_t set_friends_db_path) { BC_ASSERT_PTR_NULL(found_friend); unlink(friends_db); - bc_free(friends_db); + bctbx_free(friends_db); linphone_core_manager_destroy(manager); } diff --git a/tester/tester.c b/tester/tester.c index 17f11c20eb75c3ddd8766d782e26718935961f45..12cad48ffd9e136effc475bbaffec05c51089488 100644 --- a/tester/tester.c +++ b/tester/tester.c @@ -2930,6 +2930,22 @@ int liblinphone_tester_ipv4_available(void) { return FALSE; } +char *liblinphone_tester_make_unique_file_path(const char *name, const char *extension) { + char token[10] = {0}; + char *filename; + char *path; + char *ret; + + belle_sip_random_token(token, sizeof(token)); + + filename = bctbx_strdup_printf("%s-%s.%s", name, token, extension); + path = bc_tester_file(filename); + ret = bctbx_strdup(path); + bctbx_free(filename); + bc_free(path); + return ret; +} + void liblinphone_tester_keep_accounts(int keep) { liblinphone_tester_keep_accounts_flag = keep; }