From fae8e553968a48972013b317b2b252321e9d7c91 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Sat, 7 Oct 2023 22:39:28 +0900 Subject: [PATCH] pool.c (mrb_pool_realloc): add comments in reallocation code --- src/pool.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/pool.c b/src/pool.c index 067ec68a8..dbf133677 100644 --- a/src/pool.c +++ b/src/pool.c @@ -139,8 +139,12 @@ mrb_pool_realloc(mrb_pool *pool, void *p, size_t oldlen, size_t newlen) if (page->last == p) { /* if p is a last allocation from the page */ size_t beg = (char*)p - page->page; + /* check beg + oldlen points bottom */ + /* assert(beg + oldlen == page->offset) */ if (beg + oldlen != page->offset) break; if (beg + newlen > page->len) { + /* new allocation need more space */ + /* abandon this space */ page->offset = beg; break; }