1 |
– |
/* Copyright (c) 1994 Regents of the University of California */ |
2 |
– |
|
1 |
|
#ifndef lint |
2 |
< |
static char SCCSid[] = "$SunId$ LBL"; |
2 |
> |
static const char RCSid[] = "$Id$"; |
3 |
|
#endif |
6 |
– |
|
4 |
|
/* |
5 |
|
* Table lookup routines |
6 |
|
*/ |
7 |
|
|
8 |
|
#include <stdio.h> |
9 |
+ |
#include <stdlib.h> |
10 |
|
#include "lookup.h" |
11 |
|
|
12 |
|
#ifndef MEM_PTR |
13 |
|
#define MEM_PTR void * |
14 |
|
#endif |
15 |
|
|
18 |
– |
extern MEM_PTR calloc(); |
16 |
|
|
20 |
– |
|
17 |
|
int |
18 |
|
lu_init(tbl, nel) /* initialize tbl for at least nel elements */ |
19 |
|
register LUTAB *tbl; |
125 |
|
* recursive call to lu_find(). |
126 |
|
*/ |
127 |
|
while (ndx--) |
128 |
< |
if (le[ndx].key != NULL) |
128 |
> |
if (le[ndx].key != NULL) { |
129 |
|
if (le[ndx].data != NULL) |
130 |
|
*lu_find(tbl, le[ndx].key) = le[ndx]; |
131 |
|
else if (tbl->freek != NULL) |
132 |
|
(*tbl->freek)(le[ndx].key); |
133 |
+ |
} |
134 |
|
free((MEM_PTR)le); |
135 |
|
goto tryagain; /* should happen only once! */ |
136 |
|
} |