summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorEugen Wissner <belka@caraus.de>2017-01-14 21:48:21 +0100
committerEugen Wissner <belka@caraus.de>2017-01-14 21:48:21 +0100
commit48205b2fc92292329adb561cf439412b76ca462f (patch)
tree07e08e27b64670a64dad2ad2649305ac2f2982e9 /source
parentf5fe7bec4af2fc98be1a080bd890c862dad6f9d5 (diff)
downloadtanya-48205b2fc92292329adb561cf439412b76ca462f.tar.gz
MmapPool: Add invariant
Add invariant to ensure blocks are linked correctly since this error appeared several times.
Diffstat (limited to 'source')
-rw-r--r--source/tanya/memory/mmappool.d17
1 files changed, 16 insertions, 1 deletions
diff --git a/source/tanya/memory/mmappool.d b/source/tanya/memory/mmappool.d
index 804954b..2bc3cfe 100644
--- a/source/tanya/memory/mmappool.d
+++ b/source/tanya/memory/mmappool.d
@@ -3,7 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/**
- * Copyright: Eugene Wissner 2016.
+ * Copyright: Eugene Wissner 2016-2017.
* License: $(LINK2 https://www.mozilla.org/en-US/MPL/2.0/,
* Mozilla Public License, v. 2.0).
* Authors: $(LINK2 mailto:info@caraus.de, Eugene Wissner)
@@ -50,6 +50,21 @@ else version (Windows)
*/
final class MmapPool : Allocator
{
+ invariant
+ {
+ for (auto r = &head; *r !is null; r = &((*r).next))
+ {
+ auto block = cast(Block) (cast(void*) *r + RegionEntry.sizeof);
+ do
+ {
+ assert(block.prev is null || block.prev.next is block);
+ assert(block.next is null || block.next.prev is block);
+ assert(block.region is *r);
+ }
+ while ((block = block.next) !is null);
+ }
+ }
+
/**
* Allocates $(D_PARAM size) bytes of memory.
*