Skip to content

Instantly share code, notes, and snippets.

@zah
Created December 3, 2011 23:53
Show Gist options
  • Select an option

  • Save zah/1428545 to your computer and use it in GitHub Desktop.

Select an option

Save zah/1428545 to your computer and use it in GitHub Desktop.
proc unsureAsgnRef(dest: ppointer, src: pointer) {.compilerproc, inline.} =
assertAllocatedPtr(src)
dest[] = src
proc asgnRef(dest: ppointer, src: pointer) {.compilerproc, inline.} =
dest[] = src
assertAllocatedPtr(src)
proc asgnRefNoCycle(dest: ppointer, src: pointer) {.compilerproc, inline.} =
dest[] = src
assertAllocatedPtr(src)
........
proc assertAllocatedPtr(p: pointer) {.compilerRtl, noinline.} =
var c = usrToCell(p)
sysAssert(isAllocatedPtr(gch.region, c), "bad GC pointer")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment