From 8be3a8f7dc10dbc49dfcdeca572677ef1e00f714 Mon Sep 17 00:00:00 2001 From: Tycho Date: Fri, 23 May 2014 17:18:11 +0100 Subject: Implemented Allocation Pool use by cChunkData --- src/ChunkData.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/ChunkData.cpp') diff --git a/src/ChunkData.cpp b/src/ChunkData.cpp index 86b0c431c..31de364b9 100644 --- a/src/ChunkData.cpp +++ b/src/ChunkData.cpp @@ -4,7 +4,7 @@ cChunkData cChunkData::Copy() const { - cChunkData copy; + cChunkData copy(m_Pool); for (int i = 0; i < CHUNK_SECTION_NUM; i++) { if (m_Sections[i] != NULL) @@ -360,14 +360,14 @@ void cChunkData::SetSkyLight (const NIBBLETYPE * a_src) cChunkData::sChunkSection * cChunkData::Allocate() const { // TODO: use a allocation pool - return new cChunkData::sChunkSection; + return m_Pool.Allocate(); } void cChunkData::Free(cChunkData::sChunkSection * ptr) const { - delete ptr; + m_Pool.Free(ptr); } -- cgit v1.2.3 From 2a7d199df68d11f6fd1fa2b4186faa00d0e81676 Mon Sep 17 00:00:00 2001 From: Tycho Date: Sun, 25 May 2014 18:26:10 +0100 Subject: Fixed bad merge --- src/ChunkData.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/ChunkData.cpp') diff --git a/src/ChunkData.cpp b/src/ChunkData.cpp index 1bc3072c2..99421bc33 100644 --- a/src/ChunkData.cpp +++ b/src/ChunkData.cpp @@ -242,7 +242,7 @@ NIBBLETYPE cChunkData::GetSkyLight(int a_RelX, int a_RelY, int a_RelZ) const cChunkData cChunkData::Copy() const { cChunkData copy(m_Pool); - for (int i = 0; i < CHUNK_SECTION_NUM; i++) + for (size_t i = 0; i < CHUNK_SECTION_COUNT; i++) { if (m_Sections[i] != NULL) { @@ -432,7 +432,7 @@ void cChunkData::SetBlocks(const BLOCKTYPE * a_src) void cChunkData::SetMeta(const NIBBLETYPE * a_src) { - for (size_t i = 0; i < CHUNK_SECTION_NUM; i++) + for (size_t i = 0; i < CHUNK_SECTION_COUNT; i++) { const size_t segment_length = CHUNK_SECTION_HEIGHT * 16 * 16 / 2; if (m_Sections[i] != NULL) @@ -484,10 +484,10 @@ void cChunkData::SetMeta(const NIBBLETYPE * a_src) -void cChunkData::SetLight(const NIBBLETYPE * a_src) +void cChunkData::SetBlockLight(const NIBBLETYPE * a_src) { if (!a_src) return; - for (size_t i = 0; i < CHUNK_SECTION_NUM; i++) + for (size_t i = 0; i < CHUNK_SECTION_COUNT; i++) { const size_t segment_length = CHUNK_SECTION_HEIGHT * 16 * 16 / 2; if (m_Sections[i] != NULL) @@ -542,7 +542,7 @@ void cChunkData::SetLight(const NIBBLETYPE * a_src) void cChunkData::SetSkyLight (const NIBBLETYPE * a_src) { if (!a_src) return; - for (size_t i = 0; i < CHUNK_SECTION_NUM; i++) + for (size_t i = 0; i < CHUNK_SECTION_COUNT; i++) { const size_t segment_length = CHUNK_SECTION_HEIGHT * 16 * 16 / 2; if (m_Sections[i] != NULL) -- cgit v1.2.3 From 8bf37f3dd7ff017eedaac427b9291a9335d61efc Mon Sep 17 00:00:00 2001 From: Tycho Date: Sat, 14 Jun 2014 17:57:21 +0100 Subject: Fixed comments --- src/ChunkData.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/ChunkData.cpp') diff --git a/src/ChunkData.cpp b/src/ChunkData.cpp index 24a2c3e14..a80b1de0f 100644 --- a/src/ChunkData.cpp +++ b/src/ChunkData.cpp @@ -30,9 +30,9 @@ template inline bool IsAllValue(const T * a_Array, size_t a_NumElem cChunkData::cChunkData(cAllocationPool& a_Pool) : #if __cplusplus < 201103L // auto_ptr style interface for memory management - m_IsOwner(true) + m_IsOwner(true), #endif -m_Pool(a_Pool) + m_Pool(a_Pool) { for (size_t i = 0; i < NumSections; i++) { -- cgit v1.2.3 From f6af584efa60d23c06abdc86dbfdfc85da23a3dc Mon Sep 17 00:00:00 2001 From: Tycho Date: Sat, 14 Jun 2014 18:11:43 +0100 Subject: fixed const issue --- src/ChunkData.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/ChunkData.cpp') diff --git a/src/ChunkData.cpp b/src/ChunkData.cpp index a80b1de0f..d2903cff1 100644 --- a/src/ChunkData.cpp +++ b/src/ChunkData.cpp @@ -68,7 +68,7 @@ cChunkData::~cChunkData() // auto_ptr style interface for memory management cChunkData::cChunkData(const cChunkData & a_Other) : m_IsOwner(true), - m_Pool(other.m_Pool) + m_Pool(a_Other.m_Pool) { // Move contents and ownership from a_Other to this, pointer-wise: for (size_t i = 0; i < NumSections; i++) @@ -107,7 +107,7 @@ cChunkData::~cChunkData() m_Sections[i] = a_Other.m_Sections[i]; } a_Other.m_IsOwner = false; - ASSERT(&m_Pool == &other.m_Pool); + ASSERT(&m_Pool == &a_Other.m_Pool); return *this; } @@ -327,7 +327,7 @@ cChunkData cChunkData::Copy(void) const { if (m_Sections[i] != NULL) { - copy.m_Sections[i] = Allocate(); + copy.m_Sections[i] = copy.Allocate(); *copy.m_Sections[i] = *m_Sections[i]; } } -- cgit v1.2.3 From 6b99e556462fdbdf6a265c014fb03f070b0f1b25 Mon Sep 17 00:00:00 2001 From: Tycho Date: Sat, 14 Jun 2014 19:05:02 +0100 Subject: fixed spaces --- src/ChunkData.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/ChunkData.cpp') diff --git a/src/ChunkData.cpp b/src/ChunkData.cpp index d2903cff1..f9c263d88 100644 --- a/src/ChunkData.cpp +++ b/src/ChunkData.cpp @@ -27,7 +27,7 @@ template inline bool IsAllValue(const T * a_Array, size_t a_NumElem -cChunkData::cChunkData(cAllocationPool& a_Pool) : +cChunkData::cChunkData(cAllocationPool & a_Pool) : #if __cplusplus < 201103L // auto_ptr style interface for memory management m_IsOwner(true), -- cgit v1.2.3 From 94c48febd2f596648fc2616a8a577316a219b581 Mon Sep 17 00:00:00 2001 From: Tycho Date: Sat, 14 Jun 2014 19:46:34 +0100 Subject: Added generic Allocation Pool Interface --- src/ChunkData.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/ChunkData.cpp') diff --git a/src/ChunkData.cpp b/src/ChunkData.cpp index f9c263d88..03b0224a6 100644 --- a/src/ChunkData.cpp +++ b/src/ChunkData.cpp @@ -27,7 +27,7 @@ template inline bool IsAllValue(const T * a_Array, size_t a_NumElem -cChunkData::cChunkData(cAllocationPool & a_Pool) : +cChunkData::cChunkData(cAllocationPool & a_Pool) : #if __cplusplus < 201103L // auto_ptr style interface for memory management m_IsOwner(true), -- cgit v1.2.3