From 7b59452aed431ef41c205d801ccd4311067b5d9d Mon Sep 17 00:00:00 2001 From: Leo Yuriev Date: Fri, 2 Feb 2018 19:05:41 +0300 Subject: [PATCH] mdbx: less memset overhead while txn-init. --- src/mdbx.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/mdbx.c b/src/mdbx.c index f174bc2c..e8c07666 100644 --- a/src/mdbx.c +++ b/src/mdbx.c @@ -2735,7 +2735,8 @@ int mdbx_txn_begin(MDBX_env *env, MDBX_txn *parent, unsigned flags, MDBX_txn **ret) { MDBX_txn *txn; MDBX_ntxn *ntxn; - int rc, size, tsize; + int rc; + unsigned size, tsize; if (unlikely(!env || !ret)) return MDBX_EINVAL; @@ -2787,10 +2788,11 @@ int mdbx_txn_begin(MDBX_env *env, MDBX_txn *parent, unsigned flags, return MDBX_BUSY; goto renew; } - if (unlikely((txn = calloc(1, size)) == NULL)) { + if (unlikely((txn = malloc(size)) == NULL)) { mdbx_debug("calloc: %s", "failed"); return MDBX_ENOMEM; } + memset(txn, 0, tsize); txn->mt_dbxs = env->me_dbxs; /* static */ txn->mt_dbs = (MDBX_db *)((char *)txn + tsize); txn->mt_dbflags = (uint8_t *)txn + size - env->me_maxdbs;