From 44521b21e542831a95de0c63271cd38d1cd4d394 Mon Sep 17 00:00:00 2001 From: Waldemar Celes Date: Wed, 20 Apr 1994 19:07:57 -0300 Subject: Implementacao da nova estrategia para armazenar os arrays em lista encadeada. --- table.c | 128 +++++++++++++++++++++++++++------------------------------------- 1 file changed, 53 insertions(+), 75 deletions(-) (limited to 'table.c') diff --git a/table.c b/table.c index abbb8850..5d2f1b28 100644 --- a/table.c +++ b/table.c @@ -3,7 +3,7 @@ ** Module to control static tables */ -char *rcs_table="$Id: table.c,v 1.4 1994/04/06 12:55:08 celes Exp celes $"; +char *rcs_table="$Id: table.c,v 1.5 1994/04/13 22:10:21 celes Exp celes $"; #include #include @@ -75,18 +75,19 @@ static char *stringbuffer[MAXSTRING]; char **lua_string = stringbuffer; Word lua_nstring=0; -#ifndef MAXARRAY -#define MAXARRAY 512 -#endif -static Hash *arraybuffer[MAXARRAY]; -Hash **lua_array = arraybuffer; -Word lua_narray=0; - #define MAXFILE 20 char *lua_file[MAXFILE]; int lua_nfile; +#define markstring(s) (*((s)-1)) + + +/* Variables to controll garbage collection */ +Word lua_block=10; /* to check when garbage collector will be called */ +Word lua_nentity; /* counter of new entities (strings and arrays) */ + + /* ** Given a name, search it at symbol table and return its index. If not ** found, allocate at end of table, checking oveflow and return its index. @@ -158,66 +159,65 @@ int lua_findconstant (char *s) } +/* +** Traverse symbol table objects +*/ +void lua_travsymbol (void (*fn)(Object *)) +{ + int i; + for (i=0; i= MAXSTRING-1) + if (lua_nentity == lua_block || lua_nstring >= MAXSTRING-1) { lua_pack (); if (lua_nstring >= MAXSTRING-1) @@ -247,32 +247,10 @@ char *lua_createstring (char *s) } } lua_string[lua_nstring++] = s; + lua_nentity++; return s; } -/* -** Allocate a new array, already created, at array table. The function puts -** it at the end of the table, checking overflow, and returns its own pointer, -** or NULL on error. -*/ -void *lua_createarray (void *a) -{ - if (a == NULL) return NULL; - - if (lua_narray >= MAXARRAY-1) - { - lua_pack (); - if (lua_narray >= MAXARRAY-1) - { - lua_error ("indexed table overflow"); - return NULL; - } - } - lua_array[lua_narray++] = a; - return a; -} - - /* ** Add a file name at file table, checking overflow. This function also set ** the external variable "lua_filename" with the function filename set. -- cgit v1.2.3-55-g6feb