X-Git-Url: https://git.llucax.com/z.facultad/75.52/treemulator.git/blobdiff_plain/61ad6c12c81dd37c54797f5b507cdb677211f49a..2f18bb22e1573898bb70f0a46897fbd032ef2734:/src/btree.cpp diff --git a/src/btree.cpp b/src/btree.cpp index 26224a5..77967bf 100644 --- a/src/btree.cpp +++ b/src/btree.cpp @@ -97,14 +97,20 @@ void BTree::WriteBlock (uchar *block, uint num) void BTree::AddKey (const Clave &k) { uint left, right; - Clave *kout; + Clave *kout, *in; + + in = k.Clone (); + /* TODO : Hacer un contador con recuperacion */ + in->SetBlockData (0); try { - kout = AddKeyR (k.Clone (), 0, left, right); + kout = AddKeyR (in->Clone (), 0, left, right); } catch (Exception *e) { throw e; } + delete in; + if (kout) { unsigned short level; /* Debo dejar la raiz en el nodo 0, por lo que paso el nodo @@ -1181,9 +1187,9 @@ uchar *BTree::NewBlock (uint &num) BTreeNodeHeader nh; std::list::iterator it; - it = deleted_nodes.begin (); - if (it != deleted_nodes.end ()) { + if (deleted_nodes.size ()) { + it = deleted_nodes.begin (); num = *it; deleted_nodes.erase (it); } else {