From 2ed089a83f59d6558311476fcc5c52c3bbd7ebdd Mon Sep 17 00:00:00 2001 From: Joe Thornber Date: Tue, 26 May 2020 08:29:52 +0100 Subject: [PATCH] [space-map] Add new virtual methods to inc or dec by a specific amount. Provide default implementation that just loops --- persistent-data/space_map.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/persistent-data/space_map.h b/persistent-data/space_map.h index c3f66da..eacc558 100644 --- a/persistent-data/space_map.h +++ b/persistent-data/space_map.h @@ -48,6 +48,17 @@ namespace persistent_data { virtual void inc(block_address b) = 0; virtual void dec(block_address b) = 0; + // slow default implementation + virtual void inc(block_address b, uint32_t count) { + for (uint32_t i = 0; i < count; i++) + inc(b); + } + + virtual void dec(block_address b, uint32_t count) { + for (uint32_t i = 0; i < count; i++) + dec(b); + } + // FIXME: change these to return an optional, failure is // not that rare if we're restricting the area that's // searched.