summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/memory.cpp11
-rw-r--r--src/memory.hpp1
2 files changed, 12 insertions, 0 deletions
diff --git a/src/memory.cpp b/src/memory.cpp
index 775b30a..21780f2 100644
--- a/src/memory.cpp
+++ b/src/memory.cpp
@@ -94,3 +94,14 @@ void pke::EndTransientBucket(pke::MemBucket *bkt) {
bucketHead--;
}
}
+
+void pke::Flush() {
+ for (long i = bucketHead - 2; i > -1; --i) {
+ if (buckets[i].head != 0) break;
+ if (buckets[i+1].head != 0) break;
+ if (buckets[i].transient == true) break;
+ if (buckets[i+1].transient == true) break;
+ bucketHead--;
+ DestroyBucket(&buckets[i + 1]);
+ }
+}
diff --git a/src/memory.hpp b/src/memory.hpp
index 2a244f6..1d117f3 100644
--- a/src/memory.hpp
+++ b/src/memory.hpp
@@ -20,6 +20,7 @@ void PkeDelete(const void *ptr, std::size_t sz, MemBucket *bkt);
MemBucket *BeginTransientBucket(int64_t sz = DEFAULT_BUCKET_SIZE); // 256MB
void EndTransientBucket(MemBucket *bkt);
+void Flush();
template <typename T>
inline T *PkeNew() {