Keep track of the memory ranges of the blocks, and if your pointer falls in that range, set it to NULL, and don't free it unless you would no longer have any valid pointers in that range.


Quzah.