*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);
}
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);
}
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;
}
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);
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;
// 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
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;
};
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;
}
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;
#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;
}
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);
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;
}
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;
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
}
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);
};
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);
return -ENOENT;
}
- Pakfire p = pakfire_calloc(1, sizeof(*p));
+ Pakfire p = calloc(1, sizeof(*p));
if (!p)
return -ENOMEM;
}
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;
}
// Allocate a new declaration
- d = pakfire_calloc(1, sizeof(*d));
+ d = calloc(1, sizeof(*d));
if (!d)
return -1;
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);
}
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;
};
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;
}
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;
// 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);
}
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;
// 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));
};
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;
};
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;
// 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;
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);
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);
}
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;
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];
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)