A stack of space map tweaks.

new_block() is now a concrete method implemented using the virtual
find_free() and inc() methods.

recursive space map is better at giving correct reference counts.
This commit is contained in:
Joe Thornber
2013-04-23 10:57:47 +01:00
parent e0230c5c55
commit d8a208cbc8
7 changed files with 107 additions and 104 deletions

View File

@ -72,17 +72,14 @@ namespace persistent_data {
nr_free_++;
}
maybe_block new_block(span_iterator &it) {
maybe_block find_free(span_iterator &it) {
for (maybe_span ms = it.first(); ms; ms = it.next()) {
for (block_address b = ms->first; b < ms->second; b++) {
if (b >= counts_.size())
throw std::runtime_error("block out of bounds");
if (!counts_[b]) {
counts_[b] = 1;
nr_free_--;
if (!counts_[b])
return maybe_block(b);
}
}
}