Hi I'm working on an implementation of the Map class and I'm getting weird memory errors from my destructor. Any idea what's going on here?
1 2 3 4
==14581== Conditional jump or move depends on uninitialised value(s)
==14581== at 0x401DD5: Map::destructCode(Map::Elem*&) (in /home/csu/jkf1008/cs515/7P/mapTest)
==14581== by 0x401D8C: Map::~Map() (in /home/csu/jkf1008/cs515/7P/mapTest)
==14581== by 0x401A06: main (in /home/csu/jkf1008/cs515/7P/mapTest)
Probably you're trying to call delete on an uninitialized pointer. Note that "uninitialized" does not mean null -- it means it's some junk value, so the if ( p->left ) call can still pass but be harmful.
Is _root initialized? Are p->left and p->right initialized or do they become junk values at some point in the recursive iteration?
Make sure that if a node (Elem) has no valid children, that both left and right are null. Maybe you do this, but I'm not sure since we don't have context.