/* sdb - MIT - Copyright 2018-2022 - ret2libc, pancake */

#include "sdb/sdb.h"
#include "sdb/ht_pu.h"
#include "ht.inc.c"

static void free_kv_key(HT_(Kv) *kv) {
	sdb_gh_free (kv->key);
}

// creates a default HtPU that has strings as keys
SDB_API HtName_(Ht)* Ht_(new0)(void) {
	HT_(Options) opt = {
		.cmp = (HT_(ListComparator))strcmp,
		.hashfn = (HT_(HashFunction))sdb_hash,
		.dupkey = (HT_(DupKey))sdb_strdup,
		.dupvalue = NULL,
		.calcsizeK = (HT_(CalcSizeK))strlen,
		.calcsizeV = NULL,
		.freefn = free_kv_key,
		.elem_size = sizeof (HT_(Kv)),
	};
	return Ht_(new_opt) (&opt);
}
