From 962f5efdf1af9f07395c28df7a2181733e3e5125 Mon Sep 17 00:00:00 2001 From: bigfoot547 Date: Sat, 3 Feb 2024 16:58:23 -0600 Subject: add lists --- src/nbt/nbtht.internal.h | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 src/nbt/nbtht.internal.h (limited to 'src/nbt/nbtht.internal.h') diff --git a/src/nbt/nbtht.internal.h b/src/nbt/nbtht.internal.h new file mode 100644 index 0000000..f3bc14b --- /dev/null +++ b/src/nbt/nbtht.internal.h @@ -0,0 +1,44 @@ +#ifndef LIBWORLD_NBTHT_INTERNAL_H_INCLUDED +#define LIBWORLD_NBTHT_INTERNAL_H_INCLUDED + +#include "nbt.h" +#include +#include + +#include + +#define HT_PREFIX nbt__ht_ + +#define HT_VALTYPE nbt_tag_t * +#define HT_VALTYPE_CREF nbt_tag_t * + +#define HT_VAL_SENTINEL NULL +#define HT_VAL_COPY(_v, _sz) nbt_incref(_v) +#define HT_VAL_FREE(_v) nbt_decref(_v) +#define HT_VAL_STATIC_LEN sizeof(nbt_tag_t *) + +inline void *nbt__ht_memdup(const void *in, size_t sz) +{ + void *ret = malloc(sz); + if (!ret) return NULL; + memcpy(ret, in, sz); + return ret; +} + +#define HT_KEYTYPE char * +#define HT_KEYTYPE_CREF const char * +#define HT_KEY_EQ(_val1, _len1, _val2, _len2) (((_len1) == (_len2)) && !memcmp(_val1, _val2, _len1)) +#define HT_KEY_GUESS_LEN(_k) strlen(_k) +#define HT_KEY_FREE(_k) free(_k) +#define HT_KEY_COPY(_k, _klen) nbt__ht_memdup(_k, _klen) + +#define HT_KEY_FMT "%s" +#define HT_VAL_FMT "%p" + +#define HT_HASHTYPE XXH64_hash_t +#define HT_KEY_HASH(_val, _sz) XXH3_64bits(_val, _sz) +#define HT_LOADFACTOR 0.75f + +#include "../htgen.h" + +#endif /* include guard */ -- cgit v1.2.3-70-g09d2