Change true/false to yes/no for enums
This commit is contained in:
parent
5d77aa3f4a
commit
cf648c2281
@ -2,7 +2,7 @@ void DqnFixedString_Test()
|
|||||||
{
|
{
|
||||||
LOG_HEADER();
|
LOG_HEADER();
|
||||||
{
|
{
|
||||||
DqnFixedString<512> str = DQN_SLICE_NAME("hello world");
|
DqnFixedString<512> str = DQN_SLICE("hello world");
|
||||||
DQN_ASSERT(DqnStr_Cmp(str.str, "hello world") == 0);
|
DQN_ASSERT(DqnStr_Cmp(str.str, "hello world") == 0);
|
||||||
|
|
||||||
Log(Status::Ok, "Copy constructor DqnSlice<char>");
|
Log(Status::Ok, "Copy constructor DqnSlice<char>");
|
||||||
@ -10,11 +10,11 @@ void DqnFixedString_Test()
|
|||||||
|
|
||||||
{
|
{
|
||||||
DqnFixedString<512> zero = {};
|
DqnFixedString<512> zero = {};
|
||||||
DqnFixedString<512> str = DQN_SLICE_NAME("hello world");
|
DqnFixedString<512> str = DQN_SLICE("hello world");
|
||||||
str = zero;
|
str = zero;
|
||||||
DQN_ASSERT(str.len == 0 && str.str[0] == 0);
|
DQN_ASSERT(str.len == 0 && str.str[0] == 0);
|
||||||
|
|
||||||
DqnSlice<char const> helloSlice = DQN_SLICE_NAME("hello");
|
DqnSlice<char const> helloSlice = DQN_SLICE("hello");
|
||||||
str = helloSlice;
|
str = helloSlice;
|
||||||
DQN_ASSERT(DqnStr_Cmp(str.str, "hello") == 0);
|
DQN_ASSERT(DqnStr_Cmp(str.str, "hello") == 0);
|
||||||
|
|
||||||
@ -22,7 +22,7 @@ void DqnFixedString_Test()
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
DqnFixedString<512> str = DQN_SLICE_NAME("hello world");
|
DqnFixedString<512> str = DQN_SLICE("hello world");
|
||||||
DQN_ASSERT(str.Sprintf("hello %s", "sailor"));
|
DQN_ASSERT(str.Sprintf("hello %s", "sailor"));
|
||||||
DQN_ASSERT(DqnStr_Cmp(str.str, "hello sailor") == 0);
|
DQN_ASSERT(DqnStr_Cmp(str.str, "hello sailor") == 0);
|
||||||
|
|
||||||
@ -31,14 +31,14 @@ void DqnFixedString_Test()
|
|||||||
|
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
DqnFixedString<512> str = DQN_SLICE_NAME("hello world");
|
DqnFixedString<512> str = DQN_SLICE("hello world");
|
||||||
DQN_ASSERT(str.Sprintf("hello %s", "sailor"));
|
DQN_ASSERT(str.Sprintf("hello %s", "sailor"));
|
||||||
str += DQN_SLICE_NAME(".end");
|
str += DQN_SLICE(".end");
|
||||||
DQN_ASSERT(DqnStr_Cmp(str.str, "hello sailor.end") == 0);
|
DQN_ASSERT(DqnStr_Cmp(str.str, "hello sailor.end") == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
DqnFixedString<512> str = DQN_SLICE_NAME("hello world");
|
DqnFixedString<512> str = DQN_SLICE("hello world");
|
||||||
DQN_ASSERT(str.Sprintf("hello %s", "sailor"));
|
DQN_ASSERT(str.Sprintf("hello %s", "sailor"));
|
||||||
DQN_ASSERT(str.SprintfAppend(" %d, %d", 100, 200));
|
DQN_ASSERT(str.SprintfAppend(" %d, %d", 100, 200));
|
||||||
DQN_ASSERT(DqnStr_Cmp(str.str, "hello sailor 100, 200") == 0);
|
DQN_ASSERT(DqnStr_Cmp(str.str, "hello sailor 100, 200") == 0);
|
||||||
@ -58,9 +58,9 @@ void DqnFixedString_Test()
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
DqnFixedString<512> str = DQN_SLICE_NAME("hello world");
|
DqnFixedString<512> str = DQN_SLICE("hello world");
|
||||||
DQN_ASSERT(str.Sprintf("hello %s", "sailor"));
|
DQN_ASSERT(str.Sprintf("hello %s", "sailor"));
|
||||||
str = str + " end" + DQN_SLICE_NAME(" of");
|
str = str + " end" + DQN_SLICE(" of");
|
||||||
DQN_ASSERT(DqnStr_Cmp(str.str, "hello sailor end of") == 0);
|
DQN_ASSERT(DqnStr_Cmp(str.str, "hello sailor end of") == 0);
|
||||||
|
|
||||||
Log(Status::Ok, "Operator +");
|
Log(Status::Ok, "Operator +");
|
||||||
|
@ -1608,7 +1608,7 @@ void DqnArray_Test()
|
|||||||
|
|
||||||
if (1)
|
if (1)
|
||||||
{
|
{
|
||||||
DqnMemStack stack = {}; stack.Init(DQN_MEGABYTE(1), Dqn::ZeroClear::True, DqnMemStack::Flag::BoundsGuard);
|
DqnMemStack stack = {}; stack.Init(DQN_MEGABYTE(1), Dqn::ZeroClear::Yes, DqnMemStack::Flag::BoundsGuard);
|
||||||
|
|
||||||
if (1)
|
if (1)
|
||||||
{
|
{
|
||||||
@ -1759,7 +1759,7 @@ void DqnFile_Test()
|
|||||||
}
|
}
|
||||||
|
|
||||||
DqnMemStack memStack = {};
|
DqnMemStack memStack = {};
|
||||||
DQN_ASSERT(memStack.Init(DQN_MEGABYTE(1), Dqn::ZeroClear::True, DqnMemStack::Flag::BoundsGuard));
|
DQN_ASSERT(memStack.Init(DQN_MEGABYTE(1), Dqn::ZeroClear::Yes, DqnMemStack::Flag::BoundsGuard));
|
||||||
// Read data back in
|
// Read data back in
|
||||||
for (u32 i = 0; i < DQN_ARRAY_COUNT(fileNames); i++)
|
for (u32 i = 0; i < DQN_ARRAY_COUNT(fileNames); i++)
|
||||||
{
|
{
|
||||||
@ -1895,7 +1895,7 @@ FILE_SCOPE void DqnJobQueue_Test()
|
|||||||
globalDebugCounter = 0;
|
globalDebugCounter = 0;
|
||||||
|
|
||||||
DqnMemStack memStack = {};
|
DqnMemStack memStack = {};
|
||||||
DQN_ASSERT(memStack.Init(DQN_MEGABYTE(1), Dqn::ZeroClear::True, DqnMemStack::Flag::BoundsGuard));
|
DQN_ASSERT(memStack.Init(DQN_MEGABYTE(1), Dqn::ZeroClear::Yes, DqnMemStack::Flag::BoundsGuard));
|
||||||
|
|
||||||
u32 numThreads, numCores;
|
u32 numThreads, numCores;
|
||||||
DqnPlatform_GetNumThreadsAndCores(&numCores, &numThreads);
|
DqnPlatform_GetNumThreadsAndCores(&numCores, &numThreads);
|
||||||
@ -1940,7 +1940,7 @@ void DqnQuickSort_Test()
|
|||||||
if (1)
|
if (1)
|
||||||
{
|
{
|
||||||
DqnMemStack stack = {};
|
DqnMemStack stack = {};
|
||||||
DQN_ASSERT(stack.Init(DQN_KILOBYTE(1), Dqn::ZeroClear::True, DqnMemStack::Flag::BoundsGuard));
|
DQN_ASSERT(stack.Init(DQN_KILOBYTE(1), Dqn::ZeroClear::Yes, DqnMemStack::Flag::BoundsGuard));
|
||||||
|
|
||||||
// Create array of ints
|
// Create array of ints
|
||||||
u32 numInts = 1000000;
|
u32 numInts = 1000000;
|
||||||
@ -2336,7 +2336,7 @@ FILE_SCOPE void DqnMemStack_Test()
|
|||||||
if (1)
|
if (1)
|
||||||
{
|
{
|
||||||
DqnMemStack stack = {};
|
DqnMemStack stack = {};
|
||||||
DQN_ASSERT(stack.Init(DQN_MEGABYTE(1), Dqn::ZeroClear::True, DqnMemStack::Flag::BoundsGuard));
|
DQN_ASSERT(stack.Init(DQN_MEGABYTE(1), Dqn::ZeroClear::Yes, DqnMemStack::Flag::BoundsGuard));
|
||||||
|
|
||||||
i32 const ALIGN64 = 64;
|
i32 const ALIGN64 = 64;
|
||||||
i32 const ALIGN16 = 16;
|
i32 const ALIGN16 = 16;
|
||||||
@ -2374,7 +2374,7 @@ FILE_SCOPE void DqnMemStack_Test()
|
|||||||
if (1)
|
if (1)
|
||||||
{
|
{
|
||||||
DqnMemStack stack = {};
|
DqnMemStack stack = {};
|
||||||
DQN_ASSERT(stack.Init(DQN_MEGABYTE(1), Dqn::ZeroClear::True, DqnMemStack::Flag::NonExpandable));
|
DQN_ASSERT(stack.Init(DQN_MEGABYTE(1), Dqn::ZeroClear::Yes, DqnMemStack::Flag::NonExpandable));
|
||||||
auto *result1 = stack.Push(DQN_MEGABYTE(2));
|
auto *result1 = stack.Push(DQN_MEGABYTE(2));
|
||||||
DQN_ASSERT(result1 == nullptr);
|
DQN_ASSERT(result1 == nullptr);
|
||||||
DQN_ASSERT(stack.block->prevBlock == nullptr);
|
DQN_ASSERT(stack.block->prevBlock == nullptr);
|
||||||
@ -2387,7 +2387,7 @@ FILE_SCOPE void DqnMemStack_Test()
|
|||||||
if (1)
|
if (1)
|
||||||
{
|
{
|
||||||
DqnMemStack stack = {};
|
DqnMemStack stack = {};
|
||||||
DQN_ASSERT(stack.Init(DQN_MEGABYTE(1), Dqn::ZeroClear::True));
|
DQN_ASSERT(stack.Init(DQN_MEGABYTE(1), Dqn::ZeroClear::Yes));
|
||||||
DQN_ASSERT(stack.metadata.GetBoundsGuardSize() == 0);
|
DQN_ASSERT(stack.metadata.GetBoundsGuardSize() == 0);
|
||||||
|
|
||||||
auto *oldBlock = stack.block;
|
auto *oldBlock = stack.block;
|
||||||
@ -2413,7 +2413,7 @@ FILE_SCOPE void DqnMemStack_Test()
|
|||||||
if (1)
|
if (1)
|
||||||
{
|
{
|
||||||
DqnMemStack stack = {};
|
DqnMemStack stack = {};
|
||||||
DQN_ASSERT(stack.Init(DQN_MEGABYTE(1), Dqn::ZeroClear::True, DqnMemStack::Flag::BoundsGuard));
|
DQN_ASSERT(stack.Init(DQN_MEGABYTE(1), Dqn::ZeroClear::Yes, DqnMemStack::Flag::BoundsGuard));
|
||||||
|
|
||||||
DqnMemStack::Block *blockToReturnTo = stack.block;
|
DqnMemStack::Block *blockToReturnTo = stack.block;
|
||||||
auto headBefore = blockToReturnTo->head;
|
auto headBefore = blockToReturnTo->head;
|
||||||
@ -2447,7 +2447,7 @@ FILE_SCOPE void DqnMemStack_Test()
|
|||||||
if (1)
|
if (1)
|
||||||
{
|
{
|
||||||
DqnMemStack stack = {};
|
DqnMemStack stack = {};
|
||||||
DQN_ASSERT(stack.Init(DQN_MEGABYTE(1), Dqn::ZeroClear::True, DqnMemStack::Flag::BoundsGuard));
|
DQN_ASSERT(stack.Init(DQN_MEGABYTE(1), Dqn::ZeroClear::Yes, DqnMemStack::Flag::BoundsGuard));
|
||||||
|
|
||||||
DqnMemStack::Block *blockToReturnTo = stack.block;
|
DqnMemStack::Block *blockToReturnTo = stack.block;
|
||||||
auto headBefore = blockToReturnTo->head;
|
auto headBefore = blockToReturnTo->head;
|
||||||
@ -2482,7 +2482,7 @@ FILE_SCOPE void DqnMemStack_Test()
|
|||||||
if (1)
|
if (1)
|
||||||
{
|
{
|
||||||
DqnMemStack stack = {};
|
DqnMemStack stack = {};
|
||||||
DQN_ASSERT(stack.Init(DQN_MEGABYTE(1), Dqn::ZeroClear::True, DqnMemStack::Flag::BoundsGuard));
|
DQN_ASSERT(stack.Init(DQN_MEGABYTE(1), Dqn::ZeroClear::Yes, DqnMemStack::Flag::BoundsGuard));
|
||||||
|
|
||||||
auto *pop1 = stack.Push(222);
|
auto *pop1 = stack.Push(222);
|
||||||
auto *pop2 = stack.PushOnTail(333);
|
auto *pop2 = stack.PushOnTail(333);
|
||||||
@ -2533,7 +2533,7 @@ FILE_SCOPE void DqnMemStack_Test()
|
|||||||
{
|
{
|
||||||
u8 memBuf[sizeof(DqnMemStack::Block) - 1] = {};
|
u8 memBuf[sizeof(DqnMemStack::Block) - 1] = {};
|
||||||
DqnMemStack stack = {};
|
DqnMemStack stack = {};
|
||||||
auto result = stack.Init(&(memBuf[0]), DQN_ARRAY_COUNT(memBuf), Dqn::ZeroClear::False);
|
auto result = stack.Init(&(memBuf[0]), DQN_ARRAY_COUNT(memBuf), Dqn::ZeroClear::No);
|
||||||
|
|
||||||
DQN_ASSERT(result == false);
|
DQN_ASSERT(result == false);
|
||||||
DQN_ASSERT(stack.block == nullptr);
|
DQN_ASSERT(stack.block == nullptr);
|
||||||
@ -2546,7 +2546,7 @@ FILE_SCOPE void DqnMemStack_Test()
|
|||||||
i32 const bufSize = sizeof(DqnMemStack::Block) * 5;
|
i32 const bufSize = sizeof(DqnMemStack::Block) * 5;
|
||||||
u8 memBuf[bufSize] = {};
|
u8 memBuf[bufSize] = {};
|
||||||
DqnMemStack stack = {};
|
DqnMemStack stack = {};
|
||||||
auto result = stack.Init(&(memBuf[0]), bufSize, Dqn::ZeroClear::False);
|
auto result = stack.Init(&(memBuf[0]), bufSize, Dqn::ZeroClear::No);
|
||||||
|
|
||||||
DQN_ASSERT(result == true);
|
DQN_ASSERT(result == true);
|
||||||
DQN_ASSERT(stack.block);
|
DQN_ASSERT(stack.block);
|
||||||
@ -2578,7 +2578,7 @@ FILE_SCOPE void DqnMemStack_Test()
|
|||||||
usize size = 32;
|
usize size = 32;
|
||||||
usize additionalSize = DqnMemStack::MINIMUM_BLOCK_SIZE;
|
usize additionalSize = DqnMemStack::MINIMUM_BLOCK_SIZE;
|
||||||
DqnMemAPI heap = DqnMemAPI::HeapAllocator();
|
DqnMemAPI heap = DqnMemAPI::HeapAllocator();
|
||||||
DQN_ASSERT(stack.Init(size, Dqn::ZeroClear::True, 0, &heap));
|
DQN_ASSERT(stack.Init(size, Dqn::ZeroClear::Yes, 0, &heap));
|
||||||
auto *block1 = stack.block;
|
auto *block1 = stack.block;
|
||||||
|
|
||||||
size += additionalSize;
|
size += additionalSize;
|
||||||
@ -2628,7 +2628,7 @@ FILE_SCOPE void DqnMemStack_Test()
|
|||||||
if (1)
|
if (1)
|
||||||
{
|
{
|
||||||
DqnMemStack stack = {};
|
DqnMemStack stack = {};
|
||||||
DQN_ASSERT(stack.Init(DQN_MEGABYTE(1), Dqn::ZeroClear::True, DqnMemStack::Flag::BoundsGuard));
|
DQN_ASSERT(stack.Init(DQN_MEGABYTE(1), Dqn::ZeroClear::Yes, DqnMemStack::Flag::BoundsGuard));
|
||||||
auto *result = stack.Push(64);
|
auto *result = stack.Push(64);
|
||||||
|
|
||||||
// TODO(doyle): check head and tail are adjacent to the bounds of the allocation
|
// TODO(doyle): check head and tail are adjacent to the bounds of the allocation
|
||||||
@ -2647,7 +2647,7 @@ FILE_SCOPE void DqnMemStack_Test()
|
|||||||
if (1)
|
if (1)
|
||||||
{
|
{
|
||||||
DqnMemStack stack = {};
|
DqnMemStack stack = {};
|
||||||
DQN_ASSERT(stack.Init(DQN_MEGABYTE(1), Dqn::ZeroClear::True, DqnMemStack::Flag::BoundsGuard));
|
DQN_ASSERT(stack.Init(DQN_MEGABYTE(1), Dqn::ZeroClear::Yes, DqnMemStack::Flag::BoundsGuard));
|
||||||
|
|
||||||
auto *result1 = stack.Push(100);
|
auto *result1 = stack.Push(100);
|
||||||
auto *result2 = stack.PushOnTail(100);
|
auto *result2 = stack.PushOnTail(100);
|
||||||
@ -2675,7 +2675,7 @@ FILE_SCOPE void DqnMemStack_Test()
|
|||||||
if (1)
|
if (1)
|
||||||
{
|
{
|
||||||
DqnMemStack stack = {};
|
DqnMemStack stack = {};
|
||||||
DQN_ASSERT(stack.Init(DQN_MEGABYTE(1), Dqn::ZeroClear::True, DqnMemStack::Flag::BoundsGuard));
|
DQN_ASSERT(stack.Init(DQN_MEGABYTE(1), Dqn::ZeroClear::Yes, DqnMemStack::Flag::BoundsGuard));
|
||||||
|
|
||||||
auto *result1 = stack.Push(100);
|
auto *result1 = stack.Push(100);
|
||||||
DQN_ASSERT(stack.block->prevBlock == nullptr);
|
DQN_ASSERT(stack.block->prevBlock == nullptr);
|
||||||
@ -2706,7 +2706,7 @@ FILE_SCOPE void DqnMemStack_Test()
|
|||||||
if (1)
|
if (1)
|
||||||
{
|
{
|
||||||
DqnMemStack stack = {};
|
DqnMemStack stack = {};
|
||||||
DQN_ASSERT(stack.Init(DQN_MEGABYTE(1), Dqn::ZeroClear::True, DqnMemStack::Flag::NonExpandable));
|
DQN_ASSERT(stack.Init(DQN_MEGABYTE(1), Dqn::ZeroClear::Yes, DqnMemStack::Flag::NonExpandable));
|
||||||
|
|
||||||
auto *result1 = stack.Push(100);
|
auto *result1 = stack.Push(100);
|
||||||
DQN_ASSERT(stack.block->prevBlock == nullptr);
|
DQN_ASSERT(stack.block->prevBlock == nullptr);
|
||||||
@ -2744,7 +2744,7 @@ FILE_SCOPE void DqnMemStack_Test()
|
|||||||
if (1)
|
if (1)
|
||||||
{
|
{
|
||||||
DqnMemStack stack = {};
|
DqnMemStack stack = {};
|
||||||
DQN_ASSERT(stack.Init(DQN_MEGABYTE(1), Dqn::ZeroClear::True, DqnMemStack::Flag::BoundsGuard));
|
DQN_ASSERT(stack.Init(DQN_MEGABYTE(1), Dqn::ZeroClear::Yes, DqnMemStack::Flag::BoundsGuard));
|
||||||
auto *api = &stack.myHeadAPI;
|
auto *api = &stack.myHeadAPI;
|
||||||
|
|
||||||
auto *blockBefore = stack.block;
|
auto *blockBefore = stack.block;
|
||||||
@ -2775,7 +2775,7 @@ FILE_SCOPE void DqnMemStack_Test()
|
|||||||
if (1)
|
if (1)
|
||||||
{
|
{
|
||||||
DqnMemStack stack = {};
|
DqnMemStack stack = {};
|
||||||
DQN_ASSERT(stack.Init(DQN_MEGABYTE(1), Dqn::ZeroClear::True, DqnMemStack::Flag::BoundsGuard));
|
DQN_ASSERT(stack.Init(DQN_MEGABYTE(1), Dqn::ZeroClear::Yes, DqnMemStack::Flag::BoundsGuard));
|
||||||
auto *api = &stack.myHeadAPI;
|
auto *api = &stack.myHeadAPI;
|
||||||
|
|
||||||
auto *blockBefore = stack.block;
|
auto *blockBefore = stack.block;
|
||||||
@ -2811,7 +2811,7 @@ FILE_SCOPE void DqnMemStack_Test()
|
|||||||
if (1)
|
if (1)
|
||||||
{
|
{
|
||||||
DqnMemStack stack = {};
|
DqnMemStack stack = {};
|
||||||
DQN_ASSERT(stack.Init(DQN_MEGABYTE(1), Dqn::ZeroClear::True, DqnMemStack::Flag::BoundsGuard));
|
DQN_ASSERT(stack.Init(DQN_MEGABYTE(1), Dqn::ZeroClear::Yes, DqnMemStack::Flag::BoundsGuard));
|
||||||
auto *api = &stack.myHeadAPI;
|
auto *api = &stack.myHeadAPI;
|
||||||
|
|
||||||
auto *blockBefore = stack.block;
|
auto *blockBefore = stack.block;
|
||||||
@ -2841,7 +2841,7 @@ FILE_SCOPE void DqnMemStack_Test()
|
|||||||
if (1)
|
if (1)
|
||||||
{
|
{
|
||||||
DqnMemStack stack = {};
|
DqnMemStack stack = {};
|
||||||
DQN_ASSERT(stack.Init(DQN_MEGABYTE(1), Dqn::ZeroClear::True, DqnMemStack::Flag::BoundsGuard));
|
DQN_ASSERT(stack.Init(DQN_MEGABYTE(1), Dqn::ZeroClear::Yes, DqnMemStack::Flag::BoundsGuard));
|
||||||
auto *api = &stack.myHeadAPI;
|
auto *api = &stack.myHeadAPI;
|
||||||
|
|
||||||
auto *blockBefore = stack.block;
|
auto *blockBefore = stack.block;
|
||||||
|
82
dqn.h
82
dqn.h
@ -173,8 +173,8 @@ using f32 = float;
|
|||||||
// #Dqn Namespace
|
// #Dqn Namespace
|
||||||
namespace Dqn
|
namespace Dqn
|
||||||
{
|
{
|
||||||
enum struct ZeroClear { True = 1, False = 0};
|
enum struct ZeroClear { No = 0, Yes = 1};
|
||||||
enum struct IgnoreCase { True = 1, False = 0};
|
enum struct IgnoreCase { No = 0, Yes = 1};
|
||||||
FILE_SCOPE const bool IS_DEBUG = true;
|
FILE_SCOPE const bool IS_DEBUG = true;
|
||||||
}; // namespace Dqn
|
}; // namespace Dqn
|
||||||
|
|
||||||
@ -708,7 +708,7 @@ DQN_FILE_SCOPE char *DqnChar_GetNextLine (char *ptr, i32 *lineLength);
|
|||||||
// =================================================================================================
|
// =================================================================================================
|
||||||
// numBytesToCompare: If -1, cmp runs until \0 is encountered.
|
// numBytesToCompare: If -1, cmp runs until \0 is encountered.
|
||||||
// return: 0 if equal. 0 < if a is before b, > 0 if a is after b
|
// return: 0 if equal. 0 < if a is before b, > 0 if a is after b
|
||||||
DQN_FILE_SCOPE i32 DqnStr_Cmp (char const *a, char const *b, i32 numBytesToCompare = -1, Dqn::IgnoreCase ignore = Dqn::IgnoreCase::False);
|
DQN_FILE_SCOPE i32 DqnStr_Cmp (char const *a, char const *b, i32 numBytesToCompare = -1, Dqn::IgnoreCase ignore = Dqn::IgnoreCase::No);
|
||||||
|
|
||||||
// strLen: Len of string, if -1, StrLen is used.
|
// strLen: Len of string, if -1, StrLen is used.
|
||||||
// return: Pointer in str to the last slash, if none then the original string.
|
// return: Pointer in str to the last slash, if none then the original string.
|
||||||
@ -728,12 +728,12 @@ DQN_FILE_SCOPE void DqnStr_Reverse (char *buf, is
|
|||||||
DQN_FILE_SCOPE i32 DqnStr_ReadUTF8Codepoint (u32 const *a, u32 *outCodepoint);
|
DQN_FILE_SCOPE i32 DqnStr_ReadUTF8Codepoint (u32 const *a, u32 *outCodepoint);
|
||||||
|
|
||||||
// return: The offset into the src to first char of the found string. Returns -1 if not found
|
// return: The offset into the src to first char of the found string. Returns -1 if not found
|
||||||
DQN_FILE_SCOPE i32 DqnStr_FindFirstOccurence (char const *src, i32 srcLen, char const *find, i32 findLen, Dqn::IgnoreCase ignore = Dqn::IgnoreCase::False);
|
DQN_FILE_SCOPE i32 DqnStr_FindFirstOccurence (char const *src, i32 srcLen, char const *find, i32 findLen, Dqn::IgnoreCase ignore = Dqn::IgnoreCase::No);
|
||||||
DQN_FILE_SCOPE bool DqnStr_EndsWith (char const *src, i32 srcLen, char const *find, i32 findLen, Dqn::IgnoreCase ignore = Dqn::IgnoreCase::False);
|
DQN_FILE_SCOPE bool DqnStr_EndsWith (char const *src, i32 srcLen, char const *find, i32 findLen, Dqn::IgnoreCase ignore = Dqn::IgnoreCase::No);
|
||||||
|
|
||||||
// return: Helper function that returns the pointer to the first occurence, nullptr if not found.
|
// return: Helper function that returns the pointer to the first occurence, nullptr if not found.
|
||||||
DQN_FILE_SCOPE char *DqnStr_GetFirstOccurence (char const *src, i32 srcLen, char const *find, i32 findLen, Dqn::IgnoreCase ignore = Dqn::IgnoreCase::False);
|
DQN_FILE_SCOPE char *DqnStr_GetFirstOccurence (char const *src, i32 srcLen, char const *find, i32 findLen, Dqn::IgnoreCase ignore = Dqn::IgnoreCase::No);
|
||||||
DQN_FILE_SCOPE bool DqnStr_HasSubstring (char const *src, i32 srcLen, char const *find, i32 findLen, Dqn::IgnoreCase ignore = Dqn::IgnoreCase::False);
|
DQN_FILE_SCOPE bool DqnStr_HasSubstring (char const *src, i32 srcLen, char const *find, i32 findLen, Dqn::IgnoreCase ignore = Dqn::IgnoreCase::No);
|
||||||
|
|
||||||
DQN_FILE_SCOPE DqnSlice<char> DqnStr_RemoveLeadTrailChar (char const *str, i32 strLen, char leadChar, char trailChar);
|
DQN_FILE_SCOPE DqnSlice<char> DqnStr_RemoveLeadTrailChar (char const *str, i32 strLen, char leadChar, char trailChar);
|
||||||
DQN_FILE_SCOPE inline DqnSlice<char> DqnStr_RemoveLeadTrailQuotes (DqnSlice<char> slice);
|
DQN_FILE_SCOPE inline DqnSlice<char> DqnStr_RemoveLeadTrailQuotes (DqnSlice<char> slice);
|
||||||
@ -1117,7 +1117,7 @@ public:
|
|||||||
static DqnMemAPI StackAllocator(struct DqnMemStack *stack, StackPushType type = StackPushType::Head);
|
static DqnMemAPI StackAllocator(struct DqnMemStack *stack, StackPushType type = StackPushType::Head);
|
||||||
|
|
||||||
void *Realloc(void *oldPtr, isize oldSize, isize newSize);
|
void *Realloc(void *oldPtr, isize oldSize, isize newSize);
|
||||||
void *Alloc (isize size, Dqn::ZeroClear clear = Dqn::ZeroClear::True);
|
void *Alloc (isize size, Dqn::ZeroClear clear = Dqn::ZeroClear::Yes);
|
||||||
void Free (void *ptrToFree, isize sizeToFree = 0); // TODO(doyle): sizeToFree opt is iffy
|
void Free (void *ptrToFree, isize sizeToFree = 0); // TODO(doyle): sizeToFree opt is iffy
|
||||||
bool IsValid() const { return (this->allocator != nullptr); }
|
bool IsValid() const { return (this->allocator != nullptr); }
|
||||||
};
|
};
|
||||||
@ -1154,7 +1154,7 @@ struct DqnArray
|
|||||||
void Pop ();
|
void Pop ();
|
||||||
T *Peek ();
|
T *Peek ();
|
||||||
T *Get (isize index);
|
T *Get (isize index);
|
||||||
void Clear (Dqn::ZeroClear clear = Dqn::ZeroClear::False);
|
void Clear (Dqn::ZeroClear clear = Dqn::ZeroClear::No);
|
||||||
bool Remove (isize index);
|
bool Remove (isize index);
|
||||||
bool RemoveStable(isize index);
|
bool RemoveStable(isize index);
|
||||||
|
|
||||||
@ -1310,8 +1310,8 @@ struct DqnMemStack
|
|||||||
void *PushOnTail (isize size, u8 alignment = 4);
|
void *PushOnTail (isize size, u8 alignment = 4);
|
||||||
|
|
||||||
// Frees the given ptr. It MUST be the last allocated item in the stack, asserts otherwise.
|
// Frees the given ptr. It MUST be the last allocated item in the stack, asserts otherwise.
|
||||||
void Pop (void *ptr, Dqn::ZeroClear clear = Dqn::ZeroClear::False);
|
void Pop (void *ptr, Dqn::ZeroClear clear = Dqn::ZeroClear::No);
|
||||||
void PopOnTail (void *ptr, Dqn::ZeroClear zeroClear = Dqn::ZeroClear::False);
|
void PopOnTail (void *ptr, Dqn::ZeroClear zeroClear = Dqn::ZeroClear::No);
|
||||||
|
|
||||||
// Frees all blocks belonging to this stack.
|
// Frees all blocks belonging to this stack.
|
||||||
void Free ();
|
void Free ();
|
||||||
@ -1365,8 +1365,8 @@ struct DqnMemStack
|
|||||||
inline bool DqnMemStack_Init (DqnMemStack *me, isize size, Dqn::ZeroClear clear, u32 flags_ = 0, DqnMemAPI *api = DQN_DEFAULT_HEAP_ALLOCATOR) { return me->Init(size, clear, flags_, api); }
|
inline bool DqnMemStack_Init (DqnMemStack *me, isize size, Dqn::ZeroClear clear, u32 flags_ = 0, DqnMemAPI *api = DQN_DEFAULT_HEAP_ALLOCATOR) { return me->Init(size, clear, flags_, api); }
|
||||||
inline void *DqnMemStack_Push (DqnMemStack *me, isize size, u8 alignment = 4) { return me->Push(size, alignment); }
|
inline void *DqnMemStack_Push (DqnMemStack *me, isize size, u8 alignment = 4) { return me->Push(size, alignment); }
|
||||||
inline void *DqnMemStack_PushOnTail (DqnMemStack *me, isize size, u8 alignment = 4) { return me->PushOnTail(size, alignment); }
|
inline void *DqnMemStack_PushOnTail (DqnMemStack *me, isize size, u8 alignment = 4) { return me->PushOnTail(size, alignment); }
|
||||||
inline void DqnMemStack_Pop (DqnMemStack *me, void *ptr, Dqn::ZeroClear clear = Dqn::ZeroClear::False) { me->Pop(ptr, clear); }
|
inline void DqnMemStack_Pop (DqnMemStack *me, void *ptr, Dqn::ZeroClear clear = Dqn::ZeroClear::No) { me->Pop(ptr, clear); }
|
||||||
inline void DqnMemStack_PopOnTail (DqnMemStack *me, void *ptr, Dqn::ZeroClear clear = Dqn::ZeroClear::False) { me->PopOnTail(ptr, clear); }
|
inline void DqnMemStack_PopOnTail (DqnMemStack *me, void *ptr, Dqn::ZeroClear clear = Dqn::ZeroClear::No) { me->PopOnTail(ptr, clear); }
|
||||||
inline void DqnMemStack_Free (DqnMemStack *me) { me->Free(); }
|
inline void DqnMemStack_Free (DqnMemStack *me) { me->Free(); }
|
||||||
inline bool DqnMemStack_FreeMemBlock (DqnMemStack *me, DqnMemStack::Block *memBlock) { return me->FreeMemBlock(memBlock); }
|
inline bool DqnMemStack_FreeMemBlock (DqnMemStack *me, DqnMemStack::Block *memBlock) { return me->FreeMemBlock(memBlock); }
|
||||||
inline bool DqnMemStack_FreeLastBlock (DqnMemStack *me) { return me->FreeLastBlock(); }
|
inline bool DqnMemStack_FreeLastBlock (DqnMemStack *me) { return me->FreeLastBlock(); }
|
||||||
@ -1422,7 +1422,7 @@ bool DqnArray<T>::Reserve(isize newMax)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
result = (T *)this->memAPI->Alloc(newSize, Dqn::ZeroClear::False);
|
result = (T *)this->memAPI->Alloc(newSize, Dqn::ZeroClear::No);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result)
|
if (result)
|
||||||
@ -1558,7 +1558,7 @@ T *DqnArray<T>::Get(isize index)
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
void DqnArray<T>::Clear(Dqn::ZeroClear clear)
|
void DqnArray<T>::Clear(Dqn::ZeroClear clear)
|
||||||
{
|
{
|
||||||
if (clear == Dqn::ZeroClear::True)
|
if (clear == Dqn::ZeroClear::Yes)
|
||||||
{
|
{
|
||||||
isize sizeToClear = sizeof(T) * this->count;
|
isize sizeToClear = sizeof(T) * this->count;
|
||||||
DqnMem_Clear(this->data, 0, sizeToClear);
|
DqnMem_Clear(this->data, 0, sizeToClear);
|
||||||
@ -1996,19 +1996,19 @@ struct DqnString
|
|||||||
|
|
||||||
// Statics
|
// Statics
|
||||||
// =============================================================================================
|
// =============================================================================================
|
||||||
static bool Cmp(DqnString const *a, DqnString const *b, Dqn::IgnoreCase ignore = Dqn::IgnoreCase::False)
|
static bool Cmp(DqnString const *a, DqnString const *b, Dqn::IgnoreCase ignore = Dqn::IgnoreCase::No)
|
||||||
{
|
{
|
||||||
bool result = (a->len == b->len) && (DqnStr_Cmp(a->str, b->str, a->len, ignore) == 0);
|
bool result = (a->len == b->len) && (DqnStr_Cmp(a->str, b->str, a->len, ignore) == 0);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool Cmp(DqnString const *a, DqnSlice<char const> const b, Dqn::IgnoreCase ignore = Dqn::IgnoreCase::False)
|
static bool Cmp(DqnString const *a, DqnSlice<char const> const b, Dqn::IgnoreCase ignore = Dqn::IgnoreCase::No)
|
||||||
{
|
{
|
||||||
bool result = (a->len == b.len) && (DqnStr_Cmp(a->str, b.data, b.len, ignore) == 0);
|
bool result = (a->len == b.len) && (DqnStr_Cmp(a->str, b.data, b.len, ignore) == 0);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool Cmp(DqnString const *a, DqnSlice<char> const b, Dqn::IgnoreCase ignore = Dqn::IgnoreCase::False)
|
static bool Cmp(DqnString const *a, DqnSlice<char> const b, Dqn::IgnoreCase ignore = Dqn::IgnoreCase::No)
|
||||||
{
|
{
|
||||||
bool result = (a->len == b.len) && (DqnStr_Cmp(a->str, b.data, b.len, ignore) == 0);
|
bool result = (a->len == b.len) && (DqnStr_Cmp(a->str, b.data, b.len, ignore) == 0);
|
||||||
return result;
|
return result;
|
||||||
@ -2066,7 +2066,7 @@ struct DqnFixedString
|
|||||||
int VSprintf (char const *fmt, va_list argList);
|
int VSprintf (char const *fmt, va_list argList);
|
||||||
int VSprintfAppend(char const *fmt, va_list argList);
|
int VSprintfAppend(char const *fmt, va_list argList);
|
||||||
|
|
||||||
void Clear (Dqn::ZeroClear clear = Dqn::ZeroClear::False) { if (clear == Dqn::ZeroClear::True) DqnMem_Set(str, 0, MAX); this = {}; }
|
void Clear (Dqn::ZeroClear clear = Dqn::ZeroClear::No) { if (clear == Dqn::ZeroClear::Yes) DqnMem_Set(str, 0, MAX); this = {}; }
|
||||||
};
|
};
|
||||||
|
|
||||||
template <unsigned int MAX>
|
template <unsigned int MAX>
|
||||||
@ -3326,7 +3326,7 @@ FILE_SCOPE u8 *DqnMemAPIInternal_StackAllocatorCallback(DqnMemAPI *api, DqnMemAP
|
|||||||
enoughSpace = (block->head + extraBytesReq) < block->tail;
|
enoughSpace = (block->head + extraBytesReq) < block->tail;
|
||||||
if (enoughSpace)
|
if (enoughSpace)
|
||||||
{
|
{
|
||||||
stack->Pop(ptr, Dqn::ZeroClear::False);
|
stack->Pop(ptr, Dqn::ZeroClear::No);
|
||||||
result = (u8 *)stack->Push(request->newSize, alignment);
|
result = (u8 *)stack->Push(request->newSize, alignment);
|
||||||
DQN_ASSERT(stack->block == block && result == request->oldMemPtr);
|
DQN_ASSERT(stack->block == block && result == request->oldMemPtr);
|
||||||
success = true;
|
success = true;
|
||||||
@ -3340,7 +3340,7 @@ FILE_SCOPE u8 *DqnMemAPIInternal_StackAllocatorCallback(DqnMemAPI *api, DqnMemAP
|
|||||||
enoughSpace = (block->tail - extraBytesReq) > block->head;
|
enoughSpace = (block->tail - extraBytesReq) > block->head;
|
||||||
if (enoughSpace)
|
if (enoughSpace)
|
||||||
{
|
{
|
||||||
stack->PopOnTail(ptr, Dqn::ZeroClear::False);
|
stack->PopOnTail(ptr, Dqn::ZeroClear::No);
|
||||||
result = (u8 *)stack->PushOnTail(request->newSize, alignment);
|
result = (u8 *)stack->PushOnTail(request->newSize, alignment);
|
||||||
DqnMem_Copy(result, ptr, oldMemSize);
|
DqnMem_Copy(result, ptr, oldMemSize);
|
||||||
result[oldMemSize] = 0;
|
result[oldMemSize] = 0;
|
||||||
@ -3376,8 +3376,8 @@ FILE_SCOPE u8 *DqnMemAPIInternal_StackAllocatorCallback(DqnMemAPI *api, DqnMemAP
|
|||||||
auto *newBlock = stack->block;
|
auto *newBlock = stack->block;
|
||||||
stack->block = oldBlock;
|
stack->block = oldBlock;
|
||||||
|
|
||||||
if (type == PtrType::Head) stack->Pop(ptr, Dqn::ZeroClear::False);
|
if (type == PtrType::Head) stack->Pop(ptr, Dqn::ZeroClear::No);
|
||||||
else stack->PopOnTail(ptr, Dqn::ZeroClear::False);
|
else stack->PopOnTail(ptr, Dqn::ZeroClear::No);
|
||||||
stack->block = newBlock;
|
stack->block = newBlock;
|
||||||
success = true;
|
success = true;
|
||||||
}
|
}
|
||||||
@ -3427,8 +3427,8 @@ FILE_SCOPE u8 *DqnMemAPIInternal_StackAllocatorCallback(DqnMemAPI *api, DqnMemAP
|
|||||||
if (PtrIsLastAllocationInBlock(&stack->metadata, block, ptr))
|
if (PtrIsLastAllocationInBlock(&stack->metadata, block, ptr))
|
||||||
{
|
{
|
||||||
PtrType type = ClassifyPtr(block, ptr);
|
PtrType type = ClassifyPtr(block, ptr);
|
||||||
if (type == PtrType::Head) stack->Pop(ptr, Dqn::ZeroClear::False);
|
if (type == PtrType::Head) stack->Pop(ptr, Dqn::ZeroClear::No);
|
||||||
else stack->PopOnTail(ptr, Dqn::ZeroClear::False);
|
else stack->PopOnTail(ptr, Dqn::ZeroClear::No);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -3479,7 +3479,7 @@ void *DqnMemAPI::Alloc(isize size, Dqn::ZeroClear clear)
|
|||||||
Request request = {};
|
Request request = {};
|
||||||
request.type = Type::Alloc;
|
request.type = Type::Alloc;
|
||||||
request.userContext = this->userContext;
|
request.userContext = this->userContext;
|
||||||
request.e.alloc.zeroClear = (clear == Dqn::ZeroClear::True) ? true : false;
|
request.e.alloc.zeroClear = (clear == Dqn::ZeroClear::Yes) ? true : false;
|
||||||
request.e.alloc.requestSize = size;
|
request.e.alloc.requestSize = size;
|
||||||
|
|
||||||
void *result = (void *)this->allocator(this, request);
|
void *result = (void *)this->allocator(this, request);
|
||||||
@ -3676,7 +3676,7 @@ bool DqnMemStack::Init(void *mem, isize size, Dqn::ZeroClear clear, u32 flags_)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (clear == Dqn::ZeroClear::True)
|
if (clear == Dqn::ZeroClear::Yes)
|
||||||
DqnMem_Set(mem, 0, size);
|
DqnMem_Set(mem, 0, size);
|
||||||
|
|
||||||
this->block = (DqnMemStack::Block *)mem;
|
this->block = (DqnMemStack::Block *)mem;
|
||||||
@ -3767,7 +3767,7 @@ FILE_SCOPE void *DqnMemStackInternal_Push(DqnMemStack *stack, isize size, u8 ali
|
|||||||
}
|
}
|
||||||
|
|
||||||
isize newBlockSize = DQN_MAX(actualSize, DqnMemStack::MINIMUM_BLOCK_SIZE);
|
isize newBlockSize = DQN_MAX(actualSize, DqnMemStack::MINIMUM_BLOCK_SIZE);
|
||||||
DqnMemStack::Block *newBlock = DqnMemStackInternal_AllocateBlock(newBlockSize, Dqn::ZeroClear::False, stack->memAPI);
|
DqnMemStack::Block *newBlock = DqnMemStackInternal_AllocateBlock(newBlockSize, Dqn::ZeroClear::No, stack->memAPI);
|
||||||
if (!newBlock)
|
if (!newBlock)
|
||||||
{
|
{
|
||||||
DQN_LOGE(
|
DQN_LOGE(
|
||||||
@ -3912,7 +3912,7 @@ FILE_SCOPE void DqnMemStackInternal_Pop(DqnMemStack *stack, void *ptr, Dqn::Zero
|
|||||||
DQN_ASSERT(stack->block->tail <= blockEnd);
|
DQN_ASSERT(stack->block->tail <= blockEnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (clear == Dqn::ZeroClear::True)
|
if (clear == Dqn::ZeroClear::Yes)
|
||||||
DqnMem_Set(start, 0, end - start);
|
DqnMem_Set(start, 0, end - start);
|
||||||
|
|
||||||
if (stack->block->tail == blockEnd && stack->block->head == stack->block->memory)
|
if (stack->block->tail == blockEnd && stack->block->head == stack->block->memory)
|
||||||
@ -3999,7 +3999,7 @@ void DqnMemStack::Reset()
|
|||||||
{
|
{
|
||||||
this->FreeLastBlock();
|
this->FreeLastBlock();
|
||||||
}
|
}
|
||||||
this->ClearCurrBlock(Dqn::ZeroClear::False);
|
this->ClearCurrBlock(Dqn::ZeroClear::No);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -4020,7 +4020,7 @@ void DqnMemStack::ClearCurrBlock(Dqn::ZeroClear clear)
|
|||||||
|
|
||||||
this->block->head = this->block->memory;
|
this->block->head = this->block->memory;
|
||||||
this->block->tail = this->block->memory + this->block->size;
|
this->block->tail = this->block->memory + this->block->size;
|
||||||
if (clear == Dqn::ZeroClear::True)
|
if (clear == Dqn::ZeroClear::Yes)
|
||||||
{
|
{
|
||||||
DqnMem_Clear(this->block->memory, 0, this->block->size);
|
DqnMem_Clear(this->block->memory, 0, this->block->size);
|
||||||
}
|
}
|
||||||
@ -5071,7 +5071,7 @@ DQN_FILE_SCOPE i32 DqnStr_Cmp(char const *a, char const *b, i32 numBytesToCompar
|
|||||||
|
|
||||||
i32 bytesCompared = 0;
|
i32 bytesCompared = 0;
|
||||||
i32 result = 0;
|
i32 result = 0;
|
||||||
if (ignore == Dqn::IgnoreCase::True)
|
if (ignore == Dqn::IgnoreCase::Yes)
|
||||||
{
|
{
|
||||||
while (a[0] && (DqnChar_ToLower(a[0]) == DqnChar_ToLower(b[0])))
|
while (a[0] && (DqnChar_ToLower(a[0]) == DqnChar_ToLower(b[0])))
|
||||||
{
|
{
|
||||||
@ -6100,7 +6100,7 @@ bool DqnString::InitSize(i32 size, DqnMemAPI *const api)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
usize allocSize = sizeof(*(this->str)) * (size + 1);
|
usize allocSize = sizeof(*(this->str)) * (size + 1);
|
||||||
this->str = (char *)api->Alloc(allocSize, Dqn::ZeroClear::False);
|
this->str = (char *)api->Alloc(allocSize, Dqn::ZeroClear::No);
|
||||||
if (!this->str) return false;
|
if (!this->str) return false;
|
||||||
|
|
||||||
this->str[0] = 0;
|
this->str[0] = 0;
|
||||||
@ -6250,7 +6250,7 @@ bool DqnString::Expand(i32 newMax)
|
|||||||
char *result = nullptr;
|
char *result = nullptr;
|
||||||
|
|
||||||
if (this->str) result = (char *)this->memAPI->Realloc(this->str, (this->max + 1), allocSize);
|
if (this->str) result = (char *)this->memAPI->Realloc(this->str, (this->max + 1), allocSize);
|
||||||
else result = (char *)this->memAPI->Alloc(allocSize, Dqn::ZeroClear::False);
|
else result = (char *)this->memAPI->Alloc(allocSize, Dqn::ZeroClear::No);
|
||||||
|
|
||||||
if (result)
|
if (result)
|
||||||
{
|
{
|
||||||
@ -6456,7 +6456,7 @@ FILE_SCOPE int DqnFixedString__Append(char *dest, int destSize, char const *src,
|
|||||||
DQN_ASSERT(!src[0]);
|
DQN_ASSERT(!src[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
realLen = ptr - dest;
|
realLen = static_cast<i32>(ptr - dest);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -7920,7 +7920,7 @@ DQN_FILE_INTERNAL_LIST_DIR(DqnFileInternal_PlatformListDir)
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
char **list = (char **)api->Alloc(sizeof(*list) * (currNumFiles), Dqn::ZeroClear::True);
|
char **list = (char **)api->Alloc(sizeof(*list) * (currNumFiles), Dqn::ZeroClear::Yes);
|
||||||
|
|
||||||
if (!list)
|
if (!list)
|
||||||
{
|
{
|
||||||
@ -7932,7 +7932,7 @@ DQN_FILE_INTERNAL_LIST_DIR(DqnFileInternal_PlatformListDir)
|
|||||||
for (auto i = 0; i < currNumFiles; i++)
|
for (auto i = 0; i < currNumFiles; i++)
|
||||||
{
|
{
|
||||||
// TODO(doyle): Max path is bad.
|
// TODO(doyle): Max path is bad.
|
||||||
list[i] = (char *)api->Alloc(sizeof(**list) * MAX_PATH, Dqn::ZeroClear::True);
|
list[i] = (char *)api->Alloc(sizeof(**list) * MAX_PATH, Dqn::ZeroClear::Yes);
|
||||||
if (!list[i])
|
if (!list[i])
|
||||||
{
|
{
|
||||||
for (auto j = 0; j < i; j++)
|
for (auto j = 0; j < i; j++)
|
||||||
@ -8089,7 +8089,7 @@ DQN_FILE_INTERNAL_LIST_DIR(DqnFileInternal_PlatformListDir)
|
|||||||
DIR *const dirHandle = opendir(dir);
|
DIR *const dirHandle = opendir(dir);
|
||||||
if (!dirHandle) return nullptr;
|
if (!dirHandle) return nullptr;
|
||||||
|
|
||||||
char **list = (char **)api->Alloc(sizeof(*list) * currNumFiles, Dqn::ZeroClear::True);
|
char **list = (char **)api->Alloc(sizeof(*list) * currNumFiles, Dqn::ZeroClear::Yes);
|
||||||
if (!list)
|
if (!list)
|
||||||
{
|
{
|
||||||
DQN_LOGE("Memory allocation failed, required: %$_d", sizeof(*list) * currNumFiles);
|
DQN_LOGE("Memory allocation failed, required: %$_d", sizeof(*list) * currNumFiles);
|
||||||
@ -8100,7 +8100,7 @@ DQN_FILE_INTERNAL_LIST_DIR(DqnFileInternal_PlatformListDir)
|
|||||||
struct dirent *dirFile = readdir(dirHandle);
|
struct dirent *dirFile = readdir(dirHandle);
|
||||||
for (auto i = 0; i < currNumFiles; i++)
|
for (auto i = 0; i < currNumFiles; i++)
|
||||||
{
|
{
|
||||||
list[i] = (char *)api->Alloc(sizeof(**list) * DQN_ARRAY_COUNT(dirFile->d_name), Dqn::ZeroClear::True);
|
list[i] = (char *)api->Alloc(sizeof(**list) * DQN_ARRAY_COUNT(dirFile->d_name), Dqn::ZeroClear::Yes);
|
||||||
if (!list[i])
|
if (!list[i])
|
||||||
{
|
{
|
||||||
for (auto j = 0; j < i; j++) api->Free(list[j]);
|
for (auto j = 0; j < i; j++) api->Free(list[j]);
|
||||||
@ -8240,7 +8240,7 @@ u8 *DqnFile::ReadEntireFile(wchar_t const *path, usize *bufSize, DqnMemAPI *api)
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto *buf = (u8 *)api->Alloc(requiredSize, Dqn::ZeroClear::False);
|
auto *buf = (u8 *)api->Alloc(requiredSize, Dqn::ZeroClear::No);
|
||||||
if (!buf)
|
if (!buf)
|
||||||
{
|
{
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@ -8265,7 +8265,7 @@ u8 *DqnFile::ReadEntireFile(char const *path, usize *bufSize, DqnMemAPI *api)
|
|||||||
usize requiredSize = 0;
|
usize requiredSize = 0;
|
||||||
if (!DqnFile::GetFileSize(path, &requiredSize) || requiredSize == 0) return nullptr;
|
if (!DqnFile::GetFileSize(path, &requiredSize) || requiredSize == 0) return nullptr;
|
||||||
|
|
||||||
auto *buf = (u8 *)api->Alloc(requiredSize, Dqn::ZeroClear::False);
|
auto *buf = (u8 *)api->Alloc(requiredSize, Dqn::ZeroClear::No);
|
||||||
if (!buf) return nullptr;
|
if (!buf) return nullptr;
|
||||||
|
|
||||||
usize bytesRead = 0;
|
usize bytesRead = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user