[MLton-devel] cvs commit: fixed bug in w64align
Stephen Weeks
sweeks@users.sourceforge.net
Tue, 15 Jul 2003 10:00:34 -0700
sweeks 03/07/15 10:00:34
Modified: runtime gc.c
Log:
The return type of w64align was uint, not W64, which meant that it
could silently overflow. This caused GC_arrayAllocate to mistakenly
continue, instead of reporting an out of memory error.
This fixes the bug that Matthew saw with
val a = Int64Array.tabulate (valOf Int.maxInt, fn i => Int64.fromInt i)
Revision Changes Path
1.148 +6 -4 mlton/runtime/gc.c
Index: gc.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/gc.c,v
retrieving revision 1.147
retrieving revision 1.148
diff -u -r1.147 -r1.148
--- gc.c 12 Jul 2003 17:17:31 -0000 1.147
+++ gc.c 15 Jul 2003 17:00:33 -0000 1.148
@@ -168,12 +168,14 @@
return a;
}
-static inline uint w64align (W64 a, uint b) {
+static inline W64 w64align (W64 a, uint b) {
+ W64 res;
+
assert (a >= 0);
assert (b >= 1);
- a += b - 1;
- a -= a % b;
- return a;
+ res = a + b - 1;
+ res = res - res % b;
+ return res;
}
static bool isAligned (uint a, uint b) {
-------------------------------------------------------
This SF.Net email sponsored by: Parasoft
Error proof Web apps, automate testing & more.
Download & eval WebKing and get a free book.
www.parasoft.com/bulletproofapps1
_______________________________________________
MLton-devel mailing list
MLton-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mlton-devel