On Sat, Jan 04, 2003 at 02:54:12AM +0100, Michael Stefaniuc wrote:
Do we want to mimic the GlobalAlloc/GlobalReAlloc behaviour of Windows (the DiMage Viewer dosn't corrupt the images at least on Win98 and it's the same binary for Win2000 too)? Could be that some other broken, real life programs are dependent of that behaviour). At a quick glance i don't know how to fix GlobalAlloc/GlobalReAlloc without breaking it. I'll do a bugzilla report but want to save me the work if it will get anyway a WONTFIX resolution.
Well, it wasn't so hard to fix as I first thought. And the patch isn't too intrusive, it aligns only the storage needed for the HGLOBAL on an 8byte boundary. The only disatvantage is we waste 1 byte per memory region allocated with GMEM_MOVEABLE but this should be realy tolerable. Alexandre, i could replace the definition of HGLOBAL_STORAGE with something like: #define HGLOBAL_STORAGE ROUND_SIZE(sizeof(HGOBAL)) and use the ROUND_SIZE macro from dlls/ntdll/heap.c . The two magics "-2" in the patch could be also replaced by HGLOBAL_STORAGE/sizeof(HGOBAL)
License: LGPL, X11 Changelog: Michael Stefaniuc mstefani@redhat.com - the Minolta DiMAGE Image Viewer relies on Global{,Re}Alloc called with the GMEM_MOVEABLE flag set, to allocate the exact specified size and no byte more when size = 8*k, where k=1,2,3,4.... . To achieve this allign the storage needed for the HGLOBAL in the heap to 8byte boundary.
bye michael
P.S.: I'll redo the dlls/kernel/tests/alloc.c to have a test case