void BTree::AddKey (const Clave &k)
{
uint left, right;
- Clave *kout = AddKeyR (k.Clone (), 0, left, right);
+ Clave *kout = AddKeyR (&k, 0, left, right);
if (kout) {
unsigned short level;
it = node_keys.begin ();
while (it != node_keys.end ()) {
if ((*data) == (*(*it))) {
+ BTreeData *aborrar = (*it);
node_keys.erase (it);
+ delete aborrar;
break;
}
it++;
while (it != node_keys.end ()) {
if ((*data) == (*(*it))) {
/* La encontre!, retorno */
+ delete data;
delete [] node;
DeleteKeys (node_keys);
BTreeFindResult *result = new BTreeFindResult ();
result->node = node_num;
result->header = node_header;
+
return result;
}
it++;
}
+ delete data;
+
/* Si llego aca y estoy en nivel 0 (una hoja) quiere
* decir que no lo encontré
*/
if (node_header.level == 0) {
- delete data;
+ DeleteKeys (node_keys);
+ delete [] node;
return NULL;
}
/* TODO: Aca faltaria liberar memoria */
+ BTreeFindResult *ret;
if (it == posterior)
- return FindKeyR (k, lchild->getChild ());
-
- return FindKeyR (k, (*ultima)->getChild ());
+ ret = FindKeyR (k, lchild->getChild ());
+ else
+ ret = FindKeyR (k, (*ultima)->getChild ());
+
+ DeleteKeys (node_keys);
+ delete [] node;
+ return ret;
}
void BTree::DeleteKeys (std::list<BTreeData *> &keys)