Esempio n. 1
0
/* Merge the second index node into the first index node. split_key is the 
 * split key between the two node. The second index node will be freed.
 */
void
bpt_merge_index(bpt_node** root, bpt_node* n, long split_key, bpt_node** n1)
{
	bpt_node *n11 = *n1;

	/* add the split key into node */
	n->key[bpt_num_of_key(n)] = split_key;

	/* Copy keys of the second index node into the first index node */
	memcpy(n->key + n->num_of_rec, n11->key, 
			n11->num_of_rec * sizeof(long));

	/* Copy children of the second index node into the first index node */
	memcpy(n->recs.c_arr + n->num_of_rec, n11->recs.c_arr, 
			n11->num_of_rec * sizeof(bpt_node*));

	n->num_of_rec += n11->num_of_rec;

	/* NOTE!! For the children of to-be-removed index node, 
	 * they should change their parent. */
	int i;
	for(i = 0; i < n11->num_of_rec; i++)
		n11->recs.c_arr[i]->p = n;

	/* Need to remove it from its parent. */
	bpt_delete_entry(root, n->p, *n1);

	/* Free the node memory */
	bpt_delete_node(n1);
}
Esempio n. 2
0
/* Merge the second leaf node into the first leaf node. The second leaf node 
 * will be freed. 
 */
void
bpt_merge_leaf(bpt_node** root, bpt_node* n, bpt_node** n1)
{
	bpt_node *n11 = *n1;
	
	/* Copy keys of the second leaf node into the first leaf node */
	memcpy(n->key + n->num_of_rec, n11->key, 
			n11->num_of_rec * sizeof(long));

	/* Copy records of the second leaf node into the first leaf node */
	memcpy(n->recs.l_rec.r_arr + n->num_of_rec, n11->recs.l_rec.r_arr, 
			n11->num_of_rec * sizeof(bpt_record_t*));

	n->num_of_rec += n11->num_of_rec;

	/* Need to remove the second node from its parent */
	bpt_delete_entry(root, n->p, *n1);

	/* Free the node memory */
	bpt_delete_node(n1);
}
Esempio n. 3
0
void
pdf_obj_free()
{
	  pdf_map * m = parser_inst->map;//&a_pdf_map;
      pdf_map *i = m;

	  if (!parser_inst && !parser_inst->map)
		  return;

	  for (; i != 0; i = i->next)
      {
            /* delete obj tree nodes */
            bpt_delete_node(i->head, (leaf_action)pdf_obj_delete);
      }
      i = m;
      for (; i!=0; i=i->next)
      {
            /* delete obj tree */
            bpt_destroy(i->head);
            pdf_free(i->head);
      }
}