mirror of
https://github.com/nim-lang/Nim.git
synced 2026-02-12 22:33:49 +00:00
since nobody knows about =dispose, rename the existing proc to deallocRef which is a much better name anyway
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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: [].} =
|
||||
|
||||
@@ -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 =
|
||||
|
||||
Reference in New Issue
Block a user