1 |
< |
/* Copyright (c) 1994 Regents of the University of California */ |
2 |
< |
|
3 |
< |
/* SCCSid "$SunId$ LBL" */ |
4 |
< |
|
1 |
> |
/* RCSid: $Id$ */ |
2 |
|
/* |
3 |
|
* Header file for general associative table lookup routines |
4 |
|
*/ |
9 |
|
char *data; /* pointer to client data */ |
10 |
|
} LUENT; |
11 |
|
|
12 |
+ |
#ifdef NOPROTO |
13 |
|
typedef struct { |
14 |
< |
long (*hashf)(); /* key hash function */ |
14 |
> |
unsigned long (*hashf)(); /* key hash function */ |
15 |
|
int (*keycmp)(); /* key comparison function */ |
16 |
|
void (*freek)(); /* free a key */ |
17 |
|
void (*freed)(); /* free the data */ |
19 |
|
LUENT *tabl; /* table, if allocated */ |
20 |
|
int ndel; /* number of deleted entries */ |
21 |
|
} LUTAB; |
22 |
+ |
#else |
23 |
+ |
typedef struct { |
24 |
+ |
unsigned long (*hashf)(char *); /* key hash function */ |
25 |
+ |
int (*keycmp)(const char *, const char *); /* key comparison function */ |
26 |
+ |
void (*freek)(char *); /* free a key */ |
27 |
+ |
void (*freed)(char *); /* free the data */ |
28 |
+ |
int tsiz; /* current table size */ |
29 |
+ |
LUENT *tabl; /* table, if allocated */ |
30 |
+ |
int ndel; /* number of deleted entries */ |
31 |
+ |
} LUTAB; |
32 |
+ |
#endif |
33 |
|
|
34 |
|
#define LU_SINIT(fk,fd) {lu_shash,strcmp,(void (*)())(fk),\ |
35 |
|
(void (*)())(fd),0,NULL,0} |
65 |
|
* The lu_delete routine frees an entry's data (if any) by calling |
66 |
|
* the freed member function, but does not free the key field. This |
67 |
|
* will be freed later during (or instead of) table reallocation. |
68 |
+ |
* It is therefore an error to reuse or do anything with the key |
69 |
+ |
* field after calling lu_delete. |
70 |
|
* |
71 |
|
* The lu_done routine calls the given free function once for each |
72 |
|
* assigned table entry (i.e. each entry with an assigned key value). |
80 |
|
extern LUENT *lu_find(); |
81 |
|
extern void lu_delete(); |
82 |
|
extern void lu_done(); |
83 |
< |
extern long lu_shash(); |
83 |
> |
extern unsigned long lu_shash(); |
84 |
|
#else |
85 |
|
extern int lu_init(LUTAB *, int); |
86 |
|
extern LUENT *lu_find(LUTAB *, char *); |
87 |
|
extern void lu_delete(LUTAB *, char *); |
88 |
|
extern void lu_done(LUTAB *); |
89 |
< |
extern long lu_shash(char *); |
89 |
> |
extern unsigned long lu_shash(char *); |
90 |
|
#endif |
80 |
– |
|
81 |
– |
extern int strcmp(); |