switch to using calloc (initializes memory to zero)

This commit is contained in:
NunoSempere 2024-01-30 16:27:17 +01:00
parent b548d50deb
commit f524777313

View File

@ -225,7 +225,7 @@ void array_print_histogram(double* xs, int n_samples, int n_bins) {
return;
}
int *bins = (int*) malloc((size_t)n_bins * sizeof(int));
int *bins = (int*) calloc((size_t)n_bins, sizeof(int));
if (bins == NULL) {
fprintf(stderr, "Memory allocation for bins failed.\n");
return;