GlobalReAlloc16: If heap has GlobalPageLock set, try only with
HEAP_REALLOC_IN_PLACE_ONLY flag set.
This commit is contained in:
parent
1bd9474ee8
commit
9788815b9c
|
@ -266,7 +266,7 @@ HGLOBAL16 WINAPI GlobalReAlloc16(
|
||||||
) {
|
) {
|
||||||
WORD selcount;
|
WORD selcount;
|
||||||
DWORD oldsize;
|
DWORD oldsize;
|
||||||
void *ptr;
|
void *ptr, *newptr;
|
||||||
GLOBALARENA *pArena, *pNewArena;
|
GLOBALARENA *pArena, *pNewArena;
|
||||||
WORD sel = GlobalHandleToSel16( handle );
|
WORD sel = GlobalHandleToSel16( handle );
|
||||||
|
|
||||||
|
@ -318,19 +318,28 @@ HGLOBAL16 WINAPI GlobalReAlloc16(
|
||||||
|
|
||||||
ptr = (void *)pArena->base;
|
ptr = (void *)pArena->base;
|
||||||
oldsize = pArena->size;
|
oldsize = pArena->size;
|
||||||
TRACE("oldsize %08lx\n",oldsize);
|
TRACE("oldbase %p oldsize %08lx newsize %08lx\n", ptr,oldsize,size);
|
||||||
if (ptr && (size == oldsize)) return handle; /* Nothing to do */
|
if (ptr && (size == oldsize)) return handle; /* Nothing to do */
|
||||||
|
|
||||||
if (pArena->flags & GA_DOSMEM)
|
if (pArena->flags & GA_DOSMEM)
|
||||||
ptr = DOSMEM_ResizeBlock(ptr, size, NULL);
|
newptr = DOSMEM_ResizeBlock(ptr, size, NULL);
|
||||||
else
|
else
|
||||||
ptr = HeapReAlloc( GetProcessHeap(), 0, ptr, size );
|
/* if more then one reader (e.g. some pointer has been given out by GetVDMPointer32W16),
|
||||||
if (!ptr)
|
only try to realloc in place */
|
||||||
|
newptr = HeapReAlloc( GetProcessHeap(),
|
||||||
|
(pArena->pageLockCount > 0)?HEAP_REALLOC_IN_PLACE_ONLY:0, ptr, size );
|
||||||
|
if (!newptr)
|
||||||
{
|
{
|
||||||
SELECTOR_FreeBlock( sel );
|
FIXME("Realloc failed lock %d\n",pArena->pageLockCount);
|
||||||
memset( pArena, 0, sizeof(GLOBALARENA) );
|
if (pArena->pageLockCount <1)
|
||||||
|
{
|
||||||
|
HeapFree( GetProcessHeap(), 0, ptr );
|
||||||
|
SELECTOR_FreeBlock( sel );
|
||||||
|
memset( pArena, 0, sizeof(GLOBALARENA) );
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
ptr = newptr;
|
||||||
|
|
||||||
/* Reallocate the selector(s) */
|
/* Reallocate the selector(s) */
|
||||||
|
|
||||||
|
@ -350,9 +359,10 @@ HGLOBAL16 WINAPI GlobalReAlloc16(
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Fill the new arena block */
|
/* Fill the new arena block
|
||||||
|
As we may have used HEAP_REALLOC_IN_PLACE_ONLY, areas may overlap*/
|
||||||
|
|
||||||
if (pNewArena != pArena) memcpy( pNewArena, pArena, sizeof(GLOBALARENA) );
|
if (pNewArena != pArena) memmove( pNewArena, pArena, sizeof(GLOBALARENA) );
|
||||||
pNewArena->base = (DWORD)ptr;
|
pNewArena->base = (DWORD)ptr;
|
||||||
pNewArena->size = GetSelectorLimit16(sel) + 1;
|
pNewArena->size = GetSelectorLimit16(sel) + 1;
|
||||||
pNewArena->selCount = selcount;
|
pNewArena->selCount = selcount;
|
||||||
|
|
Loading…
Reference in New Issue