> Although the "(SIZE_T) -1" is a bit confusing I assume this means it returns -1 on failure or does it mean ($FFFFFFFF)-1 ?
The (SIZE_T) is just a type cast. So it is -1 interpreted as a variable of type SIZE_T (still -1 in the PB world)
MemorySize() is a direct wrapper to HeapSize(), so it is the api command actually that crashes, not the PB part. Try:
Code: Select all
Debug HeapSize_(GetProcessHeap_(), 0, 123)
So it is no use for validation either.
The only way to implement this is if PB keeps a list of all allocated memory blocks,
i think this is a bit overkill.
I also agree with Tronds opinion.
Having a memory pointer of which you do not know if it is valid or not is a bug in the program imho. This should not happen.