aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Anvin <hpa@tazenda.(none)>2005-12-08 11:29:39 -0800
committerPeter Anvin <hpa@tazenda.(none)>2005-12-08 11:29:39 -0800
commiteffaa8733130df5347a57610b2c6b14ee8ea07b5 (patch)
tree6fb66b287bcc5028abdde242284691040774cbd3
parent2e3ef5af21d57aaa8af9fb1fca3b7a938b2b39c5 (diff)
downloadlibucd-effaa8733130df5347a57610b2c6b14ee8ea07b5.tar.gz
Protoize the source
-rw-r--r--perfect/lookupa.c13
-rw-r--r--perfect/lookupa.h4
-rw-r--r--perfect/perfect.c240
-rw-r--r--perfect/perfect.h9
-rw-r--r--perfect/perfhex.c69
-rw-r--r--perfect/recycle.c13
-rw-r--r--perfect/recycle.h8
7 files changed, 148 insertions, 208 deletions
diff --git a/perfect/lookupa.c b/perfect/lookupa.c
index 9764a3f..28225c6 100644
--- a/perfect/lookupa.c
+++ b/perfect/lookupa.c
@@ -79,10 +79,10 @@ acceptable. Do NOT use for cryptographic purposes.
--------------------------------------------------------------------
*/
-uint32_t lookup( k, length, level)
-register uint8_t *k; /* the key */
-register uint32_t length; /* the length of the key */
-register uint32_t level; /* the previous hash, or an arbitrary value */
+uint32_t lookup(register uint8_t *k, register uint32_t length, register uint32_t level)
+ /* the key */
+ /* the length of the key */
+ /* the previous hash, or an arbitrary value */
{
register uint32_t a,b,c,len;
@@ -167,10 +167,7 @@ Use to detect changes between revisions of documents, assuming nobody
is trying to cause collisions. Do NOT use for cryptography.
--------------------------------------------------------------------
*/
-void checksum( k, len, state)
-register uint8_t *k;
-register uint32_t len;
-register uint32_t *state;
+void checksum(register uint8_t *k, register uint32_t len, register uint32_t *state)
{
register uint32_t a,b,c,d,e,f,g,h,length;
diff --git a/perfect/lookupa.h b/perfect/lookupa.h
index 56b1fcd..675600c 100644
--- a/perfect/lookupa.h
+++ b/perfect/lookupa.h
@@ -18,7 +18,7 @@ Source is http://burtleburtle.net/bob/c/lookupa.h
#define hashsize(n) ((uint32_t)1<<(n))
#define hashmask(n) (hashsize(n)-1)
-uint32_t lookup(/*_ ub1 *k, uint32_t length, uint32_t level _*/);
-void checksum(/*_ ub1 *k, uint32_t length, uint32_t *state _*/);
+uint32_t lookup(register uint8_t *k, register uint32_t length, register uint32_t level);
+void checksum(register uint8_t *k, register uint32_t len, register uint32_t *state);
#endif /* LOOKUPA */
diff --git a/perfect/perfect.c b/perfect/perfect.c
index 2035621..105ac1e 100644
--- a/perfect/perfect.c
+++ b/perfect/perfect.c
@@ -67,8 +67,7 @@ Find the mapping that will produce a perfect hash
*/
/* return the ceiling of the log (base 2) of val */
-uint32_t ilog2(val)
-uint32_t val;
+uint32_t ilog2(uint32_t val)
{
uint32_t i;
for (i=0; ((uint32_t)1<<i) < val; ++i)
@@ -78,9 +77,9 @@ uint32_t val;
/* compute p(x), where p is a permutation of 0..(1<<nbits)-1 */
/* permute(0)=0. This is intended and useful. */
-static uint32_t permute(x, nbits)
-uint32_t x; /* input, a value in some range */
-uint32_t nbits; /* input, number of bits in range */
+static uint32_t permute(uint32_t x, uint32_t nbits)
+ /* input, a value in some range */
+ /* input, number of bits in range */
{
int i;
int mask = ((uint32_t)1<<nbits)-1; /* all ones */
@@ -99,9 +98,9 @@ uint32_t nbits; /* input, number of bits in rang
}
/* initialize scramble[] with distinct random values in 0..smax-1 */
-static void scrambleinit(scramble, smax)
-uint32_t *scramble; /* hash is a^scramble[tab[b]] */
-uint32_t smax; /* scramble values should be in 0..smax-1 */
+static void scrambleinit(uint32_t *scramble, uint32_t smax)
+ /* hash is a^scramble[tab[b]] */
+ /* scramble values should be in 0..smax-1 */
{
uint32_t i;
@@ -116,10 +115,7 @@ uint32_t smax; /* scramble values should be in 0..smax-
* Check if key1 and key2 are the same.
* We already checked (a,b) are the same.
*/
-static void checkdup(key1, key2, form)
-key *key1;
-key *key2;
-hashform *form;
+static void checkdup(key *key1, key *key2, hashform *form)
{
switch(form->hashtype)
{
@@ -156,12 +152,12 @@ hashform *form;
* put keys in tabb according to key->b_k
* check if the initial hash might work
*/
-static int inittab(tabb, blen, keys, form, complete)
-bstuff *tabb; /* output, list of keys with b for (a,b) */
-uint32_t blen; /* length of tabb */
-key *keys; /* list of keys already hashed */
-hashform *form; /* user directives */
-int complete; /* TRUE means to complete init despite collisions */
+static int inittab(bstuff *tabb, uint32_t blen, key *keys, hashform *form, int complete)
+ /* output, list of keys with b for (a,b) */
+ /* length of tabb */
+ /* list of keys already hashed */
+ /* user directives */
+ /* TRUE means to complete init despite collisions */
{
int nocollision = TRUE;
key *mykey;
@@ -196,13 +192,13 @@ int complete; /* TRUE means to complete init despite collisions */
/* Do the initial hash for normal mode (use lookup and checksum) */
-static void initnorm(keys, alen, blen, smax, salt, final)
-key *keys; /* list of all keys */
-uint32_t alen; /* (a,b) has a in 0..alen-1, a power of 2 */
-uint32_t blen; /* (a,b) has b in 0..blen-1, a power of 2 */
-uint32_t smax; /* maximum range of computable hash values */
-uint32_t salt; /* used to initialize the hash function */
-gencode *final; /* output, code for the final hash */
+static void initnorm(key *keys, uint32_t alen, uint32_t blen, uint32_t smax, uint32_t salt, gencode *final)
+ /* list of all keys */
+ /* (a,b) has a in 0..alen-1, a power of 2 */
+ /* (a,b) has b in 0..blen-1, a power of 2 */
+ /* maximum range of computable hash values */
+ /* used to initialize the hash function */
+ /* output, code for the final hash */
{
key *mykey;
if (ilog2(alen)+ilog2(blen) > 32)
@@ -262,13 +258,13 @@ gencode *final; /* output, code for the final hash */
/* Do initial hash for inline mode */
-static void initinl(keys, alen, blen, smax, salt, final)
-key *keys; /* list of all keys */
-uint32_t alen; /* (a,b) has a in 0..alen-1, a power of 2 */
-uint32_t blen; /* (a,b) has b in 0..blen-1, a power of 2 */
-uint32_t smax; /* range of computable hash values */
-uint32_t salt; /* used to initialize the hash function */
-gencode *final; /* generated code for final hash */
+static void initinl(key *keys, uint32_t alen, uint32_t blen, uint32_t smax, uint32_t salt, gencode *final)
+ /* list of all keys */
+ /* (a,b) has a in 0..alen-1, a power of 2 */
+ /* (a,b) has b in 0..blen-1, a power of 2 */
+ /* range of computable hash values */
+ /* used to initialize the hash function */
+ /* generated code for final hash */
{
key *mykey;
uint32_t amask = alen-1;
@@ -313,16 +309,16 @@ gencode *final; /* generated code for final hash */
* 1: found distinct (a,b) for all keys, put keys in tabb[]
* 2: found a perfect hash, no need to do any more work
*/
-static uint32_t initkey(keys, nkeys, tabb, alen, blen, smax, salt, form, final)
-key *keys; /* list of all keys */
-uint32_t nkeys; /* total number of keys */
-bstuff *tabb; /* stuff indexed by b */
-uint32_t alen; /* (a,b) has a in 0..alen-1, a power of 2 */
-uint32_t blen; /* (a,b) has b in 0..blen-1, a power of 2 */
-uint32_t smax; /* range of computable hash values */
-uint32_t salt; /* used to initialize the hash function */
-hashform *form; /* user directives */
-gencode *final; /* code for final hash */
+static uint32_t initkey(key *keys, uint32_t nkeys, bstuff *tabb, uint32_t alen, uint32_t blen, uint32_t smax, uint32_t salt, hashform *form, gencode *final)
+ /* list of all keys */
+ /* total number of keys */
+ /* stuff indexed by b */
+ /* (a,b) has a in 0..alen-1, a power of 2 */
+ /* (a,b) has b in 0..blen-1, a power of 2 */
+ /* range of computable hash values */
+ /* used to initialize the hash function */
+ /* user directives */
+ /* code for final hash */
{
uint32_t finished;
@@ -356,11 +352,11 @@ gencode *final; /* code for final hash */
}
/* Print an error message and exit if there are duplicates */
-static void duplicates(tabb, blen, keys, form)
-bstuff *tabb; /* array of lists of keys with the same b */
-uint32_t blen; /* length of tabb, a power of 2 */
-key *keys;
-hashform *form; /* user directives */
+static void duplicates(bstuff *tabb, uint32_t blen, key *keys, hashform *form)
+ /* array of lists of keys with the same b */
+ /* length of tabb, a power of 2 */
+
+ /* user directives */
{
uint32_t i;
key *key1;
@@ -377,14 +373,14 @@ hashform *form; /* user directives */
/* Try to apply an augmenting list */
-static int apply(tabb, tabh, tabq, blen, scramble, tail, rollback)
-bstuff *tabb;
-hstuff *tabh;
-qstuff *tabq;
-uint32_t blen;
-uint32_t *scramble;
-uint32_t tail;
-int rollback; /* FALSE applies augmenting path, TRUE rolls back */
+static int apply(bstuff *tabb, hstuff *tabh, qstuff *tabq, uint32_t blen, uint32_t *scramble, uint32_t tail, int rollback)
+
+
+
+
+
+
+ /* FALSE applies augmenting path, TRUE rolls back */
{
uint32_t hash;
key *mykey;
@@ -454,18 +450,17 @@ an unused node is found. Sum(i=1..n)(n/i) is about nlogn, so expect
this approach to take about nlogn time to map all single-key b's.
-------------------------------------------------------------------------------
*/
-static int augment(tabb, tabh, tabq, blen, scramble, smax, item, nkeys,
- highwater, form)
-bstuff *tabb; /* stuff indexed by b */
-hstuff *tabh; /* which key is associated with which hash, indexed by hash */
-qstuff *tabq; /* queue of *b* values, this is the spanning tree */
-uint32_t blen; /* length of tabb */
-uint32_t *scramble; /* final hash is a^scramble[tab[b]] */
-uint32_t smax; /* highest value in scramble */
-bstuff *item; /* &tabb[b] for the b to be mapped */
-uint32_t nkeys; /* final hash must be in 0..nkeys-1 */
-uint32_t highwater; /* a value higher than any now in tabb[].water_b */
-hashform *form; /* TRUE if we should do a minimal perfect hash */
+static int augment(bstuff *tabb, hstuff *tabh, qstuff *tabq, uint32_t blen, uint32_t *scramble, uint32_t smax, bstuff *item, uint32_t nkeys, uint32_t highwater, hashform *form)
+ /* stuff indexed by b */
+ /* which key is associated with which hash, indexed by hash */
+ /* queue of *b* values, this is the spanning tree */
+ /* length of tabb */
+ /* final hash is a^scramble[tab[b]] */
+ /* highest value in scramble */
+ /* &tabb[b] for the b to be mapped */
+ /* final hash must be in 0..nkeys-1 */
+ /* a value higher than any now in tabb[].water_b */
+ /* TRUE if we should do a minimal perfect hash */
{
uint32_t q; /* current position walking through the queue */
uint32_t tail; /* tail of the queue. 0 is the head of the queue. */
@@ -539,15 +534,7 @@ hashform *form; /* TRUE if we should do a minimal perfect hash */
/* find a mapping that makes this a perfect hash */
-static int perfect(tabb, tabh, tabq, blen, smax, scramble, nkeys, form)
-bstuff *tabb;
-hstuff *tabh;
-qstuff *tabq;
-uint32_t blen;
-uint32_t smax;
-uint32_t *scramble;
-uint32_t nkeys;
-hashform *form;
+static int perfect(bstuff *tabb, hstuff *tabh, qstuff *tabq, uint32_t blen, uint32_t smax, uint32_t *scramble, uint32_t nkeys, hashform *form)
{
uint32_t maxkeys; /* maximum number of keys for any b */
uint32_t i, j;
@@ -582,18 +569,17 @@ hashform *form;
* Simple case: user gave (a,b). No more mixing, no guessing alen or blen.
* This assumes a,b reside in (key->a_k, key->b_k), and final->form == AB_HK.
*/
-static void hash_ab(tabb, alen, blen, salt, final,
- scramble, smax, keys, nkeys, form)
-bstuff **tabb; /* output, tab[] of the perfect hash, length *blen */
-uint32_t *alen; /* output, 0..alen-1 is range for a of (a,b) */
-uint32_t *blen; /* output, 0..blen-1 is range for b of (a,b) */
-uint32_t *salt; /* output, initializes initial hash */
-gencode *final; /* code for final hash */
-uint32_t *scramble; /* input, hash = a^scramble[tab[b]] */
-uint32_t *smax; /* input, scramble[i] in 0..smax-1 */
-key *keys; /* input, keys to hash */
-uint32_t nkeys; /* input, number of keys being hashed */
-hashform *form; /* user directives */
+static void hash_ab(bstuff **tabb, uint32_t *alen, uint32_t *blen, uint32_t *salt, gencode *final, uint32_t *scramble, uint32_t *smax, key *keys, uint32_t nkeys, hashform *form)
+ /* output, tab[] of the perfect hash, length *blen */
+ /* output, 0..alen-1 is range for a of (a,b) */
+ /* output, 0..blen-1 is range for b of (a,b) */
+ /* output, initializes initial hash */
+ /* code for final hash */
+ /* input, hash = a^scramble[tab[b]] */
+ /* input, scramble[i] in 0..smax-1 */
+ /* input, keys to hash */
+ /* input, number of keys being hashed */
+ /* user directives */
{
hstuff *tabh;
qstuff *tabq;
@@ -689,12 +675,12 @@ hashform *form; /* user directives */
/* guess initial values for alen and blen */
-static void initalen(alen, blen, smax, nkeys, form)
-uint32_t *alen; /* output, initial alen */
-uint32_t *blen; /* output, initial blen */
-uint32_t *smax; /* input, power of two greater or equal to max hash value */
-uint32_t nkeys; /* number of keys being hashed */
-hashform *form; /* user directives */
+static void initalen(uint32_t *alen, uint32_t *blen, uint32_t *smax, uint32_t nkeys, hashform *form)
+ /* output, initial alen */
+ /* output, initial blen */
+ /* input, power of two greater or equal to max hash value */
+ /* number of keys being hashed */
+ /* user directives */
{
/*
* Find initial *alen, *blen
@@ -822,18 +808,17 @@ hashform *form; /* user directives */
** Return the successful initializer for the initial hash.
** Return 0 if no perfect hash could be found.
*/
-void findhash(tabb, alen, blen, salt, final,
- scramble, smax, keys, nkeys, form)
-bstuff **tabb; /* output, tab[] of the perfect hash, length *blen */
-uint32_t *alen; /* output, 0..alen-1 is range for a of (a,b) */
-uint32_t *blen; /* output, 0..blen-1 is range for b of (a,b) */
-uint32_t *salt; /* output, initializes initial hash */
-gencode *final; /* code for final hash */
-uint32_t *scramble; /* input, hash = a^scramble[tab[b]] */
-uint32_t *smax; /* input, scramble[i] in 0..smax-1 */
-key *keys; /* input, keys to hash */
-uint32_t nkeys; /* input, number of keys being hashed */
-hashform *form; /* user directives */
+void findhash(bstuff **tabb, uint32_t *alen, uint32_t *blen, uint32_t *salt, gencode *final, uint32_t *scramble, uint32_t *smax, key *keys, uint32_t nkeys, hashform *form)
+ /* output, tab[] of the perfect hash, length *blen */
+ /* output, 0..alen-1 is range for a of (a,b) */
+ /* output, 0..blen-1 is range for b of (a,b) */
+ /* output, initializes initial hash */
+ /* code for final hash */
+ /* input, hash = a^scramble[tab[b]] */
+ /* input, scramble[i] in 0..smax-1 */
+ /* input, keys to hash */
+ /* input, number of keys being hashed */
+ /* user directives */
{
uint32_t bad_initkey; /* how many times did initkey fail? */
uint32_t bad_perfect; /* how many times did perfect fail? */
@@ -963,12 +948,12 @@ Input/output type routines
*/
/* get the list of keys */
-static void getkeys(keys, nkeys, textroot, keyroot, form)
-key **keys; /* list of all keys */
-uint32_t *nkeys; /* number of keys */
-reroot *textroot; /* get space to store key text */
-reroot *keyroot; /* get space for keys */
-hashform *form; /* user directives */
+static void getkeys(key **keys, uint32_t *nkeys, reroot *textroot, reroot *keyroot, hashform *form)
+ /* list of all keys */
+ /* number of keys */
+ /* get space to store key text */
+ /* get space for keys */
+ /* user directives */
{
key *mykey;
char *mytext;
@@ -1008,12 +993,7 @@ hashform *form; /* user directives */
}
/* make the .h file */
-static void make_h(blen, smax, nkeys, salt, form)
-uint32_t blen;
-uint32_t smax;
-uint32_t nkeys;
-uint32_t salt;
-hashform *form;
+static void make_h(uint32_t blen, uint32_t smax, uint32_t nkeys, uint32_t salt, hashform *form)
{
FILE *f;
char *guard_token, *q;
@@ -1086,13 +1066,13 @@ hashform *form;
}
/* make the .c file */
-static void make_c(tab, smax, blen, scramble, final, form)
-bstuff *tab; /* table indexed by b */
-uint32_t smax; /* range of scramble[] */
-uint32_t blen; /* b in 0..blen-1, power of 2 */
-uint32_t *scramble; /* used in final hash */
-gencode *final; /* code for the final hash */
-hashform *form; /* user directives */
+static void make_c(bstuff *tab, uint32_t smax, uint32_t blen, uint32_t *scramble, gencode *final, hashform *form)
+ /* table indexed by b */
+ /* range of scramble[] */
+ /* b in 0..blen-1, power of 2 */
+ /* used in final hash */
+ /* code for the final hash */
+ /* user directives */
{
uint32_t i;
FILE *f;
@@ -1203,8 +1183,8 @@ hashform *form; /* user directives */
Read in the keys, find the hash, and write the .c and .h files
------------------------------------------------------------------------------
*/
-static void driver(form)
-hashform *form; /* user directives */
+static void driver(hashform *form)
+ /* user directives */
{
uint32_t nkeys; /* number of keys */
key *keys; /* head of list of keys */
@@ -1256,7 +1236,7 @@ hashform *form; /* user directives */
/* Describe how to use this utility */
-static void usage_error()
+static void usage_error(void)
{
printf("Usage: perfect [-{NnIiHhDdAaBb}{MmPp}{FfSs}] [func_name [output_file [header_name]]]< key.txt \n");
printf("The input is a list of keys, one key per line.\n");
@@ -1291,9 +1271,7 @@ static void usage_error()
/* Interpret arguments and call the driver */
/* See usage_error for the expected arguments */
-int main(argc, argv)
-int argc;
-char **argv;
+int main(int argc, char **argv)
{
int mode_given = FALSE;
int minimal_given = FALSE;
diff --git a/perfect/perfect.h b/perfect/perfect.h
index 3884454..d1ac70a 100644
--- a/perfect/perfect.h
+++ b/perfect/perfect.h
@@ -118,15 +118,12 @@ struct qstuff
typedef struct qstuff qstuff;
/* return ceiling(log based 2 of x) */
-uint32_t ilog2(/*_ uint32_t x _*/);
+uint32_t ilog2(uint32_t val);
/* Given the keys, scramble[], and hash mode, find the perfect hash */
-void findhash(/*_ bstuff **tabb, uint32_t *alen, uint32_t *blen, uint32_t *salt,
- gencode *final, uint32_t *scramble, uint32_t smax, key *keys, uint32_t nkeys,
- hashform *form _*/);
+void findhash(bstuff **tabb, uint32_t *alen, uint32_t *blen, uint32_t *salt, gencode *final, uint32_t *scramble, uint32_t *smax, key *keys, uint32_t nkeys, hashform *form);
/* private, but in a different file because it's excessively verbose */
-int inithex(/*_ key *keys, uint32_t *alen, uint32_t *blen, uint32_t smax, uint32_t nkeys,
- uint32_t salt, gencode *final, gencode *form _*/);
+int inithex(key *keys, uint32_t nkeys, uint32_t alen, uint32_t blen, uint32_t smax, uint32_t salt, gencode *final, hashform *form);
#endif /* PERFECT */
diff --git a/perfect/perfhex.c b/perfect/perfhex.c
index f234f56..8dbedf0 100644
--- a/perfect/perfhex.c
+++ b/perfect/perfhex.c
@@ -31,9 +31,7 @@ those pairs.
* Find a perfect hash when there is only one key. Zero instructions.
* Hint: the one key always hashes to 0
*/
-static void hexone(keys, final)
-key *keys;
-gencode *final;
+static void hexone(key *keys, gencode *final)
{
/* 1 key: the hash is always 0 */
keys->a_k = 0;
@@ -49,9 +47,7 @@ gencode *final;
* There exists a bit that is different for the two keys. Test it.
* Note that a perfect hash of 2 keys is automatically minimal.
*/
-static void hextwo(keys, final)
-key *keys;
-gencode *final;
+static void hextwo(key *keys, gencode *final)
{
uint32_t a = keys->hash_k;
uint32_t b = keys->next_k->hash_k;
@@ -87,10 +83,7 @@ gencode *final;
* find the value to xor to a and b and c to make none of them 3
* assert, (a,b,c) are three distinct values in (0,1,2,3).
*/
-static uint32_t find_adder(a,b,c)
-uint32_t a;
-uint32_t b;
-uint32_t c;
+static uint32_t find_adder(uint32_t a, uint32_t b, uint32_t c)
{
return (a^b^c^3);
}
@@ -109,10 +102,7 @@ uint32_t c;
* A minimal perfect hash needs to xor one of 0,1,2,3 afterwards to cause
* the hole to land on 3. find_adder() finds that constant
*/
-static void hexthree(keys, final, form)
-key *keys;
-gencode *final;
-hashform *form;
+static void hexthree(key *keys, gencode *final, hashform *form)
{
uint32_t a = keys->hash_k;
uint32_t b = keys->next_k->hash_k;
@@ -261,11 +251,7 @@ hashform *form;
* Check that a,b,c,d are some permutation of 0,1,2,3
* Assume that a,b,c,d are all have values less than 32.
*/
-static int testfour(a,b,c,d)
-uint32_t a;
-uint32_t b;
-uint32_t c;
-uint32_t d;
+static int testfour(uint32_t a, uint32_t b, uint32_t c, uint32_t d)
{
uint32_t mask = (1<<a)^(1<<b)^(1<<c)^(1<<d);
return (mask == 0xf);
@@ -277,9 +263,7 @@ uint32_t d;
* Find a perfect hash when there are only four keys. Max 10 instructions.
* Note that a perfect hash for 4 keys will automatically be minimal.
*/
-static void hexfour(keys, final)
-key *keys;
-gencode *final;
+static void hexfour(key *keys, gencode *final)
{
uint32_t a = keys->hash_k;
uint32_t b = keys->next_k->hash_k;
@@ -821,9 +805,9 @@ gencode *final;
/* test if a_k is distinct and in range for all keys */
-static int testeight(keys, badmask)
-key *keys; /* keys being hashed */
-uint8_t badmask; /* used for minimal perfect hashing */
+static int testeight(key *keys, uint8_t badmask)
+ /* keys being hashed */
+ /* used for minimal perfect hashing */
{
uint8_t mask = badmask;
key *mykey;
@@ -844,11 +828,7 @@ uint8_t badmask; /* used for minimal perfect hashing
* We can't deterministically find a perfect hash, but there's a reasonable
* chance we'll get lucky. Give it a shot. Return TRUE if we succeed.
*/
-static int hexeight(keys, nkeys, final, form)
-key *keys;
-uint32_t nkeys;
-gencode *final;
-hashform *form;
+static int hexeight(key *keys, uint32_t nkeys, gencode *final, hashform *form)
{
key *mykey; /* walk through the keys */
uint32_t i,j,k;
@@ -992,12 +972,7 @@ hashform *form;
* final->i is the current state of the state machine.
* final->j and final->k are counters in the loops the states simulate.
*/
-static void hexn(keys, salt, alen, blen, final)
-key *keys;
-uint32_t salt;
-uint32_t alen;
-uint32_t blen;
-gencode *final;
+static void hexn(key *keys, uint32_t salt, uint32_t alen, uint32_t blen, gencode *final)
{
key *mykey;
uint32_t highbit = final->highbit;
@@ -1200,9 +1175,7 @@ gencode *final;
/* find the highest and lowest bit where any key differs */
-static void setlow(keys, final)
-key *keys;
-gencode *final;
+static void setlow(key *keys, gencode *final)
{
uint32_t lowbit;
uint32_t highbit;
@@ -1249,15 +1222,15 @@ gencode *final;
* Return TRUE if we found a perfect hash and no more work is needed.
* Return FALSE if we just did an initial hash and more work is needed.
*/
-int inithex(keys, nkeys, alen, blen, smax, salt, final, form)
-key *keys; /* list of all keys */
-uint32_t nkeys; /* number of keys to hash */
-uint32_t alen; /* (a,b) has a in 0..alen-1, a power of 2 */
-uint32_t blen; /* (a,b) has b in 0..blen-1, a power of 2 */
-uint32_t smax; /* maximum range of computable hash values */
-uint32_t salt; /* used to initialize the hash function */
-gencode *final; /* output, code for the final hash */
-hashform *form; /* user directives */
+int inithex(key *keys, uint32_t nkeys, uint32_t alen, uint32_t blen, uint32_t smax, uint32_t salt, gencode *final, hashform *form)
+ /* list of all keys */
+ /* number of keys to hash */
+ /* (a,b) has a in 0..alen-1, a power of 2 */
+ /* (a,b) has b in 0..blen-1, a power of 2 */
+ /* maximum range of computable hash values */
+ /* used to initialize the hash function */
+ /* output, code for the final hash */
+ /* user directives */
{
setlow(keys, final);
diff --git a/perfect/recycle.c b/perfect/recycle.c
index b14eba9..c47bbc7 100644
--- a/perfect/recycle.c
+++ b/perfect/recycle.c
@@ -20,8 +20,7 @@ This also decreases memory fragmentation, and freeing structures
# include "recycle.h"
#endif
-reroot *remkroot(size)
-size_t size;
+reroot *remkroot(size_t size)
{
reroot *r = (reroot *)remalloc(sizeof(reroot), "recycle.c, root");
r->list = (recycle *)0;
@@ -32,8 +31,7 @@ size_t size;
return r;
}
-void refree(r)
-struct reroot *r;
+void refree(struct reroot *r)
{
recycle *temp;
if (temp = r->list) while (r->list)
@@ -47,8 +45,7 @@ struct reroot *r;
}
/* to be called from the macro renew only */
-char *renewx(r)
-struct reroot *r;
+char *renewx(struct reroot *r)
{
recycle *temp;
if (r->trash)
@@ -71,9 +68,7 @@ struct reroot *r;
return (char *)temp;
}
-char *remalloc(len, purpose)
-size_t len;
-char *purpose;
+char *remalloc(size_t len, char *purpose)
{
char *x = (char *)malloc(len);
if (!x)
diff --git a/perfect/recycle.h b/perfect/recycle.h
index 41bda1b..81c157c 100644
--- a/perfect/recycle.h
+++ b/perfect/recycle.h
@@ -40,16 +40,16 @@ struct reroot
typedef struct reroot reroot;
/* make a new recycling root */
-reroot *remkroot(/*_ size_t mysize _*/);
+reroot *remkroot(size_t size);
/* free a recycling root and all the items it has made */
-void refree(/*_ struct reroot *r _*/);
+void refree(struct reroot *r);
/* get a new (cleared) item from the root */
#define renew(r) ((r)->numleft ? \
(((char *)((r)->list+1))+((r)->numleft-=(r)->size)) : renewx(r))
-char *renewx(/*_ struct reroot *r _*/);
+char *renewx(struct reroot *r);
/* delete an item; let the root recycle it */
/* void redel(/o_ struct reroot *r, struct recycle *item _o/); */
@@ -60,6 +60,6 @@ char *renewx(/*_ struct reroot *r _*/);
/* malloc, but complain to stderr and exit program if no joy */
/* use plain free() to free memory allocated by remalloc() */
-char *remalloc(/*_ size_t len, char *purpose _*/);
+char *remalloc(size_t len, char *purpose);
#endif /* RECYCLE */