summaryrefslogtreecommitdiff
path: root/lib/std/slurp.myr
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2016-01-20 00:59:50 -0800
committerOri Bernstein <ori@eigenstate.org>2016-01-20 00:59:50 -0800
commita9654273ae02c19160f5bf818b51036bfaba1f0c (patch)
tree5f790d62c593f25440a2e00d675bbfcc51cf6324 /lib/std/slurp.myr
parent55e5a374f0f22d66dbc6707a9aab1559248b81da (diff)
downloadmc-a9654273ae02c19160f5bf818b51036bfaba1f0c.tar.gz
Improve dial() and resolve()
- Fix a couple of fd leaks - Guarantee that all bytes sent to the system are initialized.
Diffstat (limited to 'lib/std/slurp.myr')
-rw-r--r--lib/std/slurp.myr6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/std/slurp.myr b/lib/std/slurp.myr
index ac90b23..534baf9 100644
--- a/lib/std/slurp.myr
+++ b/lib/std/slurp.myr
@@ -14,9 +14,13 @@ pkg std =
const Bufstart = 4096
const slurp = {path
+ var sl
match open(path, Ordonly)
- | `Ok fd: -> fslurp(fd)
| `Fail e: -> `Fail e
+ | `Ok fd:
+ sl = fslurp(fd)
+ close(fd)
+ -> sl
;;
}