3 more @trusted calls

This commit is contained in:
Nick Treleaven 2022-11-15 17:45:11 +00:00
parent cf131b797d
commit 597e73fd93

View file

@ -5689,13 +5689,13 @@ private size_t readlnImpl(FILE* fps, ref char[] buf, dchar terminator, File.Orie
if (n > 128 * 1024) if (n > 128 * 1024)
{ {
// Bound memory used by readln // Bound memory used by readln
free(lineptr); () @trusted { free(lineptr); }();
lineptr = null; lineptr = null;
n = 0; n = 0;
} }
} }
auto s = core.sys.posix.stdio.getdelim(&lineptr, &n, terminator, fps); const s = (() @trusted => core.sys.posix.stdio.getdelim(&lineptr, &n, terminator, fps))();
if (s < 0) if (s < 0)
{ {
if (ferror(fps)) if (ferror(fps))
@ -5704,14 +5704,15 @@ private size_t readlnImpl(FILE* fps, ref char[] buf, dchar terminator, File.Orie
return 0; return 0;
} }
const line = (() @trusted => lineptr[0 .. s])();
if (s <= buf.length) if (s <= buf.length)
{ {
buf = buf[0 .. s]; buf = buf[0 .. s];
buf[] = lineptr[0 .. s]; buf[] = line;
} }
else else
{ {
buf = lineptr[0 .. s].dup; buf = line.dup;
} }
return s; return s;
} }