hash.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
#ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.3.2.1 */
#include "hash.h"
#include "defs.h"
/*
NOTE: The following algorithm only works on machines where
the results of multiplying two integers is the least
significant part of the double word integer required to hold
the result. It is adapted from Knuth, Volume 3, section 6.4.
*/
struct node
{
};
static unsigned int bitsper; /* Bits per byte */
static unsigned int shift;
static unsigned int crunch();
hcreate()
{
unsigned char c = (unsigned char)~0; /* A byte full of 1's */
int j;
for (j=0; j < TABLENGTH; ++j)
{
table[j] = 0;
}
bitsper = 0;
while (c)
{
c = (unsigned int)c >> 1;
bitsper++;
}
}
void (*uscan)();
{
int j;
for (j=0; j < TABLENGTH; ++j)
{
p = table[j];
while (p)
{
p = nxt;
}
}
}
ENTRY *
unsigned char *str;
{
struct node *p;
struct node **q;
unsigned int i;
int res;
if(table[i] == 0)
{
next = 0;
return(0);
}
else
{
q = &table[i];
p = table[i];
{
q = &(p->next);
p = p->next;
}
if (p != 0 && res == 0)
return(&(p->item));
else
{
last = q;
next = p;
return(0);
}
}
}
ENTRY *
{
*last = p;
return(&(p->item));
}
static unsigned int
unsigned char *key;
{
unsigned int sum = 0;
int s;
for (s = 0; *key; s++) /* Simply add up the bytes */
return(sum + s);
}