From: Michael Tremer Date: Mon, 8 Feb 2021 19:32:16 +0000 (+0000) Subject: libpakfire: Drop pakfire_calloc X-Git-Tag: 0.9.28~1285^2~781 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=90312f5cc7cf5025676a3bb3b82a2047f944696d;p=pakfire.git libpakfire: Drop pakfire_calloc Signed-off-by: Michael Tremer --- diff --git a/src/libpakfire/archive.c b/src/libpakfire/archive.c index 2ca54d01a..4edacec58 100644 --- a/src/libpakfire/archive.c +++ b/src/libpakfire/archive.c @@ -186,7 +186,7 @@ static int payload_archive_open(struct archive** a, struct archive* source_archi *a = archive_read_new(); configure_archive(*a); - struct payload_archive_data* data = pakfire_calloc(1, sizeof(*data)); + struct payload_archive_data* data = calloc(1, sizeof(*data)); data->archive = source_archive; archive_read_set_callback_data(*a, data); @@ -231,7 +231,7 @@ static void pakfire_archive_checksum_free(archive_checksum_t* c) { } static archive_checksum_t* pakfire_archive_checksum_create(Pakfire pakfire, const char* filename, archive_checksum_algo_t algo, const char* s) { - archive_checksum_t* c = pakfire_calloc(1, sizeof(*c)); + archive_checksum_t* c = calloc(1, sizeof(*c)); if (c) { c->pakfire = pakfire_ref(pakfire); c->filename = pakfire_strdup(filename); @@ -265,7 +265,7 @@ static archive_checksum_t* pakfire_archive_checksum_find(PakfireArchive archive, } static PakfireArchiveSignature pakfire_archive_signature_create(PakfireArchive archive, const char* sigdata) { - PakfireArchiveSignature signature = pakfire_calloc(1, sizeof(*signature)); + PakfireArchiveSignature signature = calloc(1, sizeof(*signature)); if (signature) { signature->pakfire = pakfire_ref(archive->pakfire); signature->nrefs = 1; @@ -319,7 +319,7 @@ PAKFIRE_EXPORT size_t pakfire_archive_count_signatures(PakfireArchive archive) { } PAKFIRE_EXPORT PakfireArchive pakfire_archive_create(Pakfire pakfire) { - PakfireArchive archive = pakfire_calloc(1, sizeof(*archive)); + PakfireArchive archive = calloc(1, sizeof(*archive)); if (archive) { DEBUG(pakfire, "Allocated new archive at %p\n", archive); archive->pakfire = pakfire_ref(pakfire); @@ -455,7 +455,7 @@ static int pakfire_archive_parse_entry_checksums(PakfireArchive archive, data[data_size] = '\0'; // Allocate some space to save the checksums - archive_checksum_t** checksums = archive->checksums = pakfire_calloc(10, sizeof(*archive->checksums)); + archive_checksum_t** checksums = archive->checksums = calloc(10, sizeof(*archive->checksums)); const char* filename = NULL; const char* checksum = NULL; @@ -947,7 +947,7 @@ static int pakfire_archive_parse_entry_signature(PakfireArchive archive, // Resize the array archive->signatures = pakfire_realloc(archive->signatures, sizeof(*archive->signatures) * num_signatures); } else { - archive->signatures = pakfire_calloc(2, sizeof(*archive->signatures)); + archive->signatures = calloc(2, sizeof(*archive->signatures)); } // Look for last element diff --git a/src/libpakfire/db.c b/src/libpakfire/db.c index 461404898..1d78a6b2d 100644 --- a/src/libpakfire/db.c +++ b/src/libpakfire/db.c @@ -450,7 +450,7 @@ static int pakfire_db_setup(struct pakfire_db* db) { PAKFIRE_EXPORT int pakfire_db_open(struct pakfire_db** db, Pakfire pakfire, int flags) { int r = 1; - struct pakfire_db* o = pakfire_calloc(1, sizeof(*o)); + struct pakfire_db* o = calloc(1, sizeof(*o)); if (!o) return -ENOMEM; diff --git a/src/libpakfire/file.c b/src/libpakfire/file.c index 5bf716d79..3207fe93e 100644 --- a/src/libpakfire/file.c +++ b/src/libpakfire/file.c @@ -55,7 +55,7 @@ struct _PakfireFile { }; PAKFIRE_EXPORT int pakfire_file_create(PakfireFile* file) { - PakfireFile f = pakfire_calloc(1, sizeof(*f)); + PakfireFile f = calloc(1, sizeof(*f)); if (!f) return -ENOMEM; diff --git a/src/libpakfire/filelist.c b/src/libpakfire/filelist.c index 21bb4bbb3..644022b8c 100644 --- a/src/libpakfire/filelist.c +++ b/src/libpakfire/filelist.c @@ -49,7 +49,7 @@ static int pakfire_filelist_grow(PakfireFilelist list, size_t size) { } PAKFIRE_EXPORT int pakfire_filelist_create(PakfireFilelist* list) { - PakfireFilelist l = pakfire_calloc(1, sizeof(*l)); + PakfireFilelist l = calloc(1, sizeof(*l)); if (!l) return -ENOMEM; diff --git a/src/libpakfire/filter.c b/src/libpakfire/filter.c index 386612785..e09400404 100644 --- a/src/libpakfire/filter.c +++ b/src/libpakfire/filter.c @@ -26,7 +26,7 @@ #include PAKFIRE_EXPORT PakfireFilter pakfire_filter_create(void) { - PakfireFilter filter = pakfire_calloc(1, sizeof(*filter)); + PakfireFilter filter = calloc(1, sizeof(*filter)); return filter; } diff --git a/src/libpakfire/include/pakfire/util.h b/src/libpakfire/include/pakfire/util.h index e3a4b8bfd..2ebf1add2 100644 --- a/src/libpakfire/include/pakfire/util.h +++ b/src/libpakfire/include/pakfire/util.h @@ -31,7 +31,6 @@ void pakfire_oom(size_t num, size_t len); void* pakfire_malloc(size_t len); -void* pakfire_calloc(size_t num, size_t len); void* pakfire_realloc(void* ptr, size_t size); char* pakfire_strdup(const char* s); diff --git a/src/libpakfire/key.c b/src/libpakfire/key.c index 30be26499..ba9346b6e 100644 --- a/src/libpakfire/key.c +++ b/src/libpakfire/key.c @@ -130,7 +130,7 @@ PAKFIRE_EXPORT PakfireKey* pakfire_key_list(Pakfire pakfire) { gpgme_ctx_t gpgctx = pakfire_get_gpgctx(pakfire); - PakfireKey* first = pakfire_calloc(count + 1, sizeof(PakfireKey)); + PakfireKey* first = calloc(count + 1, sizeof(PakfireKey)); PakfireKey* list = first; gpgme_key_t gpgkey = NULL; @@ -155,7 +155,7 @@ PAKFIRE_EXPORT PakfireKey* pakfire_key_list(Pakfire pakfire) { } PAKFIRE_EXPORT PakfireKey pakfire_key_create(Pakfire pakfire, gpgme_key_t gpgkey) { - PakfireKey key = pakfire_calloc(1, sizeof(*key)); + PakfireKey key = calloc(1, sizeof(*key)); if (key) { key->nrefs = 1; @@ -411,7 +411,7 @@ PAKFIRE_EXPORT PakfireKey* pakfire_key_import(Pakfire pakfire, const char* data) if (!status) return NULL; - PakfireKey* head = pakfire_calloc(result->imported + 1, sizeof(*head)); + PakfireKey* head = calloc(result->imported + 1, sizeof(*head)); PakfireKey* list = head; // Retrieve all imported keys diff --git a/src/libpakfire/package.c b/src/libpakfire/package.c index e278bc22a..ae429da92 100644 --- a/src/libpakfire/package.c +++ b/src/libpakfire/package.c @@ -60,7 +60,7 @@ static void pakfire_package_add_self_provides(Pakfire pakfire, PakfirePackage pk } PAKFIRE_EXPORT PakfirePackage pakfire_package_create(Pakfire pakfire, Id id) { - PakfirePackage pkg = pakfire_calloc(1, sizeof(*pkg)); + PakfirePackage pkg = calloc(1, sizeof(*pkg)); if (pkg) { DEBUG(pakfire, "Allocated Package at %p\n", pkg); diff --git a/src/libpakfire/packagelist.c b/src/libpakfire/packagelist.c index c11eebeec..a0416d33a 100644 --- a/src/libpakfire/packagelist.c +++ b/src/libpakfire/packagelist.c @@ -43,7 +43,7 @@ struct _PakfirePackageList { }; PAKFIRE_EXPORT PakfirePackageList pakfire_packagelist_create(Pakfire pakfire) { - PakfirePackageList list = pakfire_calloc(1, sizeof(*list)); + PakfirePackageList list = calloc(1, sizeof(*list)); if (list) { DEBUG(pakfire, "Allocated PackageList at %p\n", list); list->pakfire = pakfire_ref(pakfire); diff --git a/src/libpakfire/pakfire.c b/src/libpakfire/pakfire.c index e352497dd..645079f93 100644 --- a/src/libpakfire/pakfire.c +++ b/src/libpakfire/pakfire.c @@ -143,7 +143,7 @@ PAKFIRE_EXPORT int pakfire_create(Pakfire* pakfire, const char* path, const char return -ENOENT; } - Pakfire p = pakfire_calloc(1, sizeof(*p)); + Pakfire p = calloc(1, sizeof(*p)); if (!p) return -ENOMEM; diff --git a/src/libpakfire/parser.c b/src/libpakfire/parser.c index 0a6350615..d7288c22e 100644 --- a/src/libpakfire/parser.c +++ b/src/libpakfire/parser.c @@ -75,7 +75,7 @@ static char* pakfire_parser_make_canonical_name(PakfireParser parser, const char } PAKFIRE_EXPORT PakfireParser pakfire_parser_create(Pakfire pakfire, PakfireParser parent, const char* namespace) { - PakfireParser parser = pakfire_calloc(1, sizeof(*parser)); + PakfireParser parser = calloc(1, sizeof(*parser)); if (parser) { parser->pakfire = pakfire_ref(pakfire); parser->nrefs = 1; @@ -200,7 +200,7 @@ static int pakfire_parser_set_declaration(PakfireParser parser, } // Allocate a new declaration - d = pakfire_calloc(1, sizeof(*d)); + d = calloc(1, sizeof(*d)); if (!d) return -1; diff --git a/src/libpakfire/problem.c b/src/libpakfire/problem.c index e5234cae2..627b4b61d 100644 --- a/src/libpakfire/problem.c +++ b/src/libpakfire/problem.c @@ -207,7 +207,7 @@ static char* to_string(PakfireProblem problem) { PAKFIRE_EXPORT PakfireProblem pakfire_problem_create(PakfireRequest request, Id id) { Pakfire pakfire = pakfire_request_get_pakfire(request); - PakfireProblem problem = pakfire_calloc(1, sizeof(*problem)); + PakfireProblem problem = calloc(1, sizeof(*problem)); if (problem) { DEBUG(pakfire, "Allocated Problem at %p\n", problem); problem->pakfire = pakfire_ref(pakfire); diff --git a/src/libpakfire/relation.c b/src/libpakfire/relation.c index 8b649bf2b..5b84fd17f 100644 --- a/src/libpakfire/relation.c +++ b/src/libpakfire/relation.c @@ -95,7 +95,7 @@ PAKFIRE_EXPORT PakfireRelation pakfire_relation_create(Pakfire pakfire, const ch } PAKFIRE_EXPORT PakfireRelation pakfire_relation_create_from_id(Pakfire pakfire, Id id) { - PakfireRelation relation = pakfire_calloc(1, sizeof(*relation)); + PakfireRelation relation = calloc(1, sizeof(*relation)); if (relation) { DEBUG(pakfire, "Allocated Relation at %p\n", relation); relation->nrefs = 1; diff --git a/src/libpakfire/relationlist.c b/src/libpakfire/relationlist.c index 0c7bf61ad..52c4b7146 100644 --- a/src/libpakfire/relationlist.c +++ b/src/libpakfire/relationlist.c @@ -39,7 +39,7 @@ struct _PakfireRelationList { }; PAKFIRE_EXPORT int pakfire_relationlist_create(PakfireRelationList* list, Pakfire pakfire) { - PakfireRelationList l = pakfire_calloc(1, sizeof(*l)); + PakfireRelationList l = calloc(1, sizeof(*l)); if (!l) return ENOMEM; diff --git a/src/libpakfire/repo.c b/src/libpakfire/repo.c index 22ccb9d6e..f15ef7497 100644 --- a/src/libpakfire/repo.c +++ b/src/libpakfire/repo.c @@ -93,7 +93,7 @@ void pakfire_repo_free_all(Pakfire pakfire) { } PAKFIRE_EXPORT PakfireRepo pakfire_repo_create(Pakfire pakfire, const char* name) { - PakfireRepo repo = pakfire_calloc(1, sizeof(*repo)); + PakfireRepo repo = calloc(1, sizeof(*repo)); if (repo) { DEBUG(pakfire, "Allocated Repo at %p\n", repo); repo->nrefs = 1; @@ -106,7 +106,7 @@ PAKFIRE_EXPORT PakfireRepo pakfire_repo_create(Pakfire pakfire, const char* name // Allocate repository appdata repo->appdata = repo->repo->appdata = \ - pakfire_calloc(1, sizeof(*repo->appdata)); + calloc(1, sizeof(*repo->appdata)); repo->appdata->repodata = repo_add_repodata(repo->repo, REPO_EXTEND_SOLVABLES|REPO_LOCALPOOL|REPO_NO_INTERNALIZE|REPO_NO_LOCATION); @@ -116,7 +116,7 @@ PAKFIRE_EXPORT PakfireRepo pakfire_repo_create(Pakfire pakfire, const char* name } PakfireRepo pakfire_repo_create_from_repo(Pakfire pakfire, Repo* r) { - PakfireRepo repo = pakfire_calloc(1, sizeof(*repo)); + PakfireRepo repo = calloc(1, sizeof(*repo)); if (repo) { DEBUG(pakfire, "Allocated Repo at %p\n", repo); repo->nrefs = 1; @@ -570,7 +570,7 @@ PAKFIRE_EXPORT PakfirePackage pakfire_repo_add_archive(PakfireRepo repo, Pakfire // Cache static char* pakfire_repo_get_cache_prefix(PakfireRepo repo) { - char* prefix = pakfire_calloc(1, STRING_SIZE + 1); + char* prefix = calloc(1, STRING_SIZE + 1); snprintf(prefix, STRING_SIZE, "repodata/%s", pakfire_repo_get_name(repo)); diff --git a/src/libpakfire/request.c b/src/libpakfire/request.c index bccc8d2e2..4ec816ed8 100644 --- a/src/libpakfire/request.c +++ b/src/libpakfire/request.c @@ -48,7 +48,7 @@ struct _PakfireRequest { }; PAKFIRE_EXPORT PakfireRequest pakfire_request_create(Pakfire pakfire) { - PakfireRequest request = pakfire_calloc(1, sizeof(*request)); + PakfireRequest request = calloc(1, sizeof(*request)); if (request) { DEBUG(pakfire, "Allocated Request at %p\n", request); request->nrefs = 1; diff --git a/src/libpakfire/selector.c b/src/libpakfire/selector.c index 0659b2ffe..2dc50547b 100644 --- a/src/libpakfire/selector.c +++ b/src/libpakfire/selector.c @@ -47,7 +47,7 @@ struct _PakfireSelector { }; PAKFIRE_EXPORT PakfireSelector pakfire_selector_create(Pakfire pakfire) { - PakfireSelector selector = pakfire_calloc(1, sizeof(*selector)); + PakfireSelector selector = calloc(1, sizeof(*selector)); if (selector) { DEBUG(pakfire, "Allocated Selector at %p\n", selector); selector->nrefs = 1; diff --git a/src/libpakfire/solution.c b/src/libpakfire/solution.c index 0dc74e2bd..9465bd79b 100644 --- a/src/libpakfire/solution.c +++ b/src/libpakfire/solution.c @@ -50,7 +50,7 @@ static void import_elements(PakfireSolution solution) { // Reserve memory unsigned int num = solver_solutionelement_count(solver, pakfire_problem_get_id(solution->problem), solution->id); - char** elements = solution->elements = pakfire_calloc(num + 1, sizeof(*elements)); + char** elements = solution->elements = calloc(num + 1, sizeof(*elements)); Id p; Id rp; @@ -123,7 +123,7 @@ static void import_elements(PakfireSolution solution) { PAKFIRE_EXPORT PakfireSolution pakfire_solution_create(PakfireProblem problem, Id id) { Pakfire pakfire = pakfire_problem_get_pakfire(problem); - PakfireSolution solution = pakfire_calloc(1, sizeof(*solution)); + PakfireSolution solution = calloc(1, sizeof(*solution)); if (solution) { DEBUG(pakfire, "Allocated Solution at %p\n", solution); solution->pakfire = pakfire_ref(pakfire); diff --git a/src/libpakfire/step.c b/src/libpakfire/step.c index 307173308..c88d10b90 100644 --- a/src/libpakfire/step.c +++ b/src/libpakfire/step.c @@ -52,7 +52,7 @@ PAKFIRE_EXPORT PakfireStep pakfire_step_create(PakfireTransaction transaction, pakfire_step_type_t type, PakfirePackage pkg) { Pakfire pakfire = pakfire_transaction_get_pakfire(transaction); - PakfireStep step = pakfire_calloc(1, sizeof(*step)); + PakfireStep step = calloc(1, sizeof(*step)); if (step) { DEBUG(pakfire, "Allocated Step at %p\n", step); step->pakfire = pakfire_ref(pakfire); diff --git a/src/libpakfire/transaction.c b/src/libpakfire/transaction.c index b1810b7c5..19e91724c 100644 --- a/src/libpakfire/transaction.c +++ b/src/libpakfire/transaction.c @@ -80,7 +80,7 @@ static pakfire_step_type_t transaction_get_step_type(Transaction* transaction, I } PAKFIRE_EXPORT PakfireTransaction pakfire_transaction_create(Pakfire pakfire, Transaction* trans) { - PakfireTransaction transaction = pakfire_calloc(1, sizeof(*transaction)); + PakfireTransaction transaction = calloc(1, sizeof(*transaction)); if (transaction) { DEBUG(pakfire, "Allocated Transaction at %p\n", transaction); transaction->nrefs = 1; @@ -99,7 +99,7 @@ PAKFIRE_EXPORT PakfireTransaction pakfire_transaction_create(Pakfire pakfire, Tr transaction->num_steps = transaction->transaction->steps.count; // Import all steps - PakfireStep* steps = transaction->steps = pakfire_calloc(transaction->num_steps + 1, sizeof(*steps)); + PakfireStep* steps = transaction->steps = calloc(transaction->num_steps + 1, sizeof(*steps)); for (unsigned int i = 0; i < transaction->num_steps; i++) { Id id = transaction->transaction->steps.elements[i]; diff --git a/src/libpakfire/util.c b/src/libpakfire/util.c index d3a2dca97..a440df170 100644 --- a/src/libpakfire/util.c +++ b/src/libpakfire/util.c @@ -53,20 +53,6 @@ void* pakfire_malloc(size_t len) { return r; } -void* pakfire_calloc(size_t num, size_t len) { - void* r; - - if (num == 0 || len == 0) - r = malloc(1); - else - r = calloc(num, len); - - if (!r) - pakfire_oom(num, len); - - return r; -} - void* pakfire_realloc(void* ptr, size_t size) { ptr = realloc(ptr, size); if (!ptr)