diff options
author | Matthieu Herrb <matthieu@cvs.openbsd.org> | 2024-11-11 09:19:14 +0000 |
---|---|---|
committer | Matthieu Herrb <matthieu@cvs.openbsd.org> | 2024-11-11 09:19:14 +0000 |
commit | 29b8e9a9a25ae4b3d253f60b552ed8b9803a551b (patch) | |
tree | 0c31dce09e1769b7239414a1d17215e577bf9457 /app/bdftopcf/atom.c | |
parent | 5e5a5a104964facd1dbf587ced73da2c9c800b23 (diff) |
update to bdftopcf 1.1.2
Diffstat (limited to 'app/bdftopcf/atom.c')
-rw-r--r-- | app/bdftopcf/atom.c | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/app/bdftopcf/atom.c b/app/bdftopcf/atom.c index f60191f4b..3f02ec33f 100644 --- a/app/bdftopcf/atom.c +++ b/app/bdftopcf/atom.c @@ -44,34 +44,32 @@ typedef struct _AtomList { static AtomListPtr *hashTable; -static int hashSize, hashUsed; -static int hashMask; -static int rehash; +static unsigned hashSize, hashUsed; +static unsigned hashMask; +static unsigned rehash; static AtomListPtr *reverseMap; static size_t reverseMapSize; static Atom lastAtom; -static int -Hash(const char *string, int len) +static unsigned +Hash(const char *string, unsigned len) { - int h; + unsigned h = 0; - h = 0; while (len--) h = (h << 3) ^ *string++; - if (h < 0) - return -h; + return h; } static int ResizeHashTable(void) { - int newHashSize; - int newHashMask; + unsigned newHashSize; + unsigned newHashMask; AtomListPtr *newHashTable; - int newRehash; + unsigned newRehash; if (hashSize == 0) newHashSize = 1024; @@ -88,9 +86,9 @@ ResizeHashTable(void) newRehash = (newHashMask - 2); for (int i = 0; i < hashSize; i++) { if (hashTable[i]) { - int h = (hashTable[i]->hash) & newHashMask; + unsigned h = (hashTable[i]->hash) & newHashMask; if (newHashTable[h]) { - int r = hashTable[i]->hash % newRehash | 1; + unsigned r = hashTable[i]->hash % newRehash | 1; do { h += r; if (h >= newHashSize) @@ -143,9 +141,9 @@ Atom MakeAtom(const char *string, unsigned len, int makeit) { AtomListPtr a; - int hash; - int h = 0; - int r; + unsigned hash; + unsigned h = 0; + unsigned r; hash = Hash(string, len); if (hashTable) { |