[pacman-dev] [PATCH 3/4] When setting package name, set hash value as well
Dan McGee
dan at archlinux.org
Tue Dec 14 13:46:18 EST 2010
Signed-off-by: Dan McGee <dan at archlinux.org>
---
lib/libalpm/be_package.c | 1 +
lib/libalpm/package.c | 1 +
lib/libalpm/package.h | 1 +
lib/libalpm/util.c | 1 +
4 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/lib/libalpm/be_package.c b/lib/libalpm/be_package.c
index ae95194..32ec993 100644
--- a/lib/libalpm/be_package.c
+++ b/lib/libalpm/be_package.c
@@ -179,6 +179,7 @@ static int parse_descfile(struct archive *a, pmpkg_t *newpkg)
ptr = _alpm_strtrim(ptr);
if(strcmp(key, "pkgname") == 0) {
STRDUP(newpkg->name, ptr, RET_ERR(PM_ERR_MEMORY, -1));
+ newpkg->name_hash = _alpm_hash_sdbm(newpkg->name);
} else if(strcmp(key, "pkgver") == 0) {
STRDUP(newpkg->version, ptr, RET_ERR(PM_ERR_MEMORY, -1));
} else if(strcmp(key, "pkgdesc") == 0) {
diff --git a/lib/libalpm/package.c b/lib/libalpm/package.c
index 57ab9a6..5b479b4 100644
--- a/lib/libalpm/package.c
+++ b/lib/libalpm/package.c
@@ -414,6 +414,7 @@ pmpkg_t *_alpm_pkg_dup(pmpkg_t *pkg)
CALLOC(newpkg, 1, sizeof(pmpkg_t), RET_ERR(PM_ERR_MEMORY, NULL));
+ newpkg->name_hash = pkg->name_hash;
STRDUP(newpkg->filename, pkg->filename, RET_ERR(PM_ERR_MEMORY, newpkg));
STRDUP(newpkg->name, pkg->name, RET_ERR(PM_ERR_MEMORY, newpkg));
STRDUP(newpkg->version, pkg->version, RET_ERR(PM_ERR_MEMORY, newpkg));
diff --git a/lib/libalpm/package.h b/lib/libalpm/package.h
index 9a6f0cb..d1abb55 100644
--- a/lib/libalpm/package.h
+++ b/lib/libalpm/package.h
@@ -89,6 +89,7 @@ struct pkg_operations {
extern struct pkg_operations default_pkg_ops;
struct __pmpkg_t {
+ unsigned long name_hash;
char *filename;
char *name;
char *version;
diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c
index 8e83bda..1291ea0 100644
--- a/lib/libalpm/util.c
+++ b/lib/libalpm/util.c
@@ -840,6 +840,7 @@ int _alpm_splitname(const char *target, pmpkg_t *pkg)
FREE(pkg->name);
}
STRDUP(pkg->name, tmp, RET_ERR(PM_ERR_MEMORY, -1));
+ pkg->name_hash = _alpm_hash_sdbm(pkg->name);
free(tmp);
return(0);
--
1.7.3.3
More information about the pacman-dev
mailing list