<2> rbuf: (#9): [3][4][103][104][203][204][-1][-1][-1]
*/
-static void print_buffer_int(void *buf, int len, char *msg, int rank)
+static void print_buffer_int(void *buf, int len, const char *msg, int rank)
{
printf("[%d] %s (#%d): ", rank, msg, len);
for (int tmp = 0; tmp < len; tmp++) {
printf("[%d]", v[tmp]);
}
printf("\n");
- free(msg);
}
int main(int argc, char **argv)
sdispls[i] = (i * (i + 1)) / 2;
}
- print_buffer_int( sbuf, size*size, strdup("sbuf:"),rank);
- print_buffer_int( sendcounts, size, strdup("scount:"),rank);
- print_buffer_int( recvcounts, size, strdup("rcount:"),rank);
- print_buffer_int( sdispls, size, strdup("sdisp:"),rank);
- print_buffer_int( rdispls, size, strdup("rdisp:"),rank);
+ print_buffer_int(sbuf, size * size, "sbuf:", rank);
+ print_buffer_int(sendcounts, size, "scount:", rank);
+ print_buffer_int(recvcounts, size, "rcount:", rank);
+ print_buffer_int(sdispls, size, "sdisp:", rank);
+ print_buffer_int(rdispls, size, "rdisp:", rank);
MPI_Alltoallv(sbuf, sendcounts, sdispls, MPI_INT, rbuf, recvcounts, rdispls, MPI_INT, comm);
- print_buffer_int( rbuf, size*size, strdup("rbuf:"),rank);
+ print_buffer_int(rbuf, size * size, "rbuf:", rank);
MPI_Barrier(MPI_COMM_WORLD);
if (0 == rank) {
-/* Copyright (c) 2009-2015. The SimGrid Team.
+/* Copyright (c) 2009-2017. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
#include <stdint.h>
#include <inttypes.h>
-static void* hash(char *str, uint64_t* ans)
+static void* hash(const char *str, uint64_t* ans)
{
- char *tohash = str;
+ const char *tohash = str;
*ans=5381;
printf("hashing !\n");
int c = *tohash;
MPI_Barrier(MPI_COMM_WORLD);
//Try SMPI_SHARED_CALL function, which should call hash only once and for all.
- char *str = strdup("onceandforall");
+ static const char str[] = "onceandforall";
if(rank==size-1){
SMPI_SHARED_CALL(hash,str,str,buf);
}
printf("[%d] After change, the value in the shared buffer is: %" PRIu64"\n", rank, *buf);
SMPI_SHARED_FREE(buf);
- free(str);
MPI_Finalize();
return 0;
/* synchro_crashtest -- tries to crash the logging mechanism by doing parallel logs*/
-/* Copyright (c) 2007-2014. The SimGrid Team.
+/* Copyright (c) 2007-2017. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
/* spawn threads */
for (int i = 0; i < crasher_amount; i++) {
- char *name = bprintf("thread %d", i);
+ char name[16];
+ snprintf(name, sizeof name, "thread %d", i);
crashers[i] = xbt_os_thread_create(name, &crasher_thread, &id[i], NULL );
- free(name);
}
/* wait for them */