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);
......
This diff is collapsed.
......@@ -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