switch to using calloc (initializes memory to zero)
This commit is contained in:
parent
b548d50deb
commit
f524777313
|
@ -225,7 +225,7 @@ void array_print_histogram(double* xs, int n_samples, int n_bins) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int *bins = (int*) malloc((size_t)n_bins * sizeof(int));
|
int *bins = (int*) calloc((size_t)n_bins, sizeof(int));
|
||||||
if (bins == NULL) {
|
if (bins == NULL) {
|
||||||
fprintf(stderr, "Memory allocation for bins failed.\n");
|
fprintf(stderr, "Memory allocation for bins failed.\n");
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user