Simplify DqnMemAPI and DqnMemStack api
This commit is contained in:
parent
d01e2fbc2f
commit
15dad9d8d2
@ -1350,7 +1350,7 @@ void DqnMemStack_Test()
|
||||
for (u32 i = 0; i < sizeA; i++)
|
||||
ptrA[i] = 1;
|
||||
|
||||
DqnMemStackBlock *blockA = stack.block;
|
||||
DqnMemStack::Block *blockA = stack.block;
|
||||
// Alocate B
|
||||
size_t sizeB = (size_t)(allocSize * 2.0f);
|
||||
void *resultB = stack.Push(sizeB);
|
||||
@ -1372,7 +1372,7 @@ void DqnMemStack_Test()
|
||||
DQN_ASSERT(stack.block != blockA);
|
||||
DQN_ASSERT(stack.byteAlign == ALIGNMENT);
|
||||
DQN_ASSERT(blockA->used == sizeA);
|
||||
DqnMemStackBlock *blockB = stack.block;
|
||||
DqnMemStack::Block *blockB = stack.block;
|
||||
|
||||
// Check temp regions work
|
||||
DqnMemStackTempRegion tempBuffer = stack.TempRegionBegin();
|
||||
@ -1443,7 +1443,7 @@ void DqnMemStack_Test()
|
||||
const u32 ALIGNMENT = 4;
|
||||
stack.InitWithFixedMem(memory, DQN_ARRAY_COUNT(memory), ALIGNMENT);
|
||||
DQN_ASSERT(stack.block && stack.block->memory);
|
||||
DQN_ASSERT(stack.block->size == DQN_ARRAY_COUNT(memory) - sizeof(DqnMemStackBlock));
|
||||
DQN_ASSERT(stack.block->size == DQN_ARRAY_COUNT(memory) - sizeof(DqnMemStack::Block));
|
||||
DQN_ASSERT(stack.block->used == 0);
|
||||
DQN_ASSERT(stack.byteAlign == ALIGNMENT);
|
||||
|
||||
@ -1454,7 +1454,7 @@ void DqnMemStack_Test()
|
||||
stack.Free();
|
||||
stack.FreeLastBlock();
|
||||
DQN_ASSERT(stack.block && stack.block->memory);
|
||||
DQN_ASSERT(stack.block->size == DQN_ARRAY_COUNT(memory) - sizeof(DqnMemStackBlock));
|
||||
DQN_ASSERT(stack.block->size == DQN_ARRAY_COUNT(memory) - sizeof(DqnMemStack::Block));
|
||||
DQN_ASSERT(stack.block->used == 0);
|
||||
DQN_ASSERT(stack.byteAlign == ALIGNMENT);
|
||||
LogSuccess("DqnMemStack(): Test stack with fixed memory does not allocate more");
|
||||
@ -1482,7 +1482,9 @@ void DqnMemStack_Test()
|
||||
// Freeing should work
|
||||
stack.Free();
|
||||
DQN_ASSERT(!stack.block);
|
||||
LogSuccess("DqnMemStack(): Test stack with fixed size allocates one from platform but does not grow further");
|
||||
LogSuccess(
|
||||
"DqnMemStack(): Test stack with fixed size allocates one from platform but does not "
|
||||
"grow further");
|
||||
}
|
||||
|
||||
// Test freeing/clear block and alignment
|
||||
@ -1493,7 +1495,7 @@ void DqnMemStack_Test()
|
||||
const u32 ALIGNMENT = 16;
|
||||
stack.Init(firstBlockSize, false, ALIGNMENT);
|
||||
|
||||
DqnMemStackBlock *firstBlock = stack.block;
|
||||
DqnMemStack::Block *firstBlock = stack.block;
|
||||
u8 *first = NULL;
|
||||
{
|
||||
u32 allocate40Bytes = 40;
|
||||
@ -1548,19 +1550,19 @@ void DqnMemStack_Test()
|
||||
// Force it to allocate three new blocks and write out data to each
|
||||
size_t secondBlockSize = DQN_KILOBYTE(2);
|
||||
u8 *second = (u8 *)stack.Push(secondBlockSize);
|
||||
DqnMemStackBlock *secondBlock = stack.block;
|
||||
DqnMemStack::Block *secondBlock = stack.block;
|
||||
for (u32 i = 0; i < secondBlockSize; i++)
|
||||
second[i] = 'd';
|
||||
|
||||
size_t thirdBlockSize = DQN_KILOBYTE(3);
|
||||
u8 *third = (u8 *)stack.Push(thirdBlockSize);
|
||||
DqnMemStackBlock *thirdBlock = stack.block;
|
||||
DqnMemStack::Block *thirdBlock = stack.block;
|
||||
for (u32 i = 0; i < thirdBlockSize; i++)
|
||||
third[i] = 'e';
|
||||
|
||||
size_t fourthBlockSize = DQN_KILOBYTE(4);
|
||||
u8 *fourth = (u8 *)stack.Push(fourthBlockSize);
|
||||
DqnMemStackBlock *fourthBlock = stack.block;
|
||||
DqnMemStack::Block *fourthBlock = stack.block;
|
||||
for (u32 i = 0; i < fourthBlockSize; i++)
|
||||
fourth[i] = 'f';
|
||||
|
||||
@ -1574,7 +1576,7 @@ void DqnMemStack_Test()
|
||||
// NOTE: Making blocks manually is not really recommended ..
|
||||
// Try and free an invalid block by mocking a fake block
|
||||
u8 fakeBlockMem[DQN_KILOBYTE(3)] = {};
|
||||
DqnMemStackBlock fakeBlock = {};
|
||||
DqnMemStack::Block fakeBlock = {};
|
||||
fakeBlock.memory = fakeBlockMem;
|
||||
fakeBlock.size = DQN_ARRAY_COUNT(fakeBlockMem);
|
||||
fakeBlock.used = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user