| ... | ... | @@ -186,7 +186,7 @@ pub const LimitedAllocError = Allocator.Error || ShortError || error{StreamTooLo |
| 186 | 186 | pub fn readRemainingAlloc(r: Reader, gpa: Allocator, limit: Reader.Limit) LimitedAllocError![]u8 { |
| 187 | 187 | var buffer: ArrayList(u8) = .empty; |
| 188 | 188 | defer buffer.deinit(gpa); |
| 189 | | try readRemainingArrayList(r, gpa, null, &buffer, limit); |
| 189 | try readRemainingArrayList(r, gpa, null, &buffer, limit, 1); |
| 190 | 190 | return buffer.toOwnedSlice(gpa); |
| 191 | 191 | } |
| 192 | 192 | |
| ... | ... | @@ -209,10 +209,11 @@ pub fn readRemainingArrayList( |
| 209 | 209 | comptime alignment: ?std.mem.Alignment, |
| 210 | 210 | list: *std.ArrayListAlignedUnmanaged(u8, alignment), |
| 211 | 211 | limit: Limit, |
| 212 | minimum_buffer_size: usize, |
| 212 | 213 | ) LimitedAllocError!void { |
| 213 | 214 | var remaining = limit; |
| 214 | 215 | while (true) { |
| 215 | | try list.ensureUnusedCapacity(gpa, 1); |
| 216 | try list.ensureUnusedCapacity(gpa, minimum_buffer_size); |
| 216 | 217 | const buffer = remaining.slice1(list.unusedCapacitySlice()); |
| 217 | 218 | const n = r.vtable.readVec(r.context, &.{buffer}) catch |err| switch (err) { |
| 218 | 219 | error.EndOfStream => return, |