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:
Axel Dörfler 2007-07-22 23:50:34 +00:00
parent 5286819920
commit 6a05ab0186
1 changed files with 19 additions and 1 deletions

View File

@ -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.
*
* Authors:
@ -42,6 +42,24 @@ ClientMemoryAllocator::ClientMemoryAllocator(ServerApp* application)
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);
}
}