Michael Stefaniuc : winefile: Replace malloc with HeapAlloc.

Michael Stefaniuc mstefani at redhat.com
Thu Jul 26 04:41:20 CDT 2007

Hello Martin,

Martin Fuchs wrote:
> may I ask why you are replacing the simple malloc/free calls
> by the more complicated HeapAlloc API? This just makes
> the source longer and less readable. There is no point in avoiding
> C library usage in Winefile. It is just a unix application using
> Wine libraries - not a Wine system library.
It's not a Wine system library, true. But it is definitely not a unix
application; it's a Windows application that knows about the underlying
unix system if it is compiled for Wine. To keep it consistent with the
rest of the wine code it makes sense to move it to the
HeapFree/HeapAlloc functions.

For somebody used to Windows/Wine code it isn't less readable. And for
the length of the code: Half of the lines with the calls do not exceed
80 chars and the other half that exceeds that is still shorter then the
surrounding code. I pondered writing some macros around
HeapFree/HeapAlloc but dropped the idea due to that and because there
aren't that many calls to those functions.


> On 24.07.2007 07:06:08 Alexandre Julliard wrote:
>> Module: wine
>> Branch: master
>> Commit: 11bb71d3d6a34d301291b2d15c849a1381bd7789
>> URL:
>> http://source.winehq.org/git/wine.git/?a=commit;h=11bb71d3d6a34d301291b2d15c8
>> 49a1381bd7789
>> Author: Michael Stefaniuc <mstefani at redhat.de>
>> Date:   Mon Jul 23 22:25:20 2007 +0200
>> winefile: Replace malloc with HeapAlloc.
>> -    Entry* entry = (Entry*) malloc(sizeof(Entry));
>> +    Entry* entry = HeapAlloc(GetProcessHeap(), 0, sizeof(Entry));
>> -    free(entry);
>> +    HeapFree(GetProcessHeap(), 0, entry);
>>  }

Michael Stefaniuc               Tel.: +49-711-96437-199
Sr. Network Engineer            Fax.: +49-711-96437-111
Reg. Adresse: Red Hat GmbH, Hauptstätter Strasse 58, 70178 Stuttgart
Handelsregister: Amtsgericht Stuttgart HRB 153243
Geschäftsführer: Brendan Lane, Charlie Peters, Michael Cunningham,
                 Werner Knoblich

More information about the wine-devel mailing list