From dff2d916baac88b71dec0af81645ea2fe876cf6c Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Mon, 28 Mar 2011 12:54:47 -0500 Subject: Remove indirection on get_name and get_version operations For a package to be loaded from any of our backends, these two fields are always required upfront. Due to this fact, we don't need them to be backend-specific operations and can just refer to the field directly. Additionally, our static (and thus private) cache package accessors had a NULL check on pkg before returning the relevant field. Eliminate this since they only way they are ever called is via the packages attached callback struct, which would have caused the NULL pointer dereference in the first place. Signed-off-by: Dan McGee --- lib/libalpm/package.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'lib/libalpm/package.c') diff --git a/lib/libalpm/package.c b/lib/libalpm/package.c index 59a1283b..3a4f23fd 100644 --- a/lib/libalpm/package.c +++ b/lib/libalpm/package.c @@ -99,8 +99,6 @@ int SYMEXPORT alpm_pkg_checkmd5sum(pmpkg_t *pkg) * a lazy-load cache. However, the defaults will work just fine for fully- * populated package structures. */ static const char *_pkg_get_filename(pmpkg_t *pkg) { return pkg->filename; } -static const char *_pkg_get_name(pmpkg_t *pkg) { return pkg->name; } -static const char *_pkg_get_version(pmpkg_t *pkg) { return pkg->version; } static const char *_pkg_get_desc(pmpkg_t *pkg) { return pkg->desc; } static const char *_pkg_get_url(pmpkg_t *pkg) { return pkg->url; } static time_t _pkg_get_builddate(pmpkg_t *pkg) { return pkg->builddate; } @@ -133,8 +131,6 @@ static int _pkg_changelog_close(const pmpkg_t *pkg, void *fp) { return EOF; } */ struct pkg_operations default_pkg_ops = { .get_filename = _pkg_get_filename, - .get_name = _pkg_get_name, - .get_version = _pkg_get_version, .get_desc = _pkg_get_desc, .get_url = _pkg_get_url, .get_builddate = _pkg_get_builddate, @@ -173,12 +169,12 @@ const char SYMEXPORT *alpm_pkg_get_filename(pmpkg_t *pkg) const char SYMEXPORT *alpm_pkg_get_name(pmpkg_t *pkg) { - return pkg->ops->get_name(pkg); + return pkg->name; } const char SYMEXPORT *alpm_pkg_get_version(pmpkg_t *pkg) { - return pkg->ops->get_version(pkg); + return pkg->version; } const char SYMEXPORT *alpm_pkg_get_desc(pmpkg_t *pkg) -- cgit v1.2.3