Changeset - ec2bd041e1de
[Not reviewed]
longmem
0 2 0
Hasan Yavuz Ă–ZDERYA - 8 years ago 2017-08-12 12:58:41
hy@ozderya.net
added clear method
2 files changed with 19 insertions and 3 deletions:
0 comments (0 inline, 0 general)
src/chunkedbuffer.cpp
Show inline comments
 
@@ -58,6 +58,22 @@ void ChunkedBuffer::addSamples(double* s
 
    _size += size;
 
}
 

	
 
void ChunkedBuffer::clear()
 
{
 
    // delete all chunks
 
    for (auto chunk : chunks)
 
    {
 
        delete chunk;
 
    }
 
    chunks.clear();
 

	
 
    numChunks = 0;
 
    _size = 0;
 

	
 
    // create first chunk
 
    addNewChunk();
 
}
 

	
 
DataChunk* ChunkedBuffer::addNewChunk()
 
{
 
    auto chunk = new DataChunk(_size, CHUNK_SIZE);
tests/test.cpp
Show inline comments
 
@@ -116,9 +116,9 @@ TEST_CASE("ChunkedBuffer adding data and
 
    REQUIRE(b.size() == CHUNK_SIZE*4);
 
    REQUIRE(b.boundingRect() == QRectF(0,10,CHUNK_SIZE*4,10));
 

	
 
    // TODO: clear
 
    // b.clear();
 
    // REQUIRE(b.size() == 0);
 
    // clear
 
    b.clear();
 
    REQUIRE(b.size() == 0);
 
}
 

	
 
TEST_CASE("ChunkedBuffer accessing data", "[memory]")
0 comments (0 inline, 0 general)