From f858ae13ae3152cb0d1e0e3add6f8b5e19ef76e7 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sat, 21 Sep 2024 20:59:00 -0700 Subject: [PATCH] terminal: clarify comment --- src/terminal/PageList.zig | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/terminal/PageList.zig b/src/terminal/PageList.zig index 9ea15944c..8d9641bfa 100644 --- a/src/terminal/PageList.zig +++ b/src/terminal/PageList.zig @@ -1694,7 +1694,14 @@ pub fn grow(self: *PageList) !?*List.Node { // If allocation would exceed our max size, we prune the first page. // We don't need to reallocate because we can simply reuse that first // page. - if (self.pages.len > 1 and self.page_size + PagePool.item_size > self.maxSize()) prune: { + // + // We only take this path if we have more than one page since pruning + // reuses the popped page. It is possible to have a single page and + // exceed the max size if that page was adjusted to be larger after + // initial allocation. + if (self.pages.len > 1 and + self.page_size + PagePool.item_size > self.maxSize()) + prune: { // If we need to add more memory to ensure our active area is // satisfied then we do not prune. if (self.growRequiredForActive()) break :prune;