Commit a1ac18a7 authored by Bradley C. Kuszmaul's avatar Bradley C. Kuszmaul

Clean up the way cursors are handled. This code shows that something is freed...

Clean up the way cursors are handled.  This code shows that something is freed that shouldn't be.  Addresses #162.

git-svn-id: file:///svn/tokudb@1073 c7de825b-a66e-492c-adef-691d508d4ae1
parent 4b85c787
...@@ -137,9 +137,11 @@ static void close_databases (void) { ...@@ -137,9 +137,11 @@ static void close_databases (void) {
if (delete_cursor) { if (delete_cursor) {
r = delete_cursor->c_close(delete_cursor); CKERR(r); r = delete_cursor->c_close(delete_cursor); CKERR(r);
} }
delete_cursor=0;
if (name_cursor) { if (name_cursor) {
r = name_cursor->c_close(name_cursor); CKERR(r); r = name_cursor->c_close(name_cursor); CKERR(r);
} }
name_cursor=0;
if (nc_key.data) free(nc_key.data); if (nc_key.data) free(nc_key.data);
if (nc_data.data) free(nc_data.data); if (nc_data.data) free(nc_data.data);
r = namedb->close(namedb, 0); CKERR(r); r = namedb->close(namedb, 0); CKERR(r);
...@@ -293,7 +295,8 @@ static void activity (void) { ...@@ -293,7 +295,8 @@ static void activity (void) {
|| (oppass==1 && opnum==26) || (oppass==1 && opnum==26)
|| (oppass==1 && opnum==30) || (oppass==1 && opnum==30)
|| (oppass==2 && opnum==9) || (oppass==2 && opnum==9)
|| (oppass==2 && opnum==15)); || (oppass==2 && opnum==15)
);
if (do_insert) { if (do_insert) {
insert_person(); insert_person();
} else { } else {
...@@ -315,10 +318,10 @@ int main (int argc, const char *argv[]) { ...@@ -315,10 +318,10 @@ int main (int argc, const char *argv[]) {
memset(&nc_key, 0, sizeof(nc_key)); memset(&nc_key, 0, sizeof(nc_key));
memset(&nc_data, 0, sizeof(nc_data)); memset(&nc_data, 0, sizeof(nc_data));
nc_key.flags = DB_DBT_REALLOC; nc_key.flags = DB_DBT_REALLOC;
nc_key.data = malloc(1); // Iniitalize it. nc_key.data = malloc(1); // Initalize it.
((char*)nc_key.data)[0]=0; ((char*)nc_key.data)[0]=0;
nc_data.flags = DB_DBT_REALLOC; nc_data.flags = DB_DBT_REALLOC;
nc_data.data = malloc(1); // Iniitalize it. nc_data.data = malloc(1); // Initalize it.
mode = MODE_DEFAULT; mode = MODE_DEFAULT;
...@@ -345,6 +348,8 @@ int main (int argc, const char *argv[]) { ...@@ -345,6 +348,8 @@ int main (int argc, const char *argv[]) {
activity(); activity();
} }
} }
close_databases();
break; break;
case MODE_MORE: case MODE_MORE:
oppass=2; oppass=2;
...@@ -360,11 +365,10 @@ int main (int argc, const char *argv[]) { ...@@ -360,11 +365,10 @@ int main (int argc, const char *argv[]) {
activity(); activity();
} }
} }
close_databases();
break; break;
} }
close_databases();
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