summary refs log tree commit diff stats
path: root/lib/system/gc_stack.nim
diff options
context:
space:
mode:
Diffstat (limited to 'lib/system/gc_stack.nim')
-rw-r--r--lib/system/gc_stack.nim7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/system/gc_stack.nim b/lib/system/gc_stack.nim
index 5f72b8959..3eda08df9 100644
--- a/lib/system/gc_stack.nim
+++ b/lib/system/gc_stack.nim
@@ -79,6 +79,7 @@ template withRegion*(r: MemRegion; body: untyped) =
   try:
     body
   finally:
+    r = tlRegion
     tlRegion = oldRegion
 
 template inc(p: pointer, s: int) =
@@ -464,4 +465,10 @@ proc getFreeMem(): int = tlRegion.remaining
 proc getTotalMem(): int =
   result = tlRegion.totalSize
 
+proc getOccupiedMem*(r: MemRegion): int =
+  result = r.totalSize - r.remaining
+proc getFreeMem*(r: MemRegion): int = r.remaining
+proc getTotalMem*(r: MemRegion): int =
+  result = r.totalSize
+
 proc setStackBottom(theStackBottom: pointer) = discard