klisp

an open source interpreter for the Kernel Programming Language.
git clone http://git.hanabi.in/repos/klisp.git
Log | Files | Refs | README

commit 2f44bb564e26560e7e37d32cabad35e13fee0c1e
parent b35a510b715d14e024eae9f292df7187ccaf5ab3
Author: Andres Navarro <canavarro82@gmail.com>
Date:   Fri, 15 Apr 2011 17:07:18 -0300

Changed the old value stack to check for growth after adding an element, so that it is never the case that the array needs to be grown when we are waiting to add an object.

Diffstat:
Msrc/kstate.h | 7+++++--
1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/kstate.h b/src/kstate.h @@ -182,10 +182,13 @@ inline bool ks_sisempty(klisp_State *K); inline void ks_spush(klisp_State *K, TValue obj) { - if (ks_stop(K) == ks_ssize(K)) - ks_sgrow(K, ks_stop(K)+1); ks_selem(K, ks_stop(K)) = obj; ++ks_stop(K); + /* put check after so that there is always space for one obj, and if + realloc is needed, obj is already rooted */ + if (ks_stop(K) == ks_ssize(K)) { + ks_sgrow(K, ks_stop(K)+1); + } }