From b68eb1cad0dc13d497ae0e620dd2178a6367644c Mon Sep 17 00:00:00 2001 From: Ico Doornekamp Date: Thu, 23 Jan 2020 14:25:22 +0100 Subject: Removed lib/system/allocators.nim. seqs_v2 and strs_v2 now uses allocShared0. (#13190) * Cleanup, remove lib/system/allocators.nim. seqs_v2 and strs_v2 now use allocShared0 by default. * Fixed -d:useMalloc allocShared / reallocShared / deallocShared. These now use the alloc/dealloc/realloc implementation that also takes care of zeroing memory at realloc. * Removed debug printfs * Removed unpairedEnvAllocs() from tests/destructor/tnewruntime_misc * More mmdisp cleanups. The shared allocators do not need to zero memory or throw since the regular ones already do that * Introduced realloc0 and reallocShared0, these procs are now used by strs_v2 and seqs_v2. This also allowed the -d:useMalloc allocator to drop the extra header with allocation length. * Moved strs_v2/seqs_v2 'allocated' flag into 'cap' field * Added 'getAllocStats()' to get low level alloc/dealloc counters. Enable with -d:allocStats * *allocShared implementations for boehm and go allocators now depend on the proper *allocImpl procs --- lib/system/ansi_c.nim | 2 ++ 1 file changed, 2 insertions(+) (limited to 'lib/system/ansi_c.nim') diff --git a/lib/system/ansi_c.nim b/lib/system/ansi_c.nim index 55e004f6e..6649e9517 100644 --- a/lib/system/ansi_c.nim +++ b/lib/system/ansi_c.nim @@ -140,6 +140,8 @@ proc c_sprintf*(buf, frmt: cstring): cint {. proc c_malloc*(size: csize_t): pointer {. importc: "malloc", header: "".} +proc c_calloc*(nmemb, size: csize_t): pointer {. + importc: "calloc", header: "".} proc c_free*(p: pointer) {. importc: "free", header: "".} proc c_realloc*(p: pointer, newsize: csize_t): pointer {. -- cgit 1.4.1-2-gfad0