language

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit bc424e317025ea59cb6ff9144ae430b4d27a6d6e
parent a38198ce818127a70bb9a3a33bdcb0d2b1c0be52
Author: Paul Longtine <paullongtine@gmail.com>
Date:   Tue, 26 Sep 2017 23:12:43 -0400

Improved memory use a ton by dynamically allocating new namespace instances

Diffstat:
Asrc/lc/test_files/class | 0
Asrc/lc/test_files/depthtest | 0
Asrc/lc/test_files/depthtest.ti | 27+++++++++++++++++++++++++++
Asrc/lc/test_files/example | 0
Asrc/lc/test_files/extern | 0
Asrc/lc/test_files/problem | 0
Asrc/lc/test_files/test | 0
Msrc/vm/inc/ns.h | 3+--
Msrc/vm/src/ns.c | 8+++++++-
9 files changed, 35 insertions(+), 3 deletions(-)

diff --git a/src/lc/test_files/class b/src/lc/test_files/class Binary files differ. diff --git a/src/lc/test_files/depthtest b/src/lc/test_files/depthtest Binary files differ. diff --git a/src/lc/test_files/depthtest.ti b/src/lc/test_files/depthtest.ti @@ -0,0 +1,27 @@ +DEBUG; + +func recurse_me_please(int i) -> int: +{ + print(i); + if (i < 200): + { + return recurse_me_please(i + 1); + } + else: + { + return i; + } +} + +func loop_me_please(int i) -> int: +{ + while (i < 200): + { + print(i); + i = i + 1; + } + + return i; +} + +print recurse_me_please(0); diff --git a/src/lc/test_files/example b/src/lc/test_files/example Binary files differ. diff --git a/src/lc/test_files/extern b/src/lc/test_files/extern Binary files differ. diff --git a/src/lc/test_files/problem b/src/lc/test_files/problem Binary files differ. diff --git a/src/lc/test_files/test b/src/lc/test_files/test Binary files differ. diff --git a/src/vm/inc/ns.h b/src/vm/inc/ns.h @@ -11,11 +11,10 @@ typedef unsigned int ns_addr; -#define NS_CONT_MAX_NAMES 0xFFF typedef struct ns_cont { int level; ns_addr size; - var_cont* names[NS_CONT_MAX_NAMES]; + var_cont** names; struct ns_cont* next; } ns_cont; diff --git a/src/vm/src/ns.c b/src/vm/src/ns.c @@ -60,10 +60,13 @@ ns_cont* ns_cont_init(ns_addr size, int level) ns_cont* new = (ns_cont*)malloc(sizeof(ns_cont)); M_ASSERT(new); + new->names = (var_cont**)malloc(sizeof(var_cont*)*size); + M_ASSERT(new->names); + new->size = size; new->level = level; - for (int i = 0; i < NS_CONT_MAX_NAMES; i++) + for (int i = 0; i < size; i++) { new->names[i] = NULL; } @@ -124,6 +127,8 @@ var_cont* ns_cont_del(ns_cont* container, ns_addr to_return) } } + free(container->names); + free(container); return rv; @@ -138,6 +143,7 @@ void ns_cont_free(ns_cont* container) ns_cont_free(container->next); } + free(container->names); free(container); }