From 71636059e98ec83bbdb61d9b2627b948670475e8 Mon Sep 17 00:00:00 2001 From: LemonBoy Date: Fri, 12 Oct 2018 08:56:14 +0200 Subject: Avoid memory allocation during dynlib loading (#9320) By using `write` instead of `rawWrite` we'd end up asking the compiler to generate the GC dynlib _while_ we were already generating another dynlib! Fixes #9123 --- lib/system/dyncalls.nim | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'lib/system') diff --git a/lib/system/dyncalls.nim b/lib/system/dyncalls.nim index 8fb694829..d6c361b2c 100644 --- a/lib/system/dyncalls.nim +++ b/lib/system/dyncalls.nim @@ -20,7 +20,7 @@ const proc c_fwrite(buf: pointer, size, n: csize, f: File): cint {. importc: "fwrite", header: "".} -proc rawWrite(f: File, s: string) = +proc rawWrite(f: File, s: string|cstring) = # we cannot throw an exception here! discard c_fwrite(cstring(s), 1, s.len, f) @@ -43,7 +43,7 @@ proc nimLoadLibraryError(path: string) = proc procAddrError(name: cstring) {.noinline.} = # carefully written to avoid memory allocation: stderr.rawWrite("could not import: ") - stderr.write(name) + stderr.rawWrite(name) stderr.rawWrite("\n") quit(1) @@ -86,7 +86,7 @@ when defined(posix): when defined(nimDebugDlOpen): let error = dlerror() if error != nil: - stderr.write(error) + stderr.rawWrite(error) stderr.rawWrite("\n") proc nimGetProcAddr(lib: LibHandle, name: cstring): ProcAddr = @@ -181,7 +181,7 @@ elif defined(nintendoswitch): proc nimGetProcAddr(lib: LibHandle, name: cstring): ProcAddr = stderr.rawWrite("nimGetProAddr not implemented") - stderr.write(name) + stderr.rawWrite(name) stderr.rawWrite("\n") quit(1) -- cgit 1.4.1-2-gfad0