mirror of
https://github.com/reactos/reactos.git
synced 2025-08-02 20:17:19 +00:00
Always return 8-byte aligned blocks
svn path=/trunk/; revision=8226
This commit is contained in:
parent
a57cc3b82a
commit
d842500eb1
1 changed files with 5 additions and 20 deletions
|
@ -46,7 +46,6 @@ typedef struct tagARENA_INUSE
|
||||||
DWORD size; /* Block size; must be the first field */
|
DWORD size; /* Block size; must be the first field */
|
||||||
WORD threadId; /* Allocating thread id */
|
WORD threadId; /* Allocating thread id */
|
||||||
WORD magic; /* Magic number */
|
WORD magic; /* Magic number */
|
||||||
void *callerEIP; /* EIP of caller upon allocation */
|
|
||||||
} ARENA_INUSE;
|
} ARENA_INUSE;
|
||||||
|
|
||||||
typedef struct tagARENA_FREE
|
typedef struct tagARENA_FREE
|
||||||
|
@ -94,7 +93,6 @@ typedef struct tagSUBHEAP
|
||||||
struct tagSUBHEAP *next; /* Next sub-heap */
|
struct tagSUBHEAP *next; /* Next sub-heap */
|
||||||
struct tagHEAP *heap; /* Main heap structure */
|
struct tagHEAP *heap; /* Main heap structure */
|
||||||
DWORD magic; /* Magic number */
|
DWORD magic; /* Magic number */
|
||||||
WORD selector; /* Selector for HEAP_WINE_SEGPTR heaps */
|
|
||||||
} SUBHEAP, *PSUBHEAP;
|
} SUBHEAP, *PSUBHEAP;
|
||||||
|
|
||||||
#define SUBHEAP_MAGIC ((DWORD)('S' | ('U'<<8) | ('B'<<16) | ('H'<<24)))
|
#define SUBHEAP_MAGIC ((DWORD)('S' | ('U'<<8) | ('B'<<16) | ('H'<<24)))
|
||||||
|
@ -107,7 +105,7 @@ typedef struct tagHEAP
|
||||||
CRITICAL_SECTION critSection; /* Critical section for serialization */
|
CRITICAL_SECTION critSection; /* Critical section for serialization */
|
||||||
DWORD flags; /* Heap flags */
|
DWORD flags; /* Heap flags */
|
||||||
DWORD magic; /* Magic number */
|
DWORD magic; /* Magic number */
|
||||||
void *private; /* Private pointer for the user of the heap */
|
BYTE filler[4]; /* Make multiple of 8 bytes */
|
||||||
} HEAP, *PHEAP;
|
} HEAP, *PHEAP;
|
||||||
|
|
||||||
#define HEAP_MAGIC ((DWORD)('H' | ('E'<<8) | ('A'<<16) | ('P'<<24)))
|
#define HEAP_MAGIC ((DWORD)('H' | ('E'<<8) | ('A'<<16) | ('P'<<24)))
|
||||||
|
@ -119,14 +117,6 @@ typedef struct tagHEAP
|
||||||
|
|
||||||
static BOOL HEAP_IsRealArena( HANDLE heap, DWORD flags, LPCVOID block, BOOL quiet );
|
static BOOL HEAP_IsRealArena( HANDLE heap, DWORD flags, LPCVOID block, BOOL quiet );
|
||||||
|
|
||||||
#ifdef __GNUC__
|
|
||||||
#define GET_EIP() (__builtin_return_address(0))
|
|
||||||
#define SET_EIP(ptr) ((ARENA_INUSE*)(ptr) - 1)->callerEIP = GET_EIP()
|
|
||||||
#else
|
|
||||||
#define GET_EIP() 0
|
|
||||||
#define SET_EIP(ptr) /* nothing */
|
|
||||||
#endif /* __GNUC__ */
|
|
||||||
|
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* HEAP_Dump
|
* HEAP_Dump
|
||||||
|
@ -181,10 +171,9 @@ HEAP_Dump(PHEAP heap)
|
||||||
else if (*(DWORD *)ptr & ARENA_FLAG_PREV_FREE)
|
else if (*(DWORD *)ptr & ARENA_FLAG_PREV_FREE)
|
||||||
{
|
{
|
||||||
ARENA_INUSE *pArena = (ARENA_INUSE *)ptr;
|
ARENA_INUSE *pArena = (ARENA_INUSE *)ptr;
|
||||||
DPRINTF( "%08lx Used %08lx %04x back=%08lx EIP=%p\n",
|
DPRINTF( "%08lx Used %08lx %04x back=%08lx\n",
|
||||||
(DWORD)pArena, pArena->size & ARENA_SIZE_MASK,
|
(DWORD)pArena, pArena->size & ARENA_SIZE_MASK,
|
||||||
pArena->threadId, *((DWORD *)pArena - 1),
|
pArena->threadId, *((DWORD *)pArena - 1));
|
||||||
pArena->callerEIP );
|
|
||||||
ptr += sizeof(*pArena) + (pArena->size & ARENA_SIZE_MASK);
|
ptr += sizeof(*pArena) + (pArena->size & ARENA_SIZE_MASK);
|
||||||
arenaSize += sizeof(ARENA_INUSE);
|
arenaSize += sizeof(ARENA_INUSE);
|
||||||
usedSize += pArena->size & ARENA_SIZE_MASK;
|
usedSize += pArena->size & ARENA_SIZE_MASK;
|
||||||
|
@ -192,9 +181,9 @@ HEAP_Dump(PHEAP heap)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ARENA_INUSE *pArena = (ARENA_INUSE *)ptr;
|
ARENA_INUSE *pArena = (ARENA_INUSE *)ptr;
|
||||||
DPRINTF( "%08lx used %08lx %04x EIP=%p\n",
|
DPRINTF( "%08lx used %08lx %04x\n",
|
||||||
(DWORD)pArena, pArena->size & ARENA_SIZE_MASK,
|
(DWORD)pArena, pArena->size & ARENA_SIZE_MASK,
|
||||||
pArena->threadId, pArena->callerEIP );
|
pArena->threadId);
|
||||||
ptr += sizeof(*pArena) + (pArena->size & ARENA_SIZE_MASK);
|
ptr += sizeof(*pArena) + (pArena->size & ARENA_SIZE_MASK);
|
||||||
arenaSize += sizeof(ARENA_INUSE);
|
arenaSize += sizeof(ARENA_INUSE);
|
||||||
usedSize += pArena->size & ARENA_SIZE_MASK;
|
usedSize += pArena->size & ARENA_SIZE_MASK;
|
||||||
|
@ -524,7 +513,6 @@ static BOOL HEAP_InitSubHeap( HEAP *heap, LPVOID address, DWORD flags,
|
||||||
DWORD commitSize, DWORD totalSize )
|
DWORD commitSize, DWORD totalSize )
|
||||||
{
|
{
|
||||||
SUBHEAP *subheap = (SUBHEAP *)address;
|
SUBHEAP *subheap = (SUBHEAP *)address;
|
||||||
WORD selector = 0;
|
|
||||||
FREE_LIST_ENTRY *pEntry;
|
FREE_LIST_ENTRY *pEntry;
|
||||||
int i;
|
int i;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
@ -550,7 +538,6 @@ static BOOL HEAP_InitSubHeap( HEAP *heap, LPVOID address, DWORD flags,
|
||||||
|
|
||||||
subheap = (SUBHEAP *)address;
|
subheap = (SUBHEAP *)address;
|
||||||
subheap->heap = heap;
|
subheap->heap = heap;
|
||||||
subheap->selector = selector;
|
|
||||||
subheap->size = totalSize;
|
subheap->size = totalSize;
|
||||||
subheap->commitSize = commitSize;
|
subheap->commitSize = commitSize;
|
||||||
subheap->magic = SUBHEAP_MAGIC;
|
subheap->magic = SUBHEAP_MAGIC;
|
||||||
|
@ -1172,7 +1159,6 @@ RtlAllocateHeap(HANDLE heap, /* [in] Handle of private heap block */
|
||||||
pInUse = (ARENA_INUSE *)pArena;
|
pInUse = (ARENA_INUSE *)pArena;
|
||||||
pInUse->size = (pInUse->size & ~ARENA_FLAG_FREE)
|
pInUse->size = (pInUse->size & ~ARENA_FLAG_FREE)
|
||||||
+ sizeof(ARENA_FREE) - sizeof(ARENA_INUSE);
|
+ sizeof(ARENA_FREE) - sizeof(ARENA_INUSE);
|
||||||
pInUse->callerEIP = GET_EIP();
|
|
||||||
pInUse->threadId = (DWORD)NtCurrentTeb()->Cid.UniqueThread;
|
pInUse->threadId = (DWORD)NtCurrentTeb()->Cid.UniqueThread;
|
||||||
pInUse->magic = ARENA_INUSE_MAGIC;
|
pInUse->magic = ARENA_INUSE_MAGIC;
|
||||||
|
|
||||||
|
@ -1363,7 +1349,6 @@ LPVOID STDCALL RtlReAllocateHeap(
|
||||||
|
|
||||||
/* Return the new arena */
|
/* Return the new arena */
|
||||||
|
|
||||||
pArena->callerEIP = GET_EIP();
|
|
||||||
if (!(flags & HEAP_NO_SERIALIZE)) RtlLeaveCriticalSection( &heapPtr->critSection );
|
if (!(flags & HEAP_NO_SERIALIZE)) RtlLeaveCriticalSection( &heapPtr->critSection );
|
||||||
|
|
||||||
TRACE("(%08x,%08lx,%08lx,%08lx): returning %08lx\n",
|
TRACE("(%08x,%08lx,%08lx,%08lx): returning %08lx\n",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue