libcoap  4.2.0
uthash.h File Reference
#include <string.h>
#include <stddef.h>
#include <stdlib.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
 

Macros

#define UTHASH_VERSION   2.0.2
 
#define DECLTYPE(x)   (__typeof(x))
 
#define DECLTYPE_ASSIGN(dst, src)
 
#define uthash_fatal(msg)   exit(-1) /* fatal error (out of memory,etc) */
 
#define uthash_malloc(sz)   malloc(sz) /* malloc fcn */
 
#define uthash_free(ptr, sz)   free(ptr) /* free fcn */
 
#define uthash_bzero(a, n)   memset(a,'\0',n)
 
#define uthash_memcmp(a, b, n)   memcmp(a,b,n)
 
#define uthash_strlen(s)   strlen(s)
 
#define uthash_noexpand_fyi(tbl)   /* can be defined to log noexpand */
 
#define uthash_expand_fyi(tbl)   /* can be defined to log expands */
 
#define HASH_INITIAL_NUM_BUCKETS   32U /* initial number of buckets */
 
#define HASH_INITIAL_NUM_BUCKETS_LOG2   5U /* lg2 of initial number of buckets */
 
#define HASH_BKT_CAPACITY_THRESH   10U /* expand when bucket count reaches */
 
#define ELMT_FROM_HH(tbl, hhp)   ((void*)(((char*)(hhp)) - ((tbl)->hho)))
 
#define HH_FROM_ELMT(tbl, elp)   ((UT_hash_handle *)(((char*)(elp)) + ((tbl)->hho)))
 
#define HASH_VALUE(keyptr, keylen, hashv)
 
#define HASH_FIND_BYHASHVALUE(hh, head, keyptr, keylen, hashval, out)
 
#define HASH_FIND(hh, head, keyptr, keylen, out)
 
#define HASH_BLOOM_MAKE(tbl)
 
#define HASH_BLOOM_FREE(tbl)
 
#define HASH_BLOOM_ADD(tbl, hashv)
 
#define HASH_BLOOM_TEST(tbl, hashv)   (1)
 
#define HASH_BLOOM_BYTELEN   0U
 
#define HASH_MAKE_TABLE(hh, head)
 
#define HASH_REPLACE_BYHASHVALUE_INORDER(hh, head, fieldname, keylen_in, hashval, add, replaced, cmpfcn)
 
#define HASH_REPLACE_BYHASHVALUE(hh, head, fieldname, keylen_in, hashval, add, replaced)
 
#define HASH_REPLACE(hh, head, fieldname, keylen_in, add, replaced)
 
#define HASH_REPLACE_INORDER(hh, head, fieldname, keylen_in, add, replaced, cmpfcn)
 
#define HASH_APPEND_LIST(hh, head, add)
 
#define HASH_AKBI_INNER_LOOP(hh, head, add, cmpfcn)
 
#define HASH_ADD_KEYPTR_BYHASHVALUE_INORDER(hh, head, keyptr, keylen_in, hashval, add, cmpfcn)
 
#define HASH_ADD_KEYPTR_INORDER(hh, head, keyptr, keylen_in, add, cmpfcn)
 
#define HASH_ADD_BYHASHVALUE_INORDER(hh, head, fieldname, keylen_in, hashval, add, cmpfcn)   HASH_ADD_KEYPTR_BYHASHVALUE_INORDER(hh, head, &((add)->fieldname), keylen_in, hashval, add, cmpfcn)
 
#define HASH_ADD_INORDER(hh, head, fieldname, keylen_in, add, cmpfcn)   HASH_ADD_KEYPTR_INORDER(hh, head, &((add)->fieldname), keylen_in, add, cmpfcn)
 
#define HASH_ADD_KEYPTR_BYHASHVALUE(hh, head, keyptr, keylen_in, hashval, add)
 
#define HASH_ADD_KEYPTR(hh, head, keyptr, keylen_in, add)
 
#define HASH_ADD_BYHASHVALUE(hh, head, fieldname, keylen_in, hashval, add)   HASH_ADD_KEYPTR_BYHASHVALUE(hh, head, &((add)->fieldname), keylen_in, hashval, add)
 
#define HASH_ADD(hh, head, fieldname, keylen_in, add)   HASH_ADD_KEYPTR(hh, head, &((add)->fieldname), keylen_in, add)
 
#define HASH_TO_BKT(hashv, num_bkts, bkt)
 
#define HASH_DELETE(hh, head, delptr)   HASH_DELETE_HH(hh, head, &(delptr)->hh)
 
#define HASH_DELETE_HH(hh, head, delptrhh)
 
#define HASH_FIND_STR(head, findstr, out)   HASH_FIND(hh,head,findstr,(unsigned)uthash_strlen(findstr),out)
 
#define HASH_ADD_STR(head, strfield, add)   HASH_ADD(hh,head,strfield[0],(unsigned)uthash_strlen(add->strfield),add)
 
#define HASH_REPLACE_STR(head, strfield, add, replaced)   HASH_REPLACE(hh,head,strfield[0],(unsigned)uthash_strlen(add->strfield),add,replaced)
 
#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_REPLACE_INT(head, intfield, add, replaced)   HASH_REPLACE(hh,head,intfield,sizeof(int),add,replaced)
 
#define HASH_FIND_PTR(head, findptr, out)   HASH_FIND(hh,head,findptr,sizeof(void *),out)
 
#define HASH_ADD_PTR(head, ptrfield, add)   HASH_ADD(hh,head,ptrfield,sizeof(void *),add)
 
#define HASH_REPLACE_PTR(head, ptrfield, add, replaced)   HASH_REPLACE(hh,head,ptrfield,sizeof(void *),add,replaced)
 
#define HASH_DEL(head, delptr)   HASH_DELETE(hh,head,delptr)
 
#define HASH_FSCK(hh, head, where)
 
#define HASH_EMIT_KEY(hh, head, keyptr, fieldlen)
 
#define HASH_FCN   HASH_JEN
 
#define HASH_BER(key, keylen, hashv)
 
#define HASH_SAX(key, keylen, hashv)
 
#define HASH_FNV(key, keylen, hashv)
 
#define HASH_OAT(key, keylen, hashv)
 
#define HASH_JEN_MIX(a, b, c)
 
#define HASH_JEN(key, keylen, hashv)
 
#define get16bits(d)
 
#define HASH_SFH(key, keylen, hashv)
 
#define HASH_FIND_IN_BKT(tbl, hh, head, keyptr, keylen_in, hashval, out)
 
#define HASH_ADD_TO_BKT(head, addhh)
 
#define HASH_DEL_IN_BKT(head, delhh)
 
#define HASH_EXPAND_BUCKETS(tbl)
 
#define HASH_SORT(head, cmpfcn)   HASH_SRT(hh,head,cmpfcn)
 
#define HASH_SRT(hh, head, cmpfcn)
 
#define HASH_SELECT(hh_dst, dst, hh_src, src, cond)
 
#define HASH_CLEAR(hh, head)
 
#define HASH_OVERHEAD(hh, head)
 
#define HASH_ITER(hh, head, el, tmp)
 
#define HASH_COUNT(head)   HASH_CNT(hh,head)
 
#define HASH_CNT(hh, head)   ((head != NULL)?((head)->hh.tbl->num_items):0U)
 
#define HASH_SIGNATURE   0xa0111fe1u
 
#define HASH_BLOOM_SIGNATURE   0xb12220f2u
 

Typedefs

typedef unsigned int uint32_t
 
typedef unsigned char uint8_t
 
typedef struct UT_hash_bucket UT_hash_bucket
 
typedef struct UT_hash_table UT_hash_table
 
typedef struct UT_hash_handle UT_hash_handle
 

Macro Definition Documentation

◆ DECLTYPE

#define DECLTYPE (   x)    (__typeof(x))

Definition at line 47 of file uthash.h.

◆ DECLTYPE_ASSIGN

#define DECLTYPE_ASSIGN (   dst,
  src 
)
Value:
do { \
(dst) = DECLTYPE(dst)(src); \
} while (0)
#define DECLTYPE(x)
Definition: uthash.h:47

Definition at line 59 of file uthash.h.

◆ ELMT_FROM_HH

#define ELMT_FROM_HH (   tbl,
  hhp 
)    ((void*)(((char*)(hhp)) - ((tbl)->hho)))

Definition at line 114 of file uthash.h.

◆ get16bits

#define get16bits (   d)
Value:
((((uint32_t)(((const uint8_t *)(d))[1])) << 8) \
+(uint32_t)(((const uint8_t *)(d))[0]) )
unsigned int uint32_t
Definition: uthash.h:78
unsigned char uint8_t
Definition: uthash.h:79

Definition at line 613 of file uthash.h.

◆ HASH_ADD

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

Definition at line 348 of file uthash.h.

◆ HASH_ADD_BYHASHVALUE

#define HASH_ADD_BYHASHVALUE (   hh,
  head,
  fieldname,
  keylen_in,
  hashval,
  add 
)    HASH_ADD_KEYPTR_BYHASHVALUE(hh, head, &((add)->fieldname), keylen_in, hashval, add)

Definition at line 345 of file uthash.h.

◆ HASH_ADD_BYHASHVALUE_INORDER

#define HASH_ADD_BYHASHVALUE_INORDER (   hh,
  head,
  fieldname,
  keylen_in,
  hashval,
  add,
  cmpfcn 
)    HASH_ADD_KEYPTR_BYHASHVALUE_INORDER(hh, head, &((add)->fieldname), keylen_in, hashval, add, cmpfcn)

Definition at line 309 of file uthash.h.

◆ HASH_ADD_INORDER

#define HASH_ADD_INORDER (   hh,
  head,
  fieldname,
  keylen_in,
  add,
  cmpfcn 
)    HASH_ADD_KEYPTR_INORDER(hh, head, &((add)->fieldname), keylen_in, add, cmpfcn)

Definition at line 312 of file uthash.h.

◆ HASH_ADD_INT

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

Definition at line 410 of file uthash.h.

◆ HASH_ADD_KEYPTR

#define HASH_ADD_KEYPTR (   hh,
  head,
  keyptr,
  keylen_in,
  add 
)
Value:
do { \
unsigned _ha_hashv; \
HASH_VALUE(keyptr, keylen_in, _ha_hashv); \
HASH_ADD_KEYPTR_BYHASHVALUE(hh, head, keyptr, keylen_in, _ha_hashv, add); \
} while (0)

Definition at line 338 of file uthash.h.

◆ HASH_ADD_KEYPTR_BYHASHVALUE

#define HASH_ADD_KEYPTR_BYHASHVALUE (   hh,
  head,
  keyptr,
  keylen_in,
  hashval,
  add 
)
Value:
do { \
unsigned _ha_bkt; \
(add)->hh.hashv = (hashval); \
(add)->hh.key = (const void *) (keyptr); \
(add)->hh.keylen = (unsigned) (keylen_in); \
if (!(head)) { \
(add)->hh.next = NULL; \
(add)->hh.prev = NULL; \
(head) = (add); \
HASH_MAKE_TABLE(hh, head); \
} else { \
(add)->hh.tbl = (head)->hh.tbl; \
HASH_APPEND_LIST(hh, head, add); \
} \
(head)->hh.tbl->num_items++; \
HASH_TO_BKT(hashval, (head)->hh.tbl->num_buckets, _ha_bkt); \
HASH_ADD_TO_BKT((head)->hh.tbl->buckets[_ha_bkt], &(add)->hh); \
HASH_BLOOM_ADD((head)->hh.tbl, hashval); \
HASH_EMIT_KEY(hh, head, keyptr, keylen_in); \
HASH_FSCK(hh, head, "HASH_ADD_KEYPTR_BYHASHVALUE"); \
} while (0)
#define HASH_TO_BKT(hashv, num_bkts, bkt)
Definition: uthash.h:351

Definition at line 315 of file uthash.h.

◆ HASH_ADD_KEYPTR_BYHASHVALUE_INORDER

#define HASH_ADD_KEYPTR_BYHASHVALUE_INORDER (   hh,
  head,
  keyptr,
  keylen_in,
  hashval,
  add,
  cmpfcn 
)

Definition at line 267 of file uthash.h.

◆ HASH_ADD_KEYPTR_INORDER

#define HASH_ADD_KEYPTR_INORDER (   hh,
  head,
  keyptr,
  keylen_in,
  add,
  cmpfcn 
)
Value:
do { \
unsigned _hs_hashv; \
HASH_VALUE(keyptr, keylen_in, _hs_hashv); \
HASH_ADD_KEYPTR_BYHASHVALUE_INORDER(hh, head, keyptr, keylen_in, _hs_hashv, add, cmpfcn); \
} while (0)

Definition at line 302 of file uthash.h.

◆ HASH_ADD_PTR

#define HASH_ADD_PTR (   head,
  ptrfield,
  add 
)    HASH_ADD(hh,head,ptrfield,sizeof(void *),add)

Definition at line 416 of file uthash.h.

◆ HASH_ADD_STR

#define HASH_ADD_STR (   head,
  strfield,
  add 
)    HASH_ADD(hh,head,strfield[0],(unsigned)uthash_strlen(add->strfield),add)

Definition at line 404 of file uthash.h.

◆ HASH_ADD_TO_BKT

#define HASH_ADD_TO_BKT (   head,
  addhh 
)
Value:
do { \
UT_hash_bucket *_ha_head = &(head); \
_ha_head->count++; \
(addhh)->hh_next = _ha_head->hh_head; \
(addhh)->hh_prev = NULL; \
if (_ha_head->hh_head != NULL) { \
_ha_head->hh_head->hh_prev = (addhh); \
} \
_ha_head->hh_head = (addhh); \
if ((_ha_head->count >= ((_ha_head->expand_mult + 1U) * HASH_BKT_CAPACITY_THRESH)) \
&& !(addhh)->tbl->noexpand) { \
HASH_EXPAND_BUCKETS((addhh)->tbl); \
} \
} while (0)
struct UT_hash_handle * hh_next
Definition: uthash.h:1102
#define HASH_BKT_CAPACITY_THRESH
Definition: uthash.h:111
struct UT_hash_table * tbl
Definition: uthash.h:1098
struct UT_hash_handle * hh_prev
Definition: uthash.h:1101

Definition at line 763 of file uthash.h.

◆ HASH_AKBI_INNER_LOOP

#define HASH_AKBI_INNER_LOOP (   hh,
  head,
  add,
  cmpfcn 
)
Value:
do { \
do { \
if (cmpfcn(DECLTYPE(head)(_hs_iter), add) > 0) { \
break; \
} \
} while ((_hs_iter = HH_FROM_ELMT((head)->hh.tbl, _hs_iter)->next)); \
} while (0)
#define HH_FROM_ELMT(tbl, elp)
Definition: uthash.h:116
#define DECLTYPE(x)
Definition: uthash.h:47

Definition at line 242 of file uthash.h.

◆ HASH_APPEND_LIST

#define HASH_APPEND_LIST (   hh,
  head,
  add 
)
Value:
do { \
(add)->hh.next = NULL; \
(add)->hh.prev = ELMT_FROM_HH((head)->hh.tbl, (head)->hh.tbl->tail); \
(head)->hh.tbl->tail->next = (add); \
(head)->hh.tbl->tail = &((add)->hh); \
} while (0)
#define ELMT_FROM_HH(tbl, hhp)
Definition: uthash.h:114

Definition at line 234 of file uthash.h.

◆ HASH_BER

#define HASH_BER (   key,
  keylen,
  hashv 
)
Value:
do { \
unsigned _hb_keylen = (unsigned)keylen; \
const unsigned char *_hb_key = (const unsigned char*)(key); \
(hashv) = 0; \
while (_hb_keylen-- != 0U) { \
(hashv) = (((hashv) << 5) + (hashv)) + *_hb_key++; \
} \
} while (0)
unsigned keylen
Definition: uthash.h:1104
const void * key
Definition: uthash.h:1103
unsigned hashv
Definition: uthash.h:1105

Definition at line 502 of file uthash.h.

◆ HASH_BKT_CAPACITY_THRESH

#define HASH_BKT_CAPACITY_THRESH   10U /* expand when bucket count reaches */

Definition at line 111 of file uthash.h.

◆ HASH_BLOOM_ADD

#define HASH_BLOOM_ADD (   tbl,
  hashv 
)

Definition at line 173 of file uthash.h.

◆ HASH_BLOOM_BYTELEN

#define HASH_BLOOM_BYTELEN   0U

Definition at line 175 of file uthash.h.

◆ HASH_BLOOM_FREE

#define HASH_BLOOM_FREE (   tbl)

Definition at line 172 of file uthash.h.

◆ HASH_BLOOM_MAKE

#define HASH_BLOOM_MAKE (   tbl)

Definition at line 171 of file uthash.h.

◆ HASH_BLOOM_SIGNATURE

#define HASH_BLOOM_SIGNATURE   0xb12220f2u

Definition at line 1062 of file uthash.h.

◆ HASH_BLOOM_TEST

#define HASH_BLOOM_TEST (   tbl,
  hashv 
)    (1)

Definition at line 174 of file uthash.h.

◆ HASH_CLEAR

#define HASH_CLEAR (   hh,
  head 
)
Value:
do { \
if ((head) != NULL) { \
HASH_BLOOM_FREE((head)->hh.tbl); \
uthash_free((head)->hh.tbl->buckets, \
(head)->hh.tbl->num_buckets*sizeof(struct UT_hash_bucket)); \
uthash_free((head)->hh.tbl, sizeof(UT_hash_table)); \
(head) = NULL; \
} \
} while (0)

Definition at line 1008 of file uthash.h.

◆ HASH_CNT

#define HASH_CNT (   hh,
  head 
)    ((head != NULL)?((head)->hh.tbl->num_items):0U)

Definition at line 1038 of file uthash.h.

◆ HASH_COUNT

#define HASH_COUNT (   head)    HASH_CNT(hh,head)

Definition at line 1037 of file uthash.h.

◆ HASH_DEL

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

Definition at line 420 of file uthash.h.

◆ HASH_DEL_IN_BKT

#define HASH_DEL_IN_BKT (   head,
  delhh 
)
Value:
do { \
UT_hash_bucket *_hd_head = &(head); \
_hd_head->count--; \
if (_hd_head->hh_head == (delhh)) { \
_hd_head->hh_head = (delhh)->hh_next; \
} \
if ((delhh)->hh_prev) { \
(delhh)->hh_prev->hh_next = (delhh)->hh_next; \
} \
if ((delhh)->hh_next) { \
(delhh)->hh_next->hh_prev = (delhh)->hh_prev; \
} \
} while (0)
struct UT_hash_handle * hh_next
Definition: uthash.h:1102
struct UT_hash_handle * hh_prev
Definition: uthash.h:1101

Definition at line 780 of file uthash.h.

◆ HASH_DELETE

#define HASH_DELETE (   hh,
  head,
  delptr 
)    HASH_DELETE_HH(hh, head, &(delptr)->hh)

Definition at line 368 of file uthash.h.

◆ HASH_DELETE_HH

#define HASH_DELETE_HH (   hh,
  head,
  delptrhh 
)
Value:
do { \
struct UT_hash_handle *_hd_hh_del = (delptrhh); \
if ((_hd_hh_del->prev == NULL) && (_hd_hh_del->next == NULL)) { \
HASH_BLOOM_FREE((head)->hh.tbl); \
uthash_free((head)->hh.tbl->buckets, \
(head)->hh.tbl->num_buckets * sizeof(struct UT_hash_bucket)); \
uthash_free((head)->hh.tbl, sizeof(UT_hash_table)); \
(head) = NULL; \
} else { \
unsigned _hd_bkt; \
if (_hd_hh_del == (head)->hh.tbl->tail) { \
(head)->hh.tbl->tail = HH_FROM_ELMT((head)->hh.tbl, _hd_hh_del->prev); \
} \
if (_hd_hh_del->prev != NULL) { \
HH_FROM_ELMT((head)->hh.tbl, _hd_hh_del->prev)->next = _hd_hh_del->next; \
} else { \
DECLTYPE_ASSIGN(head, _hd_hh_del->next); \
} \
if (_hd_hh_del->next != NULL) { \
HH_FROM_ELMT((head)->hh.tbl, _hd_hh_del->next)->prev = _hd_hh_del->prev; \
} \
HASH_TO_BKT(_hd_hh_del->hashv, (head)->hh.tbl->num_buckets, _hd_bkt); \
HASH_DEL_IN_BKT((head)->hh.tbl->buckets[_hd_bkt], _hd_hh_del); \
(head)->hh.tbl->num_items--; \
} \
HASH_FSCK(hh, head, "HASH_DELETE"); \
} while (0)
#define HH_FROM_ELMT(tbl, elp)
Definition: uthash.h:116

Definition at line 371 of file uthash.h.

◆ HASH_EMIT_KEY

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

Definition at line 491 of file uthash.h.

◆ HASH_EXPAND_BUCKETS

#define HASH_EXPAND_BUCKETS (   tbl)

Definition at line 824 of file uthash.h.

◆ HASH_FCN

#define HASH_FCN   HASH_JEN

Definition at line 498 of file uthash.h.

◆ HASH_FIND

#define HASH_FIND (   hh,
  head,
  keyptr,
  keylen,
  out 
)
Value:
do { \
unsigned _hf_hashv; \
HASH_VALUE(keyptr, keylen, _hf_hashv); \
HASH_FIND_BYHASHVALUE(hh, head, keyptr, keylen, _hf_hashv, out); \
} while (0)
unsigned keylen
Definition: uthash.h:1104

Definition at line 135 of file uthash.h.

◆ HASH_FIND_BYHASHVALUE

#define HASH_FIND_BYHASHVALUE (   hh,
  head,
  keyptr,
  keylen,
  hashval,
  out 
)
Value:
do { \
(out) = NULL; \
if (head) { \
unsigned _hf_bkt; \
HASH_TO_BKT(hashval, (head)->hh.tbl->num_buckets, _hf_bkt); \
if (HASH_BLOOM_TEST((head)->hh.tbl, hashval) != 0) { \
HASH_FIND_IN_BKT((head)->hh.tbl, hh, (head)->hh.tbl->buckets[ _hf_bkt ], keyptr, keylen, hashval, out); \
} \
} \
} while (0)
unsigned keylen
Definition: uthash.h:1104
#define HASH_BLOOM_TEST(tbl, hashv)
Definition: uthash.h:174

Definition at line 123 of file uthash.h.

◆ HASH_FIND_IN_BKT

#define HASH_FIND_IN_BKT (   tbl,
  hh,
  head,
  keyptr,
  keylen_in,
  hashval,
  out 
)
Value:
do { \
if ((head).hh_head != NULL) { \
DECLTYPE_ASSIGN(out, ELMT_FROM_HH(tbl, (head).hh_head)); \
} else { \
(out) = NULL; \
} \
while ((out) != NULL) { \
if ((out)->hh.hashv == (hashval) && (out)->hh.keylen == (keylen_in)) { \
if (uthash_memcmp((out)->hh.key, keyptr, keylen_in) == 0) { \
break; \
} \
} \
if ((out)->hh.hh_next != NULL) { \
DECLTYPE_ASSIGN(out, ELMT_FROM_HH(tbl, (out)->hh.hh_next)); \
} else { \
(out) = NULL; \
} \
} \
} while (0)
struct UT_hash_table * tbl
Definition: uthash.h:1098
#define uthash_memcmp(a, b, n)
Definition: uthash.h:95
#define ELMT_FROM_HH(tbl, hhp)
Definition: uthash.h:114

Definition at line 741 of file uthash.h.

◆ HASH_FIND_INT

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

Definition at line 408 of file uthash.h.

◆ HASH_FIND_PTR

#define HASH_FIND_PTR (   head,
  findptr,
  out 
)    HASH_FIND(hh,head,findptr,sizeof(void *),out)

Definition at line 414 of file uthash.h.

◆ HASH_FIND_STR

#define HASH_FIND_STR (   head,
  findstr,
  out 
)    HASH_FIND(hh,head,findstr,(unsigned)uthash_strlen(findstr),out)

Definition at line 402 of file uthash.h.

◆ HASH_FNV

#define HASH_FNV (   key,
  keylen,
  hashv 
)
Value:
do { \
unsigned _fn_i; \
const unsigned char *_hf_key = (const unsigned char*)(key); \
(hashv) = 2166136261U; \
for (_fn_i=0; _fn_i < keylen; _fn_i++) { \
hashv = hashv ^ _hf_key[_fn_i]; \
hashv = hashv * 16777619U; \
} \
} while (0)
unsigned keylen
Definition: uthash.h:1104
const void * key
Definition: uthash.h:1103
unsigned hashv
Definition: uthash.h:1105

Definition at line 525 of file uthash.h.

◆ HASH_FSCK

#define HASH_FSCK (   hh,
  head,
  where 
)

Definition at line 477 of file uthash.h.

◆ HASH_INITIAL_NUM_BUCKETS

#define HASH_INITIAL_NUM_BUCKETS   32U /* initial number of buckets */

Definition at line 109 of file uthash.h.

◆ HASH_INITIAL_NUM_BUCKETS_LOG2

#define HASH_INITIAL_NUM_BUCKETS_LOG2   5U /* lg2 of initial number of buckets */

Definition at line 110 of file uthash.h.

◆ HASH_ITER

#define HASH_ITER (   hh,
  head,
  el,
  tmp 
)
Value:
for(((el)=(head)), ((tmp)=DECLTYPE(el)((head!=NULL)?(head)->hh.next:NULL)); \
(el) != NULL; ((el)=(tmp)), ((tmp)=DECLTYPE(el)((tmp!=NULL)?(tmp)->hh.next:NULL)))
#define DECLTYPE(x)
Definition: uthash.h:47

Definition at line 1031 of file uthash.h.

◆ HASH_JEN

#define HASH_JEN (   key,
  keylen,
  hashv 
)

Definition at line 564 of file uthash.h.

◆ HASH_JEN_MIX

#define HASH_JEN_MIX (   a,
  b,
 
)
Value:
do { \
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 ); \
} while (0)

Definition at line 551 of file uthash.h.

◆ HASH_MAKE_TABLE

#define HASH_MAKE_TABLE (   hh,
  head 
)
Value:
do { \
(head)->hh.tbl = (UT_hash_table*)uthash_malloc(sizeof(UT_hash_table)); \
if (!(head)->hh.tbl) { \
uthash_fatal("out of memory"); \
} \
uthash_bzero((head)->hh.tbl, sizeof(UT_hash_table)); \
(head)->hh.tbl->tail = &((head)->hh); \
(head)->hh.tbl->num_buckets = HASH_INITIAL_NUM_BUCKETS; \
(head)->hh.tbl->log2_num_buckets = HASH_INITIAL_NUM_BUCKETS_LOG2; \
(head)->hh.tbl->hho = (char*)(&(head)->hh) - (char*)(head); \
(head)->hh.tbl->buckets = (UT_hash_bucket*)uthash_malloc( \
if (!(head)->hh.tbl->buckets) { \
uthash_fatal("out of memory"); \
} \
uthash_bzero((head)->hh.tbl->buckets, \
HASH_BLOOM_MAKE((head)->hh.tbl); \
(head)->hh.tbl->signature = HASH_SIGNATURE; \
} while (0)
#define HASH_INITIAL_NUM_BUCKETS
Definition: uthash.h:109
#define HASH_SIGNATURE
Definition: uthash.h:1061
#define HASH_INITIAL_NUM_BUCKETS_LOG2
Definition: uthash.h:110
#define uthash_malloc(sz)
Definition: uthash.h:86

Definition at line 178 of file uthash.h.

◆ HASH_OAT

#define HASH_OAT (   key,
  keylen,
  hashv 
)
Value:
do { \
unsigned _ho_i; \
const unsigned char *_ho_key=(const unsigned char*)(key); \
hashv = 0; \
for(_ho_i=0; _ho_i < keylen; _ho_i++) { \
hashv += _ho_key[_ho_i]; \
hashv += (hashv << 10); \
hashv ^= (hashv >> 6); \
} \
hashv += (hashv << 3); \
hashv ^= (hashv >> 11); \
hashv += (hashv << 15); \
} while (0)
unsigned keylen
Definition: uthash.h:1104
const void * key
Definition: uthash.h:1103
unsigned hashv
Definition: uthash.h:1105

Definition at line 536 of file uthash.h.

◆ HASH_OVERHEAD

#define HASH_OVERHEAD (   hh,
  head 
)
Value:
(((head) != NULL) ? ( \
(size_t)(((head)->hh.tbl->num_items * sizeof(UT_hash_handle)) + \
((head)->hh.tbl->num_buckets * sizeof(UT_hash_bucket)) + \
sizeof(UT_hash_table) + \
#define HASH_BLOOM_BYTELEN
Definition: uthash.h:175
struct UT_hash_handle UT_hash_handle

Definition at line 1019 of file uthash.h.

◆ HASH_REPLACE

#define HASH_REPLACE (   hh,
  head,
  fieldname,
  keylen_in,
  add,
  replaced 
)
Value:
do { \
unsigned _hr_hashv; \
HASH_VALUE(&((add)->fieldname), keylen_in, _hr_hashv); \
HASH_REPLACE_BYHASHVALUE(hh, head, fieldname, keylen_in, _hr_hashv, add, replaced); \
} while (0)

Definition at line 220 of file uthash.h.

◆ HASH_REPLACE_BYHASHVALUE

#define HASH_REPLACE_BYHASHVALUE (   hh,
  head,
  fieldname,
  keylen_in,
  hashval,
  add,
  replaced 
)
Value:
do { \
(replaced) = NULL; \
HASH_FIND_BYHASHVALUE(hh, head, &((add)->fieldname), keylen_in, hashval, replaced); \
if (replaced) { \
HASH_DELETE(hh, head, replaced); \
} \
HASH_ADD_KEYPTR_BYHASHVALUE(hh, head, &((add)->fieldname), keylen_in, hashval, add); \
} while (0)

Definition at line 210 of file uthash.h.

◆ HASH_REPLACE_BYHASHVALUE_INORDER

#define HASH_REPLACE_BYHASHVALUE_INORDER (   hh,
  head,
  fieldname,
  keylen_in,
  hashval,
  add,
  replaced,
  cmpfcn 
)
Value:
do { \
(replaced) = NULL; \
HASH_FIND_BYHASHVALUE(hh, head, &((add)->fieldname), keylen_in, hashval, replaced); \
if (replaced) { \
HASH_DELETE(hh, head, replaced); \
} \
HASH_ADD_KEYPTR_BYHASHVALUE_INORDER(hh, head, &((add)->fieldname), keylen_in, hashval, add, cmpfcn); \
} while (0)

Definition at line 200 of file uthash.h.

◆ HASH_REPLACE_INORDER

#define HASH_REPLACE_INORDER (   hh,
  head,
  fieldname,
  keylen_in,
  add,
  replaced,
  cmpfcn 
)
Value:
do { \
unsigned _hr_hashv; \
HASH_VALUE(&((add)->fieldname), keylen_in, _hr_hashv); \
HASH_REPLACE_BYHASHVALUE_INORDER(hh, head, fieldname, keylen_in, _hr_hashv, add, replaced, cmpfcn); \
} while (0)

Definition at line 227 of file uthash.h.

◆ HASH_REPLACE_INT

#define HASH_REPLACE_INT (   head,
  intfield,
  add,
  replaced 
)    HASH_REPLACE(hh,head,intfield,sizeof(int),add,replaced)

Definition at line 412 of file uthash.h.

◆ HASH_REPLACE_PTR

#define HASH_REPLACE_PTR (   head,
  ptrfield,
  add,
  replaced 
)    HASH_REPLACE(hh,head,ptrfield,sizeof(void *),add,replaced)

Definition at line 418 of file uthash.h.

◆ HASH_REPLACE_STR

#define HASH_REPLACE_STR (   head,
  strfield,
  add,
  replaced 
)    HASH_REPLACE(hh,head,strfield[0],(unsigned)uthash_strlen(add->strfield),add,replaced)

Definition at line 406 of file uthash.h.

◆ HASH_SAX

#define HASH_SAX (   key,
  keylen,
  hashv 
)
Value:
do { \
unsigned _sx_i; \
const unsigned char *_hs_key = (const unsigned char*)(key); \
hashv = 0; \
for (_sx_i=0; _sx_i < keylen; _sx_i++) { \
hashv ^= (hashv << 5) + (hashv >> 2) + _hs_key[_sx_i]; \
} \
} while (0)
unsigned keylen
Definition: uthash.h:1104
const void * key
Definition: uthash.h:1103

Definition at line 515 of file uthash.h.

◆ HASH_SELECT

#define HASH_SELECT (   hh_dst,
  dst,
  hh_src,
  src,
  cond 
)

Definition at line 967 of file uthash.h.

◆ HASH_SFH

#define HASH_SFH (   key,
  keylen,
  hashv 
)

Definition at line 616 of file uthash.h.

◆ HASH_SIGNATURE

#define HASH_SIGNATURE   0xa0111fe1u

Definition at line 1061 of file uthash.h.

◆ HASH_SORT

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

Definition at line 877 of file uthash.h.

◆ HASH_SRT

#define HASH_SRT (   hh,
  head,
  cmpfcn 
)

Definition at line 878 of file uthash.h.

◆ HASH_TO_BKT

#define HASH_TO_BKT (   hashv,
  num_bkts,
  bkt 
)
Value:
do { \
bkt = ((hashv) & ((num_bkts) - 1U)); \
} while (0)
unsigned hashv
Definition: uthash.h:1105

Definition at line 351 of file uthash.h.

◆ HASH_VALUE

#define HASH_VALUE (   keyptr,
  keylen,
  hashv 
)
Value:
do { \
HASH_FCN(keyptr, keylen, hashv); \
} while (0)
unsigned keylen
Definition: uthash.h:1104
unsigned hashv
Definition: uthash.h:1105

Definition at line 118 of file uthash.h.

◆ HH_FROM_ELMT

#define HH_FROM_ELMT (   tbl,
  elp 
)    ((UT_hash_handle *)(((char*)(elp)) + ((tbl)->hho)))

Definition at line 116 of file uthash.h.

◆ uthash_bzero

#define uthash_bzero (   a,
 
)    memset(a,'\0',n)

Definition at line 92 of file uthash.h.

◆ uthash_expand_fyi

#define uthash_expand_fyi (   tbl)    /* can be defined to log expands */

Definition at line 105 of file uthash.h.

◆ uthash_fatal

#define uthash_fatal (   msg)    exit(-1) /* fatal error (out of memory,etc) */

Definition at line 83 of file uthash.h.

◆ uthash_free

#define uthash_free (   ptr,
  sz 
)    free(ptr) /* free fcn */

Definition at line 89 of file uthash.h.

◆ uthash_malloc

#define uthash_malloc (   sz)    malloc(sz) /* malloc fcn */

Definition at line 86 of file uthash.h.

◆ uthash_memcmp

#define uthash_memcmp (   a,
  b,
 
)    memcmp(a,b,n)

Definition at line 95 of file uthash.h.

◆ uthash_noexpand_fyi

#define uthash_noexpand_fyi (   tbl)    /* can be defined to log noexpand */

Definition at line 102 of file uthash.h.

◆ uthash_strlen

#define uthash_strlen (   s)    strlen(s)

Definition at line 98 of file uthash.h.

◆ UTHASH_VERSION

#define UTHASH_VERSION   2.0.2

Definition at line 27 of file uthash.h.

Typedef Documentation

◆ uint32_t

typedef unsigned int uint32_t

Definition at line 78 of file uthash.h.

◆ uint8_t

typedef unsigned char uint8_t

Definition at line 79 of file uthash.h.

◆ UT_hash_bucket

◆ UT_hash_handle

◆ UT_hash_table

typedef struct UT_hash_table UT_hash_table