alloc et al don't have any effect; fixes #9746

This commit is contained in:
Araq 2019-03-01 14:50:41 +01:00
commit e1d17ece5b

View file

@ -13,10 +13,10 @@ type
ZerosMem ## the allocator always zeros the memory on an allocation
Allocator* = ptr AllocatorObj
AllocatorObj* {.inheritable.} = object
alloc*: proc (a: Allocator; size: int; alignment: int = 8): pointer {.nimcall.}
dealloc*: proc (a: Allocator; p: pointer; size: int) {.nimcall.}
realloc*: proc (a: Allocator; p: pointer; oldSize, newSize: int): pointer {.nimcall.}
deallocAll*: proc (a: Allocator) {.nimcall.}
alloc*: proc (a: Allocator; size: int; alignment: int = 8): pointer {.nimcall, raises: [], tags: [].}
dealloc*: proc (a: Allocator; p: pointer; size: int) {.nimcall, raises: [], tags: [].}
realloc*: proc (a: Allocator; p: pointer; oldSize, newSize: int): pointer {.nimcall, raises: [], tags: [].}
deallocAll*: proc (a: Allocator) {.nimcall, raises: [], tags: [].}
flags*: set[AllocatorFlag]
name*: cstring
allocCount: int
@ -31,13 +31,13 @@ proc getLocalAllocator*(): Allocator =
result = localAllocator
if result == nil:
result = addr allocatorStorage
result.alloc = proc (a: Allocator; size: int; alignment: int = 8): pointer {.nimcall.} =
result.alloc = proc (a: Allocator; size: int; alignment: int = 8): pointer {.nimcall, raises: [].} =
result = system.alloc(size)
inc a.allocCount
result.dealloc = proc (a: Allocator; p: pointer; size: int) {.nimcall.} =
result.dealloc = proc (a: Allocator; p: pointer; size: int) {.nimcall, raises: [].} =
system.dealloc(p)
inc a.deallocCount
result.realloc = proc (a: Allocator; p: pointer; oldSize, newSize: int): pointer {.nimcall.} =
result.realloc = proc (a: Allocator; p: pointer; oldSize, newSize: int): pointer {.nimcall, raises: [].} =
result = system.realloc(p, newSize)
result.deallocAll = nil
result.flags = {ThreadLocal}