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/Copies.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'tests/ChunkData/Copies.cpp') 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); -- 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/Copies.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/ChunkData/Copies.cpp') diff --git a/tests/ChunkData/Copies.cpp b/tests/ChunkData/Copies.cpp index 6f5d40792..4a672380f 100644 --- a/tests/ChunkData/Copies.cpp +++ b/tests/ChunkData/Copies.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 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/Copies.cpp | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'tests/ChunkData/Copies.cpp') diff --git a/tests/ChunkData/Copies.cpp b/tests/ChunkData/Copies.cpp index 4a672380f..440819e91 100644 --- a/tests/ChunkData/Copies.cpp +++ b/tests/ChunkData/Copies.cpp @@ -6,14 +6,19 @@ 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())); + class cMockAllocationPool + : public cAllocationPool + { + 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