I have a tree and I want to release the allocated memory, but I face a problem that a pointer may refers to a variable that isn't dynamically allocated,so how to know wether this pointer refers to dynamic a variable or not
A:
This is compiler-specific. You may compare given pointer with pointer to a local variable. Result interpretation depends on the way compiler implements heap and stack. Generally, for given compiler, stack pointer is always less (or greater) than heap pointer. In any case, THIS IS BAD DESIGN. This may not work if pointer belongs to another heap (for example, allocated in another Dll).
Alex Farber
2010-03-10 12:09:07