From: Michael Tremer Date: Mon, 8 Feb 2021 19:27:17 +0000 (+0000) Subject: libpakfire: Drop pakfire_free X-Git-Tag: 0.9.28~1285^2~782 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f0d6233d06458683b29dacac3ab2561efeef6911;p=pakfire.git libpakfire: Drop pakfire_free There is no point in using an own function to free any memory. Signed-off-by: Michael Tremer --- diff --git a/src/_pakfire/archive.c b/src/_pakfire/archive.c index e50f5c899..cac0ece9b 100644 --- a/src/_pakfire/archive.c +++ b/src/_pakfire/archive.c @@ -87,7 +87,7 @@ static PyObject* Archive_read(ArchiveObject* self, PyObject* args, PyObject* kwd int ret = pakfire_archive_read(self->archive, filename, &data, &data_size, flags); if (ret) { - pakfire_free(data); + free(data); Py_RETURN_NONE; } @@ -95,7 +95,7 @@ static PyObject* Archive_read(ArchiveObject* self, PyObject* args, PyObject* kwd // XXX This is not ideal since PyBytes_FromStringAndSize creates a // copy of data. PyObject* bytes = PyBytes_FromStringAndSize(data, data_size); - pakfire_free(data); + free(data); return bytes; } @@ -142,7 +142,7 @@ static PyObject* Archive_extract(ArchiveObject* self, PyObject* args) { // Extract payload int r = pakfire_archive_extract(self->archive, prefix, PAKFIRE_ARCHIVE_USE_PAYLOAD); - pakfire_free(prefix); + free(prefix); // Throw an exception on error if (r) { @@ -187,7 +187,7 @@ static PyObject* Archive_get(ArchiveObject* self, PyObject* args) { Py_RETURN_NONE; PyObject* ret = PyUnicode_FromString(value); - pakfire_free(value); + free(value); return ret; } diff --git a/src/_pakfire/key.c b/src/_pakfire/key.c index 36f81719f..457d34c38 100644 --- a/src/_pakfire/key.c +++ b/src/_pakfire/key.c @@ -74,7 +74,7 @@ static PyObject* Key_str(KeyObject* self) { char* string = pakfire_key_dump(self->key); PyObject* object = PyUnicode_FromString(string); - pakfire_free(string); + free(string); return object; } @@ -101,7 +101,7 @@ static PyObject* Key_export(KeyObject* self, PyObject* args) { char* export = pakfire_key_export(self->key, mode); PyObject* object = PyUnicode_FromFormat("%s", export); - pakfire_free(export); + free(export); return object; } diff --git a/src/_pakfire/package.c b/src/_pakfire/package.c index 8f7ffc616..9df378eba 100644 --- a/src/_pakfire/package.c +++ b/src/_pakfire/package.c @@ -77,7 +77,7 @@ static PyObject* Package_repr(PackageObject* self) { PyObject* repr = PyUnicode_FromFormat("<_pakfire.Package object id %ld, %s>", Package_hash(self), nevra); - pakfire_free(nevra); + free(nevra); return repr; } @@ -86,7 +86,7 @@ static PyObject* Package_str(PackageObject* self) { char* nevra = pakfire_package_get_nevra(self->package); PyObject* str = PyUnicode_FromString(nevra); - pakfire_free(nevra); + free(nevra); return str; } @@ -300,12 +300,12 @@ static PyObject* Package_get_groups(PackageObject* self) { while ((group = *groups++) != NULL) { PyObject* item = PyUnicode_FromString(group); PyList_Append(list, item); - pakfire_free(group); + free(group); Py_DECREF(item); } - pakfire_free(groups); + free(groups); return list; } @@ -426,7 +426,7 @@ static void Package_set_buildtime(PackageObject* self, PyObject* value) { static PyObject* Package_get_cache_path(PackageObject* self) { char* cache_path = pakfire_package_get_cache_path(self->package); PyObject* ret = PyUnicode_FromString(cache_path); - pakfire_free(cache_path); + free(cache_path); return ret; } @@ -451,7 +451,7 @@ static PyObject* Package_get_location(PackageObject* self) { char* location = pakfire_package_get_location(self->package); PyObject* str = PyUnicode_FromString(location); - pakfire_free(location); + free(location); return str; } diff --git a/src/_pakfire/pakfire.c b/src/_pakfire/pakfire.c index 6cf25d00d..5b90967b3 100644 --- a/src/_pakfire/pakfire.c +++ b/src/_pakfire/pakfire.c @@ -147,7 +147,7 @@ static PyObject* Pakfire_get_cache_path(PakfireObject* self) { Py_RETURN_NONE; PyObject* obj = PyUnicode_FromString(path); - pakfire_free(path); + free(path); return obj; } diff --git a/src/_pakfire/relation.c b/src/_pakfire/relation.c index 215aea6ee..ac4f21cc6 100644 --- a/src/_pakfire/relation.c +++ b/src/_pakfire/relation.c @@ -77,7 +77,7 @@ static PyObject* Relation_repr(RelationObject* self) { char* relation = pakfire_relation_str(self->relation); PyObject* repr = PyUnicode_FromFormat("<_pakfire.Relation %s>", relation); - pakfire_free(relation); + free(relation); return repr; } @@ -86,7 +86,7 @@ static PyObject* Relation_str(RelationObject* self) { char* relation = pakfire_relation_str(self->relation); PyObject* str = PyUnicode_FromString(relation); - pakfire_free(relation); + free(relation); return str; } diff --git a/src/_pakfire/repo.c b/src/_pakfire/repo.c index bbf3e1958..40335260f 100644 --- a/src/_pakfire/repo.c +++ b/src/_pakfire/repo.c @@ -221,7 +221,7 @@ static PyObject* Repo_get_config(RepoObject* self) { if (config) { PyObject* obj = PyUnicode_FromString(config); - pakfire_free(config); + free(config); return obj; } @@ -380,7 +380,7 @@ static PyObject* Repo_cache_path(RepoObject* self, PyObject* args) { char* cache_path = pakfire_repo_cache_get_path(self->repo, path); PyObject* obj = PyUnicode_FromString(cache_path); - pakfire_free(cache_path); + free(cache_path); return obj; } diff --git a/src/_pakfire/step.c b/src/_pakfire/step.c index c8cba3271..80d795a85 100644 --- a/src/_pakfire/step.c +++ b/src/_pakfire/step.c @@ -91,7 +91,7 @@ static PyObject* Step_repr(StepObject* self) { pakfire_step_get_type_string(self->step), nevra); pakfire_package_unref(package); - pakfire_free(nevra); + free(nevra); return repr; } diff --git a/src/libpakfire/archive.c b/src/libpakfire/archive.c index b2a1a6d97..2ca54d01a 100644 --- a/src/libpakfire/archive.c +++ b/src/libpakfire/archive.c @@ -140,7 +140,7 @@ static int archive_read(struct archive* a, void** data, size_t* data_size) { break; if (size < 0) { - pakfire_free(*data); + free(*data); *data = NULL; return 1; @@ -177,7 +177,7 @@ static ssize_t payload_archive_read(struct archive* a, void* client_data, const static int payload_archive_close(struct archive* a, void* client_data) { struct payload_archive_data* data = client_data; - pakfire_free(data); + free(data); return ARCHIVE_OK; } @@ -226,8 +226,8 @@ static void pakfire_archive_checksum_free(archive_checksum_t* c) { DEBUG(c->pakfire, "Releasing archive checksum at %p\n", c); pakfire_unref(c->pakfire); - pakfire_free(c->filename); - pakfire_free(c); + free(c->filename); + free(c); } static archive_checksum_t* pakfire_archive_checksum_create(Pakfire pakfire, const char* filename, archive_checksum_algo_t algo, const char* s) { @@ -285,8 +285,8 @@ static void pakfire_archive_signature_free(PakfireArchiveSignature signature) { if (signature->key) pakfire_key_unref(signature->key); - pakfire_free(signature->sigdata); - pakfire_free(signature); + free(signature->sigdata); + free(signature); } PAKFIRE_EXPORT PakfireArchiveSignature pakfire_archive_signature_ref(PakfireArchiveSignature signature) { @@ -343,7 +343,7 @@ static void pakfire_archive_free(PakfireArchive archive) { DEBUG(archive->pakfire, "Releasing archive at %p\n", archive); if (archive->path) - pakfire_free(archive->path); + free(archive->path); // Free checksums archive_checksum_t** checksums = archive->checksums; @@ -356,7 +356,7 @@ static void pakfire_archive_free(PakfireArchive archive) { while (signatures && *signatures) pakfire_archive_signature_unref(*signatures++); - pakfire_free(archive->signatures); + free(archive->signatures); } // Free scriptlets @@ -368,7 +368,7 @@ static void pakfire_archive_free(PakfireArchive archive) { pakfire_parser_unref(archive->parser); pakfire_unref(archive->pakfire); - pakfire_free(archive); + free(archive); } PAKFIRE_EXPORT PakfireArchive pakfire_archive_unref(PakfireArchive archive) { @@ -411,7 +411,7 @@ static int pakfire_archive_parse_entry_metadata(PakfireArchive archive, // Parse metadata file r = pakfire_parser_parse_data(archive->parser, (const char*)data, data_size); - pakfire_free(data); + free(data); return r; } @@ -433,7 +433,7 @@ static int pakfire_archive_parse_entry_filelist(PakfireArchive archive, r = pakfire_filelist_create_from_file(&archive->filelist, data, archive->format); } - pakfire_free(data); + free(data); return r; } @@ -500,7 +500,7 @@ static int pakfire_archive_parse_entry_checksums(PakfireArchive archive, // Terminate the list *checksums = NULL; - pakfire_free(data); + free(data); return 0; } @@ -685,7 +685,7 @@ static int archive_extract(Pakfire pakfire, struct archive* a, const char* prefi archive_entry_set_pathname(entry, pathname); DEBUG(pakfire, "Extracting %s (%zu bytes)\n", pathname, size); - pakfire_free(pathname); + free(pathname); // Update hardlink targets const char* hardlink = archive_entry_hardlink(entry); @@ -695,7 +695,7 @@ static int archive_extract(Pakfire pakfire, struct archive* a, const char* prefi // Update the entry archive_entry_set_hardlink(entry, h); - pakfire_free(h); + free(h); } // Create file @@ -875,7 +875,7 @@ PAKFIRE_EXPORT char* pakfire_archive_extraction_path(PakfireArchive archive, con // Cleanup pakfire_package_unref(pkg); pakfire_repo_unref(repo); - pakfire_free(nevra); + free(nevra); return prefix; } @@ -1265,76 +1265,76 @@ PAKFIRE_EXPORT PakfirePackage pakfire_archive_make_package(PakfireArchive archiv archive->pakfire, repo, name, evr, (arch) ? arch : "src" ); - pakfire_free(name); - pakfire_free(type); - pakfire_free(e); - pakfire_free(v); - pakfire_free(r); - pakfire_free(evr); + free(name); + free(type); + free(e); + free(v); + free(r); + free(evr); if (arch) - pakfire_free(arch); + free(arch); #ifdef ENABLE_DEBUG char* nevra = pakfire_package_get_nevra(pkg); DEBUG(archive->pakfire, "Created package %s (%p) from archive %p\n", nevra, pkg, archive); - pakfire_free(nevra); + free(nevra); #endif // Set filename char* filename = pakfire_basename(archive->path); if (filename) { pakfire_package_set_filename(pkg, filename); - pakfire_free(filename); + free(filename); } // Set UUID char* uuid = pakfire_archive_get(archive, "package.uuid"); if (uuid) { pakfire_package_set_uuid(pkg, uuid); - pakfire_free(uuid); + free(uuid); } // Set groups char* groups = pakfire_archive_get(archive, "package.groups"); if (groups) { pakfire_package_set_groups(pkg, groups); - pakfire_free(groups); + free(groups); } // Set maintainer char* maintainer = pakfire_archive_get(archive, "package.maintainer"); if (maintainer) { pakfire_package_set_maintainer(pkg, maintainer); - pakfire_free(maintainer); + free(maintainer); } // Set URL char* url = pakfire_archive_get(archive, "package.url"); if (url) { pakfire_package_set_url(pkg, url); - pakfire_free(url); + free(url); } // Set license char* license = pakfire_archive_get(archive, "package.license"); if (license) { pakfire_package_set_license(pkg, license); - pakfire_free(license); + free(license); } // Set summary char* summary = pakfire_archive_get(archive, "package.summary"); if (summary) { pakfire_package_set_summary(pkg, summary); - pakfire_free(summary); + free(summary); } // Set description char* description = pakfire_archive_get(archive, "package.description"); if (description) { pakfire_package_set_description(pkg, description); - pakfire_free(description); + free(description); } // Get package size @@ -1344,7 +1344,7 @@ PAKFIRE_EXPORT PakfirePackage pakfire_archive_make_package(PakfireArchive archiv char* size = pakfire_archive_get(archive, "package.size"); if (size) { size_t s = pakfire_string_to_size(size); - pakfire_free(size); + free(size); pakfire_package_set_installsize(pkg, s); } @@ -1353,21 +1353,21 @@ PAKFIRE_EXPORT PakfirePackage pakfire_archive_make_package(PakfireArchive archiv char* vendor = pakfire_archive_get(archive, "distribution.vendor"); if (vendor) { pakfire_package_set_vendor(pkg, vendor); - pakfire_free(vendor); + free(vendor); } // Set build host char* buildhost = pakfire_archive_get(archive, "build.host"); if (buildhost) { pakfire_package_set_buildhost(pkg, buildhost); - pakfire_free(buildhost); + free(buildhost); } // Set build time char* buildtime = pakfire_archive_get(archive, "build.time"); if (buildtime) { unsigned long long t = strtoull(buildtime, NULL, 10); - pakfire_free(buildtime); + free(buildtime); pakfire_package_set_buildtime(pkg, t); } diff --git a/src/libpakfire/db.c b/src/libpakfire/db.c index bb1db554d..461404898 100644 --- a/src/libpakfire/db.c +++ b/src/libpakfire/db.c @@ -112,7 +112,7 @@ static void pakfire_db_free(struct pakfire_db* db) { pakfire_unref(db->pakfire); - pakfire_free(db); + free(db); } static sqlite3_value* pakfire_db_get(struct pakfire_db* db, const char* key) { diff --git a/src/libpakfire/file.c b/src/libpakfire/file.c index f15bdac6f..5bf716d79 100644 --- a/src/libpakfire/file.c +++ b/src/libpakfire/file.c @@ -67,15 +67,15 @@ PAKFIRE_EXPORT int pakfire_file_create(PakfireFile* file) { static void pakfire_file_free(PakfireFile file) { if (file->name) - pakfire_free(file->name); + free(file->name); if (file->user) - pakfire_free(file->user); + free(file->user); if (file->group) - pakfire_free(file->group); + free(file->group); if (file->chksum) - pakfire_free(file->chksum); + free(file->chksum); - pakfire_free(file); + free(file); } PAKFIRE_EXPORT PakfireFile pakfire_file_ref(PakfireFile file) { @@ -156,8 +156,8 @@ PAKFIRE_EXPORT void pakfire_file_sprintf(PakfireFile file, char* str, size_t len snprintf(str, len, "%s %-8s %-8s %8d %s %s", perms, user, group, (int)size, mtime, name); - pakfire_free(perms); - pakfire_free(mtime); + free(perms); + free(mtime); } PAKFIRE_EXPORT const char* pakfire_file_get_name(PakfireFile file) { @@ -166,7 +166,7 @@ PAKFIRE_EXPORT const char* pakfire_file_get_name(PakfireFile file) { PAKFIRE_EXPORT void pakfire_file_set_name(PakfireFile file, const char* name) { if (file->name) - pakfire_free(file->name); + free(file->name); if (*name == '/') { file->name = pakfire_strdup(name); diff --git a/src/libpakfire/filelist.c b/src/libpakfire/filelist.c index aed051174..21bb4bbb3 100644 --- a/src/libpakfire/filelist.c +++ b/src/libpakfire/filelist.c @@ -61,7 +61,7 @@ PAKFIRE_EXPORT int pakfire_filelist_create(PakfireFilelist* list) { static void pakfire_filelist_free(PakfireFilelist list) { pakfire_filelist_clear(list); - pakfire_free(list); + free(list); } PAKFIRE_EXPORT PakfireFilelist pakfire_filelist_ref(PakfireFilelist list) { diff --git a/src/libpakfire/filter.c b/src/libpakfire/filter.c index 0be50e1c8..386612785 100644 --- a/src/libpakfire/filter.c +++ b/src/libpakfire/filter.c @@ -18,6 +18,8 @@ # # #############################################################################*/ +#include + #include #include #include @@ -30,6 +32,6 @@ PAKFIRE_EXPORT PakfireFilter pakfire_filter_create(void) { } PAKFIRE_EXPORT void pakfire_filter_free(PakfireFilter filter) { - pakfire_free(filter->match); - pakfire_free(filter); + free(filter->match); + free(filter); } diff --git a/src/libpakfire/include/pakfire/util.h b/src/libpakfire/include/pakfire/util.h index 100971acb..e3a4b8bfd 100644 --- a/src/libpakfire/include/pakfire/util.h +++ b/src/libpakfire/include/pakfire/util.h @@ -34,8 +34,6 @@ void* pakfire_malloc(size_t len); void* pakfire_calloc(size_t num, size_t len); void* pakfire_realloc(void* ptr, size_t size); -void* pakfire_free(void* mem); - char* pakfire_strdup(const char* s); int pakfire_string_startswith(const char* s, const char* prefix); diff --git a/src/libpakfire/key.c b/src/libpakfire/key.c index 690b4fa82..30be26499 100644 --- a/src/libpakfire/key.c +++ b/src/libpakfire/key.c @@ -20,6 +20,7 @@ #include #include +#include #include #include #include @@ -80,7 +81,7 @@ gpgme_ctx_t pakfire_get_gpgctx(Pakfire pakfire) { // Setup engine error = gpgme_ctx_set_engine_info(ctx, GPGME_PROTOCOL_OpenPGP, NULL, home); - pakfire_free(home); + free(home); if (gpg_err_code(error) != GPG_ERR_NO_ERROR) goto FAIL; @@ -171,7 +172,7 @@ static void pakfire_key_free(PakfireKey key) { pakfire_unref(key->pakfire); gpgme_key_unref(key->gpgkey); - pakfire_free(key); + free(key); } PAKFIRE_EXPORT PakfireKey pakfire_key_ref(PakfireKey key) { @@ -465,7 +466,7 @@ PAKFIRE_EXPORT char* pakfire_key_dump(PakfireKey key) { pakfire_key_get_fingerprint(key), date_created ); - pakfire_free(date_created); + free(date_created); const char* uid = pakfire_key_get_uid(key); if (uid) { @@ -476,7 +477,7 @@ PAKFIRE_EXPORT char* pakfire_key_dump(PakfireKey key) { if (expires) { char* date_expires = pakfire_format_date(expires); asprintf(&s, "%s\n %s: %s", s, _("Expires"), date_expires); - pakfire_free(date_expires); + free(date_expires); } return s; diff --git a/src/libpakfire/libpakfire.sym b/src/libpakfire/libpakfire.sym index 53a4d8e20..f96304afc 100644 --- a/src/libpakfire/libpakfire.sym +++ b/src/libpakfire/libpakfire.sym @@ -383,7 +383,6 @@ global: pakfire_access; pakfire_basename; pakfire_dirname; - pakfire_free; pakfire_get_errno; pakfire_partition_string; pakfire_path_isdir; diff --git a/src/libpakfire/package.c b/src/libpakfire/package.c index a08eb1890..e278bc22a 100644 --- a/src/libpakfire/package.c +++ b/src/libpakfire/package.c @@ -90,7 +90,7 @@ static void pakfire_package_free(PakfirePackage pkg) { DEBUG(pkg->pakfire, "Releasing Package at %p\n", pkg); pakfire_unref(pkg->pakfire); - pakfire_free(pkg); + free(pkg); } PAKFIRE_EXPORT PakfirePackage pakfire_package_ref(PakfirePackage pkg) { @@ -716,7 +716,7 @@ static void pakfire_package_dump_add_line_relations(char** str, const char* key, if (dep) { pakfire_package_dump_add_line(str, (i == 0) ? key : "", dep); - pakfire_free(dep); + free(dep); } } } @@ -727,7 +727,7 @@ static void pakfire_package_dump_add_line_size(char** str, const char* key, unsi if (val) { pakfire_package_dump_add_line(str, key, val); - pakfire_free(val); + free(val); } } @@ -878,7 +878,7 @@ PAKFIRE_EXPORT int pakfire_package_is_cached(PakfirePackage pkg) { // Check if the file is readable int r = pakfire_access(pkg->pakfire, path, NULL, R_OK); - pakfire_free(path); + free(path); return (r == 0); } @@ -906,7 +906,7 @@ PAKFIRE_EXPORT PakfireArchive pakfire_package_get_archive(PakfirePackage pkg) { // Open archive PakfireArchive archive = pakfire_archive_open(pkg->pakfire, path); - pakfire_free(path); + free(path); return archive; } diff --git a/src/libpakfire/packagelist.c b/src/libpakfire/packagelist.c index da8ec6914..c11eebeec 100644 --- a/src/libpakfire/packagelist.c +++ b/src/libpakfire/packagelist.c @@ -67,8 +67,8 @@ static void pakfire_packagelist_free(PakfirePackageList list) { pakfire_package_unref(list->elements[i]); } - pakfire_free(list->elements); - pakfire_free(list); + free(list->elements); + free(list); } PAKFIRE_EXPORT PakfirePackageList pakfire_packagelist_unref(PakfirePackageList list) { diff --git a/src/libpakfire/pakfire.c b/src/libpakfire/pakfire.c index b822d8cfc..e352497dd 100644 --- a/src/libpakfire/pakfire.c +++ b/src/libpakfire/pakfire.c @@ -99,8 +99,7 @@ static int pakfire_populate_pool(Pakfire pakfire) { return 0; } -// A utility function is already called pakfire_free -static void _pakfire_free(Pakfire pakfire) { +static void pakfire_free(Pakfire pakfire) { DEBUG(pakfire, "Releasing Pakfire at %p\n", pakfire); pakfire_repo_free_all(pakfire); @@ -111,15 +110,15 @@ static void _pakfire_free(Pakfire pakfire) { queue_free(&pakfire->installonly); if (pakfire->arch) - pakfire_free(pakfire->arch); + free(pakfire->arch); if (pakfire->path) - pakfire_free(pakfire->path); + free(pakfire->path); if (pakfire->cache_path) - pakfire_free(pakfire->cache_path); + free(pakfire->cache_path); - pakfire_free(pakfire); + free(pakfire); } PAKFIRE_EXPORT int pakfire_create(Pakfire* pakfire, const char* path, const char* arch) { @@ -174,7 +173,7 @@ PAKFIRE_EXPORT int pakfire_create(Pakfire* pakfire, const char* path, const char private_dir, strerror(errno)); free(private_dir); - _pakfire_free(p); + pakfire_free(p); return r; } @@ -192,7 +191,7 @@ PAKFIRE_EXPORT int pakfire_create(Pakfire* pakfire, const char* path, const char // Populate pool r = pakfire_populate_pool(p); if (r) { - _pakfire_free(p); + pakfire_free(p); return r; } @@ -215,7 +214,7 @@ PAKFIRE_EXPORT Pakfire pakfire_unref(Pakfire pakfire) { if (--pakfire->nrefs > 0) return pakfire; - _pakfire_free(pakfire); + pakfire_free(pakfire); return NULL; } @@ -428,7 +427,7 @@ PAKFIRE_EXPORT char* pakfire_get_cache_path(Pakfire pakfire, const char* path) { PAKFIRE_EXPORT void pakfire_set_cache_path(Pakfire pakfire, const char* path) { // Release old path if (pakfire->cache_path) - pakfire_free(pakfire->cache_path); + free(pakfire->cache_path); pakfire->cache_path = pakfire_strdup(path); @@ -444,7 +443,7 @@ PAKFIRE_EXPORT int pakfire_cache_destroy(Pakfire pakfire, const char* path) { // Completely delete the tree of files int r = nftw(cache_path, _unlink, 64, FTW_DEPTH|FTW_PHYS); - pakfire_free(cache_path); + free(cache_path); // It is okay if the path doesn't exist if (r < 0 && errno == ENOENT) @@ -457,7 +456,7 @@ PAKFIRE_EXPORT int pakfire_cache_stat(Pakfire pakfire, const char* path, struct char* cache_path = pakfire_get_cache_path(pakfire, path); int r = stat(cache_path, buffer); - pakfire_free(cache_path); + free(cache_path); return r; } @@ -466,7 +465,7 @@ PAKFIRE_EXPORT int pakfire_cache_access(Pakfire pakfire, const char* path, int m char* cache_path = pakfire_get_cache_path(pakfire, path); int r = pakfire_access(pakfire, cache_path, NULL, mode); - pakfire_free(cache_path); + free(cache_path); return r; } @@ -501,8 +500,8 @@ PAKFIRE_EXPORT FILE* pakfire_cache_open(Pakfire pakfire, const char* path, const f = fopen(cache_path, flags); FAIL: - pakfire_free(cache_path); - pakfire_free(cache_dirname); + free(cache_path); + free(cache_dirname); return f; } diff --git a/src/libpakfire/parser.c b/src/libpakfire/parser.c index 220d9431c..0a6350615 100644 --- a/src/libpakfire/parser.c +++ b/src/libpakfire/parser.c @@ -19,6 +19,7 @@ #############################################################################*/ #include +#include #include #include @@ -121,10 +122,10 @@ static void pakfire_parser_free_declarations(PakfireParser parser) { // Free everything if (d->name) - pakfire_free(d->name); + free(d->name); if (d->value) - pakfire_free(d->value); - pakfire_free(d); + free(d->value); + free(d); } } @@ -133,11 +134,11 @@ static void pakfire_parser_free(PakfireParser parser) { pakfire_parser_free_declarations(parser); if (parser->namespace) - pakfire_free(parser->namespace); + free(parser->namespace); pakfire_parser_unref(parser->parent); pakfire_unref(parser->pakfire); - pakfire_free(parser); + free(parser); } PAKFIRE_EXPORT PakfireParser pakfire_parser_unref(PakfireParser parser) { @@ -182,7 +183,7 @@ static int pakfire_parser_set_declaration(PakfireParser parser, if (d) { // Replace value if (d->value) - pakfire_free(d->value); + free(d->value); d->value = pakfire_strdup(value); DEBUG(parser->pakfire, "Updated declaration: %s = %s\n", @@ -219,7 +220,7 @@ PAKFIRE_EXPORT int pakfire_parser_set(PakfireParser parser, const char* name, co char* canonical_name = pakfire_parser_make_canonical_name(parser, name); int r = pakfire_parser_set_declaration(parser, canonical_name, value); - pakfire_free(canonical_name); + free(canonical_name); return r; } @@ -260,7 +261,7 @@ PAKFIRE_EXPORT int pakfire_parser_append(PakfireParser parser, // Set the new value r = pakfire_parser_set_declaration(parser, name, buffer); - pakfire_free(buffer); + free(buffer); return r; } @@ -310,10 +311,10 @@ static struct pakfire_parser_declaration* pakfire_parser_find_declaration( pakfire_parser_strip_namespace(n); } - pakfire_free(buffer); + free(buffer); if (n) - pakfire_free(n); + free(n); if (!d && parser->parent) d = pakfire_parser_find_declaration(parser->parent, name); @@ -406,7 +407,7 @@ PAKFIRE_EXPORT char* pakfire_parser_expand(PakfireParser parser, const char* val DEBUG(parser->pakfire, "New buffer: %s\n", b); // Drop old buffer - pakfire_free(buffer); + free(buffer); buffer = b; } @@ -455,7 +456,7 @@ PAKFIRE_EXPORT int pakfire_parser_read(PakfireParser parser, FILE* f) { r = pakfire_parser_parse_data(parser, data, len); if (data) - pakfire_free(data); + free(data); return r; } diff --git a/src/libpakfire/parser/grammar.y b/src/libpakfire/parser/grammar.y index b428236b3..77d01d972 100644 --- a/src/libpakfire/parser/grammar.y +++ b/src/libpakfire/parser/grammar.y @@ -25,6 +25,7 @@ %{ #include +#include #include #include @@ -278,7 +279,7 @@ int pakfire_parser_parse_data(PakfireParser parent, const char* data, size_t len char* dump = pakfire_parser_dump(parent); DEBUG(pakfire, "Status of the parser %p:\n%s\n", parent, dump); - pakfire_free(dump); + free(dump); // Log time we needed to parse data DEBUG(pakfire, "Parser finished in %.4fms\n", @@ -329,8 +330,8 @@ static PakfireParser make_if_stmt(PakfireParser parser, const enum operator op, } pakfire_unref(pakfire); - pakfire_free(v1); - pakfire_free(v2); + free(v1); + free(v2); return result; } diff --git a/src/libpakfire/parser/scanner.l b/src/libpakfire/parser/scanner.l index 54fbc228b..1a7aac769 100644 --- a/src/libpakfire/parser/scanner.l +++ b/src/libpakfire/parser/scanner.l @@ -26,6 +26,7 @@ int num_lines; #include +#include #include #include #include "grammar.h" @@ -92,7 +93,7 @@ template2 {whitespace}template.* unput(buffer[i]); } - pakfire_free(buffer); + free(buffer); } ^{template1}$ { @@ -103,7 +104,7 @@ template2 {whitespace}template.* unput(buffer[i]); } - pakfire_free(buffer); + free(buffer); } ^{template2}$ { @@ -114,7 +115,7 @@ template2 {whitespace}template.* unput(buffer[i]); } - pakfire_free(buffer); + free(buffer); } ^{script} { @@ -125,7 +126,7 @@ template2 {whitespace}template.* unput(buffer[i]); } - pakfire_free(buffer); + free(buffer); } ^{keywords}$ { @@ -141,7 +142,7 @@ template2 {whitespace}template.* unput(buffer[i]); } - pakfire_free(buffer); + free(buffer); } "==" { return T_EQUALS; } diff --git a/src/libpakfire/problem.c b/src/libpakfire/problem.c index b48bc0d16..e5234cae2 100644 --- a/src/libpakfire/problem.c +++ b/src/libpakfire/problem.c @@ -18,6 +18,8 @@ # # #############################################################################*/ +#include + #include #include #include @@ -236,10 +238,10 @@ static void pakfire_problem_free(PakfireProblem problem) { pakfire_request_unref(problem->request); if (problem->string) - pakfire_free(problem->string); + free(problem->string); pakfire_unref(problem->pakfire); - pakfire_free(problem); + free(problem); } PAKFIRE_EXPORT PakfireProblem pakfire_problem_unref(PakfireProblem problem) { diff --git a/src/libpakfire/relation.c b/src/libpakfire/relation.c index 5ca6310b2..8b649bf2b 100644 --- a/src/libpakfire/relation.c +++ b/src/libpakfire/relation.c @@ -19,6 +19,7 @@ #############################################################################*/ #include +#include #include #include @@ -126,8 +127,8 @@ PAKFIRE_EXPORT PakfireRelation pakfire_relation_create_from_string(Pakfire pakfi PakfireRelation rel = pakfire_relation_create(pakfire, name, cmp2type(*delim), evr); // Cleanup - pakfire_free(name); - pakfire_free(evr); + free(name); + free(evr); return rel; } @@ -146,7 +147,7 @@ static void pakfire_relation_free(PakfireRelation relation) { DEBUG(relation->pakfire, "Releasing Relation at %p\n", relation); pakfire_unref(relation->pakfire); - pakfire_free(relation); + free(relation); } PAKFIRE_EXPORT PakfireRelation pakfire_relation_unref(PakfireRelation relation) { diff --git a/src/libpakfire/relationlist.c b/src/libpakfire/relationlist.c index 11fde75af..0c7bf61ad 100644 --- a/src/libpakfire/relationlist.c +++ b/src/libpakfire/relationlist.c @@ -19,6 +19,7 @@ #############################################################################*/ #include +#include #include #include @@ -69,10 +70,10 @@ PAKFIRE_EXPORT int pakfire_relationlist_create_from_string(PakfireRelationList* pakfire_relation_unref(rel); } - pakfire_free(*element); + free(*element); } - pakfire_free(elements); + free(elements); return 0; } @@ -88,7 +89,7 @@ static void pakfire_relationlist_free(PakfireRelationList relationlist) { pakfire_unref(relationlist->pakfire); queue_free(&relationlist->queue); - pakfire_free(relationlist); + free(relationlist); } PAKFIRE_EXPORT PakfireRelationList pakfire_relationlist_unref(PakfireRelationList relationlist) { diff --git a/src/libpakfire/repo.c b/src/libpakfire/repo.c index f99a8567a..22ccb9d6e 100644 --- a/src/libpakfire/repo.c +++ b/src/libpakfire/repo.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -63,18 +64,18 @@ static void free_repo_appdata(struct pakfire_repo_appdata* appdata) { // repodata is being destroyed with the repository if (appdata->description) - pakfire_free(appdata->description); + free(appdata->description); if (appdata->baseurl) - pakfire_free(appdata->baseurl); + free(appdata->baseurl); if (appdata->keyfile) - pakfire_free(appdata->keyfile); + free(appdata->keyfile); if (appdata->mirrorlist) - pakfire_free(appdata->mirrorlist); + free(appdata->mirrorlist); - pakfire_free(appdata); + free(appdata); } void pakfire_repo_free_all(Pakfire pakfire) { @@ -140,7 +141,7 @@ static void pakfire_repo_free(PakfireRepo repo) { DEBUG(repo->pakfire, "Releasing Repo at %p\n", repo); pakfire_unref(repo->pakfire); - pakfire_free(repo); + free(repo); } PAKFIRE_EXPORT PakfireRepo pakfire_repo_unref(PakfireRepo repo) { @@ -245,7 +246,7 @@ PAKFIRE_EXPORT const char* pakfire_repo_get_description(PakfireRepo repo) { PAKFIRE_EXPORT int pakfire_repo_set_description(PakfireRepo repo, const char* description) { if (repo->appdata->description) - pakfire_free(repo->appdata->description); + free(repo->appdata->description); if (description) repo->appdata->description = pakfire_strdup(description); @@ -282,7 +283,7 @@ PAKFIRE_EXPORT const char* pakfire_repo_get_baseurl(PakfireRepo repo) { PAKFIRE_EXPORT int pakfire_repo_set_baseurl(PakfireRepo repo, const char* baseurl) { if (repo->appdata->baseurl) - pakfire_free(repo->appdata->baseurl); + free(repo->appdata->baseurl); if (baseurl) repo->appdata->baseurl = pakfire_strdup(baseurl); @@ -298,7 +299,7 @@ PAKFIRE_EXPORT const char* pakfire_repo_get_keyfile(PakfireRepo repo) { PAKFIRE_EXPORT int pakfire_repo_set_keyfile(PakfireRepo repo, const char* keyfile) { if (repo->appdata->keyfile) - pakfire_free(repo->appdata->keyfile); + free(repo->appdata->keyfile); if (keyfile) repo->appdata->keyfile = pakfire_strdup(keyfile); @@ -314,7 +315,7 @@ PAKFIRE_EXPORT const char* pakfire_repo_get_mirrorlist(PakfireRepo repo) { PAKFIRE_EXPORT int pakfire_repo_set_mirrorlist(PakfireRepo repo, const char* mirrorlist) { if (repo->appdata->mirrorlist) - pakfire_free(repo->appdata->mirrorlist); + free(repo->appdata->mirrorlist); if (mirrorlist) repo->appdata->mirrorlist = pakfire_strdup(mirrorlist); @@ -581,7 +582,7 @@ static char* pakfire_repo_make_cache_path(PakfireRepo repo, const char* path) { // Add the prefix for the repository first char* cache_path = pakfire_path_join(prefix, path); - pakfire_free(prefix); + free(prefix); return cache_path; } @@ -599,7 +600,7 @@ PAKFIRE_EXPORT char* pakfire_repo_cache_get_path(PakfireRepo repo, const char* p char* repo_cache_path = pakfire_repo_make_cache_path(repo, path); char* cache_path = pakfire_get_cache_path(repo->pakfire, repo_cache_path); - pakfire_free(repo_cache_path); + free(repo_cache_path); return cache_path; } @@ -608,7 +609,7 @@ PAKFIRE_EXPORT FILE* pakfire_repo_cache_open(PakfireRepo repo, const char* path, char* cache_path = pakfire_repo_make_cache_path(repo, path); FILE* f = pakfire_cache_open(repo->pakfire, cache_path, mode); - pakfire_free(cache_path); + free(cache_path); return f; } @@ -617,7 +618,7 @@ PAKFIRE_EXPORT int pakfire_repo_cache_access(PakfireRepo repo, const char* path, char* cache_path = pakfire_repo_make_cache_path(repo, path); int r = pakfire_cache_access(repo->pakfire, cache_path, mode); - pakfire_free(cache_path); + free(cache_path); return r; } @@ -626,7 +627,7 @@ PAKFIRE_EXPORT time_t pakfire_repo_cache_age(PakfireRepo repo, const char* path) char* cache_path = pakfire_repo_make_cache_path(repo, path); time_t t = pakfire_cache_age(repo->pakfire, cache_path); - pakfire_free(cache_path); + free(cache_path); return t; } diff --git a/src/libpakfire/request.c b/src/libpakfire/request.c index df9853e5e..bccc8d2e2 100644 --- a/src/libpakfire/request.c +++ b/src/libpakfire/request.c @@ -18,6 +18,8 @@ # # #############################################################################*/ +#include + #include #include #include @@ -76,7 +78,7 @@ static void pakfire_request_free(PakfireRequest request) { queue_free(&request->queue); pakfire_unref(request->pakfire); - pakfire_free(request); + free(request); } PAKFIRE_EXPORT PakfireRequest pakfire_request_unref(PakfireRequest request) { diff --git a/src/libpakfire/selector.c b/src/libpakfire/selector.c index b620bb725..0659b2ffe 100644 --- a/src/libpakfire/selector.c +++ b/src/libpakfire/selector.c @@ -19,6 +19,7 @@ #############################################################################*/ #include +#include #include #include @@ -73,7 +74,7 @@ static void pakfire_selector_free(PakfireSelector selector) { DEBUG(selector->pakfire, "Releasing Selector at %p\n", selector); pakfire_unref(selector->pakfire); - pakfire_free(selector); + free(selector); } PAKFIRE_EXPORT PakfireSelector pakfire_selector_unref(PakfireSelector selector) { diff --git a/src/libpakfire/solution.c b/src/libpakfire/solution.c index d659eee2c..0dc74e2bd 100644 --- a/src/libpakfire/solution.c +++ b/src/libpakfire/solution.c @@ -19,6 +19,7 @@ #############################################################################*/ #include +#include #include @@ -157,9 +158,9 @@ static void pakfire_solution_free(PakfireSolution solution) { if (solution->elements) while (*solution->elements) - pakfire_free(*solution->elements++); + free(*solution->elements++); - pakfire_free(solution); + free(solution); } PAKFIRE_EXPORT PakfireSolution pakfire_solution_unref(PakfireSolution solution) { diff --git a/src/libpakfire/step.c b/src/libpakfire/step.c index 33fa1d97c..307173308 100644 --- a/src/libpakfire/step.c +++ b/src/libpakfire/step.c @@ -80,7 +80,7 @@ static void pakfire_step_free(PakfireStep step) { pakfire_package_unref(step->package); pakfire_archive_unref(step->archive); pakfire_unref(step->pakfire); - pakfire_free(step); + free(step); } PAKFIRE_EXPORT PakfireStep pakfire_step_unref(PakfireStep step) { @@ -201,8 +201,8 @@ static int pakfire_step_verify(PakfireStep step) { ERROR(step->pakfire, "Could not open package archive for %s: %s\n", nevra, cache_path); - pakfire_free(nevra); - pakfire_free(cache_path); + free(nevra); + free(cache_path); return -1; } @@ -296,7 +296,7 @@ out: unlink(path); // Cleanup - pakfire_free(path); + free(path); return r; } @@ -356,7 +356,7 @@ static int pakfire_step_extract(PakfireStep step) { if (r) { char* nevra = pakfire_package_get_nevra(step->package); ERROR(step->pakfire, "Could not extract package %s: %d\n", nevra, r); - pakfire_free(nevra); + free(nevra); } // Update the runtime linker cache diff --git a/src/libpakfire/transaction.c b/src/libpakfire/transaction.c index 48363580d..b1810b7c5 100644 --- a/src/libpakfire/transaction.c +++ b/src/libpakfire/transaction.c @@ -19,6 +19,8 @@ #############################################################################*/ #include +#include + #include #include @@ -134,7 +136,7 @@ void pakfire_transaction_free(PakfireTransaction transaction) { pakfire_step_unref(*transaction->steps++); transaction_free(transaction->transaction); - pakfire_free(transaction); + free(transaction); } PAKFIRE_EXPORT PakfireTransaction pakfire_transaction_unref(PakfireTransaction transaction) { @@ -244,7 +246,7 @@ static void pakfire_transaction_add_package(char** str, size_t width, PakfirePac ); pakfire_repo_unref(repo); - pakfire_free(size_str); + free(size_str); } static void pakfire_transaction_add_separator(char** str, size_t width) { @@ -293,7 +295,7 @@ static void pakfire_transaction_add_usage_line(char** str, size_t width, const c asprintf(str, "%s%-21s: %s\n", *str, headline, s); - pakfire_free(s); + free(s); } PAKFIRE_EXPORT char* pakfire_transaction_dump(PakfireTransaction transaction, size_t width) { diff --git a/src/libpakfire/util.c b/src/libpakfire/util.c index 8abcffdb1..d3a2dca97 100644 --- a/src/libpakfire/util.c +++ b/src/libpakfire/util.c @@ -75,13 +75,6 @@ void* pakfire_realloc(void* ptr, size_t size) { return ptr; } -PAKFIRE_EXPORT void* pakfire_free(void* mem) { - if (mem) - free(mem); - - return 0; -} - char* pakfire_strdup(const char* s) { if (!s) return 0; @@ -173,7 +166,7 @@ PAKFIRE_EXPORT char* pakfire_basename(const char* path) { if (r) r = pakfire_strdup(r); - pakfire_free(name); + free(name); return r; } @@ -185,7 +178,7 @@ PAKFIRE_EXPORT char* pakfire_dirname(const char* path) { if (r) r = pakfire_strdup(r); - pakfire_free(parent); + free(parent); return r; } @@ -209,7 +202,7 @@ PAKFIRE_EXPORT int pakfire_access(Pakfire pakfire, const char* dir, const char* DEBUG(pakfire, "%s does not exist\n", path); } - pakfire_free(path); + free(path); return r; } @@ -226,7 +219,7 @@ int pakfire_mkdir(Pakfire pakfire, const char* path, mode_t mode) { if (r) r = pakfire_mkdir(pakfire, parent, 0); - pakfire_free(parent); + free(parent); // Exit if parent directory could not be created if (r) @@ -327,7 +320,7 @@ PAKFIRE_EXPORT int pakfire_read_file_into_buffer(FILE* f, char** buffer, size_t* // Check we encountered any errors r = ferror(f); if (r) { - pakfire_free(*buffer); + free(*buffer); return r; } diff --git a/tests/libpakfire/archive.c b/tests/libpakfire/archive.c index e3b71047f..6ddd1853a 100644 --- a/tests/libpakfire/archive.c +++ b/tests/libpakfire/archive.c @@ -18,6 +18,7 @@ # # #############################################################################*/ +#include #include #include @@ -43,7 +44,7 @@ static int test_open(const struct test* t) { ASSERT(verify == PAKFIRE_ARCHIVE_VERIFY_OK); pakfire_archive_unref(archive); - pakfire_free(path); + free(path); return EXIT_SUCCESS; } @@ -74,7 +75,7 @@ static int test_extract(const struct test* t) { char* path = pakfire_path_join(TEST_SRC_PATH, TEST_PKG1_PATH); PakfireArchive archive = pakfire_archive_open(t->pakfire, path); - pakfire_free(path); + free(path); // Extract the archive payload int r = pakfire_archive_extract(archive, NULL, PAKFIRE_ARCHIVE_USE_PAYLOAD); @@ -93,7 +94,7 @@ static int test_import(const struct test* t) { char* path = pakfire_path_join(TEST_SRC_PATH, TEST_PKG1_PATH); PakfireArchive archive = pakfire_archive_open(t->pakfire, path); - pakfire_free(path); + free(path); PakfireRepo repo = pakfire_repo_create(t->pakfire, "tmp"); ASSERT(repo); diff --git a/tests/libpakfire/key.c b/tests/libpakfire/key.c index d434f532b..3905f0fac 100644 --- a/tests/libpakfire/key.c +++ b/tests/libpakfire/key.c @@ -18,6 +18,7 @@ # # #############################################################################*/ +#include #include #include @@ -73,14 +74,14 @@ static int test_import_export(const struct test* t) { char* dump = pakfire_key_dump(key); ASSERT(dump); LOG("%s\n", dump); - pakfire_free(dump); + free(dump); // Export the key char* data = pakfire_key_export(key, 0); ASSERT(data); LOG("Exported key:\n%s\n", data); - pakfire_free(data); + free(data); pakfire_key_unref(key); diff --git a/tests/libpakfire/makefile.c b/tests/libpakfire/makefile.c index 02205b0c0..c0b839a93 100644 --- a/tests/libpakfire/makefile.c +++ b/tests/libpakfire/makefile.c @@ -18,6 +18,7 @@ # # #############################################################################*/ +#include #include #include @@ -42,10 +43,10 @@ static int test_parse(const struct test* t) { ASSERT(value); printf("VALUE: sources = %s\n", value); - pakfire_free(value); + free(value); // Cleanup - pakfire_free(path); + free(path); pakfire_parser_unref(parser); diff --git a/tests/libpakfire/parser.c b/tests/libpakfire/parser.c index cb23b2fed..941cb41bc 100644 --- a/tests/libpakfire/parser.c +++ b/tests/libpakfire/parser.c @@ -18,6 +18,7 @@ # # #############################################################################*/ +#include #include #include @@ -97,7 +98,7 @@ static int test_parser(const struct test* t) { // Cleanup pakfire_parser_unref(subparser); pakfire_parser_unref(parser); - pakfire_free(value); + free(value); return EXIT_SUCCESS; } diff --git a/tests/libpakfire/util.c b/tests/libpakfire/util.c index 5021801a4..b8ee61d41 100644 --- a/tests/libpakfire/util.c +++ b/tests/libpakfire/util.c @@ -18,6 +18,7 @@ # # #############################################################################*/ +#include #include #include @@ -30,7 +31,7 @@ static int test_basename(const struct test* t) { char* output = pakfire_basename(dir); ASSERT_STRING_EQUALS(output, "c"); - pakfire_free(output); + free(output); return EXIT_SUCCESS; } @@ -40,7 +41,7 @@ static int test_dirname(const struct test* t) { char* output = pakfire_dirname(dir); ASSERT_STRING_EQUALS(output, "/a/b"); - pakfire_free(output); + free(output); return EXIT_SUCCESS; }