From 6de9e3a67f3a171a13e4706e448ce9247c7e478f Mon Sep 17 00:00:00 2001 From: Dominic Masters Date: Mon, 3 Jul 2023 23:05:59 -0700 Subject: [PATCH] Moving some scene files around --- src/dawn/asset/AssetLoader.cpp | 2 +- src/dawn/asset/assets/TextureAsset.cpp | 1 + src/dawnliminal/game/LiminalGame.cpp | 6 ++---- src/dawnlinux64/host/DawnHostTux32.cpp | 12 ++++++++++++ src/dawnshared/util/memory.hpp | 13 +++++++++++++ 5 files changed, 29 insertions(+), 5 deletions(-) diff --git a/src/dawn/asset/AssetLoader.cpp b/src/dawn/asset/AssetLoader.cpp index c22ad2f1..42cfb5d8 100644 --- a/src/dawn/asset/AssetLoader.cpp +++ b/src/dawn/asset/AssetLoader.cpp @@ -78,7 +78,7 @@ size_t AssetLoader::loadRaw(uint8_t **buffer) { this->rewind(); // Read the string then close the file handle. - *buffer = static_cast(malloc(sizeof(uint8_t) * length)); + *buffer = static_cast(memoryAllocate(sizeof(uint8_t) * length)); read = this->read(*buffer, length); this->close(); diff --git a/src/dawn/asset/assets/TextureAsset.cpp b/src/dawn/asset/assets/TextureAsset.cpp index 900a2bbe..64cf8a4f 100644 --- a/src/dawn/asset/assets/TextureAsset.cpp +++ b/src/dawn/asset/assets/TextureAsset.cpp @@ -127,5 +127,6 @@ void TextureAsset::updateAsync() { TextureAsset::~TextureAsset() { if(this->buffer != nullptr) { memoryFree(this->buffer); + this->buffer = nullptr; } } \ No newline at end of file diff --git a/src/dawnliminal/game/LiminalGame.cpp b/src/dawnliminal/game/LiminalGame.cpp index 00fcf087..128d914c 100644 --- a/src/dawnliminal/game/LiminalGame.cpp +++ b/src/dawnliminal/game/LiminalGame.cpp @@ -4,12 +4,10 @@ // https://opensource.org/licenses/MIT #include "game/DawnGame.hpp" -#include "vnscenes/SceneTest.hpp" -#include "scenes/HelloWorldScene.hpp" +#include "vnscenes/ScenePrologue0.hpp" using namespace Dawn; Scene * Dawn::dawnGameGetInitialScene(DawnGame *game) { - // return new HelloWorldScene(game); - return new SceneTest(game); + return new ScenePrologue0(game); } \ No newline at end of file diff --git a/src/dawnlinux64/host/DawnHostTux32.cpp b/src/dawnlinux64/host/DawnHostTux32.cpp index 4cd3927f..21bf915e 100644 --- a/src/dawnlinux64/host/DawnHostTux32.cpp +++ b/src/dawnlinux64/host/DawnHostTux32.cpp @@ -5,11 +5,19 @@ #include "DawnHostTux32.hpp" +#if DAWN_DEBUG_BUILD + uint64_t dawnAllocatedItemCount; +#endif + using namespace Dawn; int32_t main(int32_t argc, char **args) { int32_t result; + #if DAWN_DEBUG_BUILD + dawnAllocatedItemCount = 0; + #endif + // Create the host auto host = new DawnHost(); auto game = new DawnGame(host); @@ -40,6 +48,10 @@ int32_t main(int32_t argc, char **args) { delete game; delete host; + #if DAWN_DEBUG_BUILD + assertTrue(dawnAllocatedItemCount == 0); + #endif + // Success return 0; } \ No newline at end of file diff --git a/src/dawnshared/util/memory.hpp b/src/dawnshared/util/memory.hpp index 5f80af07..041ccd12 100644 --- a/src/dawnshared/util/memory.hpp +++ b/src/dawnshared/util/memory.hpp @@ -8,6 +8,10 @@ #pragma once #include "assert/assert.hpp" +#if DAWN_DEBUG_BUILD + extern uint64_t dawnAllocatedItemCount; +#endif + /** * Allocate some space in memory to use for your needs. Memory allocation may * change how it functions later on to keep things nice and efficient. For now @@ -18,6 +22,9 @@ */ static inline void * memoryAllocate(const size_t size) { assertTrue(size > 0); + #if DAWN_DEBUG_BUILD + dawnAllocatedItemCount++; + #endif auto x = (void *)malloc(size); assertNotNull(x); return x; @@ -31,6 +38,9 @@ static inline void * memoryAllocate(const size_t size) { */ static inline void * memoryFillWithZero(const size_t size) { assertTrue(size > 0); + #if DAWN_DEBUG_BUILD + dawnAllocatedItemCount++; + #endif auto x =(void *)calloc(1, size); assertNotNull(x); return x; @@ -43,6 +53,9 @@ static inline void * memoryFillWithZero(const size_t size) { */ static inline void memoryFree(void *pointer) { assertNotNull(pointer); + #if DAWN_DEBUG_BUILD + dawnAllocatedItemCount--; + #endif free(pointer); }