mirror of
https://github.com/dlang/phobos.git
synced 2025-04-28 22:21:09 +03:00
3 more @trusted calls
This commit is contained in:
parent
cf131b797d
commit
597e73fd93
1 changed files with 5 additions and 4 deletions
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue