From 0c88b5e31475e07d0d06ae9af01ad05a0efdc875 Mon Sep 17 00:00:00 2001 From: Javier Sancho Date: Tue, 15 Jul 2014 15:01:51 +0200 Subject: [PATCH] Resolve VM Stack Overflow when reading mesh vertices * src/low-level.scm: Function array implemented with tail recursion. --- src/low-level.scm | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/low-level.scm b/src/low-level.scm index 7842aca..d604789 100644 --- a/src/low-level.scm +++ b/src/low-level.scm @@ -111,12 +111,12 @@ (cond ((= (pointer-address root) 0) '()) (else - (let loop ((i 0)) - (cond ((= i size) - '()) - (else - (cons (element-proc root (* element-size i)) - (loop (+ i 1))))))))) + (reverse + (let loop ((i 0) (res '())) + (cond ((= i size) + res) + (else + (loop (+ i 1) (cons (element-proc root (* element-size i)) res))))))))) (define (get-element-address root-pointer offset) (make-pointer (+ (pointer-address root-pointer) offset))) -- 2.39.5