GC'ed wide strings for windows

This commit is contained in:
Araq 2013-05-20 02:17:24 +02:00
commit baf89e3d66
7 changed files with 155 additions and 297 deletions

View file

@ -168,18 +168,14 @@ when defined(windows) and not defined(useWinAnsi):
importc: "_wfreopen", nodecl.}
proc fopen(filename, mode: CString): pointer =
var f = allocWideCString(filename)
var m = allocWideCString(mode)
var f = newWideCString(filename)
var m = newWideCString(mode)
result = wfopen(f, m)
dealloc m
dealloc f
proc freopen(filename, mode: cstring, stream: TFile): TFile =
var f = allocWideCString(filename)
var m = allocWideCString(mode)
var f = newWideCString(filename)
var m = newWideCString(mode)
result = wfreopen(f, m, stream)
dealloc m
dealloc f
else:
proc fopen(filename, mode: CString): pointer {.importc: "fopen", noDecl.}