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

This commit is contained in:
Araq
2019-03-01 14:50:41 +01:00
parent ca7980f301
commit e1d17ece5b
3 changed files with 25 additions and 25 deletions

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}

View File

@@ -80,7 +80,7 @@ type
cap: int
region: Allocator
proc newSeqPayload(cap, elemSize: int): pointer {.compilerRtl.} =
proc newSeqPayload(cap, elemSize: int): pointer {.compilerRtl, raises: [].} =
# we have to use type erasure here as Nim does not support generic
# compilerProcs. Oh well, this will all be inlined anyway.
if cap > 0:
@@ -93,7 +93,7 @@ proc newSeqPayload(cap, elemSize: int): pointer {.compilerRtl.} =
result = nil
proc prepareSeqAdd(len: int; p: pointer; addlen, elemSize: int): pointer {.
compilerRtl, noSideEffect.} =
compilerRtl, noSideEffect, raises: [].} =
{.noSideEffect.}:
if len+addlen <= len:
result = p