klisp

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

commit 659779ebc303dd5dd15c784427d874633768c117
parent 52a6299a4846ead4f969c8574d61fe5785349fb8
Author: Andres Navarro <canavarro82@gmail.com>
Date:   Fri, 25 Mar 2011 02:59:06 -0300

Bugfix: in equal? variables obj1 & obj2 were being used in inner loop and were holding wrong values when calling unmark.

Diffstat:
Msrc/kgequalp.c | 8++++----
Msrc/kobject.h | 2++
2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/kgequalp.c b/src/kgequalp.c @@ -165,7 +165,6 @@ inline bool equal_find2_mergep(klisp_State *K, TValue obj1, TValue obj2) bool equal2p(klisp_State *K, TValue obj1, TValue obj2) { assert(ks_sisempty(K)); - kcheck_mark_balance(); /* the stack has the elements to be compaired, always in pairs. So the top should be compared with the one below, the third with @@ -175,6 +174,8 @@ bool equal2p(klisp_State *K, TValue obj1, TValue obj2) /* if the stacks becomes empty, all pairs of elements were equal */ bool result = true; + TValue saved_obj1 = obj1; + TValue saved_obj2 = obj2; while(!ks_sisempty(K)) { obj2 = ks_spop(K); @@ -205,9 +206,8 @@ bool equal2p(klisp_State *K, TValue obj1, TValue obj2) /* if result is false, the stack may not be empty */ ks_sclear(K); - unmark_tree(K, obj1); - unmark_tree(K, obj2); + unmark_tree(K, saved_obj1); + unmark_tree(K, saved_obj2); - kcheck_mark_balance(); return result; } diff --git a/src/kobject.h b/src/kobject.h @@ -33,7 +33,9 @@ #include <stdio.h> /* This should be in a configuration .h */ +/* #define KTRACK_MARKS (true) +*/ /* ** Union of all collectible objects