Hi,
please note that I'm not a very experienced C (or CW) programmer, so if my question should be stupid, please issue a simple "RTFM" and an URL (I'm not too lazy too read, I just did not find the answer yet) ...
I am creating several cryptography classes and tgo make life easier, I chose to do it like this:
class _CryptoBase is the base class with mostly (pure) virtual functions that holds a generic context (as heap pointer) and some other pointer I need.
Constructor: Allocates heap for holding key, iv, etc
Destructor: Frees allocated heap
class _TEABase is the base class for all (ok, only 2 atm) algos of the TEA family and inherits from _CryptoBase. It contains a pointer to a TEA specific context.
Constructor: Allocates heap for the specific context and passes the keysize and blocksize to the constructor of _CryptoBase
Destructor: Frees allocated heap
class TEA and class XTEA inherit from _TEABase and only contain the two function to encrypt or decrypt a block of 8 byte.
Constructor: Just falls through to the constructor of _TEABase
Destructor: Nothing
Constructor cascading works perfect, but only the destructor of _CryptoBase is called, which means that the allocated heap in _TEABase is not freed.
I changed _TEABase to use a typed var for the context instead of a pointer to type and this works of course.
Anyway, since I might need real heap pointers later, I would like to know if there is a way to get a 'destructor cascading'? Or do I need to provide a kind of pointer-table in _CryptoBase that can be used to free all heap allocations on destruction of _CryptoBase?
-- Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
-- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
