CommandLineToArgvW fix
Francois Gouget
fgouget at free.fr
Mon Oct 8 22:18:22 CDT 2001
On 8 Oct 2001, Alexandre Julliard wrote:
> Francois Gouget <fgouget at free.fr> writes:
>
> > Grrr, HGLOBAL is not a void* pointer... yet => casts :-(
>
> GlobalLock would be better...
The problem is that CommandLineToArgvW is supposed to return a
pointer, not a handle. But I cannot do:
hargv=GlobalAlloc(...);
argv=GlobalLock(hargv);
...
return argv;
Because then the the memory object is going to be locked and freeing
a locked memory object is bad according to the MSDN. And they don't say
that you should to a GlobalUnlock before the GlobalFree.
So I could do:
hargv=GlobalAlloc(...);
argv=GlobalLock(hargv);
GlobalUnlock(hargv);
...
return argv;
After all this memory object is GMEM_FIXED, it has to since I return
a pointer to it. But the MSDN says that in that case GlobalAlloc returns
a pointer, not a mere handle. And Invoking GlobalLock+GlobalUnlock just
to avoid a cast seems a bit extreme.
Sigh. What a stupid memory API.
--
Francois Gouget fgouget at free.fr http://fgouget.free.fr/
The nice thing about meditation is that it makes doing nothing quite respectable
-- Paul Dean
More information about the wine-devel
mailing list