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

A bunch of symbols that don't start with toku_ are made static or start with toku_. Addresses #8.

git-svn-id: file:///svn/tokudb@801 c7de825b-a66e-492c-adef-691d508d4ae1
parent 2020f636
This diff is collapsed.
...@@ -84,7 +84,7 @@ int tokulogger_create_and_open_logger (const char *directory, TOKULOGGER *result ...@@ -84,7 +84,7 @@ int tokulogger_create_and_open_logger (const char *directory, TOKULOGGER *result
return tokulogger_log_bytes(result, 0, ""); return tokulogger_log_bytes(result, 0, "");
} }
int log_format_version=0; static int log_format_version=0;
int tokulogger_log_bytes(TOKULOGGER logger, int nbytes, void *bytes) { int tokulogger_log_bytes(TOKULOGGER logger, int nbytes, void *bytes) {
int r; int r;
...@@ -556,7 +556,7 @@ int toku_logprint_LOGGEDBRTHEADER (FILE *outf, FILE *inf, const char *fieldname, ...@@ -556,7 +556,7 @@ int toku_logprint_LOGGEDBRTHEADER (FILE *outf, FILE *inf, const char *fieldname,
} }
int read_and_print_logmagic (FILE *f, u_int32_t *versionp) { int toku_read_and_print_logmagic (FILE *f, u_int32_t *versionp) {
{ {
char magic[8]; char magic[8];
int r=fread(magic, 1, 8, f); int r=fread(magic, 1, 8, f);
......
...@@ -49,7 +49,7 @@ int toku_logprint_u_int8_t (FILE *outf, FILE *inf, const char *fieldname, ...@@ -49,7 +49,7 @@ int toku_logprint_u_int8_t (FILE *outf, FILE *inf, const char *fieldname,
int toku_logprint_u_int32_t (FILE *outf, FILE *inf, const char *fieldname, u_int32_t *crc, u_int32_t *len, const char *); int toku_logprint_u_int32_t (FILE *outf, FILE *inf, const char *fieldname, u_int32_t *crc, u_int32_t *len, const char *);
int toku_logprint_LOGGEDBRTHEADER (FILE *outf, FILE *inf, const char *fieldname, u_int32_t *crc, u_int32_t *len, const char *); int toku_logprint_LOGGEDBRTHEADER (FILE *outf, FILE *inf, const char *fieldname, u_int32_t *crc, u_int32_t *len, const char *);
int read_and_print_logmagic (FILE *f, u_int32_t *version); int toku_read_and_print_logmagic (FILE *f, u_int32_t *version);
TXNID toku_txn_get_txnid (TOKUTXN); TXNID toku_txn_get_txnid (TOKUTXN);
LSN toku_txn_get_last_lsn (TOKUTXN); LSN toku_txn_get_last_lsn (TOKUTXN);
......
...@@ -135,7 +135,7 @@ void *toku_calloc(long nmemb, long size) { ...@@ -135,7 +135,7 @@ void *toku_calloc(long nmemb, long size) {
return r; return r;
} }
#define FREELIST_LIMIT (64+1) #define FREELIST_LIMIT (64+1)
void *freelist[FREELIST_LIMIT]; static void *freelist[FREELIST_LIMIT];
#define MALLOC_SIZE_COUNTING_LIMIT 512 #define MALLOC_SIZE_COUNTING_LIMIT 512
int malloc_counts[MALLOC_SIZE_COUNTING_LIMIT]; // We rely on static variables being initialized to 0. int malloc_counts[MALLOC_SIZE_COUNTING_LIMIT]; // We rely on static variables being initialized to 0.
......
...@@ -163,7 +163,7 @@ int main (int argc, char *argv[]) { ...@@ -163,7 +163,7 @@ int main (int argc, char *argv[]) {
FILE *f = fopen(logfiles[i], "r"); FILE *f = fopen(logfiles[i], "r");
struct log_entry le; struct log_entry le;
u_int32_t version; u_int32_t version;
r=read_and_print_logmagic(f, &version); r=toku_read_and_print_logmagic(f, &version);
assert(r==0 && version==0); assert(r==0 && version==0);
while ((r = tokulog_fread(f, &le))==0) { while ((r = tokulog_fread(f, &le))==0) {
printf("Got cmd %c\n", le.cmd); printf("Got cmd %c\n", le.cmd);
......
...@@ -129,7 +129,7 @@ void transcribe_header (void) { ...@@ -129,7 +129,7 @@ void transcribe_header (void) {
static void newmain (int count) { static void newmain (int count) {
int i; int i;
u_int32_t version; u_int32_t version;
int r = read_and_print_logmagic(stdin, &version); int r = toku_read_and_print_logmagic(stdin, &version);
assert(r==0); assert(r==0);
for (i=0; i!=count; i++) { for (i=0; i!=count; i++) {
r = toku_logprint_one_record(stdout, stdin); r = toku_logprint_one_record(stdout, stdin);
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
#include "../include/db.h" #include "../include/db.h"
#include "../newbrt/brttypes.h" #include "../newbrt/brttypes.h"
#include "../newbrt/brt.h" #include "../newbrt/brt.h"
#include "../newbrt/list.h"
struct db_header { struct db_header {
int n_databases; // Or there can be >=1 named databases. This is the count. int n_databases; // Or there can be >=1 named databases. This is the count.
...@@ -22,5 +22,8 @@ struct __toku_db_internal { ...@@ -22,5 +22,8 @@ struct __toku_db_internal {
int open_mode; int open_mode;
BRT brt; BRT brt;
FILENUM fileid; FILENUM fileid;
struct list associated; // All the associated databases. The primary is the head of the list.
DB *primary; // For secondary (associated) databases, what is the primary? NULL if not a secondary.
int(*associate_callback)(DB*, const DBT*, const DBT*, DBT*); // For secondary, the callback function for associate. NULL if not secondary
}; };
#endif #endif
/* -*- mode: C; c-basic-offset: 4 -*- */ /* -*- mode: C; c-basic-offset: 4 -*- */
#include <assert.h> #include <assert.h>
#include <brt.h>
#include "ydb-internal.h"
#include <errno.h> #include <errno.h>
#include <limits.h> #include <limits.h>
#include <stdarg.h> #include <stdarg.h>
...@@ -16,7 +14,8 @@ ...@@ -16,7 +14,8 @@
#include <unistd.h> #include <unistd.h>
#include <libgen.h> #include <libgen.h>
#include "brt.h" #include "ydb-internal.h"
#include "brt-internal.h" #include "brt-internal.h"
#include "cachetable.h" #include "cachetable.h"
#include "log.h" #include "log.h"
...@@ -400,14 +399,14 @@ int __toku_db_env_txn_stat(DB_ENV * env, DB_TXN_STAT ** statp, u_int32_t flags) ...@@ -400,14 +399,14 @@ int __toku_db_env_txn_stat(DB_ENV * env, DB_TXN_STAT ** statp, u_int32_t flags)
return 1; return 1;
} }
void __toku_default_errcall(const char *errpfx, char *msg) { void toku_default_errcall(const char *errpfx, char *msg) {
fprintf(stderr, "YDB: %s: %s", errpfx, msg); fprintf(stderr, "YDB: %s: %s", errpfx, msg);
} }
static int __toku_txn_begin(DB_ENV * env, DB_TXN * stxn, DB_TXN ** txn, u_int32_t flags); static int __toku_txn_begin(DB_ENV * env, DB_TXN * stxn, DB_TXN ** txn, u_int32_t flags);
int db_env_create(DB_ENV ** envp, u_int32_t flags) { int db_env_create(DB_ENV ** envp, u_int32_t flags) {
DB_ENV *result = toku_malloc(sizeof(*result)); DB_ENV *MALLOC(result);
if (result == 0) if (result == 0)
return ENOMEM; return ENOMEM;
memset(result, 0, sizeof *result); memset(result, 0, sizeof *result);
...@@ -433,14 +432,14 @@ int db_env_create(DB_ENV ** envp, u_int32_t flags) { ...@@ -433,14 +432,14 @@ int db_env_create(DB_ENV ** envp, u_int32_t flags) {
result->txn_stat = __toku_db_env_txn_stat; result->txn_stat = __toku_db_env_txn_stat;
result->txn_begin = __toku_txn_begin; result->txn_begin = __toku_txn_begin;
result->i = toku_malloc(sizeof(*result->i)); MALLOC(result->i);
if (result->i == 0) { if (result->i == 0) {
toku_free(result); toku_free(result);
return ENOMEM; return ENOMEM;
} }
memset(result->i, 0, sizeof *result->i); memset(result->i, 0, sizeof *result->i);
result->i->ref_count = 1; result->i->ref_count = 1;
result->i->errcall = __toku_default_errcall; result->i->errcall = toku_default_errcall;
result->i->errpfx = toku_strdup(""); result->i->errpfx = toku_strdup("");
*envp = result; *envp = result;
...@@ -460,7 +459,7 @@ int __toku_db_txn_commit(DB_TXN * txn, u_int32_t flags) { ...@@ -460,7 +459,7 @@ int __toku_db_txn_commit(DB_TXN * txn, u_int32_t flags) {
return 0; return 0;
} }
u_int32_t __toku_db_txn_id(DB_TXN * txn) { static u_int32_t toku_db_txn_id(DB_TXN * txn) {
barf(); barf();
abort(); abort();
} }
...@@ -468,14 +467,14 @@ u_int32_t __toku_db_txn_id(DB_TXN * txn) { ...@@ -468,14 +467,14 @@ u_int32_t __toku_db_txn_id(DB_TXN * txn) {
static TXNID next_txn = 0; static TXNID next_txn = 0;
static int __toku_txn_begin(DB_ENV * env, DB_TXN * stxn, DB_TXN ** txn, u_int32_t flags) { static int __toku_txn_begin(DB_ENV * env, DB_TXN * stxn, DB_TXN ** txn, u_int32_t flags) {
DB_TXN *result = toku_malloc(sizeof(*result)); DB_TXN *MALLOC(result);
if (result == 0) if (result == 0)
return ENOMEM; return ENOMEM;
memset(result, 0, sizeof *result); memset(result, 0, sizeof *result);
//notef("parent=%p flags=0x%x\n", stxn, flags); //notef("parent=%p flags=0x%x\n", stxn, flags);
result->commit = __toku_db_txn_commit; result->commit = __toku_db_txn_commit;
result->id = __toku_db_txn_id; result->id = toku_db_txn_id;
result->i = toku_malloc(sizeof(*result->i)); MALLOC(result->i);
assert(result->i); assert(result->i);
result->i->parent = stxn; result->i->parent = stxn;
int r = tokutxn_begin(stxn ? stxn->i->tokutxn : 0, &result->i->tokutxn, next_txn++, env->i->logger); int r = tokutxn_begin(stxn ? stxn->i->tokutxn : 0, &result->i->tokutxn, next_txn++, env->i->logger);
...@@ -485,8 +484,8 @@ static int __toku_txn_begin(DB_ENV * env, DB_TXN * stxn, DB_TXN ** txn, u_int32_ ...@@ -485,8 +484,8 @@ static int __toku_txn_begin(DB_ENV * env, DB_TXN * stxn, DB_TXN ** txn, u_int32_
return 0; return 0;
} }
int __toku_txn_abort(DB_TXN * txn) { static int toku_txn_abort(DB_TXN * txn) {
fprintf(stderr, "__toku_txn_abort(%p)\n", txn); fprintf(stderr, "toku_txn_abort(%p)\n", txn);
abort(); abort();
} }
...@@ -521,12 +520,12 @@ struct __toku_dbc_internal { ...@@ -521,12 +520,12 @@ struct __toku_dbc_internal {
DB_TXN *txn; DB_TXN *txn;
}; };
int __toku_c_get(DBC * c, DBT * key, DBT * data, u_int32_t flag) { static int toku_c_get(DBC * c, DBT * key, DBT * data, u_int32_t flag) {
int r = brt_cursor_get(c->i->c, key, data, flag, c->i->txn ? c->i->txn->i->tokutxn : 0); int r = brt_cursor_get(c->i->c, key, data, flag, c->i->txn ? c->i->txn->i->tokutxn : 0);
return r; return r;
} }
int __toku_c_close(DBC * c) { static int toku_c_close(DBC * c) {
int r = brt_cursor_close(c->i->c); int r = brt_cursor_close(c->i->c);
toku_free(c->i); toku_free(c->i);
toku_free(c); toku_free(c);
...@@ -539,14 +538,14 @@ int __toku_c_del(DBC * c, u_int32_t flags) { ...@@ -539,14 +538,14 @@ int __toku_c_del(DBC * c, u_int32_t flags) {
} }
int __toku_db_cursor(DB * db, DB_TXN * txn, DBC ** c, u_int32_t flags) { int __toku_db_cursor(DB * db, DB_TXN * txn, DBC ** c, u_int32_t flags) {
DBC *result = toku_malloc(sizeof(*result)); DBC *MALLOC(result);
if (result == 0) if (result == 0)
return ENOMEM; return ENOMEM;
memset(result, 0, sizeof *result); memset(result, 0, sizeof *result);
result->c_get = __toku_c_get; result->c_get = toku_c_get;
result->c_close = __toku_c_close; result->c_close = toku_c_close;
result->c_del = __toku_c_del; result->c_del = __toku_c_del;
result->i = toku_malloc(sizeof(*result->i)); MALLOC(result->i);
assert(result->i); assert(result->i);
result->i->db = db; result->i->db = db;
result->i->txn = txn; result->i->txn = txn;
...@@ -796,7 +795,7 @@ int db_create(DB ** db, DB_ENV * env, u_int32_t flags) { ...@@ -796,7 +795,7 @@ int db_create(DB ** db, DB_ENV * env, u_int32_t flags) {
assert(db_env_opened(env)); assert(db_env_opened(env));
} }
DB *result = toku_malloc(sizeof(*result)); DB *MALLOC(result);
if (result == 0) { if (result == 0) {
db_env_unref(env); db_env_unref(env);
return ENOMEM; return ENOMEM;
...@@ -817,7 +816,7 @@ int db_create(DB ** db, DB_ENV * env, u_int32_t flags) { ...@@ -817,7 +816,7 @@ int db_create(DB ** db, DB_ENV * env, u_int32_t flags) {
result->set_pagesize = __toku_db_set_pagesize; result->set_pagesize = __toku_db_set_pagesize;
result->set_flags = __toku_db_set_flags; result->set_flags = __toku_db_set_flags;
result->stat = __toku_db_stat; result->stat = __toku_db_stat;
result->i = toku_malloc(sizeof(*result->i)); MALLOC(result->i);
if (result->i == 0) { if (result->i == 0) {
toku_free(result); toku_free(result);
db_env_unref(env); db_env_unref(env);
...@@ -832,6 +831,9 @@ int db_create(DB ** db, DB_ENV * env, u_int32_t flags) { ...@@ -832,6 +831,9 @@ int db_create(DB ** db, DB_ENV * env, u_int32_t flags) {
result->i->open_flags = 0; result->i->open_flags = 0;
result->i->open_mode = 0; result->i->open_mode = 0;
result->i->brt = 0; result->i->brt = 0;
list_init(&result->i->associated);
result->i->primary = 0;
result->i->associate_callback = 0;
r = brt_create(&result->i->brt); r = brt_create(&result->i->brt);
if (r != 0) { if (r != 0) {
toku_free(result->i); toku_free(result->i);
......
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