aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWaldemar Celes <celes@tecgraf.puc-rio.br>1994-03-28 12:15:59 -0300
committerWaldemar Celes <celes@tecgraf.puc-rio.br>1994-03-28 12:15:59 -0300
commit540dc65bcd16cd8ee2d6d2983036968ea388502b (patch)
tree3a16b63b8e42553437ba5adc011a25b234500a9b
parentea1a7a6b279595b9666eead2616b323b60aef596 (diff)
downloadlua-540dc65bcd16cd8ee2d6d2983036968ea388502b.tar.gz
lua-540dc65bcd16cd8ee2d6d2983036968ea388502b.tar.bz2
lua-540dc65bcd16cd8ee2d6d2983036968ea388502b.zip
Acrescentar o gerenciador de memoria "mm", corrigir bug reservando
o byte para a coleta de lixo nas constantes pre-definidas e colocar um teste em tempo de execucao para evitar duplicidade de valores na tabela de strings (teste ainda linear).
-rw-r--r--table.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/table.c b/table.c
index 62ad696a..b4cf8c6e 100644
--- a/table.c
+++ b/table.c
@@ -3,11 +3,13 @@
3** Module to control static tables 3** Module to control static tables
4*/ 4*/
5 5
6char *rcs_table="$Id: table.c,v 1.1 1993/12/17 18:41:19 celes Exp roberto $"; 6char *rcs_table="$Id: table.c,v 1.2 1993/12/22 21:15:16 roberto Exp celes $";
7 7
8#include <stdlib.h> 8#include <stdlib.h>
9#include <string.h> 9#include <string.h>
10 10
11#include "mm.h"
12
11#include "opcode.h" 13#include "opcode.h"
12#include "hash.h" 14#include "hash.h"
13#include "inout.h" 15#include "inout.h"
@@ -49,12 +51,14 @@ static struct List *searchlist=&o0;
49#ifndef MAXCONSTANT 51#ifndef MAXCONSTANT
50#define MAXCONSTANT 256 52#define MAXCONSTANT 256
51#endif 53#endif
52static char *constantbuffer[MAXCONSTANT] = {"mark","nil","number", 54/* pre-defined constants need garbage collection extra byte */
53 "string","table", 55static char *constantbuffer[MAXCONSTANT] = {" mark"+1," nil"+1,
54 "function","cfunction" 56 " number"+1, " string"+1,
57 " table"+1, " function"+1,
58 " cfunction"+1, " userdata"+1
55 }; 59 };
56char **lua_constant = constantbuffer; 60char **lua_constant = constantbuffer;
57Word lua_nconstant=T_CFUNCTION+1; 61Word lua_nconstant=T_USERDATA+1;
58 62
59#ifndef MAXSTRING 63#ifndef MAXSTRING
60#define MAXSTRING 512 64#define MAXSTRING 512
@@ -215,8 +219,13 @@ static void lua_pack (void)
215*/ 219*/
216char *lua_createstring (char *s) 220char *lua_createstring (char *s)
217{ 221{
222 int i;
218 if (s == NULL) return NULL; 223 if (s == NULL) return NULL;
219 224
225 for (i=0; i<lua_nstring; i++)
226 if (streq(s,lua_string[i]))
227 return s;
228
220 if (lua_nstring >= MAXSTRING-1) 229 if (lua_nstring >= MAXSTRING-1)
221 { 230 {
222 lua_pack (); 231 lua_pack ();