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 --- tests/ChunkData/Coordinates.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'tests/ChunkData/Coordinates.cpp') diff --git a/tests/ChunkData/Coordinates.cpp b/tests/ChunkData/Coordinates.cpp index c0c46000e..0a7d5e3f1 100644 --- a/tests/ChunkData/Coordinates.cpp +++ b/tests/ChunkData/Coordinates.cpp @@ -6,8 +6,16 @@ int main(int argc, char** argv) { + class cStarvationCallbacks + : public cAllocationPool::cStarvationCallbacks { - cChunkData buffer; + virtual void OnStartingUsingBuffer() {} + virtual void OnStopUsingBuffer() {} + virtual void OnBufferEmpty() {} + }; + cAllocationPool Pool(std::auto_ptr::cStarvationCallbacks>(new cStarvationCallbacks())); + { + cChunkData buffer(Pool); // Empty chunks buffer.SetBlock(0,0,0, 0xAB); @@ -105,7 +113,7 @@ int main(int argc, char** argv) } { - cChunkData buffer; + cChunkData buffer(Pool); // Zero's buffer.SetBlock(0,0,0, 0x0); @@ -122,9 +130,9 @@ int main(int argc, char** argv) { // Operator = - cChunkData buffer; + cChunkData buffer(Pool); buffer.SetBlock(0,0,0,0x42); - cChunkData copy; + cChunkData copy(Pool); #if __cplusplus < 201103L copy = buffer; #else -- 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 --- tests/ChunkData/Coordinates.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'tests/ChunkData/Coordinates.cpp') diff --git a/tests/ChunkData/Coordinates.cpp b/tests/ChunkData/Coordinates.cpp index f94532183..3a4477fd6 100644 --- a/tests/ChunkData/Coordinates.cpp +++ b/tests/ChunkData/Coordinates.cpp @@ -8,8 +8,14 @@ int main(int argc, char** argv) { class cStarvationCallbacks : public cAllocationPool::cStarvationCallbacks + { + virtual void OnStartingUsingBuffer() {} + virtual void OnStopUsingBuffer() {} + virtual void OnBufferEmpty() {} + }; + cAllocationPool Pool(std::auto_ptr::cStarvationCallbacks>(new cStarvationCallbacks())); { - cChunkData buffer; + cChunkData buffer(Pool); // Empty chunks buffer.SetBlock(0, 0, 0, 0xAB); -- cgit v1.2.3 From 0310a50192fcbd4a9e5ec03c98a0d7f33457df54 Mon Sep 17 00:00:00 2001 From: Tycho Date: Sat, 14 Jun 2014 18:43:36 +0100 Subject: fixed spaces --- tests/ChunkData/Coordinates.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/ChunkData/Coordinates.cpp') diff --git a/tests/ChunkData/Coordinates.cpp b/tests/ChunkData/Coordinates.cpp index d5abbb143..66fab46ab 100644 --- a/tests/ChunkData/Coordinates.cpp +++ b/tests/ChunkData/Coordinates.cpp @@ -7,13 +7,13 @@ int main(int argc, char** argv) { class cStarvationCallbacks - : public cAllocationPool::cStarvationCallbacks + : public cAllocationPool::cStarvationCallbacks { virtual void OnStartingUsingBuffer() {} virtual void OnStopUsingBuffer() {} virtual void OnBufferEmpty() {} }; - cAllocationPool Pool(std::auto_ptr::cStarvationCallbacks>(new cStarvationCallbacks())); + cAllocationPool Pool(std::auto_ptr::cStarvationCallbacks>(new cStarvationCallbacks())); { cChunkData buffer(Pool); -- 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 --- tests/ChunkData/Coordinates.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/ChunkData/Coordinates.cpp') diff --git a/tests/ChunkData/Coordinates.cpp b/tests/ChunkData/Coordinates.cpp index 66fab46ab..1ac600f82 100644 --- a/tests/ChunkData/Coordinates.cpp +++ b/tests/ChunkData/Coordinates.cpp @@ -144,7 +144,7 @@ int main(int argc, char** argv) #else copy = std::move(copy); #endif - testassert(copy.GetBlock(0,0,0) == 0x42); + testassert(copy.GetBlock(0, 0, 0) == 0x42); } return 0; -- 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 --- tests/ChunkData/Coordinates.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'tests/ChunkData/Coordinates.cpp') diff --git a/tests/ChunkData/Coordinates.cpp b/tests/ChunkData/Coordinates.cpp index 1ac600f82..b3c66dde5 100644 --- a/tests/ChunkData/Coordinates.cpp +++ b/tests/ChunkData/Coordinates.cpp @@ -6,14 +6,19 @@ int main(int argc, char** argv) { - class cStarvationCallbacks - : public cAllocationPool::cStarvationCallbacks + class cMockAllocationPool + : public cAllocationPool { - virtual void OnStartingUsingBuffer() {} - virtual void OnStopUsingBuffer() {} - virtual void OnBufferEmpty() {} - }; - cAllocationPool Pool(std::auto_ptr::cStarvationCallbacks>(new cStarvationCallbacks())); + virtual cChunkData::sChunkSection * Allocate() + { + return new cChunkData::sChunkSection(); + } + + virtual void Free(cChunkData::sChunkSection * a_Ptr) + { + delete a_Ptr; + } + } Pool; { cChunkData buffer(Pool); -- cgit v1.2.3