X-Git-Url: https://git.llucax.com/z.facultad/75.52/treemulator.git/blobdiff_plain/2ab8041933e77875de62bc73e76febc528af258e..fd68ec89fabf4a95e4ebba38fe54041a9ad6d667:/src/btree_data.cpp?ds=inline diff --git a/src/btree_data.cpp b/src/btree_data.cpp index a5d9b68..70195fd 100644 --- a/src/btree_data.cpp +++ b/src/btree_data.cpp @@ -24,6 +24,10 @@ BTreeData::BTreeData (Clave *k, uint child) BTreeData::~BTreeData () { + if (clave) { + delete clave; + clave = NULL; + } } uint BTreeData::Size () const @@ -38,8 +42,10 @@ uchar* BTreeData::ToArray () const { uchar *out = new uchar[Size()]; if (clave) { - memcpy (out, clave->ToArray (), clave->Size ()); + uchar *n = clave->ToArray (); + memcpy (out, n, clave->Size ()); memcpy (out+clave->Size (), &hijo, sizeof (uint)); + delete [] n; } else memcpy (out, &hijo, sizeof (uint)); return out; @@ -59,6 +65,22 @@ bool BTreeData::operator == (const BTreeData &data) const return (*clave) == (*(data.clave)); } +bool BTreeData::Abrev (BTreeData *anterior) +{ + if (anterior == NULL) return false; + + ClaveVariable *c = (ClaveVariable *)clave; + return c->Abrev (dynamic_cast(anterior->GetKey ())); +} + +bool BTreeData::DesAbrev (BTreeData *anterior) +{ + if (anterior == NULL) return false; + + ClaveVariable *c = (ClaveVariable *)clave; + return c->DesAbrev (dynamic_cast(anterior->GetKey ())); +} + BTreeLeafData::BTreeLeafData (uchar *node, int key_type) { if (key_type == BTree::KEY_FIXED) @@ -69,6 +91,10 @@ BTreeLeafData::BTreeLeafData (uchar *node, int key_type) BTreeLeafData::~BTreeLeafData () { + if (clave) { + delete clave; + clave = NULL; + } } uint BTreeLeafData::Size () const