ref: aa40fda4e41feafd05bf777a969aa2b4b6c7f070
parent: f75a890bab649f57ee1f2cfffec8c74cc8b0ed49
author: Ori Bernstein <ori@eigenstate.org>
date: Sun Jun 3 13:44:08 EDT 2018
Export bytealloc/zbytealloc for users. It's occasionally useful.
--- a/lib/std/alloc.myr
+++ b/lib/std/alloc.myr
@@ -120,7 +120,7 @@
generic slfree = {sl
var head, sz
- if (sl : byte#) == Zsliceptr
+ if (sl : byte#) == Zslicep
-> void
;;
@@ -139,7 +139,7 @@
/* if the slice doesn't need a bigger bucket, we don't need to realloc. */
cap = 0
- if (sl# : byte#) != Zsliceptr
+ if (sl# : byte#) != Zslicep
cap = slcap((sl# : byte#))
;;
if cap >= len*sizeof(@a)
--- a/lib/std/bytealloc.myr
+++ b/lib/std/bytealloc.myr
@@ -15,16 +15,16 @@
const startalloctrace : (f : byte[:] -> void)
const endalloctrace : (-> void)
+ const bytealloc : (sz:size -> byte#)
+ const zbytealloc : (sz:size -> byte#)
+ const bytefree : (m:byte#, sz:size -> void)
+
/* null pointers. only used internally. */
- pkglocal const Zsliceptr = (0 : byte#)
- pkglocal const Align = 16 /* minimum allocation alignment */
+ pkglocal const Zslicep = (0 : byte#)
+ pkglocal const Align = 16 /* minimum allocation alignment */
- /* exported for testing */
- const bytealloc : (sz:size -> byte#)
- const bytefree : (m:byte#, sz:size -> void)
- pkglocal const zbytealloc : (sz:size -> byte#)
- pkglocal const align : (m : std.size, align : std.size -> std.size)
- pkglocal const allocsz : (sz : std.size -> std.size)
+ pkglocal const align : (m : std.size, align : std.size -> std.size)
+ pkglocal const allocsz : (sz : std.size -> std.size)
;;