Permalink
Browse files

FIX: rounding function for memory allocation needs. Now passing all R…

…ed runtime tests.
  • Loading branch information...
1 parent f3bfeb6 commit ee8099a77dbdc3aeb91eac59c55b1989e5774c5e @dockimbel dockimbel committed Mar 14, 2012
Showing with 13 additions and 1 deletion.
  1. +1 −1 red/runtime/allocator.reds
  2. +12 −0 red/runtime/utils.reds
@@ -437,7 +437,7 @@ alloc-series-buffer: func [
/local series frame sz
][
assert positive? size ;-- size is not zero or negative
- size: round-to size 16 ;-- size is a multiple of 16 (one cell! size)
+ size: round-to-next size 16 ;-- size is a multiple of 16 (one cell! size)
frame: memory/s-active
sz: size + size? series-buffer! ;-- add series header size
View
@@ -16,6 +16,18 @@ round-to: func [
size [integer!] ;-- a memory region size
scale [integer!] ;-- scale parameter
return: [integer!] ;-- nearest scale multiple
+][
+ assert scale <> 0
+ (size - 1 + scale) and (negate scale)
+]
+
+;-------------------------------------------
+;-- Return an integer rounded to the next nearest multiple of scale parameter
+;-------------------------------------------
+round-to-next: func [
+ size [integer!] ;-- a memory region size
+ scale [integer!] ;-- scale parameter
+ return: [integer!] ;-- nearest scale multiple
][
assert scale <> 0
(size + scale) and (negate scale)

0 comments on commit ee8099a

Please sign in to comment.