Skip to content

Commit ad0cdef

Browse files
committed
Add deallocate calls to the realloc-16687.rs test.
Fix #17303.
1 parent 0a4c136 commit ad0cdef

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

src/test/run-pass/realloc-16687.rs

+17-4
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,13 @@ unsafe fn test_triangle() -> bool {
5656

5757
ret
5858
}
59+
unsafe fn deallocate(ptr: *mut u8, size: uint, align: uint) {
60+
if PRINT { println!("deallocate(ptr=0x{:010x} size={:u} align={:u})",
61+
ptr as uint, size, align);
62+
}
63+
64+
heap::deallocate(ptr, size, align);
65+
}
5966
unsafe fn reallocate(ptr: *mut u8, size: uint, align: uint,
6067
old_size: uint) -> *mut u8 {
6168
if PRINT {
@@ -95,10 +102,16 @@ unsafe fn test_triangle() -> bool {
95102
}
96103

97104
sanity_check(ascend.as_slice());
98-
test_1(ascend);
99-
test_2(ascend);
100-
test_3(ascend);
101-
test_4(ascend);
105+
test_1(ascend); // triangle -> square
106+
test_2(ascend); // square -> triangle
107+
test_3(ascend); // triangle -> square
108+
test_4(ascend); // square -> triangle
109+
110+
for i in range(0u, COUNT / 2) {
111+
let size = idx_to_size(i);
112+
deallocate(ascend[2*i], size, ALIGN);
113+
deallocate(ascend[2*i+1], size, ALIGN);
114+
}
102115

103116
return true;
104117

0 commit comments

Comments
 (0)