void recursing(TreeNode* root, vector<int>& res) { if(root!=NULL) { recursing(root->left, res); res.push_back(root->val); recursing(root->right,res); } }
static int sm_metadata_new_block_(struct dm_space_map *sm, dm_block_t *b) { int r, r2 = 0; enum allocation_event ev; struct sm_metadata *smm = container_of(sm, struct sm_metadata, sm); r = sm_ll_find_free_block(&smm->old_ll, smm->begin, smm->old_ll.nr_blocks, b); if (r) return r; smm->begin = *b + 1; if (recursing(smm)) r = add_bop(smm, BOP_INC, *b); else { in(smm); r = sm_ll_inc(&smm->ll, *b, &ev); r2 = out(smm); } if (!r) smm->allocated_this_transaction++; return combine_errors(r, r2); }
static int sm_metadata_dec_block(struct dm_space_map *sm, dm_block_t b) { int r, r2 = 0; enum allocation_event ev; struct sm_metadata *smm = container_of(sm, struct sm_metadata, sm); if (recursing(smm)) r = add_bop(smm, BOP_DEC, b); else { in(smm); r = sm_ll_dec(&smm->ll, b, &ev); r2 = out(smm); } return combine_errors(r, r2); }
vector<int> inorderTraversal(TreeNode* root) { vector<int>res; recursing(root, res); return res; }