From 5b991ae2d3e2db32b3c77a9d140bb485a219e68d Mon Sep 17 00:00:00 2001
From: Paul Sokolovsky <pfalcon@users.sourceforge.net>
Date: Sun, 20 Apr 2014 20:46:39 +0300
Subject: [PATCH] gc: gc_realloc(): Fix byte-to-block calculation.

---
 py/gc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/py/gc.c b/py/gc.c
index 2930e9011..9a5f9d89b 100644
--- a/py/gc.c
+++ b/py/gc.c
@@ -480,7 +480,7 @@ void *gc_realloc(void *ptr_in, machine_uint_t n_bytes) {
     }
 
     // compute number of new blocks that are requested
-    machine_uint_t new_blocks = (n_bytes + BYTES_PER_BLOCK) / BYTES_PER_BLOCK;
+    machine_uint_t new_blocks = (n_bytes + BYTES_PER_BLOCK - 1) / BYTES_PER_BLOCK;
 
     // get the number of consecutive tail blocks and
     // the number of free blocks after last tail block
-- 
GitLab