Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Global variables should be initialized to zero.
authorArnaud Giersch <arnaud.giersch@iut-bm.univ-fcomte.fr>
Tue, 21 Jan 2014 09:30:36 +0000 (10:30 +0100)
committerArnaud Giersch <arnaud.giersch@iut-bm.univ-fcomte.fr>
Tue, 21 Jan 2014 14:20:28 +0000 (15:20 +0100)
include/smpi/smpi_cocci.h

index 8243e7a..c4ea46f 100644 (file)
@@ -15,7 +15,7 @@
 type *name = NULL;                                              \
 static void __attribute__((constructor)) __preinit_##name(void) { \
    if(!name)                                                    \
-      name = (type*)malloc(smpi_global_size() * sizeof(type));  \
+      name = (type*)calloc(smpi_global_size(), sizeof(type));   \
 }                                                               \
 static void __attribute__((destructor)) __postfini_##name(void) { \
    free(name);                                                  \
@@ -55,7 +55,7 @@ XBT_PUBLIC(void) smpi_free_static(void);
 #define SMPI_VARINIT_STATIC(name,type)                      \
 static type *name = NULL;                                   \
 if(!name) {                                                 \
-   name = (type*)malloc(smpi_global_size() * sizeof(type)); \
+   name = (type*)calloc(smpi_global_size(), sizeof(type));  \
    smpi_register_static(name, xbt_free);                    \
 }