Commit 424e38f3 authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

kernelbase: Fix indentation of LocalReAlloc.

parent fc12f812
...@@ -791,98 +791,97 @@ LPVOID WINAPI DECLSPEC_HOTPATCH LocalLock( HLOCAL hmem ) ...@@ -791,98 +791,97 @@ LPVOID WINAPI DECLSPEC_HOTPATCH LocalLock( HLOCAL hmem )
*/ */
HLOCAL WINAPI DECLSPEC_HOTPATCH LocalReAlloc( HLOCAL hmem, SIZE_T size, UINT flags ) HLOCAL WINAPI DECLSPEC_HOTPATCH LocalReAlloc( HLOCAL hmem, SIZE_T size, UINT flags )
{ {
struct local_header *header; struct local_header *header;
void *ptr; void *ptr;
HLOCAL ret = 0; HLOCAL ret = 0;
DWORD heap_flags = (flags & LMEM_ZEROINIT) ? HEAP_ZERO_MEMORY : 0; DWORD heap_flags = (flags & LMEM_ZEROINIT) ? HEAP_ZERO_MEMORY : 0;
RtlLockHeap( GetProcessHeap() ); RtlLockHeap( GetProcessHeap() );
if (flags & LMEM_MODIFY) /* modify flags */ if (flags & LMEM_MODIFY) /* modify flags */
{ {
if (is_pointer( hmem ) && (flags & LMEM_MOVEABLE)) if (is_pointer( hmem ) && (flags & LMEM_MOVEABLE))
{ {
/* make a fixed block moveable /* make a fixed block moveable
* actually only NT is able to do this. But it's soo simple * actually only NT is able to do this. But it's soo simple
*/ */
if (hmem == 0) if (hmem == 0)
{ {
WARN( "null handle\n"); WARN( "null handle\n" );
SetLastError( ERROR_NOACCESS ); SetLastError( ERROR_NOACCESS );
} }
else else
{ {
size = RtlSizeHeap( GetProcessHeap(), 0, hmem ); size = RtlSizeHeap( GetProcessHeap(), 0, hmem );
ret = LocalAlloc( flags, size ); ret = LocalAlloc( flags, size );
ptr = LocalLock( ret ); ptr = LocalLock( ret );
memcpy( ptr, hmem, size ); memcpy( ptr, hmem, size );
LocalUnlock( ret ); LocalUnlock( ret );
LocalFree( hmem ); LocalFree( hmem );
} }
} }
else if (!is_pointer( hmem ) && (flags & LMEM_DISCARDABLE)) else if (!is_pointer( hmem ) && (flags & LMEM_DISCARDABLE))
{ {
/* change the flags to make our block "discardable" */ /* change the flags to make our block "discardable" */
header = get_header( hmem ); header = get_header( hmem );
header->flags |= LMEM_DISCARDABLE >> 8; header->flags |= LMEM_DISCARDABLE >> 8;
ret = hmem; ret = hmem;
} }
else SetLastError( ERROR_INVALID_PARAMETER ); else SetLastError( ERROR_INVALID_PARAMETER );
} }
else else
{ {
if (is_pointer( hmem )) if (is_pointer( hmem ))
{ {
/* reallocate fixed memory */ /* reallocate fixed memory */
if (!(flags & LMEM_MOVEABLE)) heap_flags |= HEAP_REALLOC_IN_PLACE_ONLY; if (!(flags & LMEM_MOVEABLE)) heap_flags |= HEAP_REALLOC_IN_PLACE_ONLY;
ret = HeapReAlloc( GetProcessHeap(), heap_flags, hmem, size ); ret = HeapReAlloc( GetProcessHeap(), heap_flags, hmem, size );
} }
else else
{ {
/* reallocate a moveable block */ /* reallocate a moveable block */
header = get_header( hmem ); header = get_header( hmem );
if (size != 0) if (size != 0)
{ {
if (size <= INT_MAX - HLOCAL_STORAGE) if (size <= INT_MAX - HLOCAL_STORAGE)
{ {
if (header->ptr) if (header->ptr)
{ {
if ((ptr = HeapReAlloc( GetProcessHeap(), heap_flags, if ((ptr = HeapReAlloc( GetProcessHeap(), heap_flags, (char *)header->ptr - HLOCAL_STORAGE,
(char *)header->ptr - HLOCAL_STORAGE, size + HLOCAL_STORAGE )))
size + HLOCAL_STORAGE ))) {
{ header->ptr = (char *)ptr + HLOCAL_STORAGE;
header->ptr = (char *)ptr + HLOCAL_STORAGE; ret = hmem;
ret = hmem; }
} }
} else
else {
{ if ((ptr = HeapAlloc( GetProcessHeap(), heap_flags, size + HLOCAL_STORAGE )))
if ((ptr = HeapAlloc( GetProcessHeap(), heap_flags, size + HLOCAL_STORAGE ))) {
{ *(HLOCAL *)ptr = hmem;
*(HLOCAL *)ptr = hmem; header->ptr = (char *)ptr + HLOCAL_STORAGE;
header->ptr = (char *)ptr + HLOCAL_STORAGE; ret = hmem;
ret = hmem; }
} }
} }
} else SetLastError( ERROR_OUTOFMEMORY );
else SetLastError( ERROR_OUTOFMEMORY ); }
} else
else {
{ if (header->lock == 0)
if (header->lock == 0) {
{ if (header->ptr)
if (header->ptr) {
{ HeapFree( GetProcessHeap(), 0, (char *)header->ptr - HLOCAL_STORAGE );
HeapFree( GetProcessHeap(), 0, (char *)header->ptr - HLOCAL_STORAGE ); header->ptr = NULL;
header->ptr = NULL; }
} ret = hmem;
ret = hmem; }
} else WARN( "not freeing memory associated with locked handle\n" );
else WARN( "not freeing memory associated with locked handle\n" ); }
} }
} }
} RtlUnlockHeap( GetProcessHeap() );
RtlUnlockHeap( GetProcessHeap() ); return ret;
return ret;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment