home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume14 / bsd-dyna-link / assoc_internals.h < prev    next >
Encoding:
C/C++ Source or Header  |  1988-05-08  |  1.5 KB  |  43 lines

  1.  
  2. /**********************************************************************\
  3. **                                      **
  4. ** internal data types... not for use by the mortal man.. subject to  **
  5. ** changes..  information hiding and all that, don't you know.          **
  6. **                                      **
  7. \**********************************************************************/
  8.  
  9. typedef int* H_memory_cell;/* pointers to user's memory area. */
  10.  
  11. typedef H_memory_cell entry;  
  12.  
  13. typedef entry hash_table[];
  14.  
  15. typedef struct assoc_mem_rec
  16.     { hash_table *array; 
  17.        int value_size;   /* User defined size of data values; */
  18.       int size;      /* Number of slots in table.. power of 2 */
  19.       int size_div_2; /* always = size / 2 */
  20.       int mask;      /* always = size-1, for calculating (num mod size)*/
  21.       int entries;    /* number of entries in assoc mem */
  22.     }
  23.      * assoc_memory;
  24.  
  25.  
  26. /* Get unique stored string associated with a memory cell */
  27.  
  28. #define str_from_cell(cell,table) \
  29.     ((char*) (((char*) (cell))  + (table)->value_size))
  30.  
  31. /* Get memory cell associated with a string returned from string_from_cell*/
  32.  
  33. #define cell_from_str(string,table) \
  34.     ((int*)  (((char*) (string)) - (table)->value_size))
  35.  
  36. #define mem_from_cell(cell) ((int*)    ((char*)(cell) - sizeof(entry)))
  37. #define cell_from_mem(mem)  ((mem_cell)((char*)(mem)  + sizeof(entry)))
  38.  
  39. #define INIT_TABLE_SIZE 8 /* Must be a power of two */
  40. /*************************************************************************
  41. *************************************************************************/
  42.  
  43.