Skip to content

Commit cb233fb

Browse files
committed
Add local memory for testing purposes.
1 parent a724c94 commit cb233fb

3 files changed

Lines changed: 35 additions & 0 deletions

File tree

catkit_core/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ add_library(catkit_core STATIC
3737
FreeListAllocator.cpp
3838
MessageBroker.cpp
3939
UuidGenerator.cpp
40+
LocalMemory.cpp
4041
proto/core.pb.cc
4142
proto/logging.pb.cc
4243
proto/testbed.pb.cc

catkit_core/LocalMemory.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#include "LocalMemory.h"
2+
3+
LocalMemory::LocalMemory(std::size_t num_bytes)
4+
: m_Memory(new char[num_bytes])
5+
{
6+
}
7+
8+
LocalMemory::~LocalMemory()
9+
{
10+
delete[] m_Memory;
11+
}
12+
13+
void *LocalMemory::GetAddress(std::size_t offset)
14+
{
15+
return m_Memory + offset;
16+
}

catkit_core/LocalMemory.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#ifndef LOCAL_MEMORY_H
2+
#define LOCAL_MEMORY_H
3+
4+
#include "Memory.h"
5+
6+
class LocalMemory : public Memory
7+
{
8+
public:
9+
LocalMemory(std::size_t num_bytes);
10+
virtual ~LocalMemory();
11+
12+
virtual void *GetAddress(std::size_t offset = 0);
13+
14+
private:
15+
char *m_Memory;
16+
};
17+
18+
#endif // LOCAL_MEMORY_H

0 commit comments

Comments
 (0)