From af9b59e6a1a36997d7017f4841f4a934ca1ade98 Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Mon, 21 Dec 2020 23:24:11 +0100 Subject: Replace malloc + memset with calloc where appropriate calloc is faster for big allocations. It's also simpler. Signed-off-by: Rosen Penev --- libcnary/node_list.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'libcnary/node_list.c') diff --git a/libcnary/node_list.c b/libcnary/node_list.c index d071881..aee3bd6 100644 --- a/libcnary/node_list.c +++ b/libcnary/node_list.c @@ -33,11 +33,10 @@ void node_list_destroy(node_list_t* list) { } node_list_t* node_list_create() { - node_list_t* list = (node_list_t*) malloc(sizeof(node_list_t)); - if(list == NULL) { + node_list_t* list = (node_list_t*)calloc(1, sizeof(node_list_t)); + if (list == NULL) { return NULL; } - memset(list, '\0', sizeof(node_list_t)); // Initialize structure list->begin = NULL; -- cgit v1.1-32-gdbae