44 |
|
} |
45 |
|
|
46 |
|
|
47 |
< |
long |
47 |
> |
unsigned long |
48 |
|
lu_shash(s) /* hash a nul-terminated string */ |
49 |
|
char *s; |
50 |
|
{ |
75 |
|
41, 198, 99 |
76 |
|
}; |
77 |
|
register int i = 0; |
78 |
< |
register long h = 0; |
78 |
> |
register unsigned long h = 0; |
79 |
|
register unsigned char *t = (unsigned char *)s; |
80 |
|
|
81 |
|
while (*t) |
90 |
|
register LUTAB *tbl; |
91 |
|
char *key; |
92 |
|
{ |
93 |
< |
long hval; |
93 |
> |
unsigned long hval; |
94 |
|
int i, n; |
95 |
|
register int ndx; |
96 |
|
register LUENT *le; |
97 |
|
/* look up object */ |
98 |
< |
if (tbl->tsiz == 0) |
99 |
< |
lu_init(tbl, 1); |
98 |
> |
if (tbl->tsiz == 0 && !lu_init(tbl, 1)) |
99 |
> |
return(NULL); |
100 |
|
hval = (*tbl->hashf)(key); |
101 |
|
tryagain: |
102 |
|
ndx = hval % tbl->tsiz; |
103 |
– |
le = &tbl->tabl[ndx]; |
103 |
|
for (i = 0, n = 1; i < tbl->tsiz; i++, n += 2) { |
104 |
+ |
le = &tbl->tabl[ndx]; |
105 |
|
if (le->key == NULL) { |
106 |
|
le->hval = hval; |
107 |
|
return(le); |
110 |
|
(tbl->keycmp == NULL || !(*tbl->keycmp)(le->key, key))) { |
111 |
|
return(le); |
112 |
|
} |
113 |
< |
le += n; |
114 |
< |
if ((ndx += n) >= tbl->tsiz) { /* this happens rarely */ |
113 |
> |
if ((ndx += n) >= tbl->tsiz) /* this happens rarely */ |
114 |
|
ndx = ndx % tbl->tsiz; |
116 |
– |
le = &tbl->tabl[ndx]; |
117 |
– |
} |
115 |
|
} |
116 |
|
/* table is full, reallocate */ |
117 |
|
le = tbl->tabl; |
123 |
|
tbl->ndel = i; |
124 |
|
return(NULL); |
125 |
|
} |
129 |
– |
if (!ndx) |
130 |
– |
goto tryagain; |
126 |
|
/* |
127 |
|
* The following code may fail if the user has reclaimed many |
128 |
|
* deleted entries and the system runs out of memory in a |