]> git.ipfire.org Git - pakfire.git/commitdiff
libpakfire: Drop pakfire_calloc
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 8 Feb 2021 19:32:16 +0000 (19:32 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 8 Feb 2021 19:32:16 +0000 (19:32 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
21 files changed:
src/libpakfire/archive.c
src/libpakfire/db.c
src/libpakfire/file.c
src/libpakfire/filelist.c
src/libpakfire/filter.c
src/libpakfire/include/pakfire/util.h
src/libpakfire/key.c
src/libpakfire/package.c
src/libpakfire/packagelist.c
src/libpakfire/pakfire.c
src/libpakfire/parser.c
src/libpakfire/problem.c
src/libpakfire/relation.c
src/libpakfire/relationlist.c
src/libpakfire/repo.c
src/libpakfire/request.c
src/libpakfire/selector.c
src/libpakfire/solution.c
src/libpakfire/step.c
src/libpakfire/transaction.c
src/libpakfire/util.c

index 2ca54d01ab39be8666f691fc897ad4ac05196f5e..4edacec588d03d445c57371991329dc93ccac345 100644 (file)
@@ -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
index 461404898fca9548025f5b3e2cc0806f7b38977f..1d78a6b2de4d35ec674ccabc2c007528e0eb5143 100644 (file)
@@ -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;
 
index 5bf716d790c31f27290ba7d4e66f576013e9569b..3207fe93e6df196166a4ce6cba0a09ad7c0aaeb0 100644 (file)
@@ -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;
 
index 21bb4bbb308d4f6549c1769cb0ed8d3b310e6211..644022b8c74697174c7dae2b3eead7ff9acff51b 100644 (file)
@@ -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;
 
index 386612785d69ab1e3f1ad28a27b2f58974374be5..e09400404968d7cc3fd874f84d9f774b170442c2 100644 (file)
@@ -26,7 +26,7 @@
 #include <pakfire/util.h>
 
 PAKFIRE_EXPORT PakfireFilter pakfire_filter_create(void) {
-       PakfireFilter filter = pakfire_calloc(1, sizeof(*filter));
+       PakfireFilter filter = calloc(1, sizeof(*filter));
 
        return filter;
 }
index e3a4b8bfd35e53209a14e5294d34d08cae1613f0..2ebf1add2a1aa5c55ea6296d95961ddca3e7469f 100644 (file)
@@ -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);
index 30be26499d9d3c54b485c3beb63e996b078accce..ba9346b6ee31f5f086ee7060ee32be619b2e6569 100644 (file)
@@ -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
index e278bc22aa555d52a3349d1494786cb853c0c180..ae429da920404f67519076a7f3d4ec21e6abf612 100644 (file)
@@ -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);
 
index c11eebeec4b6b2ac14ad153ea71bf2dc262b8feb..a0416d33ac7e387f7a06609cd911698386b5f10e 100644 (file)
@@ -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);
index e352497dd892169a2372a666fc251de70b4c5836..645079f93a62bcafe6d6db0f02e365f366c2f30c 100644 (file)
@@ -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;
 
index 0a6350615d852e0788f7e9d93b156c603b4afdb4..d7288c22e15c8d52635d20ce7614494075f9f5cb 100644 (file)
@@ -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;
 
index e5234cae24da4e416896a0ab0e32e4c31fbf2528..627b4b61d3d5c12557110121cbe22c6b5265ea48 100644 (file)
@@ -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);
index 8b649bf2b66304cda2c2eaf2873fe272cafbab8e..5b84fd17f01eb2f734ff69d5bdb2938ff1b07063 100644 (file)
@@ -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;
index 0c7bf61adbac256575f76a6487a19e12239271c0..52c4b7146864c42c346a07573621caf80356f9ca 100644 (file)
@@ -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;
 
index 22ccb9d6e8a61a4482913320f0cc1f30db1a4256..f15ef74979793de30dabc727ceaf9221106897d7 100644 (file)
@@ -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));
 
index bccc8d2e292e58f2c02ab2cfe14ed0df060942de..4ec816ed8cf175189af048741394e11c9b605c67 100644 (file)
@@ -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;
index 0659b2ffeaf0db1cdfc7ef715cc2daf59c618322..2dc50547ba7d8e667d946b02e4f0eb4e0c86d9f3 100644 (file)
@@ -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;
index 0dc74e2bd9697460f05e089ffb03889cc24f9491..9465bd79b276915bacf5d124ed39e2d8d8f16ed4 100644 (file)
@@ -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);
index 307173308e730f70d4c00bafdffd8492cf03573f..c88d10b90578429b54041516f2cda3e5a4140b60 100644 (file)
@@ -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);
index b1810b7c5460d69c78f754c1b5b6bbbff654033c..19e91724c036ed28917f7254f3924af9af3e7d35 100644 (file)
@@ -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];
 
index d3a2dca97d6ce23400fc86bd0e39b0caab9932d5..a440df170a917edd115deb4484251c573425b09d 100644 (file)
@@ -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)