コード例 #1
0
} END_TEST

START_TEST(test_dummy) {

  item_t a = INIT_ITEM(12,"Hen");
  item_t b = INIT_ITEM(4,"Dog");
  item_t c = INIT_ITEM(11,"Cat");
  item_t d = INIT_ITEM(1,"Frog");
  item_t e = INIT_ITEM(100,"Owner");
  item_t *it;
  bbtree_t t = INIT_BBTREE; // Create the binary tree

  //Insert data into the tree - key and some text
  bb_insert(&t, &a.node_);
  bb_insert(&t, &b.node_);
  bb_insert(&t, &c.node_);
  bb_insert(&t, &d.node_);
  bb_insert(&t, &e.node_);
  bbtree_print(&t);
  bb_remove(&t, &a.node_);
  it = bb_search(&t, 11, item_t, node_);
  ck_assert(it == &c && it->node_.value_ == 11 && !strcmp(it->value_, "Cat"));
  bbtree_print(&t);
} END_TEST
コード例 #2
0
/*
 * Split the basic blocks from @first at @target.
 * @hint is a guess of a very close to the target basic block. It is probed before the RB tree as it's often possible
 * to provide a near to exact guess (next block splits, switch branch targets, etc)
 *
 */
static MonoSimpleBasicBlock*
bb_split (MonoSimpleBasicBlock *first, MonoSimpleBasicBlock *hint, MonoSimpleBasicBlock **root, guint target, gboolean link_blocks, MonoMethod *method, MonoError *error)
{
	MonoSimpleBasicBlock *res, *bb = first;

	if (bb_idx_is_contained (hint, target)) {
		first = hint;
	} else if (hint->next && bb_idx_is_contained (hint->next, target)) {
		first = hint->next;
	} else {
		first = *root;
		do {
			if (bb_idx_is_contained (first, target))
				break;
			if (first->start > target)
				first = first->left;
			else
				first = first->right;
		} while (first);
	}

	if (first == NULL) {
		mono_error_set_not_verifiable (error, method, "Invalid instruction target %x", target);
		return NULL;
	}

	if (first->start == target)
		return first;

	res = g_new0 (MonoSimpleBasicBlock, 1);
	res->start = target;
	res->end = first->end;
	res->next = first->next;
	res->out_bb = first->out_bb;
	res->dead = TRUE;

	first->end = res->start;
	first->next = res;
	first->out_bb = NULL;

	if (link_blocks)
		bb_link (first, res);
	bb_insert (bb, res, root);

	return res;
}