Releases: JacksonAllan/Verstable
Big-endian MSVC iteration fix
Version 2.1.1 patches a bug affecting iteration on big-endian platforms when the library is compiled using MSVC. Since big-endian machines running Windows are rare, it is unlikely that any current users are affected. The library has now been specifically tested on a big-endian platform under GCC and Clang (via emulation).
The README has also been updated to link to the recently published article benchmarking Verstable against a range of other C and C++ hash tables.
New integer hash function, rehash bug fix
Version 2.1.0 version introduces two significant changes:
- It replaces the default integer (which was murmur3) to a slightly weaker one (fast-hash) that proved to perform better in benchmarks.
- It fixes a bug that could theoretically cause a crash when the
NAME_shrink
function prompts a full-table rehash. In testing, I managed to trigger this bug using an (illegal) maximum load factor higher than 1.0.
Extended custom allocator support, destructor bug fix
Version 2.0.0 improves support for custom memory allocators via the introduction of an optional ctx
(context) member in the hash table struct.
To enable and specify the type of the ctx
member, define CTX_TY
before including verstable.h
.
When the ctx
member is enabled, the custom allocation and free functions supplied via MALLOC_FN
and FREE_FN
should each take an extra argument, namely a pointer to the table's ctx
member: void *( size_t size, CTX_TY *ctx )
for MALLOC_FN
and void ( void *ptr, size_t size, CTX_TY *ctx )
and for FREE_FN
.
Likewise, init
and init_clone
should each take an extra argument that sets the ctx
member on the newly initialized table struct.
Here is how enabling and using the ctx
member might look in practice:
#include <stddef.h>
// Example context data as a struct.
typedef struct
{
// Context data...
} context;
void *malloc_with_ctx( size_t size, context *ctx )
{
// Allocate size bytes, taking into account ctx, and return a pointer to the allocated memory or NULL in the case of
// failure...
}
void free_with_ctx( void *ptr, size_t size, context *ctx )
{
// Free size bytes, taking into account ctx...
}
#define NAME int_int_map
#define KEY_TY int
#define VAL_TY int
#define CTX_TY context
#define MALLOC_FN malloc_with_ctx
#define FREE_FN free_with_ctx
#include "verstable.h"
int main( void )
{
context our_ctx;
// Initialize our_ctx...
int_int_map our_map;
vt_init( &our_map, our_ctx );
// Do things with our_map...
vt_cleanup( &our_map );
}
This version also introduces various optimizations affecting insertions and lookups and fixes a bug that caused a key to be used after destruction during erasure.
Initial release
This initial release includes the header, two sets of tests, and preliminary benchmarks against several high-performance C++ hash tables.