-template<typename _Key, typename _Val>
- struct hashlistnode {
- _Key key;
- _Val val;
- struct hashlistnode<_Key,_Val> *next;
- };
+/**
+ * Hashtable linked node class, for chained storage of hash table conflicts. By
+ * default it is snapshotting, but you can pass in your own allocation
+ * functions.
+ *
+ * @tparam _Key Type name for the key
+ * @tparam _Val Type name for the values to be stored
+ * @tparam _malloc Provide your own 'malloc' for the table, or default to
+ * snapshotting.
+ * @tparam _calloc Provide your own 'calloc' for the table, or default to
+ * snapshotting.
+ * @tparam _free Provide your own 'free' for the table, or default to
+ * snapshotting.
+ */
+template<typename _Key, typename _Val, void * (* _malloc)(size_t), void * (* _calloc)(size_t, size_t), void (*_free)(void *)>
+struct hashlistnode {
+ _Key key;
+ _Val val;
+ struct hashlistnode<_Key,_Val, _malloc, _calloc, _free> *next;
+
+ void * operator new(size_t size) {
+ return _malloc(size);
+ }
+
+ void operator delete(void *p, size_t size) {
+ _free(p);
+ }
+
+ void * operator new[](size_t size) {
+ return _malloc(size);
+ }
+
+ void operator delete[](void *p, size_t size) {
+ _free(p);
+ }
+};