PageList: increase capacity for grapheme OOM during reflow
parent
3fcfc34ef7
commit
15aa9df051
|
|
@ -1004,23 +1004,34 @@ const ReflowCursor = struct {
|
||||||
// Copy the graphemes
|
// Copy the graphemes
|
||||||
const cps = src_page.lookupGrapheme(cell).?;
|
const cps = src_page.lookupGrapheme(cell).?;
|
||||||
|
|
||||||
// If our page can't support an additional cell with
|
// If our page can't support an additional cell
|
||||||
// graphemes then we create a new page for this row.
|
// with graphemes then we increase capacity.
|
||||||
if (self.page.graphemeCount() >= self.page.graphemeCapacity()) {
|
if (self.page.graphemeCount() >= self.page.graphemeCapacity()) {
|
||||||
try self.moveLastRowToNewPage(list, cap);
|
try self.adjustCapacity(list, .{
|
||||||
} else {
|
.hyperlink_bytes = cap.grapheme_bytes * 2,
|
||||||
// Attempt to allocate the space that would be required for
|
});
|
||||||
// these graphemes, and if it's not available, create a new
|
}
|
||||||
// page for this row.
|
|
||||||
if (self.page.grapheme_alloc.alloc(
|
// Attempt to allocate the space that would be required
|
||||||
u21,
|
// for these graphemes, and if it's not available, then
|
||||||
self.page.memory,
|
// increase capacity.
|
||||||
cps.len,
|
if (self.page.grapheme_alloc.alloc(
|
||||||
)) |slice| {
|
u21,
|
||||||
self.page.grapheme_alloc.free(self.page.memory, slice);
|
self.page.memory,
|
||||||
} else |_| {
|
cps.len,
|
||||||
try self.moveLastRowToNewPage(list, cap);
|
)) |slice| {
|
||||||
|
self.page.grapheme_alloc.free(self.page.memory, slice);
|
||||||
|
} else |_| {
|
||||||
|
// Grow our capacity until we can
|
||||||
|
// definitely fit the extra bytes.
|
||||||
|
const required = cps.len * @sizeOf(u21);
|
||||||
|
var new_grapheme_capacity: usize = cap.grapheme_bytes;
|
||||||
|
while (new_grapheme_capacity - cap.grapheme_bytes < required) {
|
||||||
|
new_grapheme_capacity *= 2;
|
||||||
}
|
}
|
||||||
|
try self.adjustCapacity(list, .{
|
||||||
|
.grapheme_bytes = new_grapheme_capacity,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// This shouldn't fail since we made sure we have space above.
|
// This shouldn't fail since we made sure we have space above.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue