From f5a324b0633c0b03ea190a13c40d804d11b8da92 Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Wed, 28 Mar 2007 22:58:02 +0000 Subject: [PATCH] * Fixed iteration in block_cache::RemoveUnusedBlocks() as in r20459 for the kernel implementation. * block_cache::allocated_block_count was not initialized. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20460 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../file_systems/userlandfs/server/haiku_block_cache.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/add-ons/kernel/file_systems/userlandfs/server/haiku_block_cache.cpp b/src/add-ons/kernel/file_systems/userlandfs/server/haiku_block_cache.cpp index 4030386711..2c1e12ac32 100644 --- a/src/add-ons/kernel/file_systems/userlandfs/server/haiku_block_cache.cpp +++ b/src/add-ons/kernel/file_systems/userlandfs/server/haiku_block_cache.cpp @@ -160,6 +160,7 @@ block_cache::block_cache(int _fd, off_t numBlocks, size_t blockSize, fd(_fd), max_blocks(numBlocks), block_size(blockSize), + allocated_block_count(0), next_transaction_id(1), last_transaction(NULL), transaction_hash(NULL), @@ -284,10 +285,8 @@ block_cache::RemoveUnusedBlocks(int32 maxAccessed, int32 count) { TRACE(("block_cache: remove up to %ld unused blocks\n", count)); - cached_block *next = NULL; - for (cached_block *block = unused_blocks.First(); block != NULL; - block = next) { - next = block->next; + for (block_list::Iterator it = unused_blocks.GetIterator(); + cached_block *block = it.Next();) { if (maxAccessed < block->accessed) continue; @@ -300,7 +299,7 @@ block_cache::RemoveUnusedBlocks(int32 maxAccessed, int32 count) write_cached_block(this, block, false); // remove block from lists - unused_blocks.Remove(block); + it.Remove(); hash_remove(hash, block); FreeBlock(block);