libcoap  4.3.0rc2
uthash.h File Reference
#include <string.h>
#include <stddef.h>
#include <stdlib.h>
#include <stdint.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.3.0
 
#define DECLTYPE(x)   (__typeof(x))
 
#define DECLTYPE_ASSIGN(dst, src)
 
#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_strlen(s)   strlen(s)
 
#define HASH_FUNCTION(keyptr, keylen, hashv)   HASH_JEN(keyptr, keylen, hashv)
 
#define HASH_KEYCMP(a, b, n)   memcmp(a,b,n)
 
#define uthash_noexpand_fyi(tbl)   /* can be defined to log noexpand */
 
#define uthash_expand_fyi(tbl)   /* can be defined to log expands */
 
#define HASH_NONFATAL_OOM   0
 
#define uthash_fatal(msg)   exit(-1) /* fatal OOM error */
 
#define HASH_RECORD_OOM(oomed)   uthash_fatal("out of memory")
 
#define IF_HASH_NONFATAL_OOM(x)
 
#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*)(void*)(((char*)(elp)) + ((tbl)->hho)))
 
#define HASH_ROLLBACK_BKT(hh, head, itemptrhh)
 
#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, oomed)
 
#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, oomed)
 
#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_TO_TABLE(hh, head, keyptr, keylen_in, hashval, add, oomed)
 
#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)
 
#define HASH_ADD_STR(head, strfield, add)
 
#define HASH_REPLACE_STR(head, 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_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, hh, addhh, oomed)
 
#define HASH_DEL_IN_BKT(head, delhh)
 
#define HASH_EXPAND_BUCKETS(hh, tbl, oomed)
 
#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 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 57 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:57

Definition at line 69 of file uthash.h.

◆ ELMT_FROM_HH

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

Definition at line 135 of file uthash.h.

◆ get16bits

#define get16bits (   d)
Value:
((((uint32_t)(((const uint8_t *)(d))[1])) << 8) \
+(uint32_t)(((const uint8_t *)(d))[0]) )

Definition at line 695 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 428 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 425 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 391 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 394 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 498 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 418 of file uthash.h.

◆ HASH_ADD_KEYPTR_BYHASHVALUE

#define HASH_ADD_KEYPTR_BYHASHVALUE (   hh,
  head,
  keyptr,
  keylen_in,
  hashval,
  add 
)
Value:
do { \
IF_HASH_NONFATAL_OOM( int _ha_oomed = 0; ) \
(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; \
HASH_MAKE_TABLE(hh, add, _ha_oomed); \
IF_HASH_NONFATAL_OOM( if (!_ha_oomed) { ) \
(head) = (add); \
IF_HASH_NONFATAL_OOM( } ) \
} else { \
(add)->hh.tbl = (head)->hh.tbl; \
HASH_APPEND_LIST(hh, head, add); \
} \
HASH_ADD_TO_TABLE(hh, head, keyptr, keylen_in, hashval, add, _ha_oomed); \
HASH_FSCK(hh, head, "HASH_ADD_KEYPTR_BYHASHVALUE"); \
} while (0)

Definition at line 397 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 351 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 384 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 504 of file uthash.h.

◆ HASH_ADD_STR

#define HASH_ADD_STR (   head,
  strfield,
  add 
)
Value:
do { \
unsigned _uthash_hastr_keylen = (unsigned)uthash_strlen((add)->strfield); \
HASH_ADD(hh, head, strfield[0], _uthash_hastr_keylen, add); \
} while (0)
#define uthash_strlen(s)
Definition: uthash.h:85

Definition at line 486 of file uthash.h.

◆ HASH_ADD_TO_BKT

#define HASH_ADD_TO_BKT (   head,
  hh,
  addhh,
  oomed 
)
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,(addhh)->tbl, oomed); \
IF_HASH_NONFATAL_OOM( \
if (oomed) { \
HASH_DEL_IN_BKT(head,addhh); \
} \
) \
} \
} while (0)
#define HASH_BKT_CAPACITY_THRESH
Definition: uthash.h:132

Definition at line 766 of file uthash.h.

◆ HASH_ADD_TO_TABLE

#define HASH_ADD_TO_TABLE (   hh,
  head,
  keyptr,
  keylen_in,
  hashval,
  add,
  oomed 
)
Value:
do { \
unsigned _ha_bkt; \
(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], hh, &(add)->hh, oomed); \
HASH_BLOOM_ADD((head)->hh.tbl, hashval); \
HASH_EMIT_KEY(hh, head, keyptr, keylen_in); \
} while (0)
#define HASH_TO_BKT(hashv, num_bkts, bkt)
Definition: uthash.h:431

Definition at line 338 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:137

Definition at line 287 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:135

Definition at line 279 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)

Definition at line 584 of file uthash.h.

◆ HASH_BKT_CAPACITY_THRESH

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

Definition at line 132 of file uthash.h.

◆ HASH_BLOOM_ADD

#define HASH_BLOOM_ADD (   tbl,
  hashv 
)

Definition at line 208 of file uthash.h.

◆ HASH_BLOOM_BYTELEN

#define HASH_BLOOM_BYTELEN   0U

Definition at line 210 of file uthash.h.

◆ HASH_BLOOM_FREE

#define HASH_BLOOM_FREE (   tbl)

Definition at line 207 of file uthash.h.

◆ HASH_BLOOM_MAKE

#define HASH_BLOOM_MAKE (   tbl,
  oomed 
)

Definition at line 206 of file uthash.h.

◆ HASH_BLOOM_SIGNATURE

#define HASH_BLOOM_SIGNATURE   0xb12220f2u

Definition at line 1090 of file uthash.h.

◆ HASH_BLOOM_TEST

#define HASH_BLOOM_TEST (   tbl,
  hashv 
)    (1)

Definition at line 209 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 1036 of file uthash.h.

◆ HASH_CNT

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

Definition at line 1066 of file uthash.h.

◆ HASH_COUNT

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

Definition at line 1065 of file uthash.h.

◆ HASH_DEL

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

Definition at line 508 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)

Definition at line 788 of file uthash.h.

◆ HASH_DELETE

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

Definition at line 448 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_HH"); \
} while (0)

Definition at line 451 of file uthash.h.

◆ HASH_EMIT_KEY

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

Definition at line 580 of file uthash.h.

◆ HASH_EXPAND_BUCKETS

#define HASH_EXPAND_BUCKETS (   hh,
  tbl,
  oomed 
)

Definition at line 832 of file uthash.h.

◆ HASH_FIND

#define HASH_FIND (   hh,
  head,
  keyptr,
  keylen,
  out 
)
Value:
do { \
(out) = NULL; \
if (head) { \
unsigned _hf_hashv; \
HASH_VALUE(keyptr, keylen, _hf_hashv); \
HASH_FIND_BYHASHVALUE(hh, head, keyptr, keylen, _hf_hashv, out); \
} \
} while (0)

Definition at line 166 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)
#define HASH_BLOOM_TEST(tbl, hashv)
Definition: uthash.h:209

Definition at line 154 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 (HASH_KEYCMP((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)
#define HASH_KEYCMP(a, b, n)
Definition: uthash.h:93

Definition at line 744 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 496 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 502 of file uthash.h.

◆ HASH_FIND_STR

#define HASH_FIND_STR (   head,
  findstr,
  out 
)
Value:
do { \
unsigned _uthash_hfstr_keylen = (unsigned)uthash_strlen(findstr); \
HASH_FIND(hh, head, findstr, _uthash_hfstr_keylen, out); \
} while (0)

Definition at line 481 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)

Definition at line 607 of file uthash.h.

◆ HASH_FSCK

#define HASH_FSCK (   hh,
  head,
  where 
)

Definition at line 566 of file uthash.h.

◆ HASH_FUNCTION

#define HASH_FUNCTION (   keyptr,
  keylen,
  hashv 
)    HASH_JEN(keyptr, keylen, hashv)

Definition at line 89 of file uthash.h.

◆ HASH_INITIAL_NUM_BUCKETS

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

Definition at line 130 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 131 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)))

Definition at line 1059 of file uthash.h.

◆ HASH_JEN

#define HASH_JEN (   key,
  keylen,
  hashv 
)

Definition at line 646 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 633 of file uthash.h.

◆ HASH_KEYCMP

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

Definition at line 93 of file uthash.h.

◆ HASH_MAKE_TABLE

#define HASH_MAKE_TABLE (   hh,
  head,
  oomed 
)
Value:
do { \
(head)->hh.tbl = (UT_hash_table*)uthash_malloc(sizeof(UT_hash_table)); \
if (!(head)->hh.tbl) { \
HASH_RECORD_OOM(oomed); \
} else { \
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( \
(head)->hh.tbl->signature = HASH_SIGNATURE; \
if (!(head)->hh.tbl->buckets) { \
HASH_RECORD_OOM(oomed); \
uthash_free((head)->hh.tbl, sizeof(UT_hash_table)); \
} else { \
uthash_bzero((head)->hh.tbl->buckets, \
HASH_BLOOM_MAKE((head)->hh.tbl, oomed); \
IF_HASH_NONFATAL_OOM( \
if (oomed) { \
uthash_free((head)->hh.tbl->buckets, \
uthash_free((head)->hh.tbl, sizeof(UT_hash_table)); \
} \
) \
} \
} \
} while (0)
#define HASH_INITIAL_NUM_BUCKETS_LOG2
Definition: uthash.h:131
#define HASH_INITIAL_NUM_BUCKETS
Definition: uthash.h:130
#define HASH_SIGNATURE
Definition: uthash.h:1089
#define uthash_malloc(sz)
Definition: uthash.h:76

Definition at line 213 of file uthash.h.

◆ HASH_NONFATAL_OOM

#define HASH_NONFATAL_OOM   0

Definition at line 104 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)

Definition at line 618 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) + \
struct UT_hash_handle UT_hash_handle
#define HASH_BLOOM_BYTELEN
Definition: uthash.h:210

Definition at line 1047 of file uthash.h.

◆ HASH_RECORD_OOM

#define HASH_RECORD_OOM (   oomed)    uthash_fatal("out of memory")

Definition at line 124 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 265 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 255 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 245 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 272 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 500 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 506 of file uthash.h.

◆ HASH_REPLACE_STR

#define HASH_REPLACE_STR (   head,
  strfield,
  add,
  replaced 
)
Value:
do { \
unsigned _uthash_hrstr_keylen = (unsigned)uthash_strlen((add)->strfield); \
HASH_REPLACE(hh, head, strfield[0], _uthash_hrstr_keylen, add, replaced); \
} while (0)

Definition at line 491 of file uthash.h.

◆ HASH_ROLLBACK_BKT

#define HASH_ROLLBACK_BKT (   hh,
  head,
  itemptrhh 
)
Value:
do { \
struct UT_hash_handle *_hd_hh_item = (itemptrhh); \
unsigned _hd_bkt; \
HASH_TO_BKT(_hd_hh_item->hashv, (head)->hh.tbl->num_buckets, _hd_bkt); \
(head)->hh.tbl->buckets[_hd_bkt].count++; \
_hd_hh_item->hh_next = NULL; \
_hd_hh_item->hh_prev = NULL; \
} while (0)

Definition at line 139 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)

Definition at line 597 of file uthash.h.

◆ HASH_SELECT

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

Definition at line 978 of file uthash.h.

◆ HASH_SFH

#define HASH_SFH (   key,
  keylen,
  hashv 
)

Definition at line 698 of file uthash.h.

◆ HASH_SIGNATURE

#define HASH_SIGNATURE   0xa0111fe1u

Definition at line 1089 of file uthash.h.

◆ HASH_SORT

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

Definition at line 888 of file uthash.h.

◆ HASH_SRT

#define HASH_SRT (   hh,
  head,
  cmpfcn 
)

Definition at line 889 of file uthash.h.

◆ HASH_TO_BKT

#define HASH_TO_BKT (   hashv,
  num_bkts,
  bkt 
)
Value:
do { \
bkt = ((hashv) & ((num_bkts) - 1U)); \
} while (0)

Definition at line 431 of file uthash.h.

◆ HASH_VALUE

#define HASH_VALUE (   keyptr,
  keylen,
  hashv 
)
Value:
do { \
HASH_FUNCTION(keyptr, keylen, hashv); \
} while (0)

Definition at line 149 of file uthash.h.

◆ HH_FROM_ELMT

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

Definition at line 137 of file uthash.h.

◆ IF_HASH_NONFATAL_OOM

#define IF_HASH_NONFATAL_OOM (   x)

Definition at line 125 of file uthash.h.

◆ uthash_bzero

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

Definition at line 82 of file uthash.h.

◆ uthash_expand_fyi

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

Definition at line 100 of file uthash.h.

◆ uthash_fatal

#define uthash_fatal (   msg)    exit(-1) /* fatal OOM error */

Definition at line 121 of file uthash.h.

◆ uthash_free

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

Definition at line 79 of file uthash.h.

◆ uthash_malloc

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

Definition at line 76 of file uthash.h.

◆ uthash_noexpand_fyi

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

Definition at line 97 of file uthash.h.

◆ uthash_strlen

#define uthash_strlen (   s)    strlen(s)

Definition at line 85 of file uthash.h.

◆ UTHASH_VERSION

#define UTHASH_VERSION   2.3.0

Definition at line 27 of file uthash.h.

Typedef Documentation

◆ UT_hash_bucket

◆ UT_hash_handle

◆ UT_hash_table

typedef struct UT_hash_table UT_hash_table