Skip to content

Commit a3f5add

Browse files
Replace ns_alloc with calloc (closes #218)
calloc(1,size) replaces malloc+memset in one stdlib call. closes #218
1 parent a240222 commit a3f5add

1 file changed

Lines changed: 1 addition & 2 deletions

File tree

src/ns_buffer.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,11 @@ static _Thread_local int g_ns_prepare_thread = 0;
4444
/* ------------------------------------------------------------------ */
4545

4646
static void *ns_alloc(size_t size) {
47-
void *p = malloc(size);
47+
void *p = calloc(1, size);
4848
if (!p) {
4949
fprintf(stderr, "ns_buffer: out of memory\n");
5050
exit(1);
5151
}
52-
memset(p, 0, size);
5352
return p;
5453
}
5554

0 commit comments

Comments
 (0)