On Monday 15 December 2003 17:20, Dimitrie O. Paun wrote:
Great, thanks for catching this. Our current implementation seems to be freeing memory on size=0, how can we check what Windows does?
On Windows resizing to 0 succeeds, and if you then the check the size of the memory object you find the same size as before resizing. I don't know what happens with large resizes (larger than some internal block unit), haven't checked, but I guess rounding to the nearest block multiple is involved here.
Furthermore, if you resize to anything larger than 0, but smaller than the orginal size you get your smaller size on Win2k but the original size on Win98. Again, I see this with small resizes, don't know about large resizes.
If it doesn't, we can just simpligy the code to this:
Your patch get's rid of the errors I reported, but it introduces new errors:
heap.c:46: Test failed: Can't realloc global memory heap.c:48: Test failed: Memory not resized to size 10, instead size=0 heap.c:53: Test failed: GlobalReAlloc should not fail on size 0 heap.c:70: Test failed: Can't realloc local memory heap.c:72: Test failed: Memory not resized to size 10, instead size=0 heap.c:77: Test failed: LocalReAlloc should not fail on size 0
Worse is that other tests start to fail too:
alloc.c:237: Test failed: GlobalHandle didn't return the correct memory handle alloc.c:241: Test failed: Discarded memory we shouldn't have alloc.c:327: Test failed: LocalHandle didn't return the correct memory handle alloc.c:330: Test failed: Discarded memory we shouldn't have
-Hans