Skip to content

Commit f680e77

Browse files
committed
STY: use calloc instead of malloc
1 parent 7158c52 commit f680e77

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

bottleneck/src/move_template.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ MOVE(NAME, DTYPE0) {
444444
pairs * extreme_pair;
445445
pairs * end;
446446
pairs * last;
447-
pairs * ring = (pairs *)malloc(window * sizeof(pairs));
447+
pairs * ring = (pairs *)calloc(sizeof(pairs), window);
448448
INIT(NPY_DTYPE0)
449449
BN_BEGIN_ALLOW_THREADS
450450
WHILE {
@@ -488,7 +488,7 @@ MOVE(NAME, DTYPE0) {
488488
pairs * extreme_pair;
489489
pairs * end;
490490
pairs * last;
491-
pairs * ring = (pairs *)malloc(window * sizeof(pairs));
491+
pairs * ring = (pairs *)calloc(sizeof(pairs), window);
492492
INIT(NPY_DTYPE1)
493493
BN_BEGIN_ALLOW_THREADS
494494
WHILE {

bottleneck/src/nonreduce_axis_template.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ NRA_MAIN(partition, PARSE_PARTITION)
8383

8484
/* argpartition ----------------------------------------------------------- */
8585

86-
#define BUFFER_NEW(dtype) dtype *B = malloc(LENGTH * sizeof(dtype));
86+
#define BUFFER_NEW(dtype) dtype *B = calloc(LENGTH, sizeof(dtype));
8787
#define BUFFER_DELETE free(B);
8888

8989
#define ARGWIRTH(dtype0, dtype1) \

bottleneck/src/reduce_template.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1062,7 +1062,7 @@ REDUCE_MAIN(ss, 0)
10621062
EVEN_ODD(dtype, n)
10631063

10641064
#define BUFFER_NEW(dtype, length) \
1065-
npy_##dtype *buffer = malloc(length * sizeof(npy_##dtype));
1065+
npy_##dtype *buffer = calloc(length, sizeof(npy_##dtype));
10661066

10671067
#define BUFFER_DELETE free(buffer);
10681068

0 commit comments

Comments
 (0)