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/ArraytoCoord.cpp | 15 ++++++++++++--- tests/ChunkData/Coordinates.cpp | 16 ++++++++++++---- tests/ChunkData/Copies.cpp | 18 +++++++++++++----- tests/ChunkData/creatable.cpp | 10 +++++++++- 4 files changed, 46 insertions(+), 13 deletions(-) (limited to 'tests') diff --git a/tests/ChunkData/ArraytoCoord.cpp b/tests/ChunkData/ArraytoCoord.cpp index fe82a3a7b..04e6fbc5a 100644 --- a/tests/ChunkData/ArraytoCoord.cpp +++ b/tests/ChunkData/ArraytoCoord.cpp @@ -6,9 +6,18 @@ 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())); + { + // Test first segment - cChunkData buffer; + cChunkData buffer(Pool); BLOCKTYPE* SrcBlockBuffer = new BLOCKTYPE[16 * 16 * 256]; memset(SrcBlockBuffer, 0x00, 16 * 16 * 256); @@ -45,7 +54,7 @@ int main(int argc, char** argv) { // test following segment - cChunkData buffer; + cChunkData buffer(Pool); BLOCKTYPE* SrcBlockBuffer = new BLOCKTYPE[16 * 16 * 256]; memset(SrcBlockBuffer, 0x00, 16 * 16 * 256); @@ -82,7 +91,7 @@ int main(int argc, char** argv) { // test zeros - cChunkData buffer; + cChunkData buffer(Pool); BLOCKTYPE* SrcBlockBuffer = new BLOCKTYPE[16 * 16 * 256]; memset(SrcBlockBuffer, 0x00, 16 * 16 * 256); 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 diff --git a/tests/ChunkData/Copies.cpp b/tests/ChunkData/Copies.cpp index 145ffd8e0..1ccda9d9c 100644 --- a/tests/ChunkData/Copies.cpp +++ b/tests/ChunkData/Copies.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); buffer.SetBlock(3,1,4,0xDE); buffer.SetMeta(3,1,4,0xA); @@ -47,7 +55,7 @@ int main(int argc, char** argv) } { - cChunkData buffer; + cChunkData buffer(Pool); NIBBLETYPE * SrcNibbleBuffer = new NIBBLETYPE[16 * 16 * 256/2]; for (int i = 0; i < 16 * 16 * 256 / 2; i += 4) @@ -80,7 +88,7 @@ int main(int argc, char** argv) } { - cChunkData buffer; + cChunkData buffer(Pool); NIBBLETYPE * SrcNibbleBuffer = new NIBBLETYPE[16 * 16 * 256/2]; for (int i = 0; i < 16 * 16 * 256 / 2; i += 4) @@ -114,7 +122,7 @@ int main(int argc, char** argv) } { - cChunkData buffer; + cChunkData buffer(Pool); NIBBLETYPE * SrcNibbleBuffer = new NIBBLETYPE[16 * 16 * 256/2]; for (int i = 0; i < 16 * 16 * 256 / 2; i += 4) @@ -148,7 +156,7 @@ int main(int argc, char** argv) } { - cChunkData buffer; + cChunkData buffer(Pool); BLOCKTYPE * SrcBlockBuffer = new BLOCKTYPE[16 * 16 * 256]; memset(SrcBlockBuffer, 0x00, 16 * 16 * 256); diff --git a/tests/ChunkData/creatable.cpp b/tests/ChunkData/creatable.cpp index 74025cb14..78b1a82d1 100644 --- a/tests/ChunkData/creatable.cpp +++ b/tests/ChunkData/creatable.cpp @@ -4,6 +4,14 @@ int main(int argc, char** argv) { - cChunkData buffer; + class cStarvationCallbacks + : public cAllocationPool::cStarvationCallbacks + { + virtual void OnStartingUsingBuffer() {} + virtual void OnStopUsingBuffer() {} + virtual void OnBufferEmpty() {} + }; + cAllocationPool Pool(std::auto_ptr::cStarvationCallbacks>(new cStarvationCallbacks())); + cChunkData buffer(Pool); return 0; } -- cgit v1.2.3