Skip to content

Commit

Permalink
Version 1.0.1
Browse files Browse the repository at this point in the history
- Fixed bug where metaSize was incorrectly calculated when clearing a hash, added unit test to catch this.
  • Loading branch information
jhuckaby committed Oct 8, 2019
1 parent cc0c1da commit 90806bb
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion MegaHash.cpp
Expand Up @@ -316,7 +316,7 @@ void Hash::clearTag(Tag *tag) {
bucket = bucket->next;

stats->dataSize -= (bucketGetKeyLength(lastBucket->data) + bucketGetContentLength(lastBucket->data));
stats->metaSize -= sizeof(Bucket);
stats->metaSize -= (sizeof(Bucket) + BH_KLEN_SIZE + BH_LEN_SIZE);
stats->numKeys--;

free(lastBucket->data);
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "megahash",
"version": "1.0.0",
"version": "1.0.1",
"description": "A super-fast C++ hash table with Node.js wrapper.",
"author": "Joseph Huckaby <jhuckaby@gmail.com>",
"homepage": "https://github.com/jhuckaby/megahash",
Expand Down
5 changes: 3 additions & 2 deletions test.js
Expand Up @@ -255,8 +255,9 @@ module.exports = {
hash.clear();

var stats = hash.stats();
test.ok(stats.numKeys === 0, '0 keys in stats');
test.ok(stats.dataSize === 0, '0 bytes in data store');
test.ok(stats.numKeys === 0, '0 keys in stats: ' + stats.numKeys);
test.ok(stats.dataSize === 0, '0 bytes in data store: ' + stats.dataSize);
test.ok(stats.metaSize === 0, '0 bytes in meta store: ' + stats.metaSize);
test.ok(stats.numIndexes === 1, '1 index in stats');

test.done();
Expand Down

0 comments on commit 90806bb

Please sign in to comment.