I want to avoid memory allocation/deallocation function problems by first checking (at the start of each function) if a pointer already points to some allocated memory in the heap (before trying to 'malloc' it), or not ...
All the functions that 'free' pointers in turn set the pointer to NULL, so that's an easy check to make for functions that may 'malloc' later on. However, when a pointer type in declared at the begining of the code (imagine a struct with pointers) it isn't set to NULL (so that initial check doesn't work). To get around this, I can only imagine setting them to NULL right after their initial declaration ...
But is there another way of checking for this?
All the functions that 'free' pointers in turn set the pointer to NULL, so that's an easy check to make for functions that may 'malloc' later on. However, when a pointer type in declared at the begining of the code (imagine a struct with pointers) it isn't set to NULL (so that initial check doesn't work). To get around this, I can only imagine setting them to NULL right after their initial declaration ...
But is there another way of checking for this?