From 54a654d4e11185267e94ee1cbe17c065a8453ccc Mon Sep 17 00:00:00 2001 From: Fred Suter Date: Mon, 19 Jun 2023 08:13:20 -0400 Subject: [PATCH] more use of get_unique_data --- examples/cpp/io-file-system/s4u-io-file-system.cpp | 3 +-- .../s4u/storage_client_server/storage_client_server.cpp | 5 ++--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/examples/cpp/io-file-system/s4u-io-file-system.cpp b/examples/cpp/io-file-system/s4u-io-file-system.cpp index ef57282804..40e0048e09 100644 --- a/examples/cpp/io-file-system/s4u-io-file-system.cpp +++ b/examples/cpp/io-file-system/s4u-io-file-system.cpp @@ -58,9 +58,8 @@ public: // Test attaching some user data to the file file->set_data(new std::string("777")); - const auto* file_data = file->get_data(); + auto file_data = file->get_unique_data(); XBT_INFO("User data attached to the file: %s", file_data->c_str()); - delete file_data; // Close the file file->close(); diff --git a/teshsuite/s4u/storage_client_server/storage_client_server.cpp b/teshsuite/s4u/storage_client_server/storage_client_server.cpp index 351c4e4b75..8170ff0f83 100644 --- a/teshsuite/s4u/storage_client_server/storage_client_server.cpp +++ b/teshsuite/s4u/storage_client_server/storage_client_server.cpp @@ -76,12 +76,11 @@ static void get_set_disk_data(simgrid::s4u::Disk* disk) { XBT_INFO("*** GET/SET DATA for disk: %s ***", disk->get_cname()); - const std::string* data = disk->get_data(); + auto data = disk->get_unique_data(); XBT_INFO("Get data: '%s'", data ? data->c_str() : "No User Data"); disk->set_data(new std::string("Some data")); - data = disk->get_data(); + data = disk->get_unique_data(); XBT_INFO(" Set and get data: '%s'", data->c_str()); - delete data; } static void dump_platform_disks() -- 2.20.1