From 0aa66e282332d9fd1b2142860585f982a1c7f951 Mon Sep 17 00:00:00 2001 From: yuqing Date: Tue, 4 Jul 2017 10:39:49 +0800 Subject: [PATCH] add type string_t --- src/common_define.h | 6 ++++++ src/hash.c | 1 + src/hash.h | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/common_define.h b/src/common_define.h index 68aa9e7..b6e59ae 100644 --- a/src/common_define.h +++ b/src/common_define.h @@ -169,6 +169,12 @@ typedef struct int length; } BufferInfo; +typedef struct +{ + char *str; + int len; +} string_t; + typedef void (*FreeDataFunc)(void *ptr); typedef int (*CompareFunc)(void *p1, void *p2); typedef void* (*MallocFunc)(size_t size); diff --git a/src/hash.c b/src/hash.c index 62596fd..ec9d50f 100644 --- a/src/hash.c +++ b/src/hash.c @@ -137,6 +137,7 @@ int hash_set_locks(HashArray *pHash, const int lock_count) return EINVAL; } + //do NOT support rehash if (pHash->load_factor >= 0.10) { return EINVAL; diff --git a/src/hash.h b/src/hash.h index 5791fc8..7e31c38 100644 --- a/src/hash.h +++ b/src/hash.h @@ -103,7 +103,7 @@ typedef int (*HashWalkFunc)(const int index, const HashData *data, void *args); * pHash: the hash table * hash_func: hash function * capacity: init capacity - * load_factor: hash load factor, such as 0.75 + * load_factor: hash load factor (or watermark), >= 0.10 for auto rehash. eg. 0.75 * max_bytes: max memory can be used (bytes) * bMallocValue: if need malloc value buffer * return 0 for success, != 0 for error