diff options
Diffstat (limited to 'src/nbt/nbtht.internal.h')
| -rw-r--r-- | src/nbt/nbtht.internal.h | 44 |
1 files changed, 44 insertions, 0 deletions
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 <string.h>
+#include <stdlib.h>
+
+#include <xxh3.h>
+
+#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 */
|
