mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-04 20:17:42 +00:00
[other] added system.dispose for owned refs
(cherry picked from commit f310cf5250)
This commit is contained in:
@@ -75,6 +75,9 @@ proc nimRawDispose(p: pointer) {.compilerRtl.} =
|
||||
cstderr.rawWrite "[FATAL] unpaired dealloc\n"
|
||||
quit 1
|
||||
|
||||
template dispose*[T](x: owned(ref T)) = nimRawDispose(cast[pointer](x))
|
||||
#proc dispose*(x: pointer) = nimRawDispose(x)
|
||||
|
||||
proc nimDestroyAndDispose(p: pointer) {.compilerRtl.} =
|
||||
let d = cast[ptr PNimType](p)[].destructor
|
||||
if d != nil: cast[DestructorProc](d)(p)
|
||||
|
||||
Reference in New Issue
Block a user