ctrump/common/uthash.h File Reference

#include <string.h>
#include <stddef.h>

Include dependency graph for uthash.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  UT_hash_bucket
struct  UT_hash_table
struct  UT_hash_handle

Defines

#define uthash_fatal(msg)   exit(-1)
#define uthash_bkt_malloc(sz)   malloc(sz)
#define uthash_bkt_free(ptr)   free(ptr)
#define uthash_tbl_malloc(sz)   malloc(sz)
#define uthash_tbl_free(ptr)   free(ptr)
#define uthash_noexpand_fyi(tbl)
#define uthash_expand_fyi(tbl)
#define HASH_INITIAL_NUM_BUCKETS   32
#define HASH_INITIAL_NUM_BUCKETS_LOG2   5
#define HASH_BKT_CAPACITY_THRESH   10
#define HASH_FIND(hh, head, keyptr, keylen_in, out)
#define HASH_ADD(hh, head, fieldname, keylen_in, add)   HASH_ADD_KEYPTR(hh,head,&add->fieldname,keylen_in,add)
#define HASH_ADD_KEYPTR(hh, head, keyptr, keylen_in, add)
#define HASH_TO_BKT(hashv, num_bkts, bkt)   bkt = ((hashv) & ((num_bkts) - 1))
#define HASH_DELETE(hh, head, delptr)
#define HASH_FIND_STR(head, findstr, out)   HASH_FIND(hh,head,findstr,strlen(findstr),out)
#define HASH_ADD_STR(head, strfield, add)   HASH_ADD(hh,head,strfield,strlen(add->strfield),add)
#define HASH_FIND_INT(head, findint, out)   HASH_FIND(hh,head,findint,sizeof(int),out)
#define HASH_ADD_INT(head, intfield, add)   HASH_ADD(hh,head,intfield,sizeof(int),add)
#define HASH_DEL(head, delptr)   HASH_DELETE(hh,head,delptr)
#define HASH_FSCK(hh, head)
#define HASH_EMIT_KEY(hh, head, keyptr, fieldlen)
#define HASH_FCN   HASH_JEN
#define HASH_BER(key, keylen, num_bkts, hash, bkt, i, j, k)
#define HASH_SAX(key, keylen, num_bkts, hash, bkt, i, j, k)
#define HASH_FNV(key, keylen, num_bkts, hash, bkt, i, j, k)
#define HASH_OAT(key, keylen, num_bkts, hash, bkt, i, j, k)
#define HASH_JEN_MIX(a, b, c)
#define HASH_JEN(key, keylen, num_bkts, hash, bkt, i, j, k)
#define HASH_KEYCMP(a, b, len)   memcmp(a,b,len)
#define HASH_FIND_IN_BKT(hh, head, keyptr, keylen_in, out)
#define HASH_ADD_TO_BKT(hh, head, add)
#define HASH_DEL_IN_BKT(hh, head, hh_del)
#define HASH_EXPAND_BUCKETS(tbl)
#define HASH_SORT(head, cmpfcn)   HASH_SRT(hh,head,cmpfcn)
#define HASH_SRT(hh, head, cmpfcn)


Define Documentation

#define HASH_ADD ( hh,
head,
fieldname,
keylen_in,
add   )     HASH_ADD_KEYPTR(hh,head,&add->fieldname,keylen_in,add)

Definition at line 66 of file uthash.h.

Referenced by build_label_table().

#define HASH_ADD_INT ( head,
intfield,
add   )     HASH_ADD(hh,head,intfield,sizeof(int),add)

Definition at line 165 of file uthash.h.

#define HASH_ADD_KEYPTR ( hh,
head,
keyptr,
keylen_in,
add   ) 

Definition at line 69 of file uthash.h.

#define HASH_ADD_STR ( head,
strfield,
add   )     HASH_ADD(hh,head,strfield,strlen(add->strfield),add)

Definition at line 161 of file uthash.h.

#define HASH_ADD_TO_BKT ( hh,
head,
add   ) 

Value:

head.count++;                                                                \
 add->hh.hh_next = head.hh_head;                                              \
 add->hh.hh_prev = NULL;                                                      \
 if (head.hh_head) head.hh_head->hh_prev = &add->hh;                          \
 head.hh_head=&add->hh;                                                       \
 if (head.count >= ((head.expand_mult+1) * HASH_BKT_CAPACITY_THRESH)          \
     && add->hh.tbl->noexpand != 1) {                                         \
       HASH_EXPAND_BUCKETS(add->hh.tbl)                                       \
 }

Definition at line 356 of file uthash.h.

#define HASH_BER ( key,
keylen,
num_bkts,
hash,
bkt,
i,
j,
 ) 

Value:

hash = 0;                                                                   \
  while (keylen--)  hash = (hash * 33) + *key++;                              \
  bkt = hash & (num_bkts-1);

Definition at line 259 of file uthash.h.

#define HASH_BKT_CAPACITY_THRESH   10

Definition at line 49 of file uthash.h.

#define HASH_DEL ( head,
delptr   )     HASH_DELETE(hh,head,delptr)

Definition at line 167 of file uthash.h.

Referenced by delete_table().

#define HASH_DEL_IN_BKT ( hh,
head,
hh_del   ) 

Value:

(head).count--;                                                           \
    if ((head).hh_head->elmt == hh_del->elmt) {                               \
      (head).hh_head = hh_del->hh_next;                                       \
    }                                                                         \
    if (hh_del->hh_prev) {                                                    \
        hh_del->hh_prev->hh_next = hh_del->hh_next;                           \
    }                                                                         \
    if (hh_del->hh_next) {                                                    \
        hh_del->hh_next->hh_prev = hh_del->hh_prev;                           \
    }

Definition at line 368 of file uthash.h.

#define HASH_DELETE ( hh,
head,
delptr   ) 

Definition at line 124 of file uthash.h.

#define HASH_EMIT_KEY ( hh,
head,
keyptr,
fieldlen   ) 

Definition at line 248 of file uthash.h.

#define HASH_EXPAND_BUCKETS ( tbl   ) 

Definition at line 411 of file uthash.h.

#define HASH_FCN   HASH_JEN

Definition at line 255 of file uthash.h.

#define HASH_FIND ( hh,
head,
keyptr,
keylen_in,
out   ) 

Value:

do {                                                                          \
  out=head;                                                                   \
  if (head) {                                                                 \
     (head)->hh.tbl->key = (char*)(keyptr);                                   \
     (head)->hh.tbl->keylen = keylen_in;                                      \
     HASH_FCN((head)->hh.tbl->key,(head)->hh.tbl->keylen,                     \
             (head)->hh.tbl->num_buckets,                                     \
             (head)->hh.tbl->hash_scratch, (head)->hh.tbl->bkt,               \
             (head)->hh.tbl->i, (head)->hh.tbl->j,(head)->hh.tbl->k);         \
     HASH_FIND_IN_BKT(hh, (head)->hh.tbl->buckets[ (head)->hh.tbl->bkt],      \
             keyptr,keylen_in,out);                                           \
  }                                                                           \
} while (0)

Definition at line 51 of file uthash.h.

#define HASH_FIND_IN_BKT ( hh,
head,
keyptr,
keylen_in,
out   ) 

Value:

out = (head.hh_head) ? (head.hh_head->elmt) : NULL;                           \
while (out) {                                                                 \
    if (out->hh.keylen == keylen_in) {                                        \
        if ((HASH_KEYCMP(out->hh.key,keyptr,keylen_in)) == 0) break;          \
    }                                                                         \
    out= (out->hh.hh_next) ? (out->hh.hh_next->elmt) : NULL;                  \
}

Definition at line 346 of file uthash.h.

#define HASH_FIND_INT ( head,
findint,
out   )     HASH_FIND(hh,head,findint,sizeof(int),out)

Definition at line 163 of file uthash.h.

#define HASH_FIND_STR ( head,
findstr,
out   )     HASH_FIND(hh,head,findstr,strlen(findstr),out)

Definition at line 159 of file uthash.h.

#define HASH_FNV ( key,
keylen,
num_bkts,
hash,
bkt,
i,
j,
 ) 

Value:

hash = 2166136261UL;                                                        \
  for(i=0; i < keylen; i++)                                                   \
      hash = (hash * 16777619) ^ key[i];                                      \
  bkt = hash & (num_bkts-1);

Definition at line 273 of file uthash.h.

#define HASH_FSCK ( hh,
head   ) 

Definition at line 236 of file uthash.h.

#define HASH_INITIAL_NUM_BUCKETS   32

Definition at line 47 of file uthash.h.

#define HASH_INITIAL_NUM_BUCKETS_LOG2   5

Definition at line 48 of file uthash.h.

#define HASH_JEN ( key,
keylen,
num_bkts,
hash,
bkt,
i,
j,
 ) 

Definition at line 304 of file uthash.h.

#define HASH_JEN_MIX ( a,
b,
 ) 

Value:

{                                                                             \
  a -= b; a -= c; a ^= ( c >> 13 );                                           \
  b -= c; b -= a; b ^= ( a << 8 );                                            \
  c -= a; c -= b; c ^= ( b >> 13 );                                           \
  a -= b; a -= c; a ^= ( c >> 12 );                                           \
  b -= c; b -= a; b ^= ( a << 16 );                                           \
  c -= a; c -= b; c ^= ( b >> 5 );                                            \
  a -= b; a -= c; a ^= ( c >> 3 );                                            \
  b -= c; b -= a; b ^= ( a << 10 );                                           \
  c -= a; c -= b; c ^= ( b >> 15 );                                           \
}

Definition at line 291 of file uthash.h.

#define HASH_KEYCMP ( a,
b,
len   )     memcmp(a,b,len)

Definition at line 343 of file uthash.h.

#define HASH_OAT ( key,
keylen,
num_bkts,
hash,
bkt,
i,
j,
 ) 

Value:

hash = 0;                                                                   \
  for(i=0; i < keylen; i++) {                                                 \
      hash += key[i];                                                         \
      hash += (hash << 10);                                                   \
      hash ^= (hash >> 6);                                                    \
  }                                                                           \
  hash += (hash << 3);                                                        \
  hash ^= (hash >> 11);                                                       \
  hash += (hash << 15);                                                       \
  bkt = hash & (num_bkts-1);

Definition at line 279 of file uthash.h.

#define HASH_SAX ( key,
keylen,
num_bkts,
hash,
bkt,
i,
j,
 ) 

Value:

hash = 0;                                                                   \
  for(i=0; i < keylen; i++)                                                   \
      hash ^= (hash << 5) + (hash >> 2) + key[i];                             \
  bkt = hash & (num_bkts-1);

Definition at line 267 of file uthash.h.

#define HASH_SORT ( head,
cmpfcn   )     HASH_SRT(hh,head,cmpfcn)

Definition at line 457 of file uthash.h.

#define HASH_SRT ( hh,
head,
cmpfcn   ) 

Definition at line 458 of file uthash.h.

#define HASH_TO_BKT ( hashv,
num_bkts,
bkt   )     bkt = ((hashv) & ((num_bkts) - 1))

Definition at line 110 of file uthash.h.

#define uthash_bkt_free ( ptr   )     free(ptr)

Definition at line 39 of file uthash.h.

#define uthash_bkt_malloc ( sz   )     malloc(sz)

Definition at line 38 of file uthash.h.

#define uthash_expand_fyi ( tbl   ) 

Definition at line 44 of file uthash.h.

#define uthash_fatal ( msg   )     exit(-1)

Definition at line 37 of file uthash.h.

#define uthash_noexpand_fyi ( tbl   ) 

Definition at line 43 of file uthash.h.

#define uthash_tbl_free ( ptr   )     free(ptr)

Definition at line 41 of file uthash.h.

#define uthash_tbl_malloc ( sz   )     malloc(sz)

Definition at line 40 of file uthash.h.


Generated on Tue Mar 31 20:19:24 2009 for ctrump by  doxygen 1.5.6