shithub: mc

Download patch

ref: 4fd76bb3f5d16488d7b50a5ef1b7674537889e06
parent: 9edbd938a58bdcd53f38bc4b8fcdae73177432c4
author: Andrew Chambers <andrewchamberss@gmail.com>
date: Fri Feb 5 13:49:49 EST 2016

make slzgrow match other functions

--- a/lib/std/alloc.myr
+++ b/lib/std/alloc.myr
@@ -34,7 +34,7 @@
 	generic slalloc	: (len : size	-> @a[:])
 	generic slzalloc	: (len : size	-> @a[:])
 	generic slgrow	: (sl : @a[:], len : size	-> @a[:])
-	generic slzgrow	: (sl : @a[:], len : size	-> @a[:])
+	generic slzgrow	: (sl : @a[:]#, len : size	-> @a[:])
 	generic slfree	: (sl : @a[:]	-> void)
 
 	const bytealloc	: (sz:size	-> byte#)
@@ -195,17 +195,17 @@
 }
 
 /* Grows a slice, filling new entries with zero bytes */
-generic slzgrow = {sl : @a[:], len
+generic slzgrow = {sl : @a[:]#, len
 	var oldlen
 	var base
 
-	oldlen = sl.len
-	sl = slgrow(sl, len)
-	base = sl castto(byte#) castto(intptr)
+	oldlen = sl#.len
+	sl# = slgrow(sl#, len)
+	base = sl# castto(byte#) castto(intptr)
 	if oldlen < len
-		memfill(sl[oldlen:] castto(byte#), 0, (len - oldlen)*sizeof(@a))
+		memfill(sl#[oldlen:] castto(byte#), 0, (len - oldlen)*sizeof(@a))
 	;;
-	-> sl
+	-> sl#
 }
 
 const slcap = {p
--- a/lib/std/bigint.myr
+++ b/lib/std/bigint.myr
@@ -313,7 +313,7 @@
 	carry = 0
 	n = max(a.dig.len, b.dig.len)
 	/* guaranteed to carry no more than one value */
-	a.dig = slzgrow(a.dig, n + 1)
+	slzgrow(&a.dig, n + 1)
 	for i = 0; i < n; i++
 		v = (a.dig[i] castto(uint64)) + carry;
 		if i < b.dig.len
@@ -479,7 +479,7 @@
 	shift = nlz(v.dig[n - 1])
 	bigshli(u, shift)
 	bigshli(v, shift)
-	u.dig = slzgrow(u.dig, u.dig.len + 1)
+	slzgrow(&u.dig, u.dig.len + 1)
 
 	for j = m - n; j >= 0; j--
 		/* load a few temps */
@@ -655,7 +655,7 @@
 	if a.sign == 0
 		-> a
 	;;
-	a.dig = slzgrow(a.dig, 1 + a.dig.len + off castto(size))
+	slzgrow(&a.dig, 1 + a.dig.len + off castto(size))
 	/* blit over the base values */
 	for var i = a.dig.len; i > off; i--
 		a.dig[i - 1] = a.dig[i - 1 - off]
--- a/lib/std/bitset.myr
+++ b/lib/std/bitset.myr
@@ -138,7 +138,7 @@
 
 const ensurelen = {bs, len
 	if bs.bits.len <= len
-		bs.bits = slzgrow(bs.bits, len + 1)
+		slzgrow(&bs.bits, len + 1)
 	;;
 }