cmd: Avoid rereading batch file for every call/goto executed (try 2)

Frédéric Delanoy frederic.delanoy at gmail.com
Mon Sep 5 15:24:56 CDT 2011


On Mon, Sep 5, 2011 at 14:35, Henri Verbeet <hverbeet at gmail.com> wrote:
> 2011/9/5 Frédéric Delanoy <frederic.delanoy at gmail.com>:
>> +        keys = HeapAlloc(GetProcessHeap(), 0, capacity * sizeof(WCHAR*));
>> +        vals = HeapAlloc(GetProcessHeap(), 0, capacity * sizeof(LARGE_INTEGER));
> ...
>> +                    keys = HeapReAlloc(GetProcessHeap(), 0, keys,
>> +                                       capacity * sizeof(WCHAR*));
>> +                    vals = HeapReAlloc(GetProcessHeap(), 0, vals,
>> +                                       capacity * sizeof(LARGE_INTEGER));
> Memory allocations can fail. You also never free these, but I suppose
> that happens implicitly on process termination.

They were not freed since gotos can potentially be used until the last
line of a batch file. Memory would be need to be freed after the batch
file is ran, and that is the end of the process.
But I have to put the cache in the current batch context, as François
suggested, and I'll free them on context destruction.



More information about the wine-devel mailing list