From: Augustin Degomme Date: Fri, 22 Nov 2019 14:10:07 +0000 (+0100) Subject: don't forget that calloc assigns 0 to the buffer X-Git-Tag: v3.25~371 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/5a4a50803fa81e171c6c4b6962c597a3b33f55ca?ds=sidebyside don't forget that calloc assigns 0 to the buffer --- diff --git a/src/smpi/internals/smpi_shared.cpp b/src/smpi/internals/smpi_shared.cpp index 9f9d03b868..b549d72efa 100644 --- a/src/smpi/internals/smpi_shared.cpp +++ b/src/smpi/internals/smpi_shared.cpp @@ -351,10 +351,13 @@ void *smpi_shared_malloc_intercept(size_t size, const char *file, int line) { } void* smpi_shared_calloc_intercept(size_t num_elm, size_t elem_size, const char* file, int line){ - if( simgrid::config::get_value("smpi/auto-shared-malloc-thresh") == 0 || elem_size*num_elm < simgrid::config::get_value("smpi/auto-shared-malloc-thresh")) - return ::operator new(elem_size*num_elm); - else + if( simgrid::config::get_value("smpi/auto-shared-malloc-thresh") == 0 || elem_size*num_elm < simgrid::config::get_value("smpi/auto-shared-malloc-thresh")){ + void* ptr = ::operator new(elem_size*num_elm); + memset(ptr, 0, elem_size*num_elm); + return ptr; + } else return smpi_shared_malloc(elem_size*num_elm, file, line); + } void *smpi_shared_malloc(size_t size, const char *file, int line) {