From 0b1ade35f8345d9d07180c4662f441ebda3ce226 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl=20H=C3=B6rberg?= Date: Tue, 15 Aug 2023 12:19:11 +0200 Subject: [PATCH] Only expand heap with minimal required --- src/amq/protocol/table.cr | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/amq/protocol/table.cr b/src/amq/protocol/table.cr index 8864b80..223e2ba 100644 --- a/src/amq/protocol/table.cr +++ b/src/amq/protocol/table.cr @@ -315,9 +315,9 @@ module AMQ private def ensure_capacity(size : Int) if @bytesize + size > @capacity - capacity = Math.pw2ceil(@bytesize + size) - @buffer = GC.realloc(@buffer, capacity) - @capacity = capacity + required_capacity = @bytesize + size + @buffer = GC.realloc(@buffer, required_capacity) + @capacity = required_capacity end end