Use PRSize to fix alignment problems on some platforms, although it doesn't guarantee a fix for all platforms. Patch from <scooter@gene.com>. b=160535 r=dbaron sr=alecf

This commit is contained in:
dbaron%fas.harvard.edu 2002-08-14 12:47:18 +00:00
Родитель a48a2a2e82
Коммит 6a9d9c376c
2 изменённых файлов: 8 добавлений и 8 удалений

Просмотреть файл

@ -159,7 +159,7 @@ nsRecyclingAllocator::~nsRecyclingAllocator()
// Allocation and free routines
void*
nsRecyclingAllocator::Malloc(PRUint32 bytes, PRBool zeroit)
nsRecyclingAllocator::Malloc(PRSize bytes, PRBool zeroit)
{
// Mark that we are using. This will prevent any
// timer based release of unused memory.
@ -173,7 +173,7 @@ nsRecyclingAllocator::Malloc(PRUint32 bytes, PRBool zeroit)
// We need to do an allocation
// Add 4 bytes to what we allocate to hold the bucket index
PRUint32 allocBytes = bytes + NS_ALLOCATOR_OVERHEAD_BYTES;
PRSize allocBytes = bytes + NS_ALLOCATOR_OVERHEAD_BYTES;
// We dont have that memory already. Allocate.
Block *ptr = (Block *) (zeroit ? calloc(1, allocBytes) : malloc(allocBytes));
@ -275,7 +275,7 @@ nsRecyclingAllocator::FreeUnusedBuckets()
}
nsRecyclingAllocator::Block*
nsRecyclingAllocator::FindFreeBlock(PRUint32 bytes)
nsRecyclingAllocator::FindFreeBlock(PRSize bytes)
{
// We dont enter lock for this check. This is intentional.
// Here is my logic: we are checking if (!mFreeList). Doing this check

Просмотреть файл

@ -78,7 +78,7 @@ class nsIMemory;
class NS_COM nsRecyclingAllocator {
protected:
struct Block {
PRUint32 bytes;
PRSize bytes;
};
// Make |BlockStoreNode| a |friend| so it can access |Block|.
@ -87,7 +87,7 @@ class NS_COM nsRecyclingAllocator {
struct BlockStoreNode {
BlockStoreNode() : bytes(0), block(nsnull), next(nsnull) {};
PRUint32 bytes;
PRSize bytes;
Block *block;
BlockStoreNode *next;
};
@ -150,10 +150,10 @@ class NS_COM nsRecyclingAllocator {
nsresult Init(PRUint32 nbucket, PRUint32 recycleAfter, const char *id);
// Allocation and free routines
void* Malloc(PRUint32 size, PRBool zeroit = PR_FALSE);
void* Malloc(PRSize size, PRBool zeroit = PR_FALSE);
void Free(void *ptr);
void* Calloc(PRUint32 items, PRUint32 size)
void* Calloc(PRUint32 items, PRSize size)
{
return Malloc(items * size, PR_TRUE);
}
@ -168,7 +168,7 @@ class NS_COM nsRecyclingAllocator {
// Freelist management
// FindFreeBlock: return a free block that can hold bytes (best fit)
Block* FindFreeBlock(PRUint32 bytes);
Block* FindFreeBlock(PRSize bytes);
// AddToFreeList: adds block into our freelist for future retrieval.
// Returns PR_TRUE is addition was successful. PR_FALSE otherewise.
PRBool AddToFreeList(Block* block);