# HG changeset patch # User Paul Boddie # Date 1616277403 -3600 # Node ID b66053e4b765f3591066ebd9a66cecfbe6c2179f # Parent 7e00350a9add2f43a449f55c401878cc86f429c8 Added a method to indicate whether memory was actually allocated. diff -r 7e00350a9add -r b66053e4b765 memory_preallocated.cc --- a/memory_preallocated.cc Sat Mar 20 17:05:31 2021 +0100 +++ b/memory_preallocated.cc Sat Mar 20 22:56:43 2021 +0100 @@ -38,6 +38,15 @@ delete *it; } +/* Return whether memory has been allocated. */ + +bool MemoryPreallocated::allocated() +{ + std::lock_guard guard(_lock); + + return !(_free.empty() && _used.empty()); +} + /* Allocate a new region of the configured size rounded to the nearest page. */ Region *MemoryPreallocated::region() diff -r 7e00350a9add -r b66053e4b765 memory_preallocated.h --- a/memory_preallocated.h Sat Mar 20 17:05:31 2021 +0100 +++ b/memory_preallocated.h Sat Mar 20 22:56:43 2021 +0100 @@ -21,6 +21,8 @@ virtual ~MemoryPreallocated(); + virtual bool allocated(); + virtual Region *region(); virtual void release(Region *region);