- Removed R_EXTRA_STACK because R_EXTRA_STACK and R_STACK must have the same size.

- Initialized an allocated block completely before release the lock.

svn path=/trunk/; revision=16714
This commit is contained in:
Hartmut Birr 2005-07-24 17:48:52 +00:00
parent 8c34b25c71
commit 0dea0a5836
2 changed files with 15 additions and 11 deletions

View file

@ -30,7 +30,6 @@
#define R_PRINT_ADDRESS(addr) KeRosPrintAddress(addr) #define R_PRINT_ADDRESS(addr) KeRosPrintAddress(addr)
#define R_PANIC() KeBugCheck(0) #define R_PANIC() KeBugCheck(0)
#define R_DEBUG DbgPrint #define R_DEBUG DbgPrint
#define R_EXTRA_STACK_UP 2
#define R_GET_STACK_FRAMES(ptr,cnt) KeRosGetStackFrames(ptr,cnt) #define R_GET_STACK_FRAMES(ptr,cnt) KeRosGetStackFrames(ptr,cnt)
#include "rpoolmgr.h" #include "rpoolmgr.h"

View file

@ -50,7 +50,13 @@ typedef unsigned long rulong;
#ifndef R_STACK #ifndef R_STACK
// R_STACK is the number of stack entries to store in blocks for debug purposes // R_STACK is the number of stack entries to store in blocks for debug purposes
#define R_STACK 3 #define R_STACK 6
#else // R_STACK
#if R_STACK > 0 && R_STACK < 6
/* Increase the frame depth to get a reasonable back trace */
#undef R_STACK
#define R_STACK 6
#endif // R_STACK > 0 && R_STACK < 6
#endif//R_STACK #endif//R_STACK
#ifndef R_TAG #ifndef R_TAG
@ -257,10 +263,10 @@ static void
RFreeFillStack ( PR_FREE free ) RFreeFillStack ( PR_FREE free )
{ {
int i; int i;
ULONG stack[R_EXTRA_STACK_UP+3]; // need to skip 3 known levels of stack trace ULONG stack[R_STACK+3]; // need to skip 3 known levels of stack trace
memset ( stack, 0xCD, sizeof(stack) ); memset ( stack, 0xCD, sizeof(stack) );
R_GET_STACK_FRAMES ( stack, R_EXTRA_STACK_UP+3 ); R_GET_STACK_FRAMES ( stack, R_STACK+3 );
for ( i = 0; i < R_EXTRA_STACK_UP; i++ ) for ( i = 0; i < R_STACK; i++ )
free->LastOwnerStack[i] = stack[i+3]; free->LastOwnerStack[i] = stack[i+3];
} }
@ -268,10 +274,10 @@ static void
RUsedFillStack ( PR_USED used ) RUsedFillStack ( PR_USED used )
{ {
int i; int i;
ULONG stack[R_EXTRA_STACK_UP+2]; // need to skip 2 known levels of stack trace ULONG stack[R_STACK+2]; // need to skip 2 known levels of stack trace
memset ( stack, 0xCD, sizeof(stack) ); memset ( stack, 0xCD, sizeof(stack) );
R_GET_STACK_FRAMES ( stack, R_EXTRA_STACK_UP+2 ); R_GET_STACK_FRAMES ( stack, R_STACK+2 );
for ( i = 0; i < R_EXTRA_STACK_UP; i++ ) for ( i = 0; i < R_STACK; i++ )
used->LastOwnerStack[i] = stack[i+2]; used->LastOwnerStack[i] = stack[i+2];
} }
#endif #endif
@ -719,9 +725,9 @@ RPoolAlloc ( PR_POOL pool, rulong NumberOfBytes, rulong Tag, rulong align )
{ {
if ( (NewBlock = RQueRemove ( &pool->Que[que][align] )) ) if ( (NewBlock = RQueRemove ( &pool->Que[que][align] )) )
{ {
R_RELEASE_MUTEX(pool);
RiUsedInit ( NewBlock, Tag ); RiUsedInit ( NewBlock, Tag );
RiUsedInitRedZone ( NewBlock, NumberOfBytes ); RiUsedInitRedZone ( NewBlock, NumberOfBytes );
R_RELEASE_MUTEX(pool);
return RHdrToBody(NewBlock); return RHdrToBody(NewBlock);
} }
queBytes = 16 << que; queBytes = 16 << que;
@ -865,11 +871,10 @@ try_again:
NewBlock = (PR_USED)BestBlock; NewBlock = (PR_USED)BestBlock;
RiUsedInit ( NewBlock, Tag ); RiUsedInit ( NewBlock, Tag );
R_RELEASE_MUTEX(pool);
/* RtlZeroMemory(RHdrToBody(NewBlock), NumberOfBytes);*/ /* RtlZeroMemory(RHdrToBody(NewBlock), NumberOfBytes);*/
RiUsedInitRedZone ( NewBlock, NumberOfBytes ); RiUsedInitRedZone ( NewBlock, NumberOfBytes );
R_RELEASE_MUTEX(pool);
return RHdrToBody(NewBlock); return RHdrToBody(NewBlock);
} }