ReplaceMalloc

ReplaceMalloc

This task is complete. Remaining uses of malloc in Wine are probably OK for various reasons.

The use of malloc() in Wine is discouraged. The proper Win32 way of allocating memory is HeapAlloc. However this applies to Wine dlls and winelib programs only. Pure *NIX programs, such as wineserver should still use malloc.

How To Find Them

Using git:

git grep "\W[cm]alloc\s*("

Without git:

find . -name "*.c" | xargs grep "[^_A-Za-z0-9]\+malloc\s*("

The easy dlls/programs to fix are those that use a mixture of malloc() and HeapAlloc() calls.

How To Fix Them

Just replace the existing malloc() and free() calls with the corresponding HeapAlloc() and HeapFree() calls. If the malloc() call is followed by a ZeroMemory() or memset(0) you want to remove that call and pass instead the HEAP_ZERO_MEMORY flag to HeapAlloc().


CategoryJanitorialProjects

ReplaceMalloc (last edited 2010-12-31 17:16:26 by DmitryTimoshkov)