diff --git a/__mocks__/src/packages/log/IZ_log.mock.h b/__mocks__/src/packages/log/IZ_log.mock.h index b212f82..d137f67 100644 --- a/__mocks__/src/packages/log/IZ_log.mock.h +++ b/__mocks__/src/packages/log/IZ_log.mock.h @@ -9,7 +9,7 @@ mock_modes(IZ_LogInfo) { IZ_LOG_INFO_LOG, }; -mock(IZ_LogInfo) void IZ_LogInfo(IZ_LogCategory category, const char* fmt, ...) { +mock(IZ_LogInfo) void IZ_LogInfo(IZ_LogCategory category, const char* context, const char* fmt, ...) { mock_mode_if(IZ_LogInfo, IZ_LOG_INFO_SUPPRESS) { mock_return(IZ_LogInfo); } else mock_mode_if(IZ_LogInfo, IZ_LOG_INFO_LOG) { diff --git a/__mocks__/src/packages/stdinc/IZ_stdlib.mock.h b/__mocks__/src/packages/stdinc/IZ_stdlib.mock.h index 06b2115..4e8ebed 100644 --- a/__mocks__/src/packages/stdinc/IZ_stdlib.mock.h +++ b/__mocks__/src/packages/stdinc/IZ_stdlib.mock.h @@ -8,8 +8,17 @@ mock(IZ_malloc) void* IZ_malloc(size_t size) { mock_return(IZ_malloc) SDL_malloc(size); } +mock_modes(IZ_free) { + IZ_FREE_CALLS_TRACKED = 0, + IZ_FREE_CALLS_UNTRACKED, +}; + mock(IZ_free) void IZ_free(void* mem) { - mock_return(IZ_free) SDL_free(mem); + mock_mode_if(IZ_free, IZ_FREE_CALLS_TRACKED) { + mock_return(IZ_free) SDL_free(mem); + } else mock_mode_if(IZ_free, IZ_FREE_CALLS_UNTRACKED) { + SDL_free(mem); + } } mock(IZ_calloc) void* IZ_calloc(unsigned int num, size_t size) { diff --git a/src/packages/game/data/data.test.c b/src/packages/game/data/data.test.c index 36b2d5c..5952daa 100644 --- a/src/packages/game/data/data.test.c +++ b/src/packages/game/data/data.test.c @@ -21,8 +21,8 @@ spec("data") { static IZ_List list; after_each() { + mock_mode(IZ_free, IZ_FREE_CALLS_UNTRACKED); IZ_ListTeardown(&list); - mock_reset(IZ_free); } it("sets root to NULL") { @@ -47,6 +47,8 @@ spec("data") { IZ_ListAppendNode(&list, &value1); IZ_ListAppendNode(&list, &value2); IZ_ListAppendNode(&list, &value3); + + mock_mode(IZ_free, IZ_FREE_CALLS_TRACKED); } after_each() { @@ -93,10 +95,12 @@ spec("data") { } after_each() { + mock_mode(IZ_free, IZ_FREE_CALLS_UNTRACKED); IZ_ListTeardown(&list); } after_each() { + mock_mode(IZ_free, IZ_FREE_CALLS_UNTRACKED); IZ_ListTeardown(&list2); } @@ -139,6 +143,7 @@ spec("data") { } after_each() { + mock_mode(IZ_free, IZ_FREE_CALLS_UNTRACKED); IZ_ListTeardown(&list); } @@ -167,6 +172,8 @@ spec("data") { IZ_ListAppendNode(&list, &value1); IZ_ListAppendNode(&list, &value2); IZ_ListAppendNode(&list, &value3); + + mock_mode(IZ_free, IZ_FREE_CALLS_TRACKED); } after_each() { diff --git a/src/packages/game/memory/IZ_pool.c b/src/packages/game/memory/IZ_pool.c index 45f523f..6162896 100644 --- a/src/packages/game/memory/IZ_pool.c +++ b/src/packages/game/memory/IZ_pool.c @@ -43,7 +43,10 @@ bool IZ_PoolGetSameItem(IZ_ListNode** node, u64 _index, IZ_List* list) { } void IZ_PoolDeallocate(IZ_PoolItem* item) { - IZ_ListDeleteNode(&item->pool->items, IZ_PoolGetSameItem); + IZ_ListNode** node = IZ_ListFindFirstNode(&item->pool->items, IZ_PoolGetSameItem); + if (node) { + IZ_ListDeleteNode(*node); + } } void IZ_PoolTeardown(IZ_Pool* pool) {