From 0e04c09d4896fe6ba1431c5383bde24983ed1f1f Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Fri, 21 May 2010 15:36:03 +0300 Subject: [PATCH] Move the lone hashFunctionString() into misc.[ch], eliminate rpmhash.[ch] - Besides there not being much point in having a separate source + header for a small single function, this fixes build on case-insensitive systems such as Mac OS X. --- lib/Makefile.am | 2 +- lib/depends.c | 1 + lib/fprint.c | 2 +- lib/misc.c | 17 +++++++++++++++++ lib/misc.h | 2 ++ lib/rpmal.c | 2 +- lib/rpmhash.c | 24 ------------------------ lib/rpmhash.h | 22 ---------------------- lib/rpmts_internal.h | 1 - lib/transaction.c | 1 + po/POTFILES.in | 1 - 11 files changed, 24 insertions(+), 51 deletions(-) delete mode 100644 lib/rpmhash.c delete mode 100644 lib/rpmhash.h diff --git a/lib/Makefile.am b/lib/Makefile.am index fa3288d..c5a962c 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -21,7 +21,7 @@ usrlib_LTLIBRARIES = librpm.la librpm_la_SOURCES = \ backend/dbconfig.c backend/db3.c backend/dbi.h \ headerutil.c header.c headerfmt.c header_internal.h \ - poptDB.c rpmhash.c rpmhash.h rpmdb.c rpmdb_internal.h \ + poptDB.c rpmdb.c rpmdb_internal.h \ fprint.c fprint.h tagname.c rpmtd.c \ cpio.c cpio.h depends.c order.c formats.c tagexts.c fsm.c fsm.h \ manifest.c manifest.h misc.c package.c \ diff --git a/lib/depends.c b/lib/depends.c index d9b392c..1dc411a 100644 --- a/lib/depends.c +++ b/lib/depends.c @@ -15,6 +15,7 @@ #include "lib/rpmts_internal.h" #include "lib/rpmte_internal.h" +#include "lib/misc.h" #include "debug.h" diff --git a/lib/fprint.c b/lib/fprint.c index c04c8af..2289224 100644 --- a/lib/fprint.c +++ b/lib/fprint.c @@ -9,7 +9,7 @@ #include "lib/rpmdb_internal.h" #include "lib/rpmfi_internal.h" #include "lib/fprint.h" -#include "lib/rpmhash.h" +#include "lib/misc.h" #include "debug.h" #include diff --git a/lib/misc.c b/lib/misc.c index 1cbcaa3..66fed8e 100644 --- a/lib/misc.c +++ b/lib/misc.c @@ -15,6 +15,23 @@ /* just to put a marker in librpm.a */ const char * const RPMVERSION = VERSION; +unsigned int hashFunctionString(const char * string) +{ + /* Jenkins One-at-a-time hash */ + unsigned int hash = 0xe4721b68; + + while (*string != '\0') { + hash += *string; + hash += (hash << 10); + hash ^= (hash >> 6); + string++; + } + hash += (hash << 3); + hash ^= (hash >> 11); + hash += (hash << 15); + return hash; +} + /* unameToUid(), uidTouname() and the group variants are really poorly implemented. They really ought to use hash tables. I just made the guess that most files would be owned by root or the same person/group diff --git a/lib/misc.h b/lib/misc.h index e2a5453..fb78b02 100644 --- a/lib/misc.h +++ b/lib/misc.h @@ -17,6 +17,8 @@ extern "C" { RPM_GNUC_INTERNAL int rpmIsKnownArch(const char *name); +RPM_GNUC_INTERNAL +unsigned int hashFunctionString(const char * string); /* * These may be called w/ a NULL argument to flush the cache -- they return * -1 if the user can't be found. diff --git a/lib/rpmal.c b/lib/rpmal.c index bf36a4b..abe44b3 100644 --- a/lib/rpmal.c +++ b/lib/rpmal.c @@ -10,7 +10,7 @@ #include #include "lib/rpmal.h" -#include "lib/rpmhash.h" +#include "lib/misc.h" #include "debug.h" diff --git a/lib/rpmhash.c b/lib/rpmhash.c deleted file mode 100644 index 34be313..0000000 --- a/lib/rpmhash.c +++ /dev/null @@ -1,24 +0,0 @@ -/** - * \file lib/rpmhash.c - * Hash table implemenation - */ - -#include "lib/rpmhash.h" - - -unsigned int hashFunctionString(const char * string) { - /* Jenkins One-at-a-time hash */ - - unsigned int hash = 0xe4721b68; - - while (*string != '\0') { - hash += *string; - hash += (hash << 10); - hash ^= (hash >> 6); - string++; - } - hash += (hash << 3); - hash ^= (hash >> 11); - hash += (hash << 15); - return hash; -} diff --git a/lib/rpmhash.h b/lib/rpmhash.h deleted file mode 100644 index 57cc290..0000000 --- a/lib/rpmhash.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef H_RPMHASH -#define H_RPMHASH - -#include "rpm/rpmutil.h" - -/** - * \file lib/rpmhash.h - * Hash table implemenation. - */ - -#ifdef __cplusplus -extern "C" { -#endif - -RPM_GNUC_INTERNAL -unsigned int hashFunctionString(const char * string); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/lib/rpmts_internal.h b/lib/rpmts_internal.h index f70401a..b8a22d6 100644 --- a/lib/rpmts_internal.h +++ b/lib/rpmts_internal.h @@ -4,7 +4,6 @@ #include #include "lib/rpmal.h" /* XXX availablePackage */ -#include "lib/rpmhash.h" /* XXX hashTable */ #include "lib/fprint.h" #include "lib/rpmlock.h" diff --git a/lib/transaction.c b/lib/transaction.c index 0f825d6..6771dbd 100644 --- a/lib/transaction.c +++ b/lib/transaction.c @@ -13,6 +13,7 @@ #include #include "lib/fprint.h" +#include "lib/misc.h" #include "lib/rpmlock.h" #include "lib/rpmfi_internal.h" /* only internal apis */ #include "lib/rpmte_internal.h" /* only internal apis */ diff --git a/po/POTFILES.in b/po/POTFILES.in index 2041062..2173152 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -63,7 +63,6 @@ lib/headerfmt.c lib/merge.c lib/poptDB.c lib/rpmdb.c -lib/rpmhash.c lib/tagexts.c lib/tagname.c lib/backend/db3.c -- 2.7.4