it's necessary to cast the pointers returned from malloc and realloc here because we add 1 to the pointer before assigning it to a variable. It's unusual but it works. Still, we could simplify this code a bit by only calling realloc.
Right, sorry about that.
However, let's start off with a commit that makes this explicit, to avoid mistakes by future reviewers. Something like: ```c if (llTypes[type].lpMlds) { WINE_MLD *mem = llTypes[type].lpMlds - 1;
mem = HeapReAlloc(GetProcessHeap(), 0, mem, sizeof(WINE_MLD) * (llTypes[type].wMaxId + 1)); llTypes[type].lpMlds = mem + 1; } else { WINE_MLD *mem;
mem = HeapAlloc(GetProcessHeap(), 0, sizeof(WINE_MLD) * (llTypes[type].wMaxId + 1)); llTypes[type].lpMlds = mem + 1; } ```
Then we can merge to two branches into `realloc()` in the commit that switches things to the CRT allocator.
As far as the casts in the calls to free, they are all to avoid warnings about freeing pointers to const strings, so they can't be removed.
Got it.