Does on all modern Win32 OS, HeapSize() return exactly the number of bytes requested during HeapAlloc() ?

invoke HeapAlloc,pHeap1,0,107 ; request 107 bytes
invoke HeapSize,pHeap1,0,eax
; is EAX==107 ??

I'm thinking of relying on this API function for some code of mine.
Posted on 2006-10-04 15:21:25 by Ultrano
Good question, PlatformSDK doesn't say anything 100% specific... It wouldn't surprise me if, at least on some windows versions, it could return a rounded number.
Posted on 2006-10-04 17:11:14 by f0dder
MSDN is fairly clear on this, HeapAlloc is the problem, it will not always allocate exactly the numbe rof bytes requested but will allocate "at least" the number requested. Heap size will always return the exact number of bytes allocated which may or may not match the number requested.

If HeapAlloc succeeds, it allocates at least the amount of memory requested. If the actual amount allocated is greater than the amount requested, the process can use the entire amount. To determine the actual size of the allocated block, use the HeapSize function.
Posted on 2006-10-04 19:29:31 by donkey
shame on me for not noticing  :oops:
Posted on 2006-10-04 19:59:58 by Ultrano