From 6dcc7d5441f845ea12ca05e9ea21862d2add43e8 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 28 Jun 2020 16:11:17 +0200 Subject: [PATCH] Use malloc where possible --- core_updater_list.c | 2 +- database_info.c | 40 ++++++++++++++++++++++++++++++---------- 2 files changed, 31 insertions(+), 11 deletions(-) diff --git a/core_updater_list.c b/core_updater_list.c index 3bd973cbb0..60f7457b02 100644 --- a/core_updater_list.c +++ b/core_updater_list.c @@ -109,7 +109,7 @@ core_updater_list_t *core_updater_list_init(size_t max_size) return NULL; /* Create core updater list */ - core_list = (core_updater_list_t*)calloc(1, sizeof(*core_list)); + core_list = (core_updater_list_t*)malloc(sizeof(*core_list)); if (!core_list) return NULL; diff --git a/database_info.c b/database_info.c index 45a874a52d..ff2a2385a4 100644 --- a/database_info.c +++ b/database_info.c @@ -365,7 +365,7 @@ database_info_handle_t *database_info_dir_init(const char *dir, core_info_list_t *core_info_list = NULL; struct string_list *list = NULL; database_info_handle_t *db = (database_info_handle_t*) - calloc(1, sizeof(*db)); + malloc(sizeof(*db)); if (!db) return NULL; @@ -384,10 +384,20 @@ database_info_handle_t *database_info_dir_init(const char *dir, dir_list_prioritize(list); - db->list = list; - db->list_ptr = 0; - db->status = DATABASE_STATUS_ITERATE; - db->type = type; + db->status = DATABASE_STATUS_ITERATE; + db->type = type; + db->list_ptr = 0; + db->list = list; + + db->state.type = ARCHIVE_TRANSFER_NONE; + db->state.archive_size = 0; + db->state.start_delta = 0; + db->state.handle = NULL; + db->state.stream = NULL; + db->state.footer = NULL; + db->state.directory = NULL; + db->state.data = NULL; + db->state.backend = NULL; return db; } @@ -398,7 +408,7 @@ database_info_handle_t *database_info_file_init(const char *path, union string_list_elem_attr attr; struct string_list *list = NULL; database_info_handle_t *db = (database_info_handle_t*) - calloc(1, sizeof(*db)); + malloc(sizeof(*db)); if (!db) return NULL; @@ -415,10 +425,20 @@ database_info_handle_t *database_info_file_init(const char *path, string_list_append(list, path, attr); - db->list_ptr = 0; - db->list = list; - db->status = DATABASE_STATUS_ITERATE; - db->type = type; + db->status = DATABASE_STATUS_ITERATE; + db->type = type; + db->list_ptr = 0; + db->list = list; + + db->state.type = ARCHIVE_TRANSFER_NONE; + db->state.archive_size = 0; + db->state.start_delta = 0; + db->state.handle = NULL; + db->state.stream = NULL; + db->state.footer = NULL; + db->state.directory = NULL; + db->state.data = NULL; + db->state.backend = NULL; return db; }