Fred wrote:Why is it useful to allocate a 0 bytes memory area ?
Functions the AllocateMemory and ReAllocateMemory in windose PureBasic versions should not be a procedure, it must be a macro to create the calls to HeapAlloc and HeapReAlloc.
Compiled application should not be used initially artificially created with the storage identifier Heap in this variable [_PB_MemoryBase].
This is unnatural and incompatible with a common method through GetProcessHeap().
The functions HeapAlloc and HeapReAlloc themselves are bullproof.
Ability to create zero-sized blocks specially laid well the OS level.
Because it allows a very flexible to work with pre-created buffer, further fulfilling dynamic change buffer size.
I often use this feature when working with a structured management, especially when working with files stored resources (SFX, VFX, e.t.c.), working with the Chunks-based files (resources containers, resources into the firmwares, e.t.c.).
Into the PureBasic this is impossible, not because the procedures can not do that, but because the caps before the procedures:
MOV EAX, [DWORD SS:ESP+4]
TEST EAX, EAX ; !!! if SIZE = 0
JLE do_Return_False ; !!! Then Return #False
And why deny the possibility of artificially already implemented in the OS API?
If you remove the caps and will use heap of task GetProcessHeap(), will not suffer from the compatibility and completeness of the functions will be possible.
IMHO