diff --git a/doc/destructors.md b/doc/destructors.md index 5344dfedea..0f7616d8b2 100644 --- a/doc/destructors.md +++ b/doc/destructors.md @@ -761,7 +761,7 @@ used to specialize the object traversal in order to avoid deep recursions: if x.left != nil: s.add(x.left) if x.right != nil: s.add(x.right) # free the memory explicitly: - `=dispose`(x) + deallocRef(x) # notice how even the destructor for 's' is not called implicitly # anymore thanks to .nodestroy, so we have to call it on our own: `=destroy`(s) diff --git a/lib/system/arc.nim b/lib/system/arc.nim index 5994f84ac2..65f50d67b7 100644 --- a/lib/system/arc.nim +++ b/lib/system/arc.nim @@ -192,7 +192,7 @@ proc nimRawDispose(p: pointer, alignment: int) {.compilerRtl.} = let hdrSize = align(sizeof(RefHeader), alignment) alignedDealloc(p -! hdrSize, alignment) -template `=disposeHidden`*[T](x: owned(ref T)) = nimRawDispose(cast[pointer](x), T.alignOf) +template `deallocRef`*[T](x: owned(ref T)) = nimRawDispose(cast[pointer](x), T.alignOf) #proc dispose*(x: pointer) = nimRawDispose(x) proc nimDestroyAndDispose(p: pointer) {.compilerRtl, quirky, raises: [].} = diff --git a/tests/destructor/tbintree2.nim b/tests/destructor/tbintree2.nim index 9959309285..a2962a7787 100644 --- a/tests/destructor/tbintree2.nim +++ b/tests/destructor/tbintree2.nim @@ -57,7 +57,7 @@ proc `=destroy`(t: var Tree) {.nodestroy.} = let x = s.pop if x.left != nil: s.add(x.left) if x.right != nil: s.add(x.right) - `=disposeHidden`(x) + deallocRef(x) `=destroy`(s) proc hasValue(self: var Tree, x: int32): bool =