This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
yap-6.3/packages/udi/uthash/uthash_udi_private.h
2015-10-13 08:17:51 +01:00

48 lines
1.8 KiB
C

#ifndef _UTHASH_UDI_PRIVATE_
#define _UTHASH_UDI_PRIVATE_
#include "uthash.h"
union AI {
YAP_Atom atom;
YAP_Int integer;
};
struct UTHash
{
union AI key;
void *data;
UT_hash_handle hh;
};
typedef struct UTHash *uthash_t;
/*
Used to Iterate over equal keys in hash table
*/
#define HASH_FIND_NEXT(hh,last,keyptr,keylen_in) \
do { \
if (last->hh.hh_next) \
DECLTYPE_ASSIGN(last,ELMT_FROM_HH(last->hh.tbl,last->hh.hh_next)); \
else last = NULL; \
while (last) { \
if (last->hh.keylen == keylen_in) { \
if ((HASH_KEYCMP(last->hh.key,keyptr,keylen_in)) == 0) { \
break; \
} \
} \
if (last->hh.hh_next) \
DECLTYPE_ASSIGN(last,ELMT_FROM_HH(last->hh.tbl,last->hh.hh_next)); \
else last = NULL; \
} \
} while (0) \
/* to ease code for a Atom hash table*/
#define HASH_FIND_AI(head,find,out) \
HASH_FIND(hh,head,find,sizeof(union AI),out)
#define HASH_ADD_AI(head,add) \
HASH_ADD(hh,head,key,sizeof(union AI),add)
#define HASH_FIND_NEXT_AI(last,find) \
HASH_FIND_NEXT(hh,last,find,sizeof(union AI))
#endif /* _UTHASH_UDI_PRIVATE_ */