mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-10 23:02:08 +00:00
- fixed FMemArena to always return 16 byte aligned pointers.
Unfortunately this turned out harder than expected because of FSharedStringArena making some strong assumptions about the underlying implementation.
This commit is contained in:
parent
af3d17af8b
commit
2f6dc46f14
2 changed files with 10 additions and 3 deletions
|
@ -46,6 +46,7 @@ struct FMemArena::Block
|
|||
Block *NextBlock;
|
||||
void *Limit; // End of this block
|
||||
void *Avail; // Start of free space in this block
|
||||
void *alignme; // align to 16 bytes.
|
||||
|
||||
void Reset();
|
||||
void *Alloc(size_t size);
|
||||
|
@ -94,7 +95,7 @@ FMemArena::~FMemArena()
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
void *FMemArena::Alloc(size_t size)
|
||||
void *FMemArena::iAlloc(size_t size)
|
||||
{
|
||||
Block *block;
|
||||
|
||||
|
@ -110,6 +111,11 @@ void *FMemArena::Alloc(size_t size)
|
|||
return block->Alloc(size);
|
||||
}
|
||||
|
||||
void *FMemArena::Alloc(size_t size)
|
||||
{
|
||||
return iAlloc((size + 15) & ~15);
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// FMemArena :: FreeAll
|
||||
|
@ -316,7 +322,7 @@ FString *FSharedStringArena::Alloc(const FString &source)
|
|||
strnode = FindString(source, source.Len(), hash);
|
||||
if (strnode == NULL)
|
||||
{
|
||||
strnode = (Node *)FMemArena::Alloc(sizeof(Node));
|
||||
strnode = (Node *)iAlloc(sizeof(Node));
|
||||
::new(&strnode->String) FString(source);
|
||||
strnode->Hash = hash;
|
||||
hash %= countof(Buckets);
|
||||
|
@ -351,7 +357,7 @@ FString *FSharedStringArena::Alloc(const char *source, size_t strlen)
|
|||
strnode = FindString(source, strlen, hash);
|
||||
if (strnode == NULL)
|
||||
{
|
||||
strnode = (Node *)FMemArena::Alloc(sizeof(Node));
|
||||
strnode = (Node *)iAlloc(sizeof(Node));
|
||||
::new(&strnode->String) FString(source, strlen);
|
||||
strnode->Hash = hash;
|
||||
hash %= countof(Buckets);
|
||||
|
|
|
@ -54,6 +54,7 @@ protected:
|
|||
|
||||
Block *AddBlock(size_t size);
|
||||
void FreeBlockChain(Block *&top);
|
||||
void *iAlloc(size_t size);
|
||||
|
||||
Block *TopBlock;
|
||||
Block *FreeBlocks;
|
||||
|
|
Loading…
Reference in a new issue