summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSuren A. Chilingaryan <csa@dside.dyndns.org>2012-11-11 06:14:05 +0100
committerSuren A. Chilingaryan <csa@dside.dyndns.org>2012-11-11 06:14:05 +0100
commit3b2f9f81b4acd381fde740f4086089f5c57a1a4e (patch)
tree94d3e595ac40d068169b664a1d8941f37ca703bc
parent2cbf21ae16724b7783cc31068072aaec59035ea5 (diff)
downloadlibrcc-3b2f9f81b4acd381fde740f4086089f5c57a1a4e.tar.gz
librcc-3b2f9f81b4acd381fde740f4086089f5c57a1a4e.tar.bz2
librcc-3b2f9f81b4acd381fde740f4086089f5c57a1a4e.tar.xz
librcc-3b2f9f81b4acd381fde740f4086089f5c57a1a4e.zip
Fixed memory leak with disabled bdb
-rw-r--r--src/rccdb4.c8
1 files changed, 2 insertions, 6 deletions
diff --git a/src/rccdb4.c b/src/rccdb4.c
index 738952b..1e8fdb1 100644
--- a/src/rccdb4.c
+++ b/src/rccdb4.c
@@ -50,6 +50,7 @@ db4_context rccDb4CreateContext(const char *dbpath, rcc_db4_flags flags) {
}
static int rccDb4InitContext(db4_context ctx, const char *dbpath, rcc_db4_flags flags) {
+#ifdef HAVE_DB_H
int err;
if (ctx->initialized) {
@@ -68,7 +69,6 @@ static int rccDb4InitContext(db4_context ctx, const char *dbpath, rcc_db4_flags
ctx->initialized = 1;
rccUnLock();
-#ifdef HAVE_DB_H
DB_ENV *dbe;
DB *db;
@@ -167,8 +167,8 @@ void rccDb4FreeContext(db4_context ctx) {
#ifdef HAVE_DB_H
if (ctx->db) ctx->db->close(ctx->db, 0);
if (ctx->dbe) ctx->dbe->close(ctx->dbe, 0);
- if (ctx->dbpath) free(ctx->dbpath);
#endif /* HAVE_DB_H */
+ if (ctx->dbpath) free(ctx->dbpath);
free(ctx);
}
}
@@ -197,12 +197,10 @@ static void rccDb4Strip(DBT *key) {
int rccDb4SetKey(db4_context ctx, const char *orig, size_t olen, const char *string) {
#ifdef HAVE_DB_H
DBT key, data;
-#endif /* HAVE_DB_H */
if ((!ctx)||(!orig)||(!string)) return -1;
if (rccDb4InitContext(ctx, ctx->dbpath, ctx->flags)) return -1;
-#ifdef HAVE_DB_H
memset(&key, 0, sizeof(key));
memset(&data, 0, sizeof(data));
@@ -223,12 +221,10 @@ int rccDb4SetKey(db4_context ctx, const char *orig, size_t olen, const char *str
char *rccDb4GetKey(db4_context ctx, const char *orig, size_t olen) {
#ifdef HAVE_DB_H
DBT key, data;
-#endif /* HAVE_DB_H */
if ((!ctx)||(!orig)) return NULL;
if (rccDb4InitContext(ctx, ctx->dbpath, ctx->flags)) return NULL;
-#ifdef HAVE_DB_H
memset(&key, 0, sizeof(key));
memset(&data, 0, sizeof(data));