summary refs log tree commit diff stats
path: root/lib/system
diff options
context:
space:
mode:
authorLemonBoy <LemonBoy@users.noreply.github.com>2018-10-12 08:56:14 +0200
committerAndreas Rumpf <rumpf_a@web.de>2018-10-12 08:56:14 +0200
commit71636059e98ec83bbdb61d9b2627b948670475e8 (patch)
treec2c456af22a6ab6001f3109ee427039491f44a7d /lib/system
parentfab4d38411d8f658a587bb34568fc9ec1887462e (diff)
downloadNim-71636059e98ec83bbdb61d9b2627b948670475e8.tar.gz
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
Diffstat (limited to 'lib/system')
-rw-r--r--lib/system/dyncalls.nim8
1 files changed, 4 insertions, 4 deletions
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: "<stdio.h>".}
 
-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)