/* An entry in a hash table. */
-struct hash_entry
-{
+struct hash_entry {
/* Next entry for this hash code. */
struct hash_entry *next;
/* String being hashed. */
/* A hash table. */
-struct hash_control
-{
+struct hash_control {
/* The hash array. */
struct hash_entry **table;
/* The number of slots in the hash table. */
ret->deletions = 0;
#endif
- return ret;
+ return ret;
}
/* Delete a hash table, freeing all allocated memory. */
++table->insertions;
#endif
- p = (struct hash_entry *) obstack_alloc (&table->memory, sizeof(*p));
+ p = (struct hash_entry *) obstack_alloc (&table->memory, sizeof (*p));
p->string = key;
p->hash = hash;
p->data = value;
++table->insertions;
#endif
- p = (struct hash_entry *) obstack_alloc (&table->memory, sizeof(*p));
+ p = (struct hash_entry *) obstack_alloc (&table->memory, sizeof (*p));
p->string = key;
p->hash = hash;
p->data = value;
/* This test program is left over from the old hash table code. */
-#define TABLES (6) /* number of hash tables to maintain */
- /* (at once) in any testing */
-#define STATBUFSIZE (12) /* we can have 12 statistics */
+/* Number of hash tables to maintain (at once) in any testing. */
+#define TABLES (6)
+
+/* We can have 12 statistics. */
+#define STATBUFSIZE (12)
+
+/* Display statistics here. */
+int statbuf[STATBUFSIZE];
+
+/* Human farts here. */
+char answer[100];
-int statbuf[STATBUFSIZE]; /* display statistics here */
-char answer[100]; /* human farts here */
-char *hashtable[TABLES]; /* we test many hash tables at once */
-char *h; /* points to curent hash_control */
+/* We test many hash tables at once. */
+char *hashtable[TABLES];
+
+/* Points to curent hash_control. */
+char *h;
char **pp;
char *p;
char *name;
int size;
int used;
char command;
-int number; /* number 0:TABLES-1 of current hashed */
- /* symbol table */
+
+/* Number 0:TABLES-1 of current hashed symbol table. */
+int number;
int
main ()
gets (answer);
command = answer[0];
if (isupper (command))
- command = tolower (command); /* ecch! */
+ command = tolower (command); /* Ecch! */
switch (command)
{
case '#':
case '?':
for (pp = hashtable; pp < hashtable + TABLES; pp++)
{
- printf ("address of hash table #%d control block is %xx\n"
- ,pp - hashtable, *pp);
+ printf ("address of hash table #%d control block is %xx\n",
+ pp - hashtable, *pp);
}
break;
case 'a':
printf (" %s : ", description);
gets (answer);
- /* will one day clean up answer here */
+ /* Will one day clean up answer here. */
retval = malloc (strlen (answer) + 1);
if (!retval)
{
free (value);
}
-
void
applicatee (string, value)
char *string;
printf ("%.20s-%.20s\n", string, value);
}
+/* Determine number: what hash table to use.
+ Also determine h: points to hash_control. */
+
void
-whattable () /* determine number: what hash table to use */
- /* also determine h: points to hash_control */
+whattable ()
{
-
for (;;)
{
printf (" what hash table (%d:%d) ? ", 0, TABLES - 1);
}
}
-#endif /* #ifdef TEST */
-
-/* end of hash.c */
+#endif /* TEST */