-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
20,598 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#include "AllocatorWrapper.h" | ||
|
||
namespace OS { | ||
AllocatorLib::SimpleStaticAllocator< | ||
AllocatorWrapper::ChunkType, | ||
AllocatorWrapper::CHUNK_SIZE, | ||
AllocatorWrapper::POOL_SIZE> AllocatorWrapper::allocator(lockAllocatorMutex, releaseAllocatorMutex); | ||
|
||
void AllocatorWrapper::lockAllocatorMutex() { | ||
//TODO: add mutex lock | ||
} | ||
|
||
void AllocatorWrapper::releaseAllocatorMutex() { | ||
//TODO: add mutex release | ||
} | ||
|
||
AllocatorWrapper::ChunkTypePointer AllocatorWrapper::allocate() { | ||
return allocator.allocate(); | ||
} | ||
|
||
void AllocatorWrapper::free(ChunkTypePointer chunk) { | ||
allocator.free(chunk); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#ifndef _ALLOCATOR_WRAPPER_H_ | ||
#define _ALLOCATOR_WRAPPER_H_ | ||
|
||
#include "SimpleStaticAllocator.h" | ||
|
||
namespace OS { | ||
|
||
class AllocatorWrapper { | ||
private: | ||
static constexpr size_t CHUNK_SIZE = 2; | ||
static constexpr size_t POOL_SIZE = 10; | ||
|
||
using ChunkType = uint8_t; | ||
using ChunkTypePointer = ChunkType *; | ||
|
||
private: | ||
static AllocatorLib::SimpleStaticAllocator<ChunkType, CHUNK_SIZE, POOL_SIZE> allocator; | ||
|
||
private: | ||
static void lockAllocatorMutex(); | ||
|
||
static void releaseAllocatorMutex(); | ||
|
||
public: | ||
static ChunkTypePointer allocate(); | ||
|
||
static void free(ChunkTypePointer chunk); | ||
}; | ||
|
||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
set(target "app") | ||
|
||
add_executable(${target} main.cpp AllocatorWrapper.cpp AllocatorWrapper.h) | ||
|
||
target_link_libraries(${target} PRIVATE simpleStaticAllocator) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#include "AllocatorWrapper.h" | ||
|
||
int main() | ||
{ | ||
auto chunk = OS::AllocatorWrapper::allocate(); | ||
OS::AllocatorWrapper::free(chunk); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
set(target "catch2") | ||
|
||
add_library(${target} src/catch_amalgamated.cpp) | ||
|
||
target_include_directories(${target} PUBLIC include) |
Oops, something went wrong.