Commit aab744ac authored by Leif Walsh's avatar Leif Walsh Committed by Yoni Fogel

refs #5671 add toku_memdup_dbt, it's cleaner


git-svn-id: file:///svn/toku/tokudb@50011 c7de825b-a66e-492c-adef-691d508d4ae1
parent 4258288e
...@@ -906,8 +906,7 @@ ftleaf_split( ...@@ -906,8 +906,7 @@ ftleaf_split(
LEAFENTRY CAST_FROM_VOIDP(le, lev); LEAFENTRY CAST_FROM_VOIDP(le, lev);
uint32_t keylen; uint32_t keylen;
void *key = le_key_and_len(le, &keylen); void *key = le_key_and_len(le, &keylen);
toku_fill_dbt(splitk, toku_xmemdup(key, keylen), keylen); toku_memdup_dbt(splitk, key, keylen);
splitk->flags = DB_DBT_MALLOC;
} }
node->n_children = num_children_in_node; node->n_children = num_children_in_node;
......
...@@ -37,13 +37,19 @@ toku_destroy_dbt(DBT *dbt) { ...@@ -37,13 +37,19 @@ toku_destroy_dbt(DBT *dbt) {
DBT * DBT *
toku_fill_dbt(DBT *dbt, bytevec k, ITEMLEN len) { toku_fill_dbt(DBT *dbt, bytevec k, ITEMLEN len) {
dbt->flags = 0; toku_init_dbt(dbt);
dbt->ulen = 0;
dbt->size=len; dbt->size=len;
dbt->data=(char*)k; dbt->data=(char*)k;
return dbt; return dbt;
} }
DBT *toku_memdup_dbt(DBT *dbt, const void *k, size_t len) {
toku_init_dbt_flags(dbt, DB_DBT_MALLOC);
dbt->size = len;
dbt->data = toku_xmemdup(k, len);
return dbt;
}
DBT *toku_copyref_dbt(DBT *dst, const DBT src) { DBT *toku_copyref_dbt(DBT *dst, const DBT src) {
dst->flags = 0; dst->flags = 0;
dst->ulen = 0; dst->ulen = 0;
...@@ -61,11 +67,7 @@ DBT *toku_copy_dbt(DBT *dst, const DBT &src) { ...@@ -61,11 +67,7 @@ DBT *toku_copy_dbt(DBT *dst, const DBT &src) {
} }
DBT *toku_clone_dbt(DBT *dst, const DBT &src) { DBT *toku_clone_dbt(DBT *dst, const DBT &src) {
dst->flags = DB_DBT_MALLOC; return toku_memdup_dbt(dst, src.data, src.size);
dst->ulen = 0;
dst->size = src.size;
dst->data = toku_xmemdup(src.data, src.size);
return dst;
} }
void void
......
...@@ -23,6 +23,8 @@ void toku_destroy_dbt(DBT *); ...@@ -23,6 +23,8 @@ void toku_destroy_dbt(DBT *);
DBT *toku_fill_dbt(DBT *dbt, bytevec k, ITEMLEN len); DBT *toku_fill_dbt(DBT *dbt, bytevec k, ITEMLEN len);
DBT *toku_memdup_dbt(DBT *dbt, const void *k, size_t len);
DBT *toku_copyref_dbt(DBT *dst, const DBT src); DBT *toku_copyref_dbt(DBT *dst, const DBT src);
DBT *toku_copy_dbt(DBT *dst, const DBT &src); DBT *toku_copy_dbt(DBT *dst, const DBT &src);
......
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