From: Arnaud Giersch Date: Fri, 1 Nov 2019 15:14:50 +0000 (+0100) Subject: Remove unused parameter 'free_ctn' for xbt_dict_set() and xbt_dict_set_ext(). X-Git-Tag: v3.25~465 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/5edbea104d3c5d61dc5a6dce20706a6fe5c89b2a Remove unused parameter 'free_ctn' for xbt_dict_set() and xbt_dict_set_ext(). --- diff --git a/ChangeLog b/ChangeLog index 7aa9e10373..2e47233f68 100644 --- a/ChangeLog +++ b/ChangeLog @@ -9,6 +9,9 @@ Kernel: forbidden to override these deprecated methods in a derived class. Please use the new names immediately if you need to override them. +XBT: +- Remove unused parameter 'free_ctn' for xbt_dict_set() and xbt_dict_set_ext(). + Fixed bugs (FG#.. -> framagit bugs; FG!.. -> framagit merge requests): - GH#31: [MC] please provide an option to make MPI_Send asynchronous - GH#305: Unscheduled tasks are still excuted diff --git a/contrib/benchmarking_code_block/inject.h b/contrib/benchmarking_code_block/inject.h index f5a9261ecd..50bab56c41 100644 --- a/contrib/benchmarking_code_block/inject.h +++ b/contrib/benchmarking_code_block/inject.h @@ -86,7 +86,7 @@ static inline void xbt_inject_init(char *inputfile) for (int i = 0; i < (data->n - 1); i++) data->percentage[i] = atof(strtok_r(NULL, "\t", &saveptr)); - xbt_dict_set(mydict, key, data, NULL); + xbt_dict_set(mydict, key, data); } fclose(fpInput); } @@ -139,7 +139,7 @@ static inline void inject_init_starpu(char *inputfile, xbt_dict_t *dict, RngStre data->percentage[i] = atof(strtok_r(NULL, "\t", &saveptr)); } - xbt_dict_set(mydict, key, data, NULL); + xbt_dict_set(mydict, key, data); } fclose(fpInput); } diff --git a/include/xbt/dict.h b/include/xbt/dict.h index 89e18d743f..e36d2b9558 100644 --- a/include/xbt/dict.h +++ b/include/xbt/dict.h @@ -30,10 +30,10 @@ SG_BEGIN_DECL char buff[512]; sprintf(buff,"some very precious data"); - xbt_dict_set(mydict,"my data", strdup(buff), NULL); + xbt_dict_set(mydict,"my data", strdup(buff)); sprintf(buff,"another good stuff"); - xbt_dict_set(mydict,"my data", strdup(buff), NULL); // previous data gets erased (and freed) by second add + xbt_dict_set(mydict,"my data", strdup(buff)); // previous data gets erased (and freed) by second add @endverbatim */ @@ -69,7 +69,7 @@ XBT_PUBLIC unsigned int xbt_dict_size(xbt_dict_t dict); * @{ */ -XBT_PUBLIC void xbt_dict_set(xbt_dict_t dict, const char* key, void* data, void_f_pvoid_t free_ctn); +XBT_PUBLIC void xbt_dict_set(xbt_dict_t dict, const char* key, void* data); XBT_PUBLIC void* xbt_dict_get(xbt_dict_t dict, const char* key); XBT_PUBLIC void* xbt_dict_get_or_null(xbt_dict_t dict, const char* key); XBT_PUBLIC char* xbt_dict_get_key(xbt_dict_t dict, const void* data); @@ -89,7 +89,7 @@ XBT_PUBLIC int xbt_dict_is_empty(xbt_dict_t dict); * * @{ */ -XBT_PUBLIC void xbt_dict_set_ext(xbt_dict_t dict, const char* key, int key_len, void* data, void_f_pvoid_t free_ctn); +XBT_PUBLIC void xbt_dict_set_ext(xbt_dict_t dict, const char* key, int key_len, void* data); XBT_PUBLIC void* xbt_dict_get_ext(xbt_dict_t dict, const char* key, int key_len); XBT_PUBLIC void* xbt_dict_get_or_null_ext(xbt_dict_t dict, const char* key, int key_len); XBT_PUBLIC void xbt_dict_remove_ext(xbt_dict_t dict, const char* key, int key_len); diff --git a/src/plugins/file_system/s4u_FileSystem.cpp b/src/plugins/file_system/s4u_FileSystem.cpp index 9585a66bce..d39845b386 100644 --- a/src/plugins/file_system/s4u_FileSystem.cpp +++ b/src/plugins/file_system/s4u_FileSystem.cpp @@ -747,7 +747,7 @@ xbt_dict_t sg_storage_get_content(sg_storage_t storage) for (auto const& entry : *content) { sg_size_t* psize = new sg_size_t; *psize = entry.second; - xbt_dict_set(content_as_dict, entry.first.c_str(), psize, nullptr); + xbt_dict_set(content_as_dict, entry.first.c_str(), psize); } return content_as_dict; } @@ -757,7 +757,7 @@ xbt_dict_t sg_host_get_storage_content(sg_host_t host) xbt_assert((host != nullptr), "Invalid parameters"); xbt_dict_t contents = xbt_dict_new_homogeneous(nullptr); for (auto const& elm : host->get_mounted_storages()) - xbt_dict_set(contents, elm.first.c_str(), sg_storage_get_content(elm.second), nullptr); + xbt_dict_set(contents, elm.first.c_str(), sg_storage_get_content(elm.second)); return contents; } diff --git a/src/s4u/s4u_Actor.cpp b/src/s4u/s4u_Actor.cpp index 8779aef391..154d5fbf78 100644 --- a/src/s4u/s4u_Actor.cpp +++ b/src/s4u/s4u_Actor.cpp @@ -530,7 +530,7 @@ xbt_dict_t sg_actor_get_properties(sg_actor_t actor) if (props == nullptr) return nullptr; for (auto const& kv : *props) { - xbt_dict_set(as_dict, kv.first.c_str(), xbt_strdup(kv.second.c_str()), nullptr); + xbt_dict_set(as_dict, kv.first.c_str(), xbt_strdup(kv.second.c_str())); } return as_dict; } diff --git a/src/s4u/s4u_Host.cpp b/src/s4u/s4u_Host.cpp index 305a57371a..881f96748a 100644 --- a/src/s4u/s4u_Host.cpp +++ b/src/s4u/s4u_Host.cpp @@ -429,7 +429,7 @@ xbt_dict_t sg_host_get_mounted_storage_list(sg_host_t host) for (auto const& elm : host->get_mounted_storages()) { const char* mount_name = elm.first.c_str(); sg_storage_t storage = elm.second; - xbt_dict_set(res, mount_name, (void*)storage->get_cname(), nullptr); + xbt_dict_set(res, mount_name, (void*)storage->get_cname()); } return res; @@ -551,7 +551,7 @@ xbt_dict_t sg_host_get_properties(sg_host_t host) if (props == nullptr) return nullptr; for (auto const& elm : *props) { - xbt_dict_set(as_dict, elm.first.c_str(), xbt_strdup(elm.second.c_str()), nullptr); + xbt_dict_set(as_dict, elm.first.c_str(), xbt_strdup(elm.second.c_str())); } return as_dict; } diff --git a/src/s4u/s4u_Netzone.cpp b/src/s4u/s4u_Netzone.cpp index dec17ec8aa..f5ee74e8bd 100644 --- a/src/s4u/s4u_Netzone.cpp +++ b/src/s4u/s4u_Netzone.cpp @@ -115,7 +115,7 @@ sg_netzone_t sg_zone_get_by_name(const char* name) void sg_zone_get_sons(sg_netzone_t netzone, xbt_dict_t whereto) { for (auto const& elem : netzone->get_children()) { - xbt_dict_set(whereto, elem->get_cname(), static_cast(elem), nullptr); + xbt_dict_set(whereto, elem->get_cname(), static_cast(elem)); } } diff --git a/src/s4u/s4u_Storage.cpp b/src/s4u/s4u_Storage.cpp index 08ad07863d..59667fdd4a 100644 --- a/src/s4u/s4u_Storage.cpp +++ b/src/s4u/s4u_Storage.cpp @@ -122,7 +122,7 @@ xbt_dict_t sg_storage_get_properties(sg_storage_t storage) if (props == nullptr) return nullptr; for (auto const& elm : *props) { - xbt_dict_set(as_dict, elm.first.c_str(), xbt_strdup(elm.second.c_str()), nullptr); + xbt_dict_set(as_dict, elm.first.c_str(), xbt_strdup(elm.second.c_str())); } return as_dict; } diff --git a/src/xbt/dict.cpp b/src/xbt/dict.cpp index 256c277615..44361dc7df 100644 --- a/src/xbt/dict.cpp +++ b/src/xbt/dict.cpp @@ -130,13 +130,11 @@ static void xbt_dict_rehash(xbt_dict_t dict) * @param key the key to set the new data * @param key_len the size of the @a key * @param data the data to add in the dict - * @param free_ctn unused parameter (kept for compatibility) * * Set the @a data in the structure under the @a key, which can be any kind of data, as long as its length is provided * in @a key_len. */ -void xbt_dict_set_ext(xbt_dict_t dict, const char* key, int key_len, void* data, - XBT_ATTRIB_UNUSED void_f_pvoid_t free_ctn) +void xbt_dict_set_ext(xbt_dict_t dict, const char* key, int key_len, void* data) { unsigned int hash_code = xbt_str_hash_ext(key, key_len); @@ -178,13 +176,12 @@ void xbt_dict_set_ext(xbt_dict_t dict, const char* key, int key_len, void* data, * @param dict the dict * @param key the key to set the new data * @param data the data to add in the dict - * @param free_ctn unused parameter (kept for compatibility) * * set the @a data in the structure under the @a key, which is a null terminated string. */ -void xbt_dict_set(xbt_dict_t dict, const char *key, void *data, void_f_pvoid_t free_ctn) +void xbt_dict_set(xbt_dict_t dict, const char* key, void* data) { - xbt_dict_set_ext(dict, key, strlen(key), data, free_ctn); + xbt_dict_set_ext(dict, key, strlen(key), data); } /** diff --git a/src/xbt/dict_test.cpp b/src/xbt/dict_test.cpp index dd47436d1b..c7588cd735 100644 --- a/src/xbt/dict_test.cpp +++ b/src/xbt/dict_test.cpp @@ -25,7 +25,7 @@ static void debugged_add_ext(xbt_dict_t head, const char* key, const char* data_ INFO("Add " << STR(data_to_fill) << " under " << STR(key)); - xbt_dict_set(head, key, data, nullptr); + xbt_dict_set(head, key, data); } static void debugged_add(xbt_dict_t head, const char* key) @@ -173,19 +173,19 @@ TEST_CASE("xbt::dict: dict data container", "dict") head = new_fixture(); count_check_get_key(head, 7); INFO("Change 123 to 'Changed 123'"); - xbt_dict_set(head, "123", xbt_strdup("Changed 123"), nullptr); + xbt_dict_set(head, "123", xbt_strdup("Changed 123")); count_check_get_key(head, 7); INFO("Change 123 back to '123'"); - xbt_dict_set(head, "123", xbt_strdup("123"), nullptr); + xbt_dict_set(head, "123", xbt_strdup("123")); count_check_get_key(head, 7); INFO("Change 12a to 'Dummy 12a'"); - xbt_dict_set(head, "12a", xbt_strdup("Dummy 12a"), nullptr); + xbt_dict_set(head, "12a", xbt_strdup("Dummy 12a")); count_check_get_key(head, 7); INFO("Change 12a to '12a'"); - xbt_dict_set(head, "12a", xbt_strdup("12a"), nullptr); + xbt_dict_set(head, "12a", xbt_strdup("12a")); count_check_get_key(head, 7); INFO("Traverse the resulting dictionary"); @@ -270,7 +270,7 @@ TEST_CASE("xbt::dict: dict data container", "dict") xbt_dict_t head = new_fixture(); INFO("Store nullptr under 'null'"); - xbt_dict_set(head, "null", nullptr, nullptr); + xbt_dict_set(head, "null", nullptr); search_ext(head, "null", nullptr); INFO("Check whether I see it while traversing..."); @@ -311,7 +311,7 @@ TEST_CASE("xbt::dict: dict data container", "dict") data = (char*)xbt_dict_get_or_null(head, key); } while (data != nullptr); - xbt_dict_set(head, key, key, nullptr); + xbt_dict_set(head, key, key); data = (char*)xbt_dict_get(head, key); REQUIRE(not strcmp(key, data)); // Retrieved value != Injected value @@ -328,7 +328,7 @@ TEST_CASE("xbt::dict: dict data container", "dict") char* key = (char*)xbt_malloc(10); snprintf(key, 10, "%d", j); - xbt_dict_set(head, key, key, nullptr); + xbt_dict_set(head, key, key); } INFO("Count the elements (retrieving the key and data for each)"); @@ -367,7 +367,7 @@ TEST_CASE("xbt::dict: dict data container", "dict") INFO("Insert elements"); for (int i = 0; i < count; ++i) - xbt_dict_set_ext(dict, (char*)&i, sizeof(i), (void*)(intptr_t)i, nullptr); + xbt_dict_set_ext(dict, (char*)&i, sizeof(i), (void*)(intptr_t)i); REQUIRE(xbt_dict_size(dict) == (unsigned)count); // Bad number of elements in the dictionary INFO("Check elements"); diff --git a/teshsuite/msg/app-bittorrent/bittorrent-peer.c b/teshsuite/msg/app-bittorrent/bittorrent-peer.c index c2474a7243..7abd4e9531 100644 --- a/teshsuite/msg/app-bittorrent/bittorrent-peer.c +++ b/teshsuite/msg/app-bittorrent/bittorrent-peer.c @@ -203,7 +203,7 @@ int get_peers_data(peer_t peer) // Add the peers the tracker gave us to our peer list. xbt_dynar_foreach (data->peers, i, peer_id) { if (peer_id != peer->id) - xbt_dict_set_ext(peer->peers, (char*)&peer_id, sizeof(int), connection_new(peer_id), NULL); + xbt_dict_set_ext(peer->peers, (char*)&peer_id, sizeof(int), connection_new(peer_id)); } success = 1; // free the communication and the task @@ -291,7 +291,7 @@ void update_active_peers_set(peer_t peer, connection_t remote_peer) { if ((remote_peer->interested != 0) && (remote_peer->choked_upload == 0)) { // add in the active peers set - xbt_dict_set_ext(peer->active_peers, (char*)&remote_peer->id, sizeof(int), remote_peer, NULL); + xbt_dict_set_ext(peer->active_peers, (char*)&remote_peer->id, sizeof(int), remote_peer); } else if (xbt_dict_get_or_null_ext(peer->active_peers, (char*)&remote_peer->id, sizeof(int))) { xbt_dict_remove_ext(peer->active_peers, (char*)&remote_peer->id, sizeof(int)); } @@ -316,7 +316,7 @@ void handle_message(peer_t peer, msg_task_t task) case MESSAGE_HANDSHAKE: // Check if the peer is in our connection list. if (remote_peer == 0) { - xbt_dict_set_ext(peer->peers, (char*)&message->peer_id, sizeof(int), connection_new(message->peer_id), NULL); + xbt_dict_set_ext(peer->peers, (char*)&message->peer_id, sizeof(int), connection_new(message->peer_id)); send_handshake(peer, message->mailbox); } // Send our bitfield to the peer @@ -658,7 +658,7 @@ void update_choked_peers(peer_t peer) if (chosen_peer != NULL) { xbt_assert((chosen_peer->choked_upload), "Tries to unchoked an unchoked peer"); chosen_peer->choked_upload = 0; - xbt_dict_set_ext(peer->active_peers, (char*)&chosen_peer->id, sizeof(int), chosen_peer, NULL); + xbt_dict_set_ext(peer->active_peers, (char*)&chosen_peer->id, sizeof(int), chosen_peer); chosen_peer->last_unchoke = MSG_get_clock(); XBT_DEBUG("(%d) Sending a UNCHOKE to %d", peer->id, chosen_peer->id); update_active_peers_set(peer, chosen_peer);