.cursor implementation (#12637)

* cursors: first implementation
* added currently failing test
* .cursor works for doubly linked lists
* make -d:useMalloc work again
* added code to nil out refs in a destructor
* it's now called --gc:arc
* renderer.nim: render nkBreakState properly
* make simple closure iterators work without leaking
This commit is contained in:
Andreas Rumpf 2019-11-12 15:05:36 +01:00 • committed by GitHub
commit dfb020b174
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 106 additions and 36 deletions

View file

@ -43,7 +43,7 @@ proc getLocalAllocator*(): Allocator =
result = addr allocatorStorage
result.alloc = proc (a: Allocator; size: int; alignment: int = 8): pointer {.nimcall, raises: [].} =
when defined(useMalloc) and not defined(nimscript):
result = c_malloc(size)
result = c_malloc(cuint size)
# XXX do we need this?
nimZeroMem(result, size)
else:
@ -57,7 +57,7 @@ proc getLocalAllocator*(): Allocator =
inc a.deallocCount
result.realloc = proc (a: Allocator; p: pointer; oldSize, newSize: int): pointer {.nimcall, raises: [].} =
when defined(useMalloc) and not defined(nimscript):
result = c_realloc(p, newSize)
result = c_realloc(p, cuint newSize)
else:
result = system.realloc(p, newSize)
nimZeroMem(result +! oldSize, newSize - oldSize)

View file

@ -47,7 +47,7 @@ proc nimNewObj(size: int): pointer {.compilerRtl.} =
when defined(nimscript):
discard
elif defined(useMalloc):
var orig = c_malloc(s)
var orig = c_malloc(cuint s)
nimZeroMem(orig, s)
result = orig +! sizeof(RefHeader)
else: