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

Comparing ray/src/cv/mgflib/lookup.h (file contents):
Revision 1.3 by greg, Sat Jun 25 09:47:57 1994 UTC vs.
Revision 1.4 by greg, Sat Jun 25 16:34:50 1994 UTC

# Line 3 | Line 3
3   /* SCCSid "$SunId$ LBL" */
4  
5   /*
6 < * Header file for table lookup routines
6 > * Header file for general associative table lookup routines
7   */
8  
9   typedef struct {
10 <        char    *key;           /* key name (dynamically allocated) */
10 >        char    *key;           /* key name */
11 >        long    hval;           /* key hash value (for efficiency) */
12          char    *data;          /* pointer to client data */
13   } LUENT;
14  
15   typedef struct {
16 <        void    (*freek)();     /* free entry key */
17 <        void    (*freed)();     /* free entry data */
16 >        long    (*hashf)();     /* key hash function */
17 >        int     (*keycmp)();    /* key comparison function */
18 >        void    (*freek)();     /* free a key */
19 >        void    (*freed)();     /* free the data */
20          int     tsiz;           /* current table size */
21          LUENT   *tabl;          /* table, if allocated */
22          int     ndel;           /* number of deleted entries */
23   } LUTAB;
24  
25 < #define LU_SINIT(fk,fd)         {(void (*)())(fk),(void (*)())(fd),0,NULL,0}
25 > #define LU_SINIT(fk,fd)         {lu_shash,strcmp,(void (*)())(fk),\
26 >                                (void (*)())(fd),0,NULL,0}
27  
28   /*
29   * The lu_init routine is called to initialize a table.  The number of
# Line 29 | Line 33 | typedef struct {
33   * and the expected (minimum) table size.  The value returned is the
34   * actual allocated table size (or zero if there was insufficient memory).
35   *
36 < * It isn't fully necessary to initialize the LUTAB structure.  If it
37 < * is cleared (tsiz = 0, tabl = NULL), then the first call to lu_find
38 < * will allocate a minimal table.  If key and data free functions are
39 < * to be used, the LU_SINIT macro provides a convenient declaration.
36 > * The hashf, keycmp, freek and freed member functions must be assigned
37 > * separately.  If the hash value is sufficient to guarantee equality
38 > * between keys, then the keycmp pointer may be NULL.  Otherwise, it
39 > * should return 0 if the two passed keys match.  If it is not necessary
40 > * (or possible) to free the key and/or data values, then the freek and/or
41 > * freed member functions may be NULL.
42   *
43 + * It isn't fully necessary to call lu_init to initialize the LUTAB structure.
44 + * If tsiz is 0, then the first call to lu_find will allocate a minimal table.
45 + * The LU_SINIT macro provides a convenient static declaration for character
46 + * string keys.
47 + *
48   * The lu_find routine returns the entry corresponding to the given
49 < * key (any nul-terminated string).  If the entry does not exist, the
50 < * corresponding key field will be NULL.  If the entry has been
51 < * previously deleted but not yet freed, then only the data field
52 < * will be NULL.  It is the caller's responsibility to (allocate and)
53 < * assign the key and data fields when creating a new entry.
54 < * The only case where lu_find returns NULL is when the system
44 < * has run out of memory.
49 > * key.  If the entry does not exist, the corresponding key field will
50 > * be NULL.  If the entry has been previously deleted but not yet freed,
51 > * then only the data field will be NULL.  It is the caller's
52 > * responsibility to (allocate and) assign the key and data fields when
53 > * creating a new entry.  The only case where lu_find returns NULL is when
54 > * the system has run out of memory.
55   *
56   * The lu_delete routine frees an entry's data (if any) by calling
57   * the freed member function, but does not free the key field.  This
# Line 59 | Line 69 | extern int     lu_init();
69   extern LUENT    *lu_find();
70   extern void     lu_delete();
71   extern void     lu_done();
72 < extern int      lu_hash();
72 > extern long     lu_shash();
73   #else
74   extern int      lu_init(LUTAB *, int);
75   extern LUENT    *lu_find(LUTAB *, char *);
76   extern void     lu_delete(LUTAB *, char *);
77   extern void     lu_done(LUTAB *);
78 < extern int      lu_hash(char *);
78 > extern long     lu_shash(char *);
79   #endif
80 +
81 + extern int      strcmp();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines