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.1 by greg, Tue Jun 21 14:45:40 1994 UTC vs.
Revision 1.2 by greg, Thu Jun 23 07:48:35 1994 UTC

# Line 12 | Line 12 | typedef struct {
12   } LUENT;
13  
14   typedef struct {
15 +        void    (*freek)();     /* free entry key */
16 +        void    (*freed)();     /* free entry data */
17          int     tsiz;           /* current table size */
18          LUENT   *tabl;          /* table, if allocated */
19 +        int     ndel;           /* number of deleted entries */
20   } LUTAB;
21  
22 + #define LU_SINIT(fk,fd)         {(void (*)())(fk),(void (*)())(fd),0,NULL,0}
23 +
24   /*
25   * The lu_init routine is called to initialize a table.  The number of
26   * elements passed is not a limiting factor, as a table can grow to
# Line 26 | Line 31 | typedef struct {
31   *
32   * It isn't fully necessary to initialize the LUTAB structure.  If it
33   * is cleared (tsiz = 0, tabl = NULL), then the first call to lu_find
34 < * will allocate a minimal table.
34 > * will allocate a minimal table.  If key and data free functions are
35 > * to be used, the LU_SINIT macro provides a convenient declaration.
36   *
37   * The lu_find routine returns the entry corresponding to the given
38   * key (any nul-terminated string).  If the entry does not exist, the
39 < * corresponding key field will be NULL.  It is the caller's responsibility
40 < * to (allocate and) assign the key field when creating a new entry.
41 < * If an entry exists, the corresponding data field indicates whether
42 < * or not it contains data, and this, too, is subject to user control
43 < * and interpretation.  The only case where lu_find returns NULL is
44 < * when the system has run out of memory.
39 > * corresponding key field will be NULL.  If the entry has been
40 > * previously deleted but not yet freed, then only the data field
41 > * will be NULL.  It is the caller's responsibility to (allocate and)
42 > * assign the key and data fields when creating a new entry.
43 > * The only case where lu_find returns NULL is when the system
44 > * has run out of memory.
45   *
46 + * The lu_delete routine frees an entry's data (if any) by calling
47 + * the freed member function, but does not free the key field.  This
48 + * will be freed later during (or instead of) table reallocation.
49 + *
50   * The lu_done routine calls the given free function once for each
51   * assigned table entry (i.e. each entry with an assigned key value).
52 < * The user must define this routine to free the key and the data
53 < * as appropriate.  The final action of lu_done is to free the
52 > * The user must define this routines to free the key and the data
53 > * in the LU_TAB structure.  The final action of lu_done is to free the
54   * allocated table itself.
55   */
56  
57   #ifdef NOPROTO
58   extern int      lu_init();
59   extern LUENT    *lu_find();
60 + extern void     lu_delete();
61   extern void     lu_done();
62 + extern int      lu_hash();
63   #else
64   extern int      lu_init(LUTAB *, int);
65   extern LUENT    *lu_find(LUTAB *, char *);
66 < extern void     lu_done(LUTAB *, void (*)(LUENT *));
66 > extern void     lu_delete(LUTAB *, char *);
67 > extern void     lu_done(LUTAB *);
68 > extern int      lu_hash(char *);
69   #endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines