Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Remove unused parameter 'free_ctn' for xbt_dict_set() and xbt_dict_set_ext().
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Fri, 1 Nov 2019 15:14:50 +0000 (16:14 +0100)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Sat, 2 Nov 2019 20:20:25 +0000 (21:20 +0100)
ChangeLog
contrib/benchmarking_code_block/inject.h
include/xbt/dict.h
src/plugins/file_system/s4u_FileSystem.cpp
src/s4u/s4u_Actor.cpp
src/s4u/s4u_Host.cpp
src/s4u/s4u_Netzone.cpp
src/s4u/s4u_Storage.cpp
src/xbt/dict.cpp
src/xbt/dict_test.cpp
teshsuite/msg/app-bittorrent/bittorrent-peer.c

index 7aa9e10..2e47233 100644 (file)
--- 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
index f5a9261..50bab56 100644 (file)
@@ -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);
 }
index 89e18d7..e36d2b9 100644 (file)
@@ -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);
index 9585a66..d39845b 100644 (file)
@@ -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;
 }
index 8779aef..154d5fb 100644 (file)
@@ -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;
 }
index 305a573..881f967 100644 (file)
@@ -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;
 }
index dec17ec..f5ee74e 100644 (file)
@@ -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<void*>(elem), nullptr);
+    xbt_dict_set(whereto, elem->get_cname(), static_cast<void*>(elem));
   }
 }
 
index 08ad078..59667fd 100644 (file)
@@ -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;
 }
index 256c277..44361dc 100644 (file)
@@ -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);
 }
 
 /**
index dd47436..c7588cd 100644 (file)
@@ -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");
index c2474a7..7abd4e9 100644 (file)
@@ -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);