Commit f347fb6d authored by Yoni Fogel's avatar Yoni Fogel

Addresses #479

toku_rt_super_create now checks the ptree from its caller is not NULL

git-svn-id: file:///svn/tokudb@2632 c7de825b-a66e-492c-adef-691d508d4ae1
parent af75bdb6
......@@ -89,23 +89,24 @@ int toku_rt_create(toku_range_tree** ptree,
void (*user_free) (void*),
void* (*user_realloc)(void*, size_t)) {
int r;
toku_range_tree* temptree;
toku_range_tree* tmptree;
r = toku_rt_super_create(&temptree, end_cmp, data_cmp, allow_overlaps,
if (!ptree) return EINVAL;
r = toku_rt_super_create(ptree, &tmptree, end_cmp, data_cmp, allow_overlaps,
user_malloc, user_free, user_realloc);
if (0) {
died1:
user_free(temptree);
user_free(tmptree);
return r;
}
if (r!=0) return r;
//Any local initializers go here.
temptree->i.ranges_len = minlen;
temptree->i.ranges = (toku_range*)
user_malloc(temptree->i.ranges_len * sizeof(toku_range));
if (!temptree->i.ranges) { r = errno; goto died1; }
*ptree = temptree;
tmptree->i.ranges_len = minlen;
tmptree->i.ranges = (toku_range*)
user_malloc(tmptree->i.ranges_len * sizeof(toku_range));
if (!tmptree->i.ranges) { r = errno; goto died1; }
*ptree = tmptree;
return 0;
}
......
......@@ -121,10 +121,10 @@ int toku_rt_create(toku_range_tree** ptree,
void (*user_free) (void*),
void* (*user_realloc)(void*, size_t)) {
int r;
toku_range_tree* temptree;
toku_range_tree* tmptree;
if (allow_overlaps) return ENOSYS;
r = toku_rt_super_create(&temptree, end_cmp, data_cmp, allow_overlaps,
r = toku_rt_super_create(ptree, &tmptree, end_cmp, data_cmp, allow_overlaps,
user_malloc, user_free, user_realloc);
if (0) {
died1:
......@@ -134,9 +134,9 @@ int toku_rt_create(toku_range_tree** ptree,
if (r!=0) return r;
//Any local initializers go here.
temptree->rbt = toku_rbt_init(void);
if (!temptree->rbt) { r = errno; goto died1; }
*ptree = temptree;
tmptree->rbt = toku_rbt_init(void);
if (!tmptree->rbt) { r = errno; goto died1; }
*ptree = tmptree;
return 0;
}
......
......@@ -67,7 +67,8 @@ static inline int toku__rt_increase_buffer(toku_range_tree* tree, toku_range** b
return 0;
}
static inline int toku_rt_super_create(toku_range_tree** ptree,
static inline int toku_rt_super_create(toku_range_tree** upperptree,
toku_range_tree** ptree,
int (*end_cmp)(toku_point*,toku_point*),
int (*data_cmp)(DB_TXN*,DB_TXN*),
BOOL allow_overlaps,
......@@ -75,7 +76,7 @@ static inline int toku_rt_super_create(toku_range_tree** ptree,
void (*user_free) (void*),
void* (*user_realloc)(void*, size_t)) {
toku_range_tree* temptree;
if (!ptree || !end_cmp || !data_cmp ||
if (!upperptree || !ptree || !end_cmp || !data_cmp ||
!user_malloc || !user_free || !user_realloc) return EINVAL;
temptree = (toku_range_tree*)user_malloc(sizeof(toku_range_tree));
......
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