summaryrefslogtreecommitdiff
path: root/lib/std
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2019-07-14 01:22:52 +0000
committerOri Bernstein <ori@eigenstate.org>2019-07-14 01:22:52 +0000
commit34d97453258079f514c3297f88663fc23ff6e080 (patch)
treeebfdc834ff8c434eff567653bc57126e86a1c2ee /lib/std
parentcfb284970e8c164d43d814496a5363b92782fb15 (diff)
downloadmc-34d97453258079f514c3297f88663fc23ff6e080.tar.gz
Fix memory leak in bigparse. (Thanks, Mike)
Diffstat (limited to 'lib/std')
-rw-r--r--lib/std/bigint.myr2
-rw-r--r--lib/std/dir+openbsd.myr65
-rw-r--r--lib/std/syswrap-ss+openbsd.myr31
3 files changed, 2 insertions, 96 deletions
diff --git a/lib/std/bigint.myr b/lib/std/bigint.myr
index 478d9fc..8e078cf 100644
--- a/lib/std/bigint.myr
+++ b/lib/std/bigint.myr
@@ -284,6 +284,8 @@ const bigparse = {str
bigadd(a, v)
;;
+ bigfree(b)
+ bigfree(v)
-> `Some a
}
diff --git a/lib/std/dir+openbsd.myr b/lib/std/dir+openbsd.myr
deleted file mode 100644
index 274175d..0000000
--- a/lib/std/dir+openbsd.myr
+++ /dev/null
@@ -1,65 +0,0 @@
-use sys
-
-use "alloc"
-use "die"
-use "memops"
-use "option"
-use "result"
-use "slcp"
-use "sldup"
-use "types"
-
-pkg std =
- type dir = struct
- fd : sys.fd
- buf : byte[16384]
- len : int64
- off : int64
- ;;
-
- const diropen : (p : byte[:] -> std.result(dir#, byte[:]))
- const dirread : (d : dir# -> std.option(byte[:]))
- const dirclose : (d : dir# -> void)
-;;
-
-const diropen = {p
- var fd
- var dir
-
- fd = sys.open(p, sys.Ordonly | sys.Odir)
- if fd < 0
- -> `Err "couldn't open directory"
- ;;
- dir = zalloc()
- dir.fd = fd
- -> `Ok dir
-}
-
-const dirread = {d
- var len
- var dent
- var namelen
-
- if d.off >= d.len
- len = sys.getdents(d.fd, d.buf[:])
- if len <= 0
- -> `None
- ;;
- d.len = len
- d.off = 0
- ;;
-
- dent = (&d.buf[d.off] : sys.dirent#)
- namelen = 0
- d.off += (dent.reclen : int64)
- while dent.name[namelen] != 0
- namelen++
- ;;
- -> `Some sldup(dent.name[:namelen])
-}
-
-const dirclose = {d
- sys.close(d.fd)
- free(d)
-}
-
diff --git a/lib/std/syswrap-ss+openbsd.myr b/lib/std/syswrap-ss+openbsd.myr
deleted file mode 100644
index 0f4ed65..0000000
--- a/lib/std/syswrap-ss+openbsd.myr
+++ /dev/null
@@ -1,31 +0,0 @@
-use sys
-use "types"
-use "errno"
-use "cstrconv"
-use "slcp"
-use "die"
-
-pkg std =
- const nanosleep : (nsecs : uint64 -> errno)
- $noret const exit : (status:int -> void)
-
- pkglocal const bgetcwd : (buf : byte[:] -> errno)
-;;
-
-const exit = {status; sys.exit(status)}
-
-const bgetcwd = {buf
- -> (sys.__getcwd(buf) - 1 : errno)
-}
-
-const nanosleep = {nsecs
- var req, rem
- var s, ns
-
- s = (nsecs / 1_000_000_000 : int64)
- ns = (nsecs % 1_000_000_000 : int64)
- req = [.sec = s, .nsec = ns]
-
- -> (sys.nanosleep(&req, &rem) : errno)
-}
-