diff options
| author | 2020-12-21 23:24:11 +0100 | |
|---|---|---|
| committer | 2021-01-25 16:20:57 +0100 | |
| commit | af9b59e6a1a36997d7017f4841f4a934ca1ade98 (patch) | |
| tree | f5eb124cbbfbd49b0f6195257752b62176a520ed /libcnary/node.c | |
| parent | 7b1ccb403ad284b896a4e710fab578e397f101c0 (diff) | |
| download | libplist-af9b59e6a1a36997d7017f4841f4a934ca1ade98.tar.gz libplist-af9b59e6a1a36997d7017f4841f4a934ca1ade98.tar.bz2 | |
Replace malloc + memset with calloc where appropriate
calloc is faster for big allocations. It's also simpler.
Signed-off-by: Rosen Penev <rosenp@gmail.com>
Diffstat (limited to 'libcnary/node.c')
| -rw-r--r-- | libcnary/node.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/libcnary/node.c b/libcnary/node.c index c24ca7a..6d68f6e 100644 --- a/libcnary/node.c +++ b/libcnary/node.c | |||
| @@ -46,11 +46,10 @@ void node_destroy(node_t* node) { | |||
| 46 | node_t* node_create(node_t* parent, void* data) { | 46 | node_t* node_create(node_t* parent, void* data) { |
| 47 | int error = 0; | 47 | int error = 0; |
| 48 | 48 | ||
| 49 | node_t* node = (node_t*) malloc(sizeof(node_t)); | 49 | node_t* node = (node_t*)calloc(1, sizeof(node_t)); |
| 50 | if(node == NULL) { | 50 | if (node == NULL) { |
| 51 | return NULL; | 51 | return NULL; |
| 52 | } | 52 | } |
| 53 | memset(node, '\0', sizeof(node_t)); | ||
| 54 | 53 | ||
| 55 | node->data = data; | 54 | node->data = data; |
| 56 | node->next = NULL; | 55 | node->next = NULL; |
