Ignore:
Timestamp:
Oct 17, 2008, 1:15:30 AM (17 years ago)
Author:
bird
Message:

kmk: replaced strcache with strcacahe2.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kmk/strcache2.h

    r1869 r1870  
    5151    struct strcache2_entry **hash_tab;  /* The hash table. */
    5252    int case_insensitive;               /* case insensitive or not. */
    53     unsigned int hash_size;             /* The hash table size. */
     53    unsigned int hash_mask;             /* The AND mask matching hash_size.*/
     54    unsigned long lookup_count;         /* The number of lookups. */
     55    unsigned long collision_1st_count;  /* The number of 1st level collisions. */
     56    unsigned long collision_2nd_count;  /* The number of 2nd level collisions. */
     57    unsigned long collision_3rd_count;  /* The number of 3rd level collisions. */
    5458    unsigned int count;                 /* Number entries in the cache. */
    5559    unsigned int rehash_count;          /* When to rehash the table. */
    56     unsigned long collision_count;      /* The number of collisions. */
    57     unsigned long lookup_count;         /* The number of lookups. */
     60    unsigned int init_size;             /* The initial hash table size. */
     61    unsigned int hash_size;             /* The hash table size. */
     62    unsigned int def_seg_size;          /* The default segment size. */
    5863    void *lock;                         /* The lock handle. */
    5964    struct strcache2_seg *seg_head;     /* The memory segment list. */
     
    6368
    6469
    65 void strcache2_init (struct strcache2 *cache, const char *name, int case_insensitive, int thread_safe);
     70void strcache2_init (struct strcache2 *cache, const char *name, unsigned int size,
     71                     unsigned int def_seg_size, int case_insensitive, int thread_safe);
    6672void strcache2_term (struct strcache2 *cache);
    6773void strcache2_print_stats (struct strcache2 *cache, const char *prefix);
    6874void strcache2_print_stats_all (const char *prefix);
    6975const char *strcache2_add (struct strcache2 *cache, const char *str, unsigned int length);
     76const char *strcache2_add_hashed (struct strcache2 *cache, const char *str, unsigned int length,
     77                                  unsigned int hash1, unsigned int hash2);
     78int strcache2_is_cached (struct strcache2 *cache, const char *str);
    7079int strcache2_verify_entry (struct strcache2 *cache, const char *str);
    7180unsigned int strcache2_get_hash2_fallback (struct strcache2 *cache, const char *str);
     81unsigned int strcache2_hash_str (const char *str, unsigned int length, unsigned int *hash2p);
     82unsigned int strcache2_hash_istr (const char *str, unsigned int length, unsigned int *hash2p);
    7283
    7384/* Get the hash table entry pointer. */
     
    100111{
    101112  unsigned int hash2 = strcache2_get_entry (cache, str)->hash2;
    102   if (hash2)
     113  if (!hash2)
    103114    hash2 = strcache2_get_hash2_fallback (cache, str);
    104115  return hash2;
Note: See TracChangeset for help on using the changeset viewer.