My ClientMemoryAllocator implementation wasn't complete and badly leaked memory.
It now at least frees all memory when the object is deleted. Reported by Jonas - thanks! git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21687 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2006, Haiku, Inc. All Rights Reserved.
|
* Copyright 2006-2007, Haiku, Inc. All Rights Reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -42,6 +42,24 @@ ClientMemoryAllocator::ClientMemoryAllocator(ServerApp* application)
|
|||||||
|
|
||||||
ClientMemoryAllocator::~ClientMemoryAllocator()
|
ClientMemoryAllocator::~ClientMemoryAllocator()
|
||||||
{
|
{
|
||||||
|
// delete all areas and chunks/blocks that are still allocated
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
struct block* block = fFreeBlocks.RemoveHead();
|
||||||
|
if (block == NULL)
|
||||||
|
break;
|
||||||
|
|
||||||
|
free(block);
|
||||||
|
}
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
struct chunk* chunk = fChunks.RemoveHead();
|
||||||
|
if (chunk == NULL)
|
||||||
|
break;
|
||||||
|
|
||||||
|
delete_area(chunk->area);
|
||||||
|
free(chunk);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user