22#define CHOOSE_BRANCH(n) \
23 branch = branch->branches[!!(n)];
28# define pemalloc(size, persistent) malloc(size)
29# define pefree(ptr, persistent) free(ptr)
42 int i = tree->
depth - 1;
49 if ((idx >> i) % 2 == 1) {
69 int i = tree->
depth - 1, last_superior_i = -1;
77 if ((idx >> i) % 2 == 0) {
83 if (last_superior_i == -1) {
93 }
while (--i > last_superior_i);
127 pos.cur = higher_idx;
145 int i = tree->
depth - 1;
149 if (*branch ==
NULL) {
152 branch = &(*branch)->
branches[(idx >> i) % 2];
155 if (*branch ==
NULL) {
163 (*branch)->branches[!((idx >> i) % 2)] =
NULL;
164 branch = &(*branch)->
branches[(idx >> i) % 2];
174 (*branch)->result.ptr =
ptr;
182 int i_last_dual_branch = -1, last_dual_branch_branch;
185 goto check_branch_existence;
188 last_dual_branch = branch;
189 i_last_dual_branch = i;
190 last_dual_branch_branch = (idx >> i) % 2;
192 branch = branch->
branches[(idx >> i) % 2];
194check_branch_existence:
195 if (branch ==
NULL) {
202 if (i_last_dual_branch == -1) {
206 if (last_dual_branch->
branches[last_dual_branch_branch] == last_dual_branch + 1) {
211 last_dual_branch->
branches[!last_dual_branch_branch] = last_dual_branch + 1;
213 branch = last_dual_branch->
branches[!last_dual_branch_branch];
214 for (i = i_last_dual_branch; i--;) {
215 branch = (branch->
branches[branch->
branches[1] == ++original_branch] = last_dual_branch + i_last_dual_branch - i + 1);
221 last_dual_branch->
branches[last_dual_branch_branch] =
NULL;
230 bool use_branch = branch + 1 == branch->
branches[0];
fprintf($stream, string $format, mixed ... $values)
unsigned const char * pos
void phpdbg_btree_dump(phpdbg_btree *tree)
phpdbg_btree_result * phpdbg_btree_next(phpdbg_btree_position *pos)
void phpdbg_btree_clean(phpdbg_btree *tree)
void phpdbg_btree_init(phpdbg_btree *tree, zend_ulong depth)
void phpdbg_btree_clean_recursive(phpdbg_btree_branch *branch, zend_ulong depth, bool persistent)
void phpdbg_btree_branch_dump(phpdbg_btree_branch *branch, zend_ulong depth)
phpdbg_btree_result * phpdbg_btree_find(phpdbg_btree *tree, zend_ulong idx)
int phpdbg_btree_delete(phpdbg_btree *tree, zend_ulong idx)
int phpdbg_btree_insert_or_update(phpdbg_btree *tree, zend_ulong idx, void *ptr, int flags)
phpdbg_btree_result * phpdbg_btree_find_closest(phpdbg_btree *tree, zend_ulong idx)
phpdbg_btree_position phpdbg_btree_find_between(phpdbg_btree *tree, zend_ulong lower_idx, zend_ulong higher_idx)
#define PHPDBG_BTREE_INSERT
#define PHPDBG_BTREE_UPDATE
union _phpdbg_btree_branch phpdbg_btree_branch
phpdbg_btree_branch * branch
phpdbg_btree_branch * branches[2]
phpdbg_btree_result result
#define pefree(ptr, persistent)
#define pemalloc(size, persistent)