From e0a75d5f596a9c3bb4dad6645436f0da689c0364 Mon Sep 17 00:00:00 2001 From: Paul Liu Date: Thu, 25 Jan 2024 02:29:37 +0800 Subject: [PATCH] fix: wrong new_pages calculation in StableMultiLog (#4370) Fix the wrong calculation on the new pages needed to grow stable memory in the StableMultiLog example used in our documentation. --- doc/md/examples/StableMultiLog.mo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/md/examples/StableMultiLog.mo b/doc/md/examples/StableMultiLog.mo index f1e2f99c1d4..478873d7f7e 100644 --- a/doc/md/examples/StableMultiLog.mo +++ b/doc/md/examples/StableMultiLog.mo @@ -20,7 +20,7 @@ actor StableLog { func regionEnsureSizeBytes(r : Region, new_byte_count : Nat64) { let pages = Region.size(r); if (new_byte_count > pages << 16) { - let new_pages = pages - ((new_byte_count + ((1 << 16) - 1)) / (1 << 16)); + let new_pages = ((new_byte_count + ((1 << 16) - 1)) / (1 << 16)) - pages; assert Region.grow(r, new_pages) == pages } };