Behavior of realloc vs. HeapReAlloc

Paul Chitescu paulc at
Sun Aug 23 07:51:22 CDT 2009


While trying to debug a crash in msi.dll I noticed that the local 
msi_realloc() is implemented as a (too) thin wrapper around HeapReAlloc() and 
differs from the expected behavior of realloc() when the old pointer or the 
new size are zero.

The runtime realloc() works like free() if the new size is zero and it works 
like alloc() if the old pointer is null. HeapReAlloc never allocates or 
completely frees memory.



So I suggest all implementations of heap_realloc to be modified like:

if (!size) {
    return 0;
else if (!mem)
    return HeapAlloc(...)
    return HeapReAlloc(...)

Any comments?

Paul Chitescu

More information about the wine-devel mailing list