Commit 683fd63c authored by Bradley C. Kuszmaul's avatar Bradley C. Kuszmaul

Get rid of memory leaks found by valgrind. Addresses #197.

git-svn-id: file:///svn/tokudb@1216 c7de825b-a66e-492c-adef-691d508d4ae1
parent 6f760555
...@@ -24,6 +24,9 @@ Db::Db(DbEnv *env, u_int32_t flags) ...@@ -24,6 +24,9 @@ Db::Db(DbEnv *env, u_int32_t flags)
} }
Db::~Db() { Db::~Db() {
if (is_private_env) {
delete the_Env; // The destructor closes the env.
}
if (!the_db) { if (!the_db) {
close(0); // the user should have called close, but we do it here if not done. close(0); // the user should have called close, but we do it here if not done.
} }
......
SRCS = $(wildcard *.cpp) SRCS = $(wildcard *.cpp)
TARGETS = $(patsubst %.cpp,%,$(SRCS)) TARGETS = $(patsubst %.cpp,%,$(SRCS))
DBCXX = ../dbt.o ../db.o ../dbenv.o ../dbc.o
CPPFLAGS = -I../ -I../../include CPPFLAGS = -I../ -I../../include
CXXFLAGS = -Wall -g CXXFLAGS = -Wall -g
LDLIBS = ../../lib/libdb.a -lz LDLIBS = ../../lib/libtdb_cxx.a ../../lib/libdb.a -lz
all: $(TARGETS) all: $(TARGETS)
$(TARGETS): $(DBCXX) $(TARGETS): $(DBCXX)
......
...@@ -28,6 +28,7 @@ int dbcreate(char *dbfile, char *dbname, int argc, char *argv[]) { ...@@ -28,6 +28,7 @@ int dbcreate(char *dbfile, char *dbname, int argc, char *argv[]) {
r = env->close(0); assert(r == 0); r = env->close(0); assert(r == 0);
delete env; delete env;
} }
delete db;
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment