From 4bbbfca83072a84a585ed0570c05792df21b33d2 Mon Sep 17 00:00:00 2001 From: Richard Russon Date: Wed, 21 Aug 2019 12:20:50 +0100 Subject: [PATCH] hcache: unify naming in free() Ensure all the hcache backends clean up in the same way. --- hcache/bdb.c | 18 +++++++++--------- hcache/gdbm.c | 7 ++++--- hcache/kc.c | 7 ++++--- hcache/lmdb.c | 18 +++++++++--------- hcache/qdbm.c | 7 ++++--- hcache/tc.c | 7 ++++--- 6 files changed, 34 insertions(+), 30 deletions(-) diff --git a/hcache/bdb.c b/hcache/bdb.c index 872520258..d9e7bcc61 100644 --- a/hcache/bdb.c +++ b/hcache/bdb.c @@ -222,19 +222,19 @@ static int hcache_bdb_delete_header(void *vctx, const char *key, size_t keylen) /** * hcache_bdb_close - Implements HcacheOps::close() */ -static void hcache_bdb_close(void **vctx) +static void hcache_bdb_close(void **ptr) { - if (!vctx || !*vctx) + if (!ptr || !*ptr) return; - struct HcacheDbCtx *ctx = *vctx; + struct HcacheDbCtx *db = *ptr; - ctx->db->close(ctx->db, 0); - ctx->env->close(ctx->env, 0); - mutt_file_unlock(ctx->fd); - close(ctx->fd); - unlink(ctx->lockfile); - FREE(vctx); + db->db->close(db->db, 0); + db->env->close(db->env, 0); + mutt_file_unlock(db->fd); + close(db->fd); + unlink(db->lockfile); + FREE(ptr); } /** diff --git a/hcache/gdbm.c b/hcache/gdbm.c index 32acd6584..017f7723b 100644 --- a/hcache/gdbm.c +++ b/hcache/gdbm.c @@ -123,13 +123,14 @@ static int hcache_gdbm_delete_header(void *ctx, const char *key, size_t keylen) /** * hcache_gdbm_close - Implements HcacheOps::close() */ -static void hcache_gdbm_close(void **ctx) +static void hcache_gdbm_close(void **ptr) { - if (!ctx) + if (!ptr || !*ptr) return; - GDBM_FILE db = *ctx; + GDBM_FILE db = *ptr; gdbm_close(db); + *ptr = NULL; } /** diff --git a/hcache/kc.c b/hcache/kc.c index c9ab8ae6f..e01381553 100644 --- a/hcache/kc.c +++ b/hcache/kc.c @@ -129,18 +129,19 @@ static int hcache_kyotocabinet_delete_header(void *ctx, const char *key, size_t /** * hcache_kyotocabinet_close - Implements HcacheOps::close() */ -static void hcache_kyotocabinet_close(void **ctx) +static void hcache_kyotocabinet_close(void **ptr) { - if (!ctx || !*ctx) + if (!ptr || !*ptr) return; - KCDB *db = *ctx; + KCDB *db = *ptr; if (!kcdbclose(db)) { int ecode = kcdbecode(db); mutt_debug(LL_DEBUG2, "kcdbclose failed: %s (ecode %d)\n", kcdbemsg(db), ecode); } kcdbdel(db); + *ptr = NULL; } /** diff --git a/hcache/lmdb.c b/hcache/lmdb.c index 3c056486b..f23a6322d 100644 --- a/hcache/lmdb.c +++ b/hcache/lmdb.c @@ -285,22 +285,22 @@ static int hcache_lmdb_delete_header(void *vctx, const char *key, size_t keylen) /** * hcache_lmdb_close - Implements HcacheOps::close() */ -static void hcache_lmdb_close(void **vctx) +static void hcache_lmdb_close(void **ptr) { - if (!vctx || !*vctx) + if (!ptr || !*ptr) return; - struct HcacheLmdbCtx *ctx = *vctx; + struct HcacheLmdbCtx *db = *ptr; - if (ctx->txn && (ctx->txn_mode == TXN_WRITE)) + if (db->txn && (db->txn_mode == TXN_WRITE)) { - mdb_txn_commit(ctx->txn); - ctx->txn_mode = TXN_UNINITIALIZED; - ctx->txn = NULL; + mdb_txn_commit(db->txn); + db->txn_mode = TXN_UNINITIALIZED; + db->txn = NULL; } - mdb_env_close(ctx->env); - FREE(vctx); + mdb_env_close(db->env); + FREE(ptr); } /** diff --git a/hcache/qdbm.c b/hcache/qdbm.c index 08ecb0162..848f8c2ed 100644 --- a/hcache/qdbm.c +++ b/hcache/qdbm.c @@ -104,13 +104,14 @@ static int hcache_qdbm_delete_header(void *ctx, const char *key, size_t keylen) /** * hcache_qdbm_close - Implements HcacheOps::close() */ -static void hcache_qdbm_close(void **ctx) +static void hcache_qdbm_close(void **ptr) { - if (!ctx || !*ctx) + if (!ptr || !*ptr) return; - VILLA *db = *ctx; + VILLA *db = *ptr; vlclose(db); + *ptr = NULL; } /** diff --git a/hcache/tc.c b/hcache/tc.c index 7a265e559..8dd6267eb 100644 --- a/hcache/tc.c +++ b/hcache/tc.c @@ -118,18 +118,19 @@ static int hcache_tokyocabinet_delete_header(void *ctx, const char *key, size_t /** * hcache_tokyocabinet_close - Implements HcacheOps::close() */ -static void hcache_tokyocabinet_close(void **ctx) +static void hcache_tokyocabinet_close(void **ptr) { - if (!ctx || !*ctx) + if (!ptr || !*ptr) return; - TCBDB *db = *ctx; + TCBDB *db = *ptr; if (!tcbdbclose(db)) { int ecode = tcbdbecode(db); mutt_debug(LL_DEBUG2, "tcbdbclose failed: %s (ecode %d)\n", tcbdberrmsg(ecode), ecode); } tcbdbdel(db); + *ptr = NULL; } /** -- 2.40.0