Commit f3a3fe1e authored by Zardosht Kasheff's avatar Zardosht Kasheff Committed by Yoni Fogel

[t:4875], clean up toku_create_new_brtheader

git-svn-id: file:///svn/toku/tokudb@43427 c7de825b-a66e-492c-adef-691d508d4ae1
parent 9a3cf167
......@@ -431,7 +431,7 @@ struct brt {
BOOL did_set_flags;
brt_compare_func compare_fun;
brt_update_func update_fun;
on_redirect_callback redirect_callback;;
on_redirect_callback redirect_callback;
void* redirect_callback_extra;
struct toku_list live_brt_link;
......
......@@ -7,7 +7,6 @@
#include "includes.h"
#include <brt-cachetable-wrappers.h>
void
toku_brt_header_suppress_rollbacks(struct brt_header *h, TOKUTXN txn) {
TXNID txnid = toku_txn_get_txnid(txn);
......@@ -37,16 +36,6 @@ brtheader_destroy(struct brt_header *h) {
}
}
static int
brtheader_alloc(struct brt_header **hh) {
int r = 0;
if ((CALLOC(*hh))==0) {
assert(errno==ENOMEM);
r = ENOMEM;
}
return r;
}
// Make a copy of the header for the purpose of a checkpoint
static void
brtheader_copy_for_checkpoint(struct brt_header *h, LSN checkpoint_lsn) {
......@@ -66,8 +55,7 @@ brtheader_copy_for_checkpoint(struct brt_header *h, LSN checkpoint_lsn) {
}
static void
brtheader_free(struct brt_header *h)
{
brtheader_free(struct brt_header *h) {
brtheader_destroy(h);
toku_free(h);
}
......@@ -354,8 +342,8 @@ brt_init_header_partial (BRT t, CACHEFILE cf, TOKUTXN txn) {
t->h->flags = t->flags;
if (t->h->cf!=NULL) assert(t->h->cf == cf);
t->h->cf = cf;
t->h->nodesize=t->nodesize;
t->h->basementnodesize=t->basementnodesize;
t->h->nodesize = t->nodesize;
t->h->basementnodesize = t->basementnodesize;
t->h->root_xid_that_created = txn ? txn->ancestor_txnid64 : TXNID_NONE;
t->h->compare_fun = t->compare_fun;
t->h->update_fun = t->update_fun;
......@@ -412,12 +400,13 @@ brt_init_header (BRT t, CACHEFILE cf, TOKUTXN txn) {
int
toku_create_new_brtheader(BRT t, CACHEFILE cf, TOKUTXN txn) {
int r;
r = brtheader_alloc(&t->h);
if (r != 0) {
if (0) { died2: toku_free(t->h); }
t->h=0;
return r;
assert (!t->h);
t->h = toku_xmalloc(sizeof(struct brt_header));
if (!t->h) {
assert(errno==ENOMEM);
r = ENOMEM;
goto exit;
}
t->h->layout_version = BRT_LAYOUT_VERSION;
......@@ -436,7 +425,19 @@ toku_create_new_brtheader(BRT t, CACHEFILE cf, TOKUTXN txn) {
memset(&t->h->cmp_descriptor, 0, sizeof(t->h->cmp_descriptor));
r = brt_init_header(t, cf, txn);
if (r != 0) goto died2;
if (r != 0) {
goto exit;
}
r = 0;
exit:
if (r != 0) {
if (t->h) {
toku_free(t->h);
t->h = NULL;
}
return r;
}
return r;
}
......
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