X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/9de2143df74699fb6e21a9eb8f37e38db0c00357..b1894c26788f6dbd49098eb00f86e79d6539ba60:/examples/s4u/actor-create/s4u-actor-create.cpp diff --git a/examples/s4u/actor-create/s4u-actor-create.cpp b/examples/s4u/actor-create/s4u-actor-create.cpp index 33ed245dac..d83d75ac11 100644 --- a/examples/s4u/actor-create/s4u-actor-create.cpp +++ b/examples/s4u/actor-create/s4u-actor-create.cpp @@ -18,6 +18,7 @@ */ #include +#include // This declares a logging channel so that XBT_INFO can be used later XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_actor_create, "The logging channel used in this example"); @@ -42,7 +43,7 @@ public: XBT_INFO("Hello s4u, I have something to send"); simgrid::s4u::MailboxPtr mailbox = simgrid::s4u::Mailbox::byName("mb42"); - mailbox->put(xbt_strdup(msg.c_str()), msg.size()); + mailbox->put(new std::string(msg), msg.size()); XBT_INFO("I'm done. See you."); } }; @@ -74,11 +75,11 @@ public: { XBT_INFO("Hello s4u, I'm ready to get any message you'd want on %s", mailbox->getName()); - char* msg1 = static_cast(mailbox->get()); - char* msg2 = static_cast(mailbox->get()); - XBT_INFO("I received '%s' and '%s'", msg1, msg2); - xbt_free(msg1); - xbt_free(msg2); + std::string* msg1 = static_cast(mailbox->get()); + std::string* msg2 = static_cast(mailbox->get()); + XBT_INFO("I received '%s' and '%s'", msg1->c_str(), msg2->c_str()); + delete msg1; + delete msg2; XBT_INFO("I'm done. See you."); } };