X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/41f8a753a029e349539da446fc3e63fda2789f1d..ed9b07e5c0c7eb6d4d38b0fe5aaea80d6996a8a7:/examples/msg/cloud/master_worker_vm.c diff --git a/examples/msg/cloud/master_worker_vm.c b/examples/msg/cloud/master_worker_vm.c index 273af4c247..3d1fb4cbe6 100644 --- a/examples/msg/cloud/master_worker_vm.c +++ b/examples/msg/cloud/master_worker_vm.c @@ -5,7 +5,7 @@ * under the terms of the license (GNU LGPL) which comes with this package. */ #include -#include "msg/msg.h" +#include "simgrid/msg.h" #include "xbt/sysdep.h" /* calloc, printf */ /* Create a log channel to have nice outputs. */ @@ -14,6 +14,8 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example"); +#define MAXMBOXLEN 64 + /** @addtogroup MSG_examples * * - cloud/masterslave_virtual_machines.c: Master/workers @@ -139,8 +141,8 @@ int master_fun(int argc, char *argv[]) XBT_INFO("# Shutdown the half of worker processes gracefuly. The remaining half will be forcibly killed."); for (i = 0; i < nb_workers; i++) { - char mbox[64]; - sprintf(mbox, "MBOX:WRK%02d", i); + char mbox[MAXMBOXLEN]; + snprintf(mbox, MAXMBOXLEN, "MBOX:WRK%02d", i); msg_task_t finalize = MSG_task_create("finalize", 0, 0, 0); MSG_task_send(finalize, mbox); } @@ -167,7 +169,8 @@ int master_fun(int argc, char *argv[]) int worker_fun(int argc, char *argv[]) { const char *pr_name = MSG_process_get_name(MSG_process_self()); - char *mbox = bprintf("MBOX:%s", pr_name); + char mbox[MAXMBOXLEN]; + snprintf(mbox, MAXMBOXLEN, "MBOX:%s", pr_name); XBT_INFO("%s is listenning on mailbox(%s)", pr_name, mbox); @@ -193,8 +196,6 @@ int worker_fun(int argc, char *argv[]) MSG_task_destroy(task); } - free(mbox); - return 0; }