Commit 945673e8 authored by Rich Prohaska's avatar Rich Prohaska Committed by Yoni Fogel

#2921 refs[t:2921] remove obsolete memory functions

git-svn-id: file:///svn/toku/tokudb@23625 c7de825b-a66e-492c-adef-691d508d4ae1
parent 3e391840
...@@ -453,7 +453,6 @@ main (int argc, const char *const argv[]) { ...@@ -453,7 +453,6 @@ main (int argc, const char *const argv[]) {
dump_node_wrapper, &info, TRUE, TRUE); dump_node_wrapper, &info, TRUE, TRUE);
} }
toku_brtheader_free(h); toku_brtheader_free(h);
toku_malloc_cleanup();
return 0; return 0;
} }
......
...@@ -41,6 +41,5 @@ int recovery_main (int argc, const char *const argv[]) { ...@@ -41,6 +41,5 @@ int recovery_main (int argc, const char *const argv[]) {
fprintf(stderr, "Recovery failed\n"); fprintf(stderr, "Recovery failed\n");
return(1); return(1);
} }
toku_malloc_cleanup();
return 0; return 0;
} }
...@@ -194,10 +194,7 @@ test_main (int argc, const char *argv[]) { ...@@ -194,10 +194,7 @@ test_main (int argc, const char *argv[]) {
fflush(stdout); fflush(stdout);
} }
unlink(fname); unlink(fname);
if (verbose>1) {
toku_malloc_report();
}
toku_malloc_cleanup();
return 0; return 0;
} }
...@@ -149,6 +149,5 @@ test_main (int argc __attribute__((__unused__)), const char *argv[] __attribute_ ...@@ -149,6 +149,5 @@ test_main (int argc __attribute__((__unused__)), const char *argv[] __attribute_
toku_memory_check = 1; toku_memory_check = 1;
test_serialize_leaf(); test_serialize_leaf();
test_serialize_nonleaf(); test_serialize_nonleaf();
toku_malloc_cleanup();
return 0; return 0;
} }
...@@ -102,8 +102,6 @@ test_main (int argc , const char *argv[]) { ...@@ -102,8 +102,6 @@ test_main (int argc , const char *argv[]) {
DB a_db; DB a_db;
DB *db = &a_db; DB *db = &a_db;
test_brt_cursor(db); test_brt_cursor(db);
toku_malloc_cleanup();
if (verbose) printf("test ok\n"); if (verbose) printf("test ok\n");
return 0; return 0;
} }
...@@ -885,40 +885,40 @@ static void test_brt_cursor(DB *db) { ...@@ -885,40 +885,40 @@ static void test_brt_cursor(DB *db) {
test_multiple_brt_cursors(3, db); test_multiple_brt_cursors(3, db);
for (n=0; n<test_brt_cursor_limit; n += test_brt_cursor_inc) { for (n=0; n<test_brt_cursor_limit; n += test_brt_cursor_inc) {
test_brt_cursor_first(n, db); toku_memory_check_all_free(); test_brt_cursor_first(n, db);
} }
for (n=0; n<test_brt_cursor_limit; n += test_brt_cursor_inc) { for (n=0; n<test_brt_cursor_limit; n += test_brt_cursor_inc) {
test_brt_cursor_rfirst(n, db); toku_memory_check_all_free(); test_brt_cursor_rfirst(n, db);
} }
for (n=0; n<test_brt_cursor_limit; n += test_brt_cursor_inc) { for (n=0; n<test_brt_cursor_limit; n += test_brt_cursor_inc) {
test_brt_cursor_walk(n, db); toku_memory_check_all_free(); test_brt_cursor_walk(n, db);
} }
for (n=0; n<test_brt_cursor_limit; n += test_brt_cursor_inc) { for (n=0; n<test_brt_cursor_limit; n += test_brt_cursor_inc) {
test_brt_cursor_last(n, db); toku_memory_check_all_free(); test_brt_cursor_last(n, db);
} }
for (n=0; n<test_brt_cursor_limit; n += test_brt_cursor_inc) { for (n=0; n<test_brt_cursor_limit; n += test_brt_cursor_inc) {
test_brt_cursor_first_last(n, db); toku_memory_check_all_free(); test_brt_cursor_first_last(n, db);
} }
for (n=0; n<test_brt_cursor_limit; n += test_brt_cursor_inc) { for (n=0; n<test_brt_cursor_limit; n += test_brt_cursor_inc) {
test_brt_cursor_split(n, db); toku_memory_check_all_free(); test_brt_cursor_split(n, db);
} }
for (n=0; n<test_brt_cursor_limit; n += test_brt_cursor_inc) { for (n=0; n<test_brt_cursor_limit; n += test_brt_cursor_inc) {
test_brt_cursor_rand(n, db); toku_memory_check_all_free(); test_brt_cursor_rand(n, db);
} }
for (n=0; n<test_brt_cursor_limit; n += test_brt_cursor_inc) { for (n=0; n<test_brt_cursor_limit; n += test_brt_cursor_inc) {
test_brt_cursor_rwalk(n, db); toku_memory_check_all_free(); test_brt_cursor_rwalk(n, db);
} }
test_brt_cursor_set(1000, DB_SET, db); toku_memory_check_all_free(); test_brt_cursor_set(1000, DB_SET, db);
test_brt_cursor_set(10000, DB_SET, db); toku_memory_check_all_free(); test_brt_cursor_set(10000, DB_SET, db);
test_brt_cursor_set(1000, DB_SET_RANGE, db); toku_memory_check_all_free(); test_brt_cursor_set(1000, DB_SET_RANGE, db);
test_brt_cursor_set_range(1000, db); toku_memory_check_all_free(); test_brt_cursor_set_range(1000, db);
test_brt_cursor_set_range(10000, db); toku_memory_check_all_free(); test_brt_cursor_set_range(10000, db);
test_brt_cursor_delete(1000, db); toku_memory_check_all_free(); test_brt_cursor_delete(1000, db);
test_multiple_brt_cursor_walk(10000, db); toku_memory_check_all_free(); test_multiple_brt_cursor_walk(10000, db);
test_multiple_brt_cursor_walk(100000, db); toku_memory_check_all_free(); test_multiple_brt_cursor_walk(100000, db);
} }
...@@ -929,8 +929,6 @@ test_main (int argc , const char *argv[]) { ...@@ -929,8 +929,6 @@ test_main (int argc , const char *argv[]) {
DB a_db; DB a_db;
DB *db = &a_db; DB *db = &a_db;
test_brt_cursor(db); test_brt_cursor(db);
toku_malloc_cleanup();
if (verbose) printf("test ok\n"); if (verbose) printf("test ok\n");
return 0; return 0;
} }
...@@ -22,7 +22,7 @@ static void test_dump_empty_db (void) { ...@@ -22,7 +22,7 @@ static void test_dump_empty_db (void) {
if (verbose) toku_dump_brt(stdout, t); if (verbose) toku_dump_brt(stdout, t);
r = toku_close_brt(t, 0); assert(r==0); r = toku_close_brt(t, 0); assert(r==0);
r = toku_cachetable_close(&ct); assert(r==0); r = toku_cachetable_close(&ct); assert(r==0);
toku_memory_check_all_free();
} }
/* Test running multiple trees in different files */ /* Test running multiple trees in different files */
...@@ -35,7 +35,7 @@ static void test_multiple_files_of_size (int size) { ...@@ -35,7 +35,7 @@ static void test_multiple_files_of_size (int size) {
if (verbose) printf("test_multiple_files_of_size(%d)\n", size); if (verbose) printf("test_multiple_files_of_size(%d)\n", size);
unlink(n0); unlink(n0);
unlink(n1); unlink(n1);
toku_memory_check_all_free();
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0); r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
r = toku_open_brt(n0, 1, &t0, size, ct, null_txn, toku_builtin_compare_fun, null_db); assert(r==0); r = toku_open_brt(n0, 1, &t0, size, ct, null_txn, toku_builtin_compare_fun, null_db); assert(r==0);
r = toku_open_brt(n1, 1, &t1, size, ct, null_txn, toku_builtin_compare_fun, null_db); assert(r==0); r = toku_open_brt(n1, 1, &t1, size, ct, null_txn, toku_builtin_compare_fun, null_db); assert(r==0);
...@@ -57,7 +57,7 @@ static void test_multiple_files_of_size (int size) { ...@@ -57,7 +57,7 @@ static void test_multiple_files_of_size (int size) {
r = toku_close_brt(t0, 0); assert(r==0); r = toku_close_brt(t0, 0); assert(r==0);
r = toku_close_brt(t1, 0); assert(r==0); r = toku_close_brt(t1, 0); assert(r==0);
r = toku_cachetable_close(&ct); assert(r==0); r = toku_cachetable_close(&ct); assert(r==0);
toku_memory_check_all_free();
/* Now see if the data is all there. */ /* Now see if the data is all there. */
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0); r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
...@@ -78,7 +78,7 @@ static void test_multiple_files_of_size (int size) { ...@@ -78,7 +78,7 @@ static void test_multiple_files_of_size (int size) {
r = toku_close_brt(t0, 0); assert(r==0); r = toku_close_brt(t0, 0); assert(r==0);
r = toku_close_brt(t1, 0); assert(r==0); r = toku_close_brt(t1, 0); assert(r==0);
r = toku_cachetable_close(&ct); assert(r==0); r = toku_cachetable_close(&ct); assert(r==0);
toku_memory_check_all_free();
} }
static void test_multiple_files (void) { static void test_multiple_files (void) {
...@@ -93,7 +93,7 @@ static void test_multiple_brts_one_db_one_file (void) { ...@@ -93,7 +93,7 @@ static void test_multiple_brts_one_db_one_file (void) {
CACHETABLE ct; CACHETABLE ct;
BRT trees[MANYN]; BRT trees[MANYN];
if (verbose) printf("test_multiple_brts_one_db_one_file:"); if (verbose) printf("test_multiple_brts_one_db_one_file:");
toku_memory_check_all_free();
unlink(fname); unlink(fname);
r = toku_brt_create_cachetable(&ct, 32, ZERO_LSN, NULL_LOGGER); assert(r==0); r = toku_brt_create_cachetable(&ct, 32, ZERO_LSN, NULL_LOGGER); assert(r==0);
for (i=0; i<MANYN; i++) { for (i=0; i<MANYN; i++) {
...@@ -117,7 +117,7 @@ static void test_multiple_brts_one_db_one_file (void) { ...@@ -117,7 +117,7 @@ static void test_multiple_brts_one_db_one_file (void) {
r=toku_close_brt(trees[i], 0); assert(r==0); r=toku_close_brt(trees[i], 0); assert(r==0);
} }
r = toku_cachetable_close(&ct); assert(r==0); r = toku_cachetable_close(&ct); assert(r==0);
toku_memory_check_all_free();
if (verbose) printf(" ok\n"); if (verbose) printf(" ok\n");
} }
...@@ -132,14 +132,14 @@ static void test_read_what_was_written (void) { ...@@ -132,14 +132,14 @@ static void test_read_what_was_written (void) {
if (verbose) printf("test_read_what_was_written(): "); fflush(stdout); if (verbose) printf("test_read_what_was_written(): "); fflush(stdout);
unlink(fname); unlink(fname);
toku_memory_check_all_free();
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0); r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
r = toku_open_brt(fname, 1, &brt, 1<<12, ct, null_txn, toku_builtin_compare_fun, null_db); assert(r==0); r = toku_open_brt(fname, 1, &brt, 1<<12, ct, null_txn, toku_builtin_compare_fun, null_db); assert(r==0);
r = toku_close_brt(brt, 0); assert(r==0); r = toku_close_brt(brt, 0); assert(r==0);
r = toku_cachetable_close(&ct); assert(r==0); r = toku_cachetable_close(&ct); assert(r==0);
toku_memory_check_all_free();
/* Now see if we can read an empty tree in. */ /* Now see if we can read an empty tree in. */
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0); r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
...@@ -154,7 +154,7 @@ static void test_read_what_was_written (void) { ...@@ -154,7 +154,7 @@ static void test_read_what_was_written (void) {
r = toku_close_brt(brt, 0); assert(r==0); r = toku_close_brt(brt, 0); assert(r==0);
r = toku_cachetable_close(&ct); assert(r==0); r = toku_cachetable_close(&ct); assert(r==0);
toku_memory_check_all_free();
/* Now see if we can read it in and get the value. */ /* Now see if we can read it in and get the value. */
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0); r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
...@@ -216,7 +216,7 @@ static void test_read_what_was_written (void) { ...@@ -216,7 +216,7 @@ static void test_read_what_was_written (void) {
if (verbose) printf("%s:%d About to close %p\n", __FILE__, __LINE__, ct); if (verbose) printf("%s:%d About to close %p\n", __FILE__, __LINE__, ct);
r = toku_cachetable_close(&ct); assert(r==0); r = toku_cachetable_close(&ct); assert(r==0);
toku_memory_check_all_free();
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0); r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
r = toku_open_brt(fname, 0, &brt, 1<<12, ct, null_txn, toku_builtin_compare_fun, null_db); assert(r==0); r = toku_open_brt(fname, 0, &brt, 1<<12, ct, null_txn, toku_builtin_compare_fun, null_db); assert(r==0);
...@@ -235,7 +235,7 @@ static void test_read_what_was_written (void) { ...@@ -235,7 +235,7 @@ static void test_read_what_was_written (void) {
r = toku_close_brt(brt, 0); assert(r==0); r = toku_close_brt(brt, 0); assert(r==0);
r = toku_cachetable_close(&ct); assert(r==0); r = toku_cachetable_close(&ct); assert(r==0);
toku_memory_check_all_free();
if (verbose) printf(" ok\n"); if (verbose) printf(" ok\n");
...@@ -249,7 +249,7 @@ static void test_cursor_last_empty(void) { ...@@ -249,7 +249,7 @@ static void test_cursor_last_empty(void) {
int r; int r;
if (verbose) printf("%s", __FUNCTION__); if (verbose) printf("%s", __FUNCTION__);
unlink(fname); unlink(fname);
toku_memory_check_all_free();
//printf("%s:%d %d alloced\n", __FILE__, __LINE__, toku_get_n_items_malloced()); toku_print_malloced_items(); //printf("%s:%d %d alloced\n", __FILE__, __LINE__, toku_get_n_items_malloced()); toku_print_malloced_items();
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0); r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
//printf("%s:%d %d alloced\n", __FILE__, __LINE__, toku_get_n_items_malloced()); toku_print_malloced_items(); //printf("%s:%d %d alloced\n", __FILE__, __LINE__, toku_get_n_items_malloced()); toku_print_malloced_items();
...@@ -272,7 +272,7 @@ static void test_cursor_last_empty(void) { ...@@ -272,7 +272,7 @@ static void test_cursor_last_empty(void) {
//printf("%s:%d %d alloced\n", __FILE__, __LINE__, toku_get_n_items_malloced()); toku_print_malloced_items(); //printf("%s:%d %d alloced\n", __FILE__, __LINE__, toku_get_n_items_malloced()); toku_print_malloced_items();
r = toku_cachetable_close(&ct); assert(r==0); r = toku_cachetable_close(&ct); assert(r==0);
//printf("%s:%d %d alloced\n", __FILE__, __LINE__, toku_get_n_items_malloced()); toku_print_malloced_items(); //printf("%s:%d %d alloced\n", __FILE__, __LINE__, toku_get_n_items_malloced()); toku_print_malloced_items();
toku_memory_check_all_free();
} }
static void test_cursor_next (void) { static void test_cursor_next (void) {
...@@ -283,7 +283,7 @@ static void test_cursor_next (void) { ...@@ -283,7 +283,7 @@ static void test_cursor_next (void) {
DBT kbt, vbt; DBT kbt, vbt;
unlink(fname); unlink(fname);
toku_memory_check_all_free();
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0); r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
//printf("%s:%d %d alloced\n", __FILE__, __LINE__, toku_get_n_items_malloced()); toku_print_malloced_items(); //printf("%s:%d %d alloced\n", __FILE__, __LINE__, toku_get_n_items_malloced()); toku_print_malloced_items();
r = toku_open_brt(fname, 1, &brt, 1<<12, ct, null_txn, toku_builtin_compare_fun, null_db); assert(r==0); r = toku_open_brt(fname, 1, &brt, 1<<12, ct, null_txn, toku_builtin_compare_fun, null_db); assert(r==0);
...@@ -323,7 +323,7 @@ static void test_cursor_next (void) { ...@@ -323,7 +323,7 @@ static void test_cursor_next (void) {
//printf("%s:%d %d alloced\n", __FILE__, __LINE__, toku_get_n_items_malloced()); toku_print_malloced_items(); //printf("%s:%d %d alloced\n", __FILE__, __LINE__, toku_get_n_items_malloced()); toku_print_malloced_items();
r = toku_cachetable_close(&ct); assert(r==0); r = toku_cachetable_close(&ct); assert(r==0);
//printf("%s:%d %d alloced\n", __FILE__, __LINE__, toku_get_n_items_malloced()); toku_print_malloced_items(); //printf("%s:%d %d alloced\n", __FILE__, __LINE__, toku_get_n_items_malloced()); toku_print_malloced_items();
toku_memory_check_all_free();
} }
...@@ -351,7 +351,7 @@ static void test_wrongendian_compare (int wrong_p, unsigned int N) { ...@@ -351,7 +351,7 @@ static void test_wrongendian_compare (int wrong_p, unsigned int N) {
unsigned int i; unsigned int i;
unlink(fname); unlink(fname);
toku_memory_check_all_free();
{ {
char a[4]={0,1,0,0}; char a[4]={0,1,0,0};
...@@ -442,7 +442,7 @@ static void test_wrongendian_compare (int wrong_p, unsigned int N) { ...@@ -442,7 +442,7 @@ static void test_wrongendian_compare (int wrong_p, unsigned int N) {
assert(r==0); assert(r==0);
} }
r = toku_cachetable_close(&ct); assert(r==0); r = toku_cachetable_close(&ct); assert(r==0);
toku_memory_check_all_free();
} }
static int test_brt_cursor_keycompare(DB *db __attribute__((unused)), const DBT *a, const DBT *b) { static int test_brt_cursor_keycompare(DB *db __attribute__((unused)), const DBT *a, const DBT *b) {
...@@ -487,7 +487,7 @@ static void test_brt_limits(void) { ...@@ -487,7 +487,7 @@ static void test_brt_limits(void) {
int bsize = 1024; int bsize = 1024;
int kvsize = 4; int kvsize = 4;
while (kvsize < bsize/2) { while (kvsize < bsize/2) {
test_large_kv(bsize, kvsize, kvsize); toku_memory_check_all_free(); test_large_kv(bsize, kvsize, kvsize);
kvsize *= 2; kvsize *= 2;
} }
} }
...@@ -774,19 +774,19 @@ static void test_insert_delete_lookup(int n) { ...@@ -774,19 +774,19 @@ static void test_insert_delete_lookup(int n) {
static void test_brt_delete(void) { static void test_brt_delete(void) {
test_brt_delete_empty(); toku_memory_check_all_free(); test_brt_delete_empty();
test_brt_delete_present(1); toku_memory_check_all_free(); test_brt_delete_present(1);
test_brt_delete_present(100); toku_memory_check_all_free(); test_brt_delete_present(100);
test_brt_delete_present(500); toku_memory_check_all_free(); test_brt_delete_present(500);
test_brt_delete_not_present(1); toku_memory_check_all_free(); test_brt_delete_not_present(1);
test_brt_delete_not_present(100); toku_memory_check_all_free(); test_brt_delete_not_present(100);
test_brt_delete_not_present(500); toku_memory_check_all_free(); test_brt_delete_not_present(500);
test_brt_delete_cursor_first(1); toku_memory_check_all_free(); test_brt_delete_cursor_first(1);
test_brt_delete_cursor_first(100); toku_memory_check_all_free(); test_brt_delete_cursor_first(100);
test_brt_delete_cursor_first(500); toku_memory_check_all_free(); test_brt_delete_cursor_first(500);
test_brt_delete_cursor_first(10000); toku_memory_check_all_free(); test_brt_delete_cursor_first(10000);
test_insert_delete_lookup(2); toku_memory_check_all_free(); test_insert_delete_lookup(2);
test_insert_delete_lookup(512); toku_memory_check_all_free(); test_insert_delete_lookup(512);
} }
static void test_new_brt_cursor_create_close (void) { static void test_new_brt_cursor_create_close (void) {
...@@ -1207,33 +1207,33 @@ static void test_new_brt_cursor_set(int n, int cursor_op, DB *db) { ...@@ -1207,33 +1207,33 @@ static void test_new_brt_cursor_set(int n, int cursor_op, DB *db) {
static void test_new_brt_cursors(int dup_mode) { static void test_new_brt_cursors(int dup_mode) {
assert(dup_mode==0); assert(dup_mode==0);
test_new_brt_cursor_create_close(); toku_memory_check_all_free(); test_new_brt_cursor_create_close();
test_new_brt_cursor_first(8, dup_mode); toku_memory_check_all_free(); test_new_brt_cursor_first(8, dup_mode);
test_new_brt_cursor_last(8, dup_mode); toku_memory_check_all_free(); test_new_brt_cursor_last(8, dup_mode);
test_new_brt_cursor_last(512, dup_mode); toku_memory_check_all_free(); test_new_brt_cursor_last(512, dup_mode);
test_new_brt_cursor_next(8, dup_mode); toku_memory_check_all_free(); test_new_brt_cursor_next(8, dup_mode);
test_new_brt_cursor_prev(8, dup_mode); toku_memory_check_all_free(); test_new_brt_cursor_prev(8, dup_mode);
test_new_brt_cursor_current(8, dup_mode); toku_memory_check_all_free(); test_new_brt_cursor_current(8, dup_mode);
test_new_brt_cursor_next(512, dup_mode); toku_memory_check_all_free(); test_new_brt_cursor_next(512, dup_mode);
test_new_brt_cursor_set_range(512, dup_mode); toku_memory_check_all_free(); test_new_brt_cursor_set_range(512, dup_mode);
test_new_brt_cursor_set(512, DB_SET, 0); toku_memory_check_all_free(); test_new_brt_cursor_set(512, DB_SET, 0);
} }
static void brt_blackbox_test (void) { static void brt_blackbox_test (void) {
toku_memory_check = 1; toku_memory_check = 1;
test_wrongendian_compare(0, 2); toku_memory_check_all_free(); test_wrongendian_compare(0, 2);
test_wrongendian_compare(1, 2); toku_memory_check_all_free(); test_wrongendian_compare(1, 2);
test_wrongendian_compare(1, 257); toku_memory_check_all_free(); test_wrongendian_compare(1, 257);
test_wrongendian_compare(1, 1000); toku_memory_check_all_free(); test_wrongendian_compare(1, 1000);
test_new_brt_cursors(0); test_new_brt_cursors(0);
test_read_what_was_written(); toku_memory_check_all_free(); if (verbose) printf("did read_what_was_written\n"); test_read_what_was_written(); if (verbose) printf("did read_what_was_written\n");
test_cursor_next(); toku_memory_check_all_free(); test_cursor_next();
test_cursor_last_empty(); toku_memory_check_all_free(); test_cursor_last_empty();
test_multiple_brts_one_db_one_file(); toku_memory_check_all_free(); test_multiple_brts_one_db_one_file();
test_dump_empty_db(); toku_memory_check_all_free(); test_dump_empty_db();
toku_memory_check_all_free();
toku_memory_check_all_free();
if (verbose) printf("test_multiple_files\n"); if (verbose) printf("test_multiple_files\n");
test_multiple_files(); test_multiple_files();
...@@ -1260,7 +1260,6 @@ test_main (int argc , const char *argv[]) { ...@@ -1260,7 +1260,6 @@ test_main (int argc , const char *argv[]) {
default_parse_args(argc, argv); default_parse_args(argc, argv);
brt_blackbox_test(); brt_blackbox_test();
toku_malloc_cleanup();
if (verbose) printf("test ok\n"); if (verbose) printf("test ok\n");
return 0; return 0;
} }
...@@ -14,7 +14,7 @@ static void test0 (void) { ...@@ -14,7 +14,7 @@ static void test0 (void) {
char fname[]= __FILE__ "0.brt"; char fname[]= __FILE__ "0.brt";
if (verbose) printf("%s:%d test0\n", __FILE__, __LINE__); if (verbose) printf("%s:%d test0\n", __FILE__, __LINE__);
toku_memory_check=1; toku_memory_check=1;
toku_memory_check_all_free();
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(r==0); assert(r==0);
if (verbose) printf("%s:%d test0\n", __FILE__, __LINE__); if (verbose) printf("%s:%d test0\n", __FILE__, __LINE__);
...@@ -27,7 +27,7 @@ static void test0 (void) { ...@@ -27,7 +27,7 @@ static void test0 (void) {
//printf("%s:%d n_items_malloced=%lld\n", __FILE__, __LINE__, n_items_malloced); //printf("%s:%d n_items_malloced=%lld\n", __FILE__, __LINE__, n_items_malloced);
r = toku_cachetable_close(&ct); r = toku_cachetable_close(&ct);
assert(r==0); assert(r==0);
toku_memory_check_all_free();
} }
int int
...@@ -37,7 +37,7 @@ test_main (int argc , const char *argv[]) { ...@@ -37,7 +37,7 @@ test_main (int argc , const char *argv[]) {
test0(); test0();
if (verbose) printf("test0 B\n"); if (verbose) printf("test0 B\n");
test0(); /* Make sure it works twice. */ test0(); /* Make sure it works twice. */
toku_malloc_cleanup();
if (verbose) printf("test0 ok\n"); if (verbose) printf("test0 ok\n");
return 0; return 0;
} }
...@@ -14,7 +14,7 @@ static void test1 (void) { ...@@ -14,7 +14,7 @@ static void test1 (void) {
char fname[]= __FILE__ "1.brt"; char fname[]= __FILE__ "1.brt";
DBT k,v; DBT k,v;
toku_memory_check=1; toku_memory_check=1;
toku_memory_check_all_free();
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(r==0); assert(r==0);
unlink(fname); unlink(fname);
...@@ -29,7 +29,7 @@ static void test1 (void) { ...@@ -29,7 +29,7 @@ static void test1 (void) {
} }
r = toku_close_brt(t, 0); assert(r==0); r = toku_close_brt(t, 0); assert(r==0);
r = toku_cachetable_close(&ct); assert(r==0); r = toku_cachetable_close(&ct); assert(r==0);
toku_memory_check_all_free();
if (verbose) printf("test1 ok\n"); if (verbose) printf("test1 ok\n");
} }
int int
...@@ -37,7 +37,7 @@ test_main (int argc , const char *argv[]) { ...@@ -37,7 +37,7 @@ test_main (int argc , const char *argv[]) {
default_parse_args(argc, argv); default_parse_args(argc, argv);
if (verbose) printf("test1\n"); if (verbose) printf("test1\n");
test1(); test1();
toku_malloc_cleanup();
if (verbose) printf("test1 ok\n"); if (verbose) printf("test1 ok\n");
return 0; return 0;
} }
...@@ -15,7 +15,7 @@ static void test2 (int memcheck, int limit) { ...@@ -15,7 +15,7 @@ static void test2 (int memcheck, int limit) {
char fname[]= __FILE__ "2.brt"; char fname[]= __FILE__ "2.brt";
toku_memory_check=memcheck; toku_memory_check=memcheck;
if (verbose) printf("%s:%d checking\n", __FILE__, __LINE__); if (verbose) printf("%s:%d checking\n", __FILE__, __LINE__);
toku_memory_check_all_free();
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0); r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
unlink(fname); unlink(fname);
r = toku_open_brt(fname, 1, &t, 1024, ct, null_txn, toku_builtin_compare_fun, null_db); r = toku_open_brt(fname, 1, &t, 1024, ct, null_txn, toku_builtin_compare_fun, null_db);
...@@ -43,7 +43,7 @@ static void test2 (int memcheck, int limit) { ...@@ -43,7 +43,7 @@ static void test2 (int memcheck, int limit) {
r = toku_verify_brt(t); assert(r==0); r = toku_verify_brt(t); assert(r==0);
r = toku_close_brt(t, 0); assert(r==0); r = toku_close_brt(t, 0); assert(r==0);
r = toku_cachetable_close(&ct); assert(r==0); r = toku_cachetable_close(&ct); assert(r==0);
toku_memory_check_all_free();
if (verbose) printf("test2 ok\n"); if (verbose) printf("test2 ok\n");
} }
...@@ -57,7 +57,7 @@ test_main (int argc , const char *argv[]) { ...@@ -57,7 +57,7 @@ test_main (int argc , const char *argv[]) {
test2(0, 27); test2(0, 27);
test2(0, 212); test2(0, 212);
test2(0, 4096); test2(0, 4096);
toku_malloc_cleanup();
if (verbose) printf("test1 ok\n"); if (verbose) printf("test1 ok\n");
return 0; return 0;
} }
...@@ -17,7 +17,7 @@ static void test3 (int nodesize, int count, int memcheck) { ...@@ -17,7 +17,7 @@ static void test3 (int nodesize, int count, int memcheck) {
int i; int i;
CACHETABLE ct; CACHETABLE ct;
toku_memory_check=memcheck; toku_memory_check=memcheck;
toku_memory_check_all_free();
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0); r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
gettimeofday(&t0, 0); gettimeofday(&t0, 0);
unlink(fname); unlink(fname);
...@@ -33,7 +33,7 @@ static void test3 (int nodesize, int count, int memcheck) { ...@@ -33,7 +33,7 @@ static void test3 (int nodesize, int count, int memcheck) {
r = toku_verify_brt(t); assert(r==0); r = toku_verify_brt(t); assert(r==0);
r = toku_close_brt(t, 0); assert(r==0); r = toku_close_brt(t, 0); assert(r==0);
r = toku_cachetable_close(&ct); assert(r==0); r = toku_cachetable_close(&ct); assert(r==0);
toku_memory_check_all_free();
gettimeofday(&t1, 0); gettimeofday(&t1, 0);
{ {
double diff = toku_tdiff(&t1, &t0); double diff = toku_tdiff(&t1, &t0);
...@@ -71,7 +71,7 @@ test_main (int argc , const char *argv[]) { ...@@ -71,7 +71,7 @@ test_main (int argc , const char *argv[]) {
default_parse_args(argc, argv); default_parse_args(argc, argv);
brt_blackbox_test(); brt_blackbox_test();
toku_malloc_cleanup();
if (verbose) printf("test ok\n"); if (verbose) printf("test ok\n");
return 0; return 0;
} }
...@@ -19,7 +19,7 @@ static void test4 (int nodesize, int count, int memcheck) { ...@@ -19,7 +19,7 @@ static void test4 (int nodesize, int count, int memcheck) {
gettimeofday(&t0, 0); gettimeofday(&t0, 0);
unlink(fname); unlink(fname);
toku_memory_check=memcheck; toku_memory_check=memcheck;
toku_memory_check_all_free();
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0); r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
r = toku_open_brt(fname, 1, &t, nodesize, ct, null_txn, toku_builtin_compare_fun, null_db); assert(r==0); r = toku_open_brt(fname, 1, &t, nodesize, ct, null_txn, toku_builtin_compare_fun, null_db); assert(r==0);
for (i=0; i<count; i++) { for (i=0; i<count; i++) {
...@@ -33,7 +33,7 @@ static void test4 (int nodesize, int count, int memcheck) { ...@@ -33,7 +33,7 @@ static void test4 (int nodesize, int count, int memcheck) {
r = toku_verify_brt(t); assert(r==0); r = toku_verify_brt(t); assert(r==0);
r = toku_close_brt(t, 0); assert(r==0); r = toku_close_brt(t, 0); assert(r==0);
r = toku_cachetable_close(&ct); assert(r==0); r = toku_cachetable_close(&ct); assert(r==0);
toku_memory_check_all_free();
gettimeofday(&t1, 0); gettimeofday(&t1, 0);
{ {
double diff = toku_tdiff(&t1, &t0); double diff = toku_tdiff(&t1, &t0);
...@@ -65,7 +65,7 @@ test_main (int argc , const char *argv[]) { ...@@ -65,7 +65,7 @@ test_main (int argc , const char *argv[]) {
default_parse_args(argc, argv); default_parse_args(argc, argv);
brt_blackbox_test(); brt_blackbox_test();
toku_malloc_cleanup();
if (verbose) printf("test ok\n"); if (verbose) printf("test ok\n");
return 0; return 0;
} }
...@@ -15,7 +15,7 @@ static void test5 (void) { ...@@ -15,7 +15,7 @@ static void test5 (void) {
int i; int i;
CACHETABLE ct; CACHETABLE ct;
char fname[]= __FILE__ ".brt"; char fname[]= __FILE__ ".brt";
toku_memory_check_all_free();
MALLOC_N(limit,values); MALLOC_N(limit,values);
for (i=0; i<limit; i++) values[i]=-1; for (i=0; i<limit; i++) values[i]=-1;
unlink(fname); unlink(fname);
...@@ -51,7 +51,7 @@ static void test5 (void) { ...@@ -51,7 +51,7 @@ static void test5 (void) {
toku_free(values); toku_free(values);
r = toku_close_brt(t, 0); assert(r==0); r = toku_close_brt(t, 0); assert(r==0);
r = toku_cachetable_close(&ct); assert(r==0); r = toku_cachetable_close(&ct); assert(r==0);
toku_memory_check_all_free();
} }
int int
...@@ -59,7 +59,7 @@ test_main (int argc , const char *argv[]) { ...@@ -59,7 +59,7 @@ test_main (int argc , const char *argv[]) {
default_parse_args(argc, argv); default_parse_args(argc, argv);
test5(); test5();
toku_malloc_cleanup();
if (verbose) printf("test ok\n"); if (verbose) printf("test ok\n");
return 0; return 0;
} }
...@@ -110,7 +110,7 @@ static void *my_malloc(size_t n) { ...@@ -110,7 +110,7 @@ static void *my_malloc(size_t n) {
(void) toku_sync_fetch_and_increment_int32(&my_big_malloc_count); // my_big_malloc_count++; (void) toku_sync_fetch_and_increment_int32(&my_big_malloc_count); // my_big_malloc_count++;
if (do_malloc_errors) { if (do_malloc_errors) {
caller = __builtin_return_address(1); caller = __builtin_return_address(1);
if ((void*)toku_xmalloc <= caller && caller <= (void*)toku_malloc_report) if ((void*)toku_xmalloc <= caller && caller <= (void*)toku_set_func_malloc)
goto skip; goto skip;
if (event_add_and_fetch()== event_count_trigger) { if (event_add_and_fetch()== event_count_trigger) {
event_hit(); event_hit();
...@@ -135,7 +135,7 @@ static void *my_realloc(void *p, size_t n) { ...@@ -135,7 +135,7 @@ static void *my_realloc(void *p, size_t n) {
(void) toku_sync_increment_and_fetch_int32(&my_big_realloc_count); // my_big_realloc_count++; (void) toku_sync_increment_and_fetch_int32(&my_big_realloc_count); // my_big_realloc_count++;
if (do_realloc_errors) { if (do_realloc_errors) {
caller = __builtin_return_address(1); caller = __builtin_return_address(1);
if ((void*)toku_xrealloc <= caller && caller <= (void*)toku_malloc_report) if ((void*)toku_xrealloc <= caller && caller <= (void*)toku_set_func_malloc)
goto skip; goto skip;
if (event_add_and_fetch() == event_count_trigger) { if (event_add_and_fetch() == event_count_trigger) {
event_hit(); event_hit();
......
...@@ -184,7 +184,7 @@ static void *my_malloc(size_t n) { ...@@ -184,7 +184,7 @@ static void *my_malloc(size_t n) {
my_big_malloc_count++; my_big_malloc_count++;
if (my_malloc_event) { if (my_malloc_event) {
caller = __builtin_return_address(1); caller = __builtin_return_address(1);
if ((void*)toku_xmalloc <= caller && caller <= (void*)toku_malloc_report) if ((void*)toku_xmalloc <= caller && caller <= (void*)toku_set_func_malloc)
goto skip; goto skip;
event_count++; event_count++;
if (event_count == event_count_trigger) { if (event_count == event_count_trigger) {
...@@ -210,7 +210,7 @@ static void *my_realloc(void *p, size_t n) { ...@@ -210,7 +210,7 @@ static void *my_realloc(void *p, size_t n) {
my_big_realloc_count++; my_big_realloc_count++;
if (do_realloc_errors) { if (do_realloc_errors) {
caller = __builtin_return_address(1); caller = __builtin_return_address(1);
if ((void*)toku_xrealloc <= caller && caller <= (void*)toku_malloc_report) if ((void*)toku_xrealloc <= caller && caller <= (void*)toku_set_func_malloc)
goto skip; goto skip;
event_count++; event_count++;
if (event_count == event_count_trigger) { if (event_count == event_count_trigger) {
......
...@@ -294,7 +294,7 @@ static void test0 (void) { ...@@ -294,7 +294,7 @@ static void test0 (void) {
assert(r==0); assert(r==0);
assert(expect_n_flushes==0); assert(expect_n_flushes==0);
expect_f = 0; expect_f = 0;
toku_memory_check_all_free();
} }
static void flush_n (CACHEFILE f __attribute__((__unused__)), int UU(fd), CACHEKEY key __attribute__((__unused__)), static void flush_n (CACHEFILE f __attribute__((__unused__)), int UU(fd), CACHEKEY key __attribute__((__unused__)),
...@@ -745,7 +745,7 @@ test_main (int argc, const char *argv[]) { ...@@ -745,7 +745,7 @@ test_main (int argc, const char *argv[]) {
} }
test_mutex_destroy(); test_mutex_destroy();
toku_malloc_cleanup();
if (verbose) printf("ok\n"); if (verbose) printf("ok\n");
return 0; return 0;
} }
...@@ -250,7 +250,7 @@ test_main (int argc, const char *argv[]) { ...@@ -250,7 +250,7 @@ test_main (int argc, const char *argv[]) {
test_mutex_init(); test_mutex_init();
test_chaining(); test_chaining();
test_mutex_destroy(); test_mutex_destroy();
toku_malloc_cleanup();
if (verbose) printf("ok\n"); if (verbose) printf("ok\n");
return 0; return 0;
} }
...@@ -87,6 +87,6 @@ test_main(int argc, const char *argv[]) { ...@@ -87,6 +87,6 @@ test_main(int argc, const char *argv[]) {
test_fifo_create(); test_fifo_create();
test_fifo_enq(4); test_fifo_enq(4);
test_fifo_enq(512); test_fifo_enq(512);
toku_malloc_cleanup();
return 0; return 0;
} }
...@@ -65,7 +65,7 @@ test_main (int argc , const char *argv[]) { ...@@ -65,7 +65,7 @@ test_main (int argc , const char *argv[]) {
default_parse_args(argc, argv); default_parse_args(argc, argv);
test_flat(); test_flat();
toku_malloc_cleanup();
if (verbose) printf("test ok\n"); if (verbose) printf("test ok\n");
return 0; return 0;
} }
......
...@@ -69,7 +69,7 @@ test_main (int argc , const char *argv[]) { ...@@ -69,7 +69,7 @@ test_main (int argc , const char *argv[]) {
default_parse_args(argc, argv); default_parse_args(argc, argv);
test_flat(); test_flat();
toku_malloc_cleanup();
if (verbose) printf("test ok\n"); if (verbose) printf("test ok\n");
return 0; return 0;
} }
......
...@@ -45,6 +45,6 @@ test_main (int argc, const char *argv[]) { ...@@ -45,6 +45,6 @@ test_main (int argc, const char *argv[]) {
verbose = 0; verbose = 0;
} }
test_overflow(); test_overflow();
toku_malloc_cleanup();
return 0; return 0;
} }
...@@ -151,6 +151,6 @@ test_main (int argc __attribute__((__unused__)), const char *argv[] __attribute_ ...@@ -151,6 +151,6 @@ test_main (int argc __attribute__((__unused__)), const char *argv[] __attribute_
} }
} }
#endif #endif
toku_malloc_cleanup();
return 0; return 0;
} }
...@@ -47,7 +47,7 @@ static void ybt_test0 (void) { ...@@ -47,7 +47,7 @@ static void ybt_test0 (void) {
cleanup_and_free(&v0); cleanup_and_free(&v0);
cleanup_and_free(&v1); cleanup_and_free(&v1);
toku_memory_check_all_free();
/* See if we can probe to find out how big something is by setting ulen=0 with YBT_USERMEM */ /* See if we can probe to find out how big something is by setting ulen=0 with YBT_USERMEM */
toku_init_dbt(&t0); toku_init_dbt(&t0);
...@@ -80,7 +80,7 @@ static void ybt_test0 (void) { ...@@ -80,7 +80,7 @@ static void ybt_test0 (void) {
assert(strcmp(t0.data, "provincial")==0); assert(strcmp(t0.data, "provincial")==0);
toku_free(t0.data); toku_free(t0.data);
toku_memory_check_all_free();
} }
int int
......
...@@ -137,21 +137,6 @@ ydb_getf_do_nothing(DBT const* UU(key), DBT const* UU(val), void* UU(extra)) { ...@@ -137,21 +137,6 @@ ydb_getf_do_nothing(DBT const* UU(key), DBT const* UU(val), void* UU(extra)) {
return 0; return 0;
} }
/* the ydb reference is used to cleanup the library when there are no more references to it */
static int toku_ydb_refs = 0;
static inline void ydb_add_ref(void) {
++toku_ydb_refs;
}
static inline void ydb_unref(void) {
assert(toku_ydb_refs > 0);
if (--toku_ydb_refs == 0) {
/* call global destructors */
toku_malloc_cleanup();
}
}
/* env methods */ /* env methods */
static int toku_env_close(DB_ENV *env, u_int32_t flags); static int toku_env_close(DB_ENV *env, u_int32_t flags);
static int toku_env_set_data_dir(DB_ENV * env, const char *dir); static int toku_env_set_data_dir(DB_ENV * env, const char *dir);
...@@ -935,7 +920,6 @@ static int toku_env_close(DB_ENV * env, u_int32_t flags) { ...@@ -935,7 +920,6 @@ static int toku_env_close(DB_ENV * env, u_int32_t flags) {
env->i = NULL; env->i = NULL;
toku_free(env); toku_free(env);
env = NULL; env = NULL;
ydb_unref();
if ((flags!=0) && !(flags==DB_CLOSE_DONT_TRIM_LOG)) if ((flags!=0) && !(flags==DB_CLOSE_DONT_TRIM_LOG))
r = EINVAL; r = EINVAL;
return r; return r;
...@@ -1829,7 +1813,6 @@ static int toku_env_create(DB_ENV ** envp, u_int32_t flags) { ...@@ -1829,7 +1813,6 @@ static int toku_env_create(DB_ENV ** envp, u_int32_t flags) {
assert(result->i->open_dbs); assert(result->i->open_dbs);
} }
ydb_add_ref();
*envp = result; *envp = result;
r = 0; r = 0;
cleanup: cleanup:
...@@ -2272,7 +2255,6 @@ db_close_before_brt(DB *db, u_int32_t UU(flags)) { ...@@ -2272,7 +2255,6 @@ db_close_before_brt(DB *db, u_int32_t UU(flags)) {
if (db->i->dname) toku_free(db->i->dname); if (db->i->dname) toku_free(db->i->dname);
toku_free(db->i); toku_free(db->i);
toku_free(db); toku_free(db);
ydb_unref();
if (r1) return r1; if (r1) return r1;
if (r2) return r2; if (r2) return r2;
if (is_panicked) return EINVAL; if (is_panicked) return EINVAL;
...@@ -4880,7 +4862,6 @@ static int toku_db_create(DB ** db, DB_ENV * env, u_int32_t flags) { ...@@ -4880,7 +4862,6 @@ static int toku_db_create(DB ** db, DB_ENV * env, u_int32_t flags) {
toku_free(result); toku_free(result);
return r; return r;
} }
ydb_add_ref();
*db = result; *db = result;
return 0; return 0;
} }
......
...@@ -113,32 +113,6 @@ toku_xstrdup (const char *s) ...@@ -113,32 +113,6 @@ toku_xstrdup (const char *s)
return toku_xmemdup(s, strlen(s)+1); return toku_xmemdup(s, strlen(s)+1);
} }
void
toku_memory_check_all_free (void)
{
}
int
toku_get_n_items_malloced (void)
{
return 0;
}
void
toku_print_malloced_items (void)
{
}
void
toku_malloc_report (void)
{
}
void
toku_malloc_cleanup (void)
{
}
int int
toku_set_func_malloc(malloc_fun_t f) { toku_set_func_malloc(malloc_fun_t f) {
t_malloc = f; t_malloc = f;
......
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