CMake fixes

This commit is contained in:
IlyaShurupov 2023-10-27 15:33:33 +03:00 committed by Ilya Shurupov
parent fa72355799
commit f6ba86aff8
19 changed files with 82 additions and 168 deletions

View file

@ -1,8 +1,3 @@
cmake_minimum_required(VERSION 3.2)
set(CMAKE_CXX_STANDARD 23)
project(Allocators)
### ---------------------- Static Library --------------------- ###
@ -16,7 +11,5 @@ target_link_libraries(${PROJECT_NAME} PUBLIC Utils)
enable_testing()
file(GLOB TEST_SOURCES "./tests/*.cpp")
add_executable(${PROJECT_NAME}Tests ${TEST_SOURCES})
target_link_libraries(${PROJECT_NAME}Tests ${PROJECT_NAME} Utils)
add_test(NAME ${PROJECT_NAME}Tests COMMAND ${PROJECT_NAME}Tests)
install(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/${PROJECT_NAME}/lib)
target_link_libraries(${PROJECT_NAME}Tests ${PROJECT_NAME} Utils)
add_test(NAME ${PROJECT_NAME}Tests COMMAND ${PROJECT_NAME}Tests)

View file

@ -5,6 +5,8 @@
#include "PrivateConfig.hpp"
#include <malloc.h>
using namespace tp;
#if not defined(MEM_DEBUG)
@ -61,7 +63,7 @@ HeapAlloc::~HeapAlloc() {
DEBUG_BREAK("Destruction of not freed Allocator")
#ifdef MEM_STACK_TRACE
// TODO : log leaks and free them up
// TODO : log leaks and free them up
#endif
}
}

View file

@ -18,6 +18,9 @@ using namespace tp;
void* HeapAllocGlobal::allocate(ualni aBlockSize) { return malloc(aBlockSize); }
void HeapAllocGlobal::deallocate(void* aPtr) { free(aPtr); }
HeapAllocGlobal::~HeapAllocGlobal() = default;
bool HeapAllocGlobal::checkLeaks() { return false; }
void HeapAllocGlobal::startIgnore() {}
void HeapAllocGlobal::stopIgnore() {}
#else
@ -95,7 +98,7 @@ ALLOCATE:
}
mEntry = head;
// 3) Trace the stack
// 3) Trace the stack
#ifdef MEM_STACK_TRACE
head->mCallStack = gCSCapture->getSnapshot();
#endif
@ -146,7 +149,7 @@ void HeapAllocGlobal::deallocate(void* aPtr) {
ASSERT(!"Allocated Block Wrap Corrupted!")
}
// 4) clear data
// 4) clear data
#ifdef MEM_CLEAR_ON_ALLOC
memSetVal(data, head->mBlockSize, CLEAR_DEALLOC_VAL);
#endif