ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/lookup.h
(Generate patch)

Comparing ray/src/common/lookup.h (file contents):
Revision 2.1 by greg, Wed Jul 6 15:14:16 1994 UTC vs.
Revision 2.9 by greg, Fri Jun 27 06:53:21 2003 UTC

# Line 1 | Line 1
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   */
5 + #ifndef _RAD_LOOKUP_H_
6 + #define _RAD_LOOKUP_H_
7 + #ifdef __cplusplus
8 + extern "C" {
9 + #endif
10  
11   typedef struct {
12 <        char    *key;           /* key name */
13 <        long    hval;           /* key hash value (for efficiency) */
14 <        char    *data;          /* pointer to client data */
12 >        char    *key;                   /* key name */
13 >        unsigned long   hval;           /* key hash value (for efficiency) */
14 >        char    *data;                  /* pointer to client data */
15   } LUENT;
16  
17   typedef struct {
18 <        long    (*hashf)();     /* key hash function */
19 <        int     (*keycmp)();    /* key comparison function */
20 <        void    (*freek)();     /* free a key */
21 <        void    (*freed)();     /* free the data */
22 <        int     tsiz;           /* current table size */
23 <        LUENT   *tabl;          /* table, if allocated */
24 <        int     ndel;           /* number of deleted entries */
18 >        unsigned long   (*hashf)();     /* key hash function */
19 >        int     (*keycmp)();            /* key comparison function */
20 >        void    (*freek)();             /* free a key */
21 >        void    (*freed)();             /* free the data */
22 >        int     tsiz;                   /* current table size */
23 >        LUENT   *tabl;                  /* table, if allocated */
24 >        int     ndel;                   /* number of deleted entries */
25   } LUTAB;
26  
27 + #undef strcmp
28   #define LU_SINIT(fk,fd)         {lu_shash,strcmp,(void (*)())(fk),\
29                                  (void (*)())(fd),0,NULL,0}
30  
# Line 56 | Line 59 | typedef struct {
59   * The lu_delete routine frees an entry's data (if any) by calling
60   * the freed member function, but does not free the key field.  This
61   * will be freed later during (or instead of) table reallocation.
62 + * It is therefore an error to reuse or do anything with the key
63 + * field after calling lu_delete.
64   *
65 + * The lu_doall routine loops through every filled table entry, calling
66 + * the given function once on each entry.  If a NULL pointer is passed
67 + * for this function, then lu_doall simply returns the total number of
68 + * active entries.  Otherwise, it returns the sum of all the function
69 + * evaluations.
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).
73   * The user must define these routines to free the key and the data
# Line 64 | Line 75 | typedef struct {
75   * allocated table itself.
76   */
77  
78 < extern int      lu_init();
68 < extern LUENT    *lu_find();
69 < extern void     lu_delete();
70 < extern void     lu_done();
71 < extern long     lu_shash();
78 > #include <string.h> /* strcmp() */
79  
80 < extern int      strcmp();
80 > extern int      lu_init(LUTAB *tbl, int nel);
81 > extern unsigned long    lu_shash(char *s);
82 > extern LUENT    *lu_find(LUTAB *tbl, char *key);
83 > extern void     lu_delete(LUTAB *tbl, char *key);
84 > extern int      lu_doall(LUTAB *tbl, int (*f)());
85 > extern void     lu_done(LUTAB *tbl);
86 >
87 >
88 > #ifdef __cplusplus
89 > }
90 > #endif
91 > #endif /* _RAD_LOOKUP_H_ */
92 >

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines