@@ -1116,11 +1116,11 @@ pub fn testAllocator(base_allocator: mem.Allocator) !void {
11161116 allocator .destroy (item );
11171117 }
11181118
1119- slice = allocator .shrink (slice , 50 );
1119+ slice = allocator .tryShrink (slice , 50 ) orelse return error . OutOfMemory ; // this allocator does not support this shrink
11201120 try testing .expect (slice .len == 50 );
1121- slice = allocator .shrink (slice , 25 );
1121+ slice = allocator .tryShrink (slice , 25 ) orelse return error . OutOfMemory ; // this allocator does not support this shrink
11221122 try testing .expect (slice .len == 25 );
1123- slice = allocator .shrink (slice , 0 );
1123+ slice = allocator .tryShrink (slice , 0 ) orelse return error . OutOfMemory ; // this allocator does not support this shrink
11241124 try testing .expect (slice .len == 0 );
11251125 slice = try allocator .realloc (slice , 10 );
11261126 try testing .expect (slice .len == 10 );
@@ -1156,19 +1156,19 @@ pub fn testAllocatorAligned(base_allocator: mem.Allocator) !void {
11561156 slice = try allocator .realloc (slice , 100 );
11571157 try testing .expect (slice .len == 100 );
11581158 // shrink
1159- slice = allocator .shrink (slice , 10 );
1159+ slice = allocator .tryShrink (slice , 10 ) orelse return error . OutOfMemory ; // this allocator does not support this shrink
11601160 try testing .expect (slice .len == 10 );
11611161 // go to zero
1162- slice = allocator .shrink (slice , 0 );
1162+ slice = allocator .tryShrink (slice , 0 ) orelse return error . OutOfMemory ; // this allocator does not support this shrink
11631163 try testing .expect (slice .len == 0 );
11641164 // realloc from zero
11651165 slice = try allocator .realloc (slice , 100 );
11661166 try testing .expect (slice .len == 100 );
11671167 // shrink with shrink
1168- slice = allocator .shrink (slice , 10 );
1168+ slice = allocator .tryShrink (slice , 10 ) orelse return error . OutOfMemory ; // this allocator does not support this shrink
11691169 try testing .expect (slice .len == 10 );
11701170 // shrink to zero
1171- slice = allocator .shrink (slice , 0 );
1171+ slice = allocator .tryShrink (slice , 0 ) orelse return error . OutOfMemory ; // this allocator does not support this shrink
11721172 try testing .expect (slice .len == 0 );
11731173 }
11741174}
@@ -1190,13 +1190,13 @@ pub fn testAllocatorLargeAlignment(base_allocator: mem.Allocator) !void {
11901190 var slice = try allocator .alignedAlloc (u8 , large_align , 500 );
11911191 try testing .expect (@ptrToInt (slice .ptr ) & align_mask == @ptrToInt (slice .ptr ));
11921192
1193- slice = allocator .shrink (slice , 100 );
1193+ slice = allocator .tryShrink (slice , 100 ) orelse return error . OutOfMemory ; // this allocator does not support this shrink
11941194 try testing .expect (@ptrToInt (slice .ptr ) & align_mask == @ptrToInt (slice .ptr ));
11951195
11961196 slice = try allocator .realloc (slice , 5000 );
11971197 try testing .expect (@ptrToInt (slice .ptr ) & align_mask == @ptrToInt (slice .ptr ));
11981198
1199- slice = allocator .shrink (slice , 10 );
1199+ slice = allocator .tryShrink (slice , 10 ) orelse return error . OutOfMemory ; // this allocator does not support this shrink
12001200 try testing .expect (@ptrToInt (slice .ptr ) & align_mask == @ptrToInt (slice .ptr ));
12011201
12021202 slice = try allocator .realloc (slice , 20000 );
0 commit comments