aboutsummaryrefslogtreecommitdiff
path: root/tests/programs/bounds_heap.zc
diff options
context:
space:
mode:
authorGravatar zinc <zinc@downsta.ir> 2026-10-14 19:36:30 +0330
committerGravatar zinc <zinc@downsta.ir> 2026-10-14 19:36:30 +0330
commit7e9abb014169b77cba5174ae92ddc3d1eca4d667 (patch)
treeb7a9b0dd17c1c9fea7b94f9ba7ad115bf2f7470b /tests/programs/bounds_heap.zc
parentmerge work/bench: make bench, bench-check, bench-selftest; baseline at 89f35bd (diff)
parentrt: exact-size heap bounds; n, the words new asked for, lives in bits 32..62 ... (diff)
merge work/exactsize: exact-size heap bounds
Diffstat (limited to 'tests/programs/bounds_heap.zc')
-rw-r--r--tests/programs/bounds_heap.zc7
1 files changed, 4 insertions, 3 deletions
diff --git a/tests/programs/bounds_heap.zc b/tests/programs/bounds_heap.zc
index d0bd318..719757e 100644
--- a/tests/programs/bounds_heap.zc
+++ b/tests/programs/bounds_heap.zc
@@ -1,12 +1,13 @@
namespace;
include rt;
-// a pointer to the start of a live heap block is checked against the block's
-// payload, which a buddy block rounds up: rt.new(4) holds 11 words. a pointer
+// a pointer to the start of a live heap block is checked against exactly the
+// words new asked for: rt.new(11) holds 11 words (its block holds 11 too, but
+// rt.new(4) would hold 4, not the 11 its 16-word block has room for). a pointer
// into the middle of a block, or to memory that is not a heap block, is not
// checked. a char is a word, so a char* counts words.
int main() {
- int* p = rt.new(4); int* q; char* c = rt.new(2); int i = 10;
+ int* p = rt.new(11); int* q; char* c = rt.new(3); int i = 10;
p[i] = 3; rt.put_n(p[i]); rt.put_c(10);
q = p + 1; i = 10; rt.put_n(q[i - 1] - 3); rt.put_c(10);
i = 2; c[i] = 'x'; rt.put_c(c[i]); rt.put_c(10);