* 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
This commit is contained in:
Ingo Weinhold
2007-03-28 22:58:02 +00:00
parent 3e414ec314
commit f5a324b063
@@ -160,6 +160,7 @@ block_cache::block_cache(int _fd, off_t numBlocks, size_t blockSize,
fd(_fd), fd(_fd),
max_blocks(numBlocks), max_blocks(numBlocks),
block_size(blockSize), block_size(blockSize),
allocated_block_count(0),
next_transaction_id(1), next_transaction_id(1),
last_transaction(NULL), last_transaction(NULL),
transaction_hash(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)); TRACE(("block_cache: remove up to %ld unused blocks\n", count));
cached_block *next = NULL; for (block_list::Iterator it = unused_blocks.GetIterator();
for (cached_block *block = unused_blocks.First(); block != NULL; cached_block *block = it.Next();) {
block = next) {
next = block->next;
if (maxAccessed < block->accessed) if (maxAccessed < block->accessed)
continue; continue;
@@ -300,7 +299,7 @@ block_cache::RemoveUnusedBlocks(int32 maxAccessed, int32 count)
write_cached_block(this, block, false); write_cached_block(this, block, false);
// remove block from lists // remove block from lists
unused_blocks.Remove(block); it.Remove();
hash_remove(hash, block); hash_remove(hash, block);
FreeBlock(block); FreeBlock(block);