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).
This commit is contained in:
19
table.c
19
table.c
@@ -3,11 +3,13 @@
|
|||||||
** Module to control static tables
|
** Module to control static tables
|
||||||
*/
|
*/
|
||||||
|
|
||||||
char *rcs_table="$Id: table.c,v 1.1 1993/12/17 18:41:19 celes Exp roberto $";
|
char *rcs_table="$Id: table.c,v 1.2 1993/12/22 21:15:16 roberto Exp celes $";
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "mm.h"
|
||||||
|
|
||||||
#include "opcode.h"
|
#include "opcode.h"
|
||||||
#include "hash.h"
|
#include "hash.h"
|
||||||
#include "inout.h"
|
#include "inout.h"
|
||||||
@@ -49,12 +51,14 @@ static struct List *searchlist=&o0;
|
|||||||
#ifndef MAXCONSTANT
|
#ifndef MAXCONSTANT
|
||||||
#define MAXCONSTANT 256
|
#define MAXCONSTANT 256
|
||||||
#endif
|
#endif
|
||||||
static char *constantbuffer[MAXCONSTANT] = {"mark","nil","number",
|
/* pre-defined constants need garbage collection extra byte */
|
||||||
"string","table",
|
static char *constantbuffer[MAXCONSTANT] = {" mark"+1," nil"+1,
|
||||||
"function","cfunction"
|
" number"+1, " string"+1,
|
||||||
|
" table"+1, " function"+1,
|
||||||
|
" cfunction"+1, " userdata"+1
|
||||||
};
|
};
|
||||||
char **lua_constant = constantbuffer;
|
char **lua_constant = constantbuffer;
|
||||||
Word lua_nconstant=T_CFUNCTION+1;
|
Word lua_nconstant=T_USERDATA+1;
|
||||||
|
|
||||||
#ifndef MAXSTRING
|
#ifndef MAXSTRING
|
||||||
#define MAXSTRING 512
|
#define MAXSTRING 512
|
||||||
@@ -215,8 +219,13 @@ static void lua_pack (void)
|
|||||||
*/
|
*/
|
||||||
char *lua_createstring (char *s)
|
char *lua_createstring (char *s)
|
||||||
{
|
{
|
||||||
|
int i;
|
||||||
if (s == NULL) return NULL;
|
if (s == NULL) return NULL;
|
||||||
|
|
||||||
|
for (i=0; i<lua_nstring; i++)
|
||||||
|
if (streq(s,lua_string[i]))
|
||||||
|
return s;
|
||||||
|
|
||||||
if (lua_nstring >= MAXSTRING-1)
|
if (lua_nstring >= MAXSTRING-1)
|
||||||
{
|
{
|
||||||
lua_pack ();
|
lua_pack ();
|
||||||
|
|||||||
Reference in New Issue
Block a user