klisp

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

commit aa28c1644c45a6bc121bafb113c8554a4ff7af1b
parent 02cdb8382269f07ceb6288f0291f0c9e773637fa
Author: Andres Navarro <canavarro82@gmail.com>
Date:   Wed, 22 Aug 2012 02:53:46 -0300

Added locking to the memory allocation routine.

Diffstat:
Msrc/kmem.c | 5++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/kmem.c b/src/kmem.c @@ -70,12 +70,13 @@ void *klispM_toobig (klisp_State *K) { /* ** generic allocation routine. */ -/* XXX lock? */ void *klispM_realloc_ (klisp_State *K, void *block, size_t osize, size_t nsize) { klisp_assert((osize == 0) == (block == NULL)); /* TEMP: for now only Stop the world GC */ /* TEMP: prevent recursive call of klispC_fullgc() */ + + klisp_lock(K); #ifdef KUSE_GC if (nsize > 0 && G(K)->totalbytes - osize + nsize >= G(K)->GCthreshold) { #ifdef KDEBUG_GC @@ -93,10 +94,12 @@ void *klispM_realloc_ (klisp_State *K, void *block, size_t osize, size_t nsize) if (block == NULL && nsize > 0) { /* TEMP: try GC if there is no more mem */ /* TODO: make this a catchable error */ + klisp_unlock(K); fprintf(stderr, MEMERRMSG); abort(); } klisp_assert((nsize == 0) == (block == NULL)); G(K)->totalbytes = (G(K)->totalbytes - osize) + nsize; + klisp_unlock(K); return block; }