Commit 0a6d3a6c authored by Bradley C. Kuszmaul's avatar Bradley C. Kuszmaul

Rename a bunch of symbols to toku_symbols. Addresses #8.

git-svn-id: file:///svn/tokudb@826 c7de825b-a66e-492c-adef-691d508d4ae1
parent 062ad802
......@@ -89,7 +89,7 @@ pma.o: pma.h yerror.h pma-internal.h memory.h key.h ybt.h brttypes.h log.h ../in
ybt.o: ybt.h brttypes.h ../include/db.h
ybt-test: ybt-test.o ybt.o memory.o
ybt-test.o: ybt.h ../include/db.h
cachetable.o: cachetable.h hashfun.h
cachetable.o: cachetable.h hashfun.h memory.h
brt-test: ybt.o brt.o hashtable.o pma.o memory.o brt-serialize.o cachetable.o header-io.o ybt.o key.o primes.o log.o mempool.o brt-verify.o fingerprint.o log_code.o
log.o: log_header.h log-internal.h log.h wbuf.h crc.h brttypes.h $(BRT_INTERNAL_H_INCLUDES)
brt-test.o brt.o: brt.h ../include/db.h hashtable.h pma.h brttypes.h cachetable.h
......
......@@ -170,7 +170,7 @@ int main (int argc, char *argv[]) {
printf("Shutdown %9.6fs\n", tdiff(&t3, &t2));
printf("Total time %9.6fs for %lld insertions = %8.0f/s\n", tdiff(&t3, &t1), 2*total_n_items, 2*total_n_items/tdiff(&t3, &t1));
malloc_report();
malloc_cleanup();
toku_malloc_cleanup();
return 0;
}
......@@ -100,8 +100,8 @@ void test_serialize(void) {
}
int main (int argc __attribute__((__unused__)), char *argv[] __attribute__((__unused__))) {
memory_check = 1;
toku_memory_check = 1;
test_serialize();
malloc_cleanup();
toku_malloc_cleanup();
return 0;
}
......@@ -82,7 +82,7 @@ unsigned int toku_serialize_brtnode_size (BRTNODE node) {
} else {
result+=4; /* n_entries in buffer table. */
result+=node->u.l.n_bytes_in_buffer;
if (memory_check) {
if (toku_memory_check) {
unsigned int slowresult = toku_serialize_brtnode_size_slow(node);
if (result!=slowresult) printf("%s:%d result=%d slowresult=%d\n", __FILE__, __LINE__, result, slowresult);
assert(result==slowresult);
......
......@@ -25,8 +25,8 @@ static void test0 (void) {
CACHETABLE ct;
char fname[]="testbrt.brt";
printf("%s:%d test0\n", __FILE__, __LINE__);
memory_check=1;
memory_check_all_free();
toku_memory_check=1;
toku_memory_check_all_free();
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(r==0);
printf("%s:%d test0\n", __FILE__, __LINE__);
......@@ -39,7 +39,7 @@ static void test0 (void) {
//printf("%s:%d n_items_malloced=%lld\n", __FILE__, __LINE__, n_items_malloced);
r = toku_cachetable_close(&ct);
assert(r==0);
memory_check_all_free();
toku_memory_check_all_free();
}
static void test1 (void) {
......@@ -48,8 +48,8 @@ static void test1 (void) {
CACHETABLE ct;
char fname[]="testbrt.brt";
DBT k,v;
memory_check=1;
memory_check_all_free();
toku_memory_check=1;
toku_memory_check_all_free();
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(r==0);
unlink(fname);
......@@ -64,7 +64,7 @@ static void test1 (void) {
}
r = toku_close_brt(t); assert(r==0);
r = toku_cachetable_close(&ct); assert(r==0);
memory_check_all_free();
toku_memory_check_all_free();
printf("test1 ok\n");
}
......@@ -74,9 +74,9 @@ static void test2 (int memcheck) {
int i;
CACHETABLE ct;
char fname[]="testbrt.brt";
memory_check=memcheck;
toku_memory_check=memcheck;
printf("%s:%d checking\n", __FILE__, __LINE__);
memory_check_all_free();
toku_memory_check_all_free();
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
unlink(fname);
r = toku_open_brt(fname, 0, 1, &t, 1024, ct, null_txn, toku_default_compare_fun, null_db);
......@@ -94,7 +94,7 @@ static void test2 (int memcheck) {
{
int n = get_n_items_malloced();
printf("%s:%d i=%d n_items_malloced=%d\n", __FILE__, __LINE__, i, n);
if (n!=3) print_malloced_items();
if (n!=3) toku_print_malloced_items();
assert(n==3);
}
}
......@@ -102,7 +102,7 @@ static void test2 (int memcheck) {
printf("%s:%d inserted\n", __FILE__, __LINE__);
r = toku_close_brt(t); assert(r==0);
r = toku_cachetable_close(&ct); assert(r==0);
memory_check_all_free();
toku_memory_check_all_free();
printf("test2 ok\n");
}
......@@ -113,8 +113,8 @@ static void test3 (int nodesize, int count, int memcheck) {
int i;
CACHETABLE ct;
char fname[]="testbrt.brt";
memory_check=memcheck;
memory_check_all_free();
toku_memory_check=memcheck;
toku_memory_check_all_free();
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
gettimeofday(&t0, 0);
unlink(fname);
......@@ -129,7 +129,7 @@ static void test3 (int nodesize, int count, int memcheck) {
}
r = toku_close_brt(t); assert(r==0);
r = toku_cachetable_close(&ct); assert(r==0);
memory_check_all_free();
toku_memory_check_all_free();
gettimeofday(&t1, 0);
{
double tdiff = (t1.tv_sec-t0.tv_sec)+1e-6*(t1.tv_usec-t0.tv_usec);
......@@ -146,8 +146,8 @@ static void test4 (int nodesize, int count, int memcheck) {
char fname[]="testbrt.brt";
gettimeofday(&t0, 0);
unlink(fname);
memory_check=memcheck;
memory_check_all_free();
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_open_brt(fname, 0, 1, &t, nodesize, ct, null_txn, toku_default_compare_fun, null_db); assert(r==0);
for (i=0; i<count; i++) {
......@@ -160,7 +160,7 @@ static void test4 (int nodesize, int count, int memcheck) {
}
r = toku_close_brt(t); assert(r==0);
r = toku_cachetable_close(&ct); assert(r==0);
memory_check_all_free();
toku_memory_check_all_free();
gettimeofday(&t1, 0);
{
double tdiff = (t1.tv_sec-t0.tv_sec)+1e-6*(t1.tv_usec-t0.tv_usec);
......@@ -176,7 +176,7 @@ static void test5 (void) {
int i;
CACHETABLE ct;
char fname[]="testbrt.brt";
memory_check_all_free();
toku_memory_check_all_free();
MALLOC_N(limit,values);
for (i=0; i<limit; i++) values[i]=-1;
unlink(fname);
......@@ -212,7 +212,7 @@ static void test5 (void) {
toku_free(values);
r = toku_close_brt(t); assert(r==0);
r = toku_cachetable_close(&ct); assert(r==0);
memory_check_all_free();
toku_memory_check_all_free();
}
static void test_dump_empty_db (void) {
......@@ -220,7 +220,7 @@ static void test_dump_empty_db (void) {
CACHETABLE ct;
int r;
char fname[]="testbrt.brt";
memory_check=1;
toku_memory_check=1;
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(r==0);
unlink(fname);
......@@ -229,7 +229,7 @@ static void test_dump_empty_db (void) {
toku_dump_brt(t);
r = toku_close_brt(t); assert(r==0);
r = toku_cachetable_close(&ct); assert(r==0);
memory_check_all_free();
toku_memory_check_all_free();
}
/* Test running multiple trees in different files */
......@@ -242,7 +242,7 @@ static void test_multiple_files_of_size (int size) {
printf("test_multiple_files_of_size(%d)\n", size);
unlink(n0);
unlink(n1);
memory_check_all_free();
toku_memory_check_all_free();
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
r = toku_open_brt(n0, 0, 1, &t0, size, ct, null_txn, toku_default_compare_fun, null_db); assert(r==0);
r = toku_open_brt(n1, 0, 1, &t1, size, ct, null_txn, toku_default_compare_fun, null_db); assert(r==0);
......@@ -264,7 +264,7 @@ static void test_multiple_files_of_size (int size) {
r = toku_close_brt(t0); assert(r==0);
r = toku_close_brt(t1); assert(r==0);
r = toku_cachetable_close(&ct); assert(r==0);
memory_check_all_free();
toku_memory_check_all_free();
/* Now see if the data is all there. */
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
......@@ -292,7 +292,7 @@ static void test_multiple_files_of_size (int size) {
r = toku_close_brt(t0); assert(r==0);
r = toku_close_brt(t1); assert(r==0);
r = toku_cachetable_close(&ct); assert(r==0);
memory_check_all_free();
toku_memory_check_all_free();
}
static void test_multiple_files (void) {
......@@ -311,7 +311,7 @@ static void test_named_db (void) {
printf("test_named_db\n");
unlink(n0);
unlink(n1);
memory_check_all_free();
toku_memory_check_all_free();
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
r = toku_open_brt(n0, "db1", 1, &t0, 1<<12, ct, null_txn, toku_default_compare_fun, null_db); assert(r==0);
......@@ -320,9 +320,9 @@ static void test_named_db (void) {
r = toku_close_brt(t0); assert(r==0);
r = toku_cachetable_close(&ct); assert(r==0);
memory_check_all_free();
toku_memory_check_all_free();
memory_check_all_free();
toku_memory_check_all_free();
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
r = toku_open_brt(n0, "db1", 0, &t0, 1<<12, ct, null_txn, toku_default_compare_fun, null_db); assert(r==0);
......@@ -335,7 +335,7 @@ static void test_named_db (void) {
r = toku_close_brt(t0); assert(r==0);
r = toku_cachetable_close(&ct); assert(r==0);
memory_check_all_free();
toku_memory_check_all_free();
}
static void test_multiple_dbs (void) {
......@@ -348,7 +348,7 @@ static void test_multiple_dbs (void) {
printf("test_multiple_dbs: ");
unlink(n0);
unlink(n1);
memory_check_all_free();
toku_memory_check_all_free();
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
r = toku_open_brt(n0, "db1", 1, &t0, 1<<12, ct, null_txn, toku_default_compare_fun, null_db); assert(r==0);
r = toku_open_brt(n1, "db2", 1, &t1, 1<<12, ct, null_txn, toku_default_compare_fun, null_db); assert(r==0);
......@@ -360,7 +360,7 @@ static void test_multiple_dbs (void) {
r = toku_close_brt(t1); assert(r==0);
r = toku_cachetable_close(&ct); assert(r==0);
memory_check_all_free();
toku_memory_check_all_free();
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
r = toku_open_brt(n0, "db1", 0, &t0, 1<<12, ct, null_txn, toku_default_compare_fun, null_db); assert(r==0);
......@@ -388,7 +388,7 @@ static void test_multiple_dbs (void) {
r = toku_close_brt(t1); assert(r==0);
r = toku_cachetable_close(&ct); assert(r==0);
memory_check_all_free();
toku_memory_check_all_free();
printf("ok\n");
}
......@@ -400,7 +400,7 @@ static void test_multiple_dbs_many (void) {
CACHETABLE ct;
BRT trees[MANYN];
printf("test_multiple_dbs_many:\n");
memory_check_all_free();
toku_memory_check_all_free();
unlink(name);
r = toku_brt_create_cachetable(&ct, MANYN+4, ZERO_LSN, NULL_LOGGER); assert(r==0);
for (i=0; i<MANYN; i++) {
......@@ -420,7 +420,7 @@ static void test_multiple_dbs_many (void) {
r = toku_close_brt(trees[i]); assert(r==0);
}
r = toku_cachetable_close(&ct); assert(r==0);
memory_check_all_free();
toku_memory_check_all_free();
}
/* Test to see that a single db can be opened many times. */
......@@ -431,7 +431,7 @@ static void test_multiple_brts_one_db_one_file (void) {
CACHETABLE ct;
BRT trees[MANYN];
printf("test_multiple_brts_one_db_one_file:");
memory_check_all_free();
toku_memory_check_all_free();
unlink(name);
r = toku_brt_create_cachetable(&ct, 32, ZERO_LSN, NULL_LOGGER); assert(r==0);
for (i=0; i<MANYN; i++) {
......@@ -459,7 +459,7 @@ static void test_multiple_brts_one_db_one_file (void) {
r=toku_close_brt(trees[i]); assert(r==0);
}
r = toku_cachetable_close(&ct); assert(r==0);
memory_check_all_free();
toku_memory_check_all_free();
printf(" ok\n");
}
......@@ -475,14 +475,14 @@ static void test_read_what_was_written (void) {
printf("test_read_what_was_written(): "); fflush(stdout);
unlink(n);
memory_check_all_free();
toku_memory_check_all_free();
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
r = toku_open_brt(n, 0, 1, &brt, 1<<12, ct, null_txn, toku_default_compare_fun, null_db); assert(r==0);
r = toku_close_brt(brt); assert(r==0);
r = toku_cachetable_close(&ct); assert(r==0);
memory_check_all_free();
toku_memory_check_all_free();
/* Now see if we can read an empty tree in. */
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
......@@ -497,7 +497,7 @@ static void test_read_what_was_written (void) {
r = toku_close_brt(brt); assert(r==0);
r = toku_cachetable_close(&ct); assert(r==0);
memory_check_all_free();
toku_memory_check_all_free();
/* 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);
......@@ -574,7 +574,7 @@ static void test_read_what_was_written (void) {
printf("%s:%d About to close %p\n", __FILE__, __LINE__, ct);
r = toku_cachetable_close(&ct); assert(r==0);
memory_check_all_free();
toku_memory_check_all_free();
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
r = toku_open_brt(n, 0, 0, &brt, 1<<12, ct, null_txn, toku_default_compare_fun, null_db); assert(r==0);
......@@ -603,7 +603,7 @@ static void test_read_what_was_written (void) {
r = toku_close_brt(brt); assert(r==0);
r = toku_cachetable_close(&ct); assert(r==0);
memory_check_all_free();
toku_memory_check_all_free();
printf(" ok\n");
......@@ -621,28 +621,28 @@ void test_cursor_last_empty(void) {
DBT kbt, vbt;
printf("%s", __FUNCTION__);
unlink(n);
memory_check_all_free();
//printf("%s:%d %d alloced\n", __FILE__, __LINE__, get_n_items_malloced()); print_malloced_items();
toku_memory_check_all_free();
//printf("%s:%d %d alloced\n", __FILE__, __LINE__, get_n_items_malloced()); toku_print_malloced_items();
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
//printf("%s:%d %d alloced\n", __FILE__, __LINE__, get_n_items_malloced()); print_malloced_items();
//printf("%s:%d %d alloced\n", __FILE__, __LINE__, get_n_items_malloced()); toku_print_malloced_items();
r = toku_open_brt(n, 0, 1, &brt, 1<<12, ct, null_txn, toku_default_compare_fun, null_db); assert(r==0);
//printf("%s:%d %d alloced\n", __FILE__, __LINE__, get_n_items_malloced()); print_malloced_items();
//printf("%s:%d %d alloced\n", __FILE__, __LINE__, get_n_items_malloced()); toku_print_malloced_items();
r = toku_brt_cursor(brt, &cursor); assert(r==0);
toku_init_dbt(&kbt);
//printf("%s:%d %d alloced\n", __FILE__, __LINE__, get_n_items_malloced()); print_malloced_items();
//printf("%s:%d %d alloced\n", __FILE__, __LINE__, get_n_items_malloced()); toku_print_malloced_items();
toku_init_dbt(&vbt);
//printf("%s:%d %d alloced\n", __FILE__, __LINE__, get_n_items_malloced()); print_malloced_items();
//printf("%s:%d %d alloced\n", __FILE__, __LINE__, get_n_items_malloced()); toku_print_malloced_items();
r = toku_brt_cursor_get(cursor, &kbt, &vbt, DB_LAST, null_txn);
//printf("%s:%d %d alloced\n", __FILE__, __LINE__, get_n_items_malloced()); print_malloced_items();
//printf("%s:%d %d alloced\n", __FILE__, __LINE__, get_n_items_malloced()); toku_print_malloced_items();
assert(r==DB_NOTFOUND);
r = toku_brt_cursor_get(cursor, &kbt, &vbt, DB_FIRST, null_txn);
//printf("%s:%d %d alloced\n", __FILE__, __LINE__, get_n_items_malloced()); print_malloced_items();
//printf("%s:%d %d alloced\n", __FILE__, __LINE__, get_n_items_malloced()); toku_print_malloced_items();
assert(r==DB_NOTFOUND);
r = toku_close_brt(brt);
//printf("%s:%d %d alloced\n", __FILE__, __LINE__, get_n_items_malloced()); print_malloced_items();
//printf("%s:%d %d alloced\n", __FILE__, __LINE__, get_n_items_malloced()); toku_print_malloced_items();
r = toku_cachetable_close(&ct); assert(r==0);
//printf("%s:%d %d alloced\n", __FILE__, __LINE__, get_n_items_malloced()); print_malloced_items();
memory_check_all_free();
//printf("%s:%d %d alloced\n", __FILE__, __LINE__, get_n_items_malloced()); toku_print_malloced_items();
toku_memory_check_all_free();
}
void test_cursor_next (void) {
......@@ -654,24 +654,24 @@ void test_cursor_next (void) {
DBT kbt, vbt;
unlink(n);
memory_check_all_free();
toku_memory_check_all_free();
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
//printf("%s:%d %d alloced\n", __FILE__, __LINE__, get_n_items_malloced()); print_malloced_items();
//printf("%s:%d %d alloced\n", __FILE__, __LINE__, get_n_items_malloced()); toku_print_malloced_items();
r = toku_open_brt(n, 0, 1, &brt, 1<<12, ct, null_txn, toku_default_compare_fun, null_db); assert(r==0);
//printf("%s:%d %d alloced\n", __FILE__, __LINE__, get_n_items_malloced()); print_malloced_items();
//printf("%s:%d %d alloced\n", __FILE__, __LINE__, get_n_items_malloced()); toku_print_malloced_items();
r = toku_brt_insert(brt, toku_fill_dbt(&kbt, "hello", 6), toku_fill_dbt(&vbt, "there", 6), null_txn);
r = toku_brt_insert(brt, toku_fill_dbt(&kbt, "byebye", 7), toku_fill_dbt(&vbt, "byenow", 7), null_txn);
printf("%s:%d calling toku_brt_cursor(...)\n", __FILE__, __LINE__);
r = toku_brt_cursor(brt, &cursor); assert(r==0);
toku_init_dbt(&kbt);
//printf("%s:%d %d alloced\n", __FILE__, __LINE__, get_n_items_malloced()); print_malloced_items();
//printf("%s:%d %d alloced\n", __FILE__, __LINE__, get_n_items_malloced()); toku_print_malloced_items();
toku_init_dbt(&vbt);
//printf("%s:%d %d alloced\n", __FILE__, __LINE__, get_n_items_malloced()); print_malloced_items();
//printf("%s:%d %d alloced\n", __FILE__, __LINE__, get_n_items_malloced()); toku_print_malloced_items();
printf("%s:%d calling toku_brt_cursor_get(...)\n", __FILE__, __LINE__);
r = toku_brt_cursor_get(cursor, &kbt, &vbt, DB_NEXT, null_txn);
printf("%s:%d called toku_brt_cursor_get(...)\n", __FILE__, __LINE__);
//printf("%s:%d %d alloced\n", __FILE__, __LINE__, get_n_items_malloced()); print_malloced_items();
//printf("%s:%d %d alloced\n", __FILE__, __LINE__, get_n_items_malloced()); toku_print_malloced_items();
assert(r==0);
assert(kbt.size==7);
assert(memcmp(kbt.data, "byebye", 7)==0);
......@@ -689,10 +689,10 @@ void test_cursor_next (void) {
assert(r==DB_NOTFOUND);
r = toku_close_brt(brt);
//printf("%s:%d %d alloced\n", __FILE__, __LINE__, get_n_items_malloced()); print_malloced_items();
//printf("%s:%d %d alloced\n", __FILE__, __LINE__, get_n_items_malloced()); toku_print_malloced_items();
r = toku_cachetable_close(&ct); assert(r==0);
//printf("%s:%d %d alloced\n", __FILE__, __LINE__, get_n_items_malloced()); print_malloced_items();
memory_check_all_free();
//printf("%s:%d %d alloced\n", __FILE__, __LINE__, get_n_items_malloced()); toku_print_malloced_items();
toku_memory_check_all_free();
}
......@@ -723,7 +723,7 @@ static void test_wrongendian_compare (int wrong_p, unsigned int N) {
unsigned int i;
unlink(n);
memory_check_all_free();
toku_memory_check_all_free();
{
char a[4]={0,1,0,0};
......@@ -813,7 +813,7 @@ static void test_wrongendian_compare (int wrong_p, unsigned int N) {
r = toku_close_brt(brt);
}
r = toku_cachetable_close(&ct); assert(r==0);
memory_check_all_free();
toku_memory_check_all_free();
}
int test_cursor_debug = 0;
......@@ -1842,41 +1842,41 @@ void test_brt_cursor(DB *db) {
test_multiple_brt_cursors(3, db);
for (n=0; n<test_brt_cursor_limit; n += test_brt_cursor_inc) {
test_brt_cursor_first(n, db); memory_check_all_free();
test_brt_cursor_first(n, db); toku_memory_check_all_free();
}
for (n=0; n<test_brt_cursor_limit; n += test_brt_cursor_inc) {
test_brt_cursor_rfirst(n, db); memory_check_all_free();
test_brt_cursor_rfirst(n, db); toku_memory_check_all_free();
}
for (n=0; n<test_brt_cursor_limit; n += test_brt_cursor_inc) {
test_brt_cursor_walk(n, db); memory_check_all_free();
test_brt_cursor_walk(n, db); toku_memory_check_all_free();
}
for (n=0; n<test_brt_cursor_limit; n += test_brt_cursor_inc) {
test_brt_cursor_last(n, db); memory_check_all_free();
test_brt_cursor_last(n, db); toku_memory_check_all_free();
}
for (n=0; n<test_brt_cursor_limit; n += test_brt_cursor_inc) {
test_brt_cursor_first_last(n, db); memory_check_all_free();
test_brt_cursor_first_last(n, db); toku_memory_check_all_free();
}
for (n=0; n<test_brt_cursor_limit; n += test_brt_cursor_inc) {
test_brt_cursor_split(n, db); memory_check_all_free();
test_brt_cursor_split(n, db); toku_memory_check_all_free();
}
for (n=0; n<test_brt_cursor_limit; n += test_brt_cursor_inc) {
test_brt_cursor_rand(n, db); memory_check_all_free();
test_brt_cursor_rand(n, db); toku_memory_check_all_free();
}
for (n=0; n<test_brt_cursor_limit; n += test_brt_cursor_inc) {
test_brt_cursor_rwalk(n, db); memory_check_all_free();
test_brt_cursor_rwalk(n, db); toku_memory_check_all_free();
}
test_brt_cursor_set(1000, DB_SET, db); memory_check_all_free();
test_brt_cursor_set(10000, DB_SET, db); memory_check_all_free();
test_brt_cursor_set(1000, DB_SET_RANGE, db); memory_check_all_free();
test_brt_cursor_set_range(1000, db); memory_check_all_free();
test_brt_cursor_set_range(10000, db); memory_check_all_free();
test_brt_cursor_set(1000, DB_SET, db); toku_memory_check_all_free();
test_brt_cursor_set(10000, DB_SET, db); toku_memory_check_all_free();
test_brt_cursor_set(1000, DB_SET_RANGE, db); toku_memory_check_all_free();
test_brt_cursor_set_range(1000, db); toku_memory_check_all_free();
test_brt_cursor_set_range(10000, db); toku_memory_check_all_free();
test_brt_cursor_delete(1000, db); memory_check_all_free();
test_multiple_brt_cursor_walk(10000, db); memory_check_all_free();
test_multiple_brt_cursor_walk(100000, db); memory_check_all_free();
test_brt_cursor_get_both(1000, db); memory_check_all_free();
test_brt_cursor_delete(1000, db); toku_memory_check_all_free();
test_multiple_brt_cursor_walk(10000, db); toku_memory_check_all_free();
test_multiple_brt_cursor_walk(100000, db); toku_memory_check_all_free();
test_brt_cursor_get_both(1000, db); toku_memory_check_all_free();
}
void test_large_kv(int bsize, int ksize, int vsize) {
......@@ -1918,7 +1918,7 @@ void test_brt_limits() {
int bsize = 1024;
int kvsize = 4;
while (kvsize < bsize/2) {
test_large_kv(bsize, kvsize, kvsize); memory_check_all_free();
test_large_kv(bsize, kvsize, kvsize); toku_memory_check_all_free();
kvsize *= 2;
}
}
......@@ -2200,37 +2200,37 @@ void test_insert_delete_lookup(int n) {
}
void test_brt_delete() {
test_brt_delete_empty(); memory_check_all_free();
test_brt_delete_present(1); memory_check_all_free();
test_brt_delete_present(100); memory_check_all_free();
test_brt_delete_present(500); memory_check_all_free();
test_brt_delete_not_present(1); memory_check_all_free();
test_brt_delete_not_present(100); memory_check_all_free();
test_brt_delete_not_present(500); memory_check_all_free();
test_brt_delete_cursor_first(1); memory_check_all_free();
test_brt_delete_cursor_first(100); memory_check_all_free();
test_brt_delete_cursor_first(500); memory_check_all_free();
test_brt_delete_cursor_first(10000); memory_check_all_free();
test_insert_delete_lookup(512); memory_check_all_free();
test_brt_delete_empty(); toku_memory_check_all_free();
test_brt_delete_present(1); toku_memory_check_all_free();
test_brt_delete_present(100); toku_memory_check_all_free();
test_brt_delete_present(500); toku_memory_check_all_free();
test_brt_delete_not_present(1); toku_memory_check_all_free();
test_brt_delete_not_present(100); toku_memory_check_all_free();
test_brt_delete_not_present(500); toku_memory_check_all_free();
test_brt_delete_cursor_first(1); toku_memory_check_all_free();
test_brt_delete_cursor_first(100); toku_memory_check_all_free();
test_brt_delete_cursor_first(500); toku_memory_check_all_free();
test_brt_delete_cursor_first(10000); toku_memory_check_all_free();
test_insert_delete_lookup(512); toku_memory_check_all_free();
}
static void brt_blackbox_test (void) {
memory_check = 1;
test_wrongendian_compare(0, 2); memory_check_all_free();
test_wrongendian_compare(1, 2); memory_check_all_free();
test_wrongendian_compare(1, 257); memory_check_all_free();
test_wrongendian_compare(1, 1000); memory_check_all_free();
test_read_what_was_written(); memory_check_all_free(); printf("did read_what_was_written\n");
test_cursor_next(); memory_check_all_free();
test_multiple_dbs_many(); memory_check_all_free();
test_cursor_last_empty(); memory_check_all_free();
test_multiple_brts_one_db_one_file(); memory_check_all_free();
test_dump_empty_db(); memory_check_all_free();
toku_memory_check = 1;
test_wrongendian_compare(0, 2); toku_memory_check_all_free();
test_wrongendian_compare(1, 2); toku_memory_check_all_free();
test_wrongendian_compare(1, 257); toku_memory_check_all_free();
test_wrongendian_compare(1, 1000); toku_memory_check_all_free();
test_read_what_was_written(); toku_memory_check_all_free(); printf("did read_what_was_written\n");
test_cursor_next(); toku_memory_check_all_free();
test_multiple_dbs_many(); toku_memory_check_all_free();
test_cursor_last_empty(); toku_memory_check_all_free();
test_multiple_brts_one_db_one_file(); toku_memory_check_all_free();
test_dump_empty_db(); toku_memory_check_all_free();
test_named_db();
memory_check_all_free();
toku_memory_check_all_free();
test_multiple_dbs();
memory_check_all_free();
toku_memory_check_all_free();
printf("test0 A\n");
test0();
printf("test0 B\n");
......@@ -2246,7 +2246,7 @@ static void brt_blackbox_test (void) {
printf("test_multiple_files\n");
test_multiple_files();
printf("test3 slow\n");
memory_check=0;
toku_memory_check=0;
test3(2048, 1<<15, 1);
printf("test4 slow\n");
test4(2048, 1<<15, 1);
......@@ -2264,7 +2264,7 @@ static void brt_blackbox_test (void) {
// Once upon a time srandom(8) caused this test to fail.
srandom(8); test4(2048, 1<<15, 1);
memory_check = 1;
toku_memory_check = 1;
test_brt_limits();
......@@ -2298,7 +2298,7 @@ static void brt_blackbox_test (void) {
int main (int argc __attribute__((__unused__)), char *argv[] __attribute__((__unused__))) {
brt_blackbox_test();
malloc_cleanup();
toku_malloc_cleanup();
printf("test ok\n");
return 0;
}
......@@ -1513,7 +1513,7 @@ int toku_brt_open(BRT t, const char *fname, const char *fname_in_env, const char
/* If dbname is NULL then we setup to hold a single tree. Otherwise we setup an array. */
int r;
char *malloced_name=0;
//printf("%s:%d %d alloced\n", __FILE__, __LINE__, get_n_items_malloced()); print_malloced_items();
//printf("%s:%d %d alloced\n", __FILE__, __LINE__, get_n_items_malloced()); toku_print_malloced_items();
WHEN_BRTTRACE(fprintf(stderr, "BRTTRACE: %s:%d toku_open_brt(%s, \"%s\", %d, %p, %d, %p)\n",
__FILE__, __LINE__, fname, dbname, is_create, newbrt, nodesize, cachetable));
if (0) { died0: assert(r); return r; }
......@@ -1553,7 +1553,7 @@ int toku_brt_open(BRT t, const char *fname, const char *fname_in_env, const char
goto died0a;
}
assert(t->nodesize>0);
//printf("%s:%d %d alloced\n", __FILE__, __LINE__, get_n_items_malloced()); print_malloced_items();
//printf("%s:%d %d alloced\n", __FILE__, __LINE__, get_n_items_malloced()); toku_print_malloced_items();
if (is_create) {
r = toku_read_and_pin_brt_header(t->cf, &t->h);
if (r==-1) {
......
......@@ -177,7 +177,7 @@ void test0 (void) {
assert(r==0);
assert(expect_n_flushes==0);
expect_f = 0;
memory_check_all_free();
toku_memory_check_all_free();
}
static void flush_n (CACHEFILE f __attribute__((__unused__)), CACHEKEY key __attribute__((__unused__)), void *value,
......@@ -619,7 +619,7 @@ int main (int argc __attribute__((__unused__)), char *argv[] __attribute__((__un
test_dirty();
test_size_resize();
test_size_flush();
malloc_cleanup();
toku_malloc_cleanup();
printf("ok\n");
return 0;
}
......@@ -169,7 +169,7 @@ void test_chaining (void) {
int main (int argc __attribute__((__unused__)), char *argv[] __attribute__((__unused__))) {
test_chaining();
malloc_cleanup();
toku_malloc_cleanup();
printf("ok\n");
return 0;
}
......@@ -259,6 +259,6 @@ int main (int argc __attribute__((__unused__)), char *argv[] __attribute__((__un
test_insert_nodup(1000);
test_insert_dup(1000, 0);
test_insert_dup(1000, 1);
malloc_cleanup();
toku_malloc_cleanup();
return 0;
}
......@@ -8,20 +8,20 @@
#include <errno.h>
#include <stdio.h>
int memory_check=0;
int toku_memory_check=0;
#define WHEN_MEM_DEBUG(x) ({if (memory_check) ({x});})
#define WHEN_MEM_DEBUG(x) ({if (toku_memory_check) ({x});})
long long n_items_malloced=0;
/* Memory checking */
enum { items_limit = 1000 };
int overflowed=0;
static int overflowed=0;
static void *items[items_limit];
static long sizes[items_limit];
void note_did_malloc (void *p, long size) {
static void note_did_malloc (void *p, long size) {
static long long count=0;
WHEN_MEM_DEBUG(
if (n_items_malloced<items_limit) { items[n_items_malloced]=p; sizes[n_items_malloced]=size; }
......@@ -32,7 +32,7 @@ void note_did_malloc (void *p, long size) {
count++;
}
void note_did_free(void *p) {
static void note_did_free(void *p) {
WHEN_MEM_DEBUG(
if (!overflowed) {
int i;
......@@ -166,7 +166,7 @@ void *toku_malloc(unsigned long size) {
//if ((long)r==0x80523f8) { printf("%s:%d %p size=%ld\n", __FILE__, __LINE__, r, size); }
return r;
}
void *tagmalloc(unsigned long size, int typtag) {
void *toku_tagmalloc(unsigned long size, int typtag) {
//printf("%s:%d tagmalloc\n", __FILE__, __LINE__);
void *r = toku_malloc(size);
assert(size>sizeof(int));
......@@ -211,17 +211,17 @@ char *toku_strdup (const char *s) {
return memdup(s, strlen(s)+1);
}
void memory_check_all_free (void) {
void toku_memory_check_all_free (void) {
if (n_items_malloced>0) {
printf("n_items_malloced=%lld\n", n_items_malloced);
if (memory_check)
if (toku_memory_check)
printf(" one item is %p size=%ld\n", items[0], sizes[0]);
}
assert(n_items_malloced==0);
}
int get_n_items_malloced (void) { return n_items_malloced; }
void print_malloced_items (void) {
void toku_print_malloced_items (void) {
int i;
for (i=0; i<n_items_malloced; i++) {
printf(" %p size=%ld\n", items[i], sizes[i]);
......@@ -237,7 +237,7 @@ void malloc_report (void) {
printf("Other: %d (%d fresh)\n", other_malloc_count, fresh_other_malloc_count);
}
void malloc_cleanup (void) {
void toku_malloc_cleanup (void) {
int i;
for (i=0; i<FREELIST_LIMIT; i++) {
void *p;
......
......@@ -13,11 +13,11 @@
/* Everything should call toku_malloc() instead of malloc(), and toku_calloc() instead of calloc() */
void *toku_calloc(long nmemb, long size);
void *toku_malloc(unsigned long size);
/* tagmalloc() performs a malloc(size), but fills in the first 4 bytes with typ.
/* toku_tagmalloc() performs a malloc(size), but fills in the first 4 bytes with typ.
* This "tag" is useful if you are debugging and run across a void* that is
* really a (struct foo *), and you want to figure out what it is.
*/
void *tagmalloc(unsigned long size, int typ);
void *toku_tagmalloc(unsigned long size, int typ);
void toku_free(void*);
/* toku_free_n() should be used if the caller knows the size of the malloc'd object. */
void toku_free_n(void*, unsigned long size);
......@@ -49,26 +49,26 @@ void *toku_realloc(void *, long size);
* then if you do
* TAGMALLOC(PMA,v);
* you declare a variable v of type PMA and malloc a struct pma, and fill
* in that "tag" with tagmalloc().
* in that "tag" with toku_tagmalloc().
*/
#define TAGMALLOC(t,v) t v = tagmalloc(sizeof(*v), TYP_ ## t);
#define TAGMALLOC(t,v) t v = toku_tagmalloc(sizeof(*v), TYP_ ## t);
/* Copy memory. Analogous to strdup() */
void *memdup (const void *v, unsigned int len);
/* Toku-version of strdup. Use this so that it calls toku_malloc() */
char *toku_strdup (const char *s);
void malloc_cleanup (void); /* Before exiting, call this function to free up any internal data structures from toku_malloc. Otherwise valgrind will complain of memory leaks. */
void toku_malloc_cleanup (void); /* Before exiting, call this function to free up any internal data structures from toku_malloc. Otherwise valgrind will complain of memory leaks. */
/* Check to see if everything malloc'd was free. Might be a no-op depending on how memory.c is configured. */
void memory_check_all_free (void);
void toku_memory_check_all_free (void);
/* Check to see if memory is "sane". Might be a no-op. Probably better to simply use valgrind. */
void do_memory_check(void);
extern int memory_check; // Set to nonzero to get a (much) slower version of malloc that does (much) more checking.
extern int toku_memory_check; // Set to nonzero to get a (much) slower version of malloc that does (much) more checking.
int get_n_items_malloced(void); /* How many items are malloc'd but not free'd. May return 0 depending on the configuration of memory.c */
void print_malloced_items(void); /* Try to print some malloced-but-not-freed items. May be a noop. */
void toku_print_malloced_items(void); /* Try to print some malloced-but-not-freed items. May be a noop. */
void malloc_report (void); /* report on statistics about number of mallocs. Maybe a no-op. */
#endif
......@@ -1182,17 +1182,17 @@ static void test_pma_split_cursor(void) {
}
static void test_pma_split(void) {
test_pma_split_n(0); memory_check_all_free();
test_pma_split_n(1); memory_check_all_free();
test_pma_split_n(2); memory_check_all_free();
test_pma_split_n(4); memory_check_all_free();
test_pma_split_n(8); memory_check_all_free();
test_pma_split_n(9); memory_check_all_free();
test_pma_dup_split_n(0, TOKU_DB_DUP); memory_check_all_free();
test_pma_dup_split_n(1, TOKU_DB_DUP); memory_check_all_free();
test_pma_dup_split_n(9, TOKU_DB_DUP); memory_check_all_free();
test_pma_split_varkey(); memory_check_all_free();
test_pma_split_cursor(); memory_check_all_free();
test_pma_split_n(0); toku_memory_check_all_free();
test_pma_split_n(1); toku_memory_check_all_free();
test_pma_split_n(2); toku_memory_check_all_free();
test_pma_split_n(4); toku_memory_check_all_free();
test_pma_split_n(8); toku_memory_check_all_free();
test_pma_split_n(9); toku_memory_check_all_free();
test_pma_dup_split_n(0, TOKU_DB_DUP); toku_memory_check_all_free();
test_pma_dup_split_n(1, TOKU_DB_DUP); toku_memory_check_all_free();
test_pma_dup_split_n(9, TOKU_DB_DUP); toku_memory_check_all_free();
test_pma_split_varkey(); toku_memory_check_all_free();
test_pma_split_cursor(); toku_memory_check_all_free();
}
/*
......@@ -1277,14 +1277,14 @@ static void test_pma_bulk_insert_n(int n) {
}
static void test_pma_bulk_insert(void) {
test_pma_bulk_insert_n(0); memory_check_all_free();
test_pma_bulk_insert_n(1); memory_check_all_free();
test_pma_bulk_insert_n(2); memory_check_all_free();
test_pma_bulk_insert_n(3); memory_check_all_free();
test_pma_bulk_insert_n(4); memory_check_all_free();
test_pma_bulk_insert_n(5); memory_check_all_free();
test_pma_bulk_insert_n(8); memory_check_all_free();
test_pma_bulk_insert_n(32); memory_check_all_free();
test_pma_bulk_insert_n(0); toku_memory_check_all_free();
test_pma_bulk_insert_n(1); toku_memory_check_all_free();
test_pma_bulk_insert_n(2); toku_memory_check_all_free();
test_pma_bulk_insert_n(3); toku_memory_check_all_free();
test_pma_bulk_insert_n(4); toku_memory_check_all_free();
test_pma_bulk_insert_n(5); toku_memory_check_all_free();
test_pma_bulk_insert_n(8); toku_memory_check_all_free();
test_pma_bulk_insert_n(32); toku_memory_check_all_free();
}
static void test_pma_insert_or_replace(void) {
......@@ -1704,13 +1704,13 @@ static void test_pma_cursor_last_delete_first() {
}
static void test_pma_delete() {
test_pma_delete_shrink(256); memory_check_all_free();
test_pma_delete_random(256); memory_check_all_free();
test_pma_delete_cursor(32); memory_check_all_free();
test_pma_delete_insert(); memory_check_all_free();
test_pma_double_delete(); memory_check_all_free();
test_pma_cursor_first_delete_last(); memory_check_all_free();
test_pma_cursor_last_delete_first(); memory_check_all_free();
test_pma_delete_shrink(256); toku_memory_check_all_free();
test_pma_delete_random(256); toku_memory_check_all_free();
test_pma_delete_cursor(32); toku_memory_check_all_free();
test_pma_delete_insert(); toku_memory_check_all_free();
test_pma_double_delete(); toku_memory_check_all_free();
test_pma_cursor_first_delete_last(); toku_memory_check_all_free();
test_pma_cursor_last_delete_first(); toku_memory_check_all_free();
}
static void test_pma_already_there() {
......@@ -2384,53 +2384,53 @@ static void test_dup_key_lookup(int n, int mode) {
}
static void test_dup() {
test_nodup_key_insert(2); memory_check_all_free();
test_dup_key_insert(0); memory_check_all_free();
test_dup_key_insert(2); memory_check_all_free();
test_dup_key_insert(1000); memory_check_all_free();
test_dup_key_delete(0, TOKU_DB_DUP); memory_check_all_free();
test_dup_key_delete(1000, TOKU_DB_DUP); memory_check_all_free();
test_dupsort_key_insert(2, 0); memory_check_all_free();
test_dupsort_key_insert(1000, 0); memory_check_all_free();
test_dupsort_key_insert(2, 1); memory_check_all_free();
test_dupsort_key_insert(1000, 1); memory_check_all_free();
test_dup_key_delete(0, TOKU_DB_DUP+TOKU_DB_DUPSORT); memory_check_all_free();
test_dup_key_delete(1000, TOKU_DB_DUP+TOKU_DB_DUPSORT); memory_check_all_free();
test_dup_key_lookup(32, TOKU_DB_DUP); memory_check_all_free();
test_dup_key_lookup(32, TOKU_DB_DUP+TOKU_DB_DUPSORT); memory_check_all_free();
test_nodup_key_insert(2); toku_memory_check_all_free();
test_dup_key_insert(0); toku_memory_check_all_free();
test_dup_key_insert(2); toku_memory_check_all_free();
test_dup_key_insert(1000); toku_memory_check_all_free();
test_dup_key_delete(0, TOKU_DB_DUP); toku_memory_check_all_free();
test_dup_key_delete(1000, TOKU_DB_DUP); toku_memory_check_all_free();
test_dupsort_key_insert(2, 0); toku_memory_check_all_free();
test_dupsort_key_insert(1000, 0); toku_memory_check_all_free();
test_dupsort_key_insert(2, 1); toku_memory_check_all_free();
test_dupsort_key_insert(1000, 1); toku_memory_check_all_free();
test_dup_key_delete(0, TOKU_DB_DUP+TOKU_DB_DUPSORT); toku_memory_check_all_free();
test_dup_key_delete(1000, TOKU_DB_DUP+TOKU_DB_DUPSORT); toku_memory_check_all_free();
test_dup_key_lookup(32, TOKU_DB_DUP); toku_memory_check_all_free();
test_dup_key_lookup(32, TOKU_DB_DUP+TOKU_DB_DUPSORT); toku_memory_check_all_free();
}
static void pma_tests (void) {
memory_check=1;
toku_test_keycompare(); memory_check_all_free();
test_pma_compare_fun(0); memory_check_all_free();
test_pma_compare_fun(1); memory_check_all_free();
toku_memory_check=1;
toku_test_keycompare(); toku_memory_check_all_free();
test_pma_compare_fun(0); toku_memory_check_all_free();
test_pma_compare_fun(1); toku_memory_check_all_free();
test_pma_iterate();
test_pma_iterate2(); memory_check_all_free();
test_make_space_at(); memory_check_all_free();
test_smooth_region(); memory_check_all_free();
test_find_insert(); memory_check_all_free();
test_pma_find(); memory_check_all_free();
test_calculate_parameters(); memory_check_all_free();
test_count_region(); memory_check_all_free();
test_pma_random_pick(); memory_check_all_free();
test_pma_cursor(); memory_check_all_free();
test_pma_split(); memory_check_all_free();
test_pma_bulk_insert(); memory_check_all_free();
test_pma_insert_or_replace(); memory_check_all_free();
test_pma_iterate2(); toku_memory_check_all_free();
test_make_space_at(); toku_memory_check_all_free();
test_smooth_region(); toku_memory_check_all_free();
test_find_insert(); toku_memory_check_all_free();
test_pma_find(); toku_memory_check_all_free();
test_calculate_parameters(); toku_memory_check_all_free();
test_count_region(); toku_memory_check_all_free();
test_pma_random_pick(); toku_memory_check_all_free();
test_pma_cursor(); toku_memory_check_all_free();
test_pma_split(); toku_memory_check_all_free();
test_pma_bulk_insert(); toku_memory_check_all_free();
test_pma_insert_or_replace(); toku_memory_check_all_free();
test_pma_delete();
test_pma_already_there(); memory_check_all_free();
test_pma_cursor_set_key(); memory_check_all_free();
test_pma_cursor_set_range(); memory_check_all_free();
test_pma_cursor_delete_under(); memory_check_all_free();
test_pma_cursor_set_both(); memory_check_all_free();
test_pma_already_there(); toku_memory_check_all_free();
test_pma_cursor_set_key(); toku_memory_check_all_free();
test_pma_cursor_set_range(); toku_memory_check_all_free();
test_pma_cursor_delete_under(); toku_memory_check_all_free();
test_pma_cursor_set_both(); toku_memory_check_all_free();
test_dup();
}
int main (int argc __attribute__((__unused__)), char *argv[] __attribute__((__unused__))) {
pma_tests();
malloc_cleanup();
toku_malloc_cleanup();
return 0;
}
......@@ -27,7 +27,7 @@ static void ybt_test0 (void) {
assert(strcmp(t1.data, "byebye")==0);
toku_free(v0); toku_free(v1);
memory_check_all_free();
toku_memory_check_all_free();
/* See if we can probe to find out how big something is by setting ulen=0 with YBT_USERMEM */
toku_init_dbt(&t0);
......@@ -51,7 +51,7 @@ static void ybt_test0 (void) {
assert(strcmp(t0.data, "provincial")==0);
toku_free(t0.data);
memory_check_all_free();
toku_memory_check_all_free();
}
int main (int argc __attribute__((__unused__)), char *argv[] __attribute__((__unused__))) {
......
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