aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>1995-01-12 12:19:04 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>1995-01-12 12:19:04 -0200
commit8faf4d1de2cbda61ae871fc23091deff3672e0fc (patch)
treec31722dca150cfc776ce5cb92dd771399446631f
parent53c0a0f43c5ced8e5f7435aa50f1bfb1e5371992 (diff)
downloadlua-8faf4d1de2cbda61ae871fc23091deff3672e0fc.tar.gz
lua-8faf4d1de2cbda61ae871fc23091deff3672e0fc.tar.bz2
lua-8faf4d1de2cbda61ae871fc23091deff3672e0fc.zip
control of garbage collection is done with Longs, as there can be
more than WORD objects to collect.
-rw-r--r--hash.c6
-rw-r--r--hash.h6
-rw-r--r--table.c8
-rw-r--r--tree.c6
-rw-r--r--tree.h4
5 files changed, 16 insertions, 14 deletions
diff --git a/hash.c b/hash.c
index db87645b..e5a0a485 100644
--- a/hash.c
+++ b/hash.c
@@ -3,7 +3,7 @@
3** hash manager for lua 3** hash manager for lua
4*/ 4*/
5 5
6char *rcs_hash="$Id: hash.c,v 2.21 1994/12/16 15:55:04 roberto Exp roberto $"; 6char *rcs_hash="$Id: hash.c,v 2.22 1994/12/20 21:20:36 roberto Exp roberto $";
7 7
8#include "mem.h" 8#include "mem.h"
9#include "opcode.h" 9#include "opcode.h"
@@ -185,10 +185,10 @@ static void call_fallbacks (void)
185** Garbage collection to arrays 185** Garbage collection to arrays
186** Delete all unmarked arrays. 186** Delete all unmarked arrays.
187*/ 187*/
188Word lua_hashcollector (void) 188Long lua_hashcollector (void)
189{ 189{
190 Hash *curr_array = listhead, *prev = NULL; 190 Hash *curr_array = listhead, *prev = NULL;
191 Word counter = 0; 191 Long counter = 0;
192 call_fallbacks(); 192 call_fallbacks();
193 while (curr_array != NULL) 193 while (curr_array != NULL)
194 { 194 {
diff --git a/hash.h b/hash.h
index f51edd00..e594a9cd 100644
--- a/hash.h
+++ b/hash.h
@@ -2,12 +2,14 @@
2** hash.h 2** hash.h
3** hash manager for lua 3** hash manager for lua
4** Luiz Henrique de Figueiredo - 17 Aug 90 4** Luiz Henrique de Figueiredo - 17 Aug 90
5** $Id: hash.h,v 2.6 1994/11/17 13:58:57 roberto Stab roberto $ 5** $Id: hash.h,v 2.7 1994/12/20 21:20:36 roberto Exp roberto $
6*/ 6*/
7 7
8#ifndef hash_h 8#ifndef hash_h
9#define hash_h 9#define hash_h
10 10
11#include "types.h"
12
11typedef struct node 13typedef struct node
12{ 14{
13 Object ref; 15 Object ref;
@@ -27,7 +29,7 @@ typedef struct Hash
27Bool lua_equalObj (Object *t1, Object *t2); 29Bool lua_equalObj (Object *t1, Object *t2);
28Hash *lua_createarray (Word nhash); 30Hash *lua_createarray (Word nhash);
29void lua_hashmark (Hash *h); 31void lua_hashmark (Hash *h);
30Word lua_hashcollector (void); 32Long lua_hashcollector (void);
31Object *lua_hashget (Hash *t, Object *ref); 33Object *lua_hashget (Hash *t, Object *ref);
32Object *lua_hashdefine (Hash *t, Object *ref); 34Object *lua_hashdefine (Hash *t, Object *ref);
33void lua_next (void); 35void lua_next (void);
diff --git a/table.c b/table.c
index f17f1ca4..85311b21 100644
--- a/table.c
+++ b/table.c
@@ -3,7 +3,7 @@
3** Module to control static tables 3** Module to control static tables
4*/ 4*/
5 5
6char *rcs_table="$Id: table.c,v 2.24 1994/12/16 15:55:04 roberto Exp roberto $"; 6char *rcs_table="$Id: table.c,v 2.25 1994/12/20 21:20:36 roberto Exp roberto $";
7 7
8#include <string.h> 8#include <string.h>
9 9
@@ -173,9 +173,9 @@ void lua_markobject (Object *o)
173*/ 173*/
174void lua_pack (void) 174void lua_pack (void)
175{ 175{
176 static Word block = GARBAGE_BLOCK; /* when garbage collector will be called */ 176 static Long block = GARBAGE_BLOCK; /* when garbage collector will be called */
177 static Word nentity = 0; /* counter of new entities (strings and arrays) */ 177 static Long nentity = 0; /* counter of new entities (strings and arrays) */
178 Word recovered = 0; 178 Long recovered = 0;
179 if (nentity++ < block) return; 179 if (nentity++ < block) return;
180 lua_travstack(lua_markobject); /* mark stack objects */ 180 lua_travstack(lua_markobject); /* mark stack objects */
181 lua_travsymbol(lua_markobject); /* mark symbol table objects */ 181 lua_travsymbol(lua_markobject); /* mark symbol table objects */
diff --git a/tree.c b/tree.c
index ac0f096d..c34b0560 100644
--- a/tree.c
+++ b/tree.c
@@ -3,7 +3,7 @@
3** TecCGraf - PUC-Rio 3** TecCGraf - PUC-Rio
4*/ 4*/
5 5
6char *rcs_tree="$Id: tree.c,v 1.11 1994/11/25 19:27:03 roberto Exp roberto $"; 6char *rcs_tree="$Id: tree.c,v 1.12 1994/12/20 21:20:36 roberto Exp roberto $";
7 7
8 8
9#include <string.h> 9#include <string.h>
@@ -78,10 +78,10 @@ TreeNode *lua_constcreate (char *str)
78** Garbage collection function. 78** Garbage collection function.
79** This function traverse the string list freeing unindexed strings 79** This function traverse the string list freeing unindexed strings
80*/ 80*/
81Word lua_strcollector (void) 81Long lua_strcollector (void)
82{ 82{
83 StringNode *curr = string_root, *prev = NULL; 83 StringNode *curr = string_root, *prev = NULL;
84 Word counter = 0; 84 Long counter = 0;
85 while (curr) 85 while (curr)
86 { 86 {
87 StringNode *next = curr->next; 87 StringNode *next = curr->next;
diff --git a/tree.h b/tree.h
index 6a42dfa4..f322e833 100644
--- a/tree.h
+++ b/tree.h
@@ -1,7 +1,7 @@
1/* 1/*
2** tree.h 2** tree.h
3** TecCGraf - PUC-Rio 3** TecCGraf - PUC-Rio
4** $Id: tree.h,v 1.7 1994/11/25 19:27:03 roberto Exp roberto $ 4** $Id: tree.h,v 1.8 1994/12/20 21:20:36 roberto Exp roberto $
5*/ 5*/
6 6
7#ifndef tree_h 7#ifndef tree_h
@@ -31,7 +31,7 @@ typedef struct TreeNode
31 31
32TaggedString *lua_createstring (char *str); 32TaggedString *lua_createstring (char *str);
33TreeNode *lua_constcreate (char *str); 33TreeNode *lua_constcreate (char *str);
34Word lua_strcollector (void); 34Long lua_strcollector (void);
35TreeNode *lua_varnext (char *n); 35TreeNode *lua_varnext (char *n);
36 36
37#endif 37#endif