shithub: mc

Download patch

ref: 23896ee4273d593cf3d32c00713c6f55e9b1369e
parent: 6bc30379e7b4d6df3325b44c423ebba9d11792cb
author: Ori Bernstein <[email protected]>
date: Tue Jul 24 18:54:40 EDT 2012

It looks like the allocator is working.

--- a/alloc.myr
+++ b/alloc.myr
@@ -53,7 +53,7 @@
 
 	if !initdone
 		for i = 0; i < buckets.len && (Align << i) < Bucketmax; i++
-			allocinit(&buckets[i], Align << i)
+			bktinit(&buckets[i], Align << i)
 		;;
 		initdone = 1
 	;;
@@ -77,7 +77,7 @@
 	;;
 }
 
-const allocinit = {b : bucket*, sz
+const bktinit = {b : bucket*, sz
 	b.sz = align(sz, Align)
 	b.nper = (Pagesz - sizeof(slab))/b.sz
 	b.slabs = Zslab
--- a/hello.myr
+++ b/hello.myr
@@ -2,12 +2,14 @@
 use "alloc.use"
 
 const main = {
-	var x
+	var x : byte*[1024]
 	var i
 
-	for i = 0; i < 200; i++
-		x = std.bytealloc(32)
+	for i = 0; i < 1024; i++
+		x[i] = std.bytealloc(32)
 	;;
-	std.bytefree(x, 32)
+	for i = 0; i < 1024; i++
+		std.bytefree(x[i], 32)
+	;;
 	std.write(1, "Hello world\n")
 }