Ver código fonte

tests/loader.c: use calloc instead of malloc to make sure memory is set to 0

Nathalie Furmento 9 anos atrás
pai
commit
a1240cbe30
1 arquivos alterados com 4 adições e 4 exclusões
  1. 4 4
      tests/loader.c

+ 4 - 4
tests/loader.c

@@ -165,7 +165,7 @@ static int _decode(char **src, char *motif, const char *value)
 	found = strstr(*src, motif);
 	if (found == NULL) return 0;
 
-	char *new_src = malloc(strlen(*src)-strlen(motif)+strlen(value)+1);
+	char *new_src = calloc(1, strlen(*src)-strlen(motif)+strlen(value)+1);
 
 	strncpy(new_src, *src, found - *src);
 	strcat(new_src, value);
@@ -215,18 +215,18 @@ int main(int argc, char *argv[])
 
 	if (strstr(test_name, "spmv/dw_block_spmv"))
 	{
-		test_args = (char *) malloc(150*sizeof(char));
+		test_args = (char *) calloc(150, sizeof(char));
 		sprintf(test_args, "%s/examples/spmv/matrix_market/examples/fidapm05.mtx", STARPU_SRC_DIR);
 	}
 
 	if (strstr(test_name, "starpu_perfmodel_display"))
 	{
-		test_args = (char *) malloc(5*sizeof(char));
+		test_args = (char *) calloc(5, sizeof(char));
 		sprintf(test_args, "-l");
 	}
 	if (strstr(test_name, "starpu_perfmodel_plot"))
 	{
-		test_args = (char *) malloc(5*sizeof(char));
+		test_args = (char *) calloc(5, sizeof(char));
 		sprintf(test_args, "-l");
 	}