aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libucl/ucl_hash.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2018-02-14 11:42:36 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2018-02-14 14:45:25 +0000
commit9f0a4220decbb0adaf8aa63d506cf01c55e3204c (patch)
treebc1f044bb9b48872137b31b383ff7d89ab9d06a6 /contrib/libucl/ucl_hash.c
parenta755e38112262b462ee2c95eedb71299c688ee5e (diff)
downloadrspamd-9f0a4220decbb0adaf8aa63d506cf01c55e3204c.tar.gz
rspamd-9f0a4220decbb0adaf8aa63d506cf01c55e3204c.zip
[Feature] Allow to reserve elements in libucl
Diffstat (limited to 'contrib/libucl/ucl_hash.c')
-rw-r--r--contrib/libucl/ucl_hash.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/contrib/libucl/ucl_hash.c b/contrib/libucl/ucl_hash.c
index 0bb8759f6..ce2a4fdb5 100644
--- a/contrib/libucl/ucl_hash.c
+++ b/contrib/libucl/ucl_hash.c
@@ -395,3 +395,25 @@ ucl_hash_delete (ucl_hash_t* hashlin, const ucl_object_t *obj)
}
}
}
+
+void ucl_hash_reserve (ucl_hash_t *hashlin, size_t sz)
+{
+ if (hashlin == NULL) {
+ return;
+ }
+
+ if (sz > hashlin->ar.m) {
+ kv_resize (const ucl_object_t *, hashlin->ar, sz);
+
+ if (hashlin->caseless) {
+ khash_t(ucl_hash_caseless_node) *h = (khash_t(
+ ucl_hash_caseless_node) *)
+ hashlin->hash;
+ kh_resize (ucl_hash_caseless_node, h, sz);
+ } else {
+ khash_t(ucl_hash_node) *h = (khash_t(ucl_hash_node) *)
+ hashlin->hash;
+ kh_resize (ucl_hash_node, h, sz);
+ }
+ }
+} \ No newline at end of file