Fixed GMEM_ZEROINIT in GlobalRealloc (thanks to Gerard Patel).

This commit is contained in:
Alexandre Julliard 1999-09-04 11:26:56 +00:00
parent 04699cca44
commit d10ca9ce46

View File

@ -1175,6 +1175,7 @@ HGLOBAL WINAPI GlobalReAlloc(
HGLOBAL hnew; HGLOBAL hnew;
PGLOBAL32_INTERN pintern; PGLOBAL32_INTERN pintern;
HANDLE heap = GLOBAL_GetHeap( hmem ); HANDLE heap = GLOBAL_GetHeap( hmem );
DWORD heap_flags = (flags & GMEM_ZEROINIT) ? HEAP_ZERO_MEMORY : 0;
hnew = 0; hnew = 0;
/* HeapLock(heap); */ /* HeapLock(heap); */
@ -1216,7 +1217,7 @@ HGLOBAL WINAPI GlobalReAlloc(
if(ISPOINTER(hmem)) if(ISPOINTER(hmem))
{ {
/* reallocate fixed memory */ /* reallocate fixed memory */
hnew=(HGLOBAL)HeapReAlloc(heap, 0, (LPVOID) hmem, size); hnew=(HGLOBAL)HeapReAlloc(heap, heap_flags, (LPVOID) hmem, size);
} }
else else
{ {
@ -1230,14 +1231,14 @@ HGLOBAL WINAPI GlobalReAlloc(
hnew=hmem; hnew=hmem;
if(pintern->Pointer) if(pintern->Pointer)
{ {
palloc=HeapReAlloc(heap, 0, palloc=HeapReAlloc(heap, heap_flags,
(char *) pintern->Pointer-sizeof(HGLOBAL), (char *) pintern->Pointer-sizeof(HGLOBAL),
size+sizeof(HGLOBAL) ); size+sizeof(HGLOBAL) );
pintern->Pointer=(char *) palloc+sizeof(HGLOBAL); pintern->Pointer=(char *) palloc+sizeof(HGLOBAL);
} }
else else
{ {
palloc=HeapAlloc(heap, 0, size+sizeof(HGLOBAL)); palloc=HeapAlloc(heap, heap_flags, size+sizeof(HGLOBAL));
*(HGLOBAL *)palloc=hmem; *(HGLOBAL *)palloc=hmem;
pintern->Pointer=(char *) palloc+sizeof(HGLOBAL); pintern->Pointer=(char *) palloc+sizeof(HGLOBAL);
} }