aboutsummaryrefslogtreecommitdiff
path: root/ltable.c
diff options
context:
space:
mode:
Diffstat (limited to 'ltable.c')
-rw-r--r--ltable.c25
1 files changed, 11 insertions, 14 deletions
diff --git a/ltable.c b/ltable.c
index fbded6cf..3070ea90 100644
--- a/ltable.c
+++ b/ltable.c
@@ -1,10 +1,9 @@
1/* 1/*
2** $Id: ltable.c,v 1.23 1999/08/16 20:52:00 roberto Exp roberto $ 2** $Id: ltable.c,v 1.24 1999/09/22 14:38:45 roberto Exp roberto $
3** Lua tables (hash) 3** Lua tables (hash)
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
6 6
7#include <stdlib.h>
8 7
9#include "lauxlib.h" 8#include "lauxlib.h"
10#include "lmem.h" 9#include "lmem.h"
@@ -69,17 +68,6 @@ Node *luaH_present (const Hash *t, const TObject *key) {
69} 68}
70 69
71 70
72void luaH_free (Hash *frees) {
73 while (frees) {
74 Hash *next = (Hash *)frees->head.next;
75 L->nblocks -= gcsize(frees->nhash);
76 luaM_free(nodevector(frees));
77 luaM_free(frees);
78 frees = next;
79 }
80}
81
82
83static Node *hashnodecreate (int nhash) { 71static Node *hashnodecreate (int nhash) {
84 Node *const v = luaM_newvector(nhash, Node); 72 Node *const v = luaM_newvector(nhash, Node);
85 int i; 73 int i;
@@ -96,12 +84,21 @@ Hash *luaH_new (int nhash) {
96 nhash(t) = nhash; 84 nhash(t) = nhash;
97 nuse(t) = 0; 85 nuse(t) = 0;
98 t->htag = TagDefault; 86 t->htag = TagDefault;
99 luaO_insertlist(&(L->roottable), (GCnode *)t); 87 t->next = L->roottable;
88 L->roottable = t;
89 t->marked = 0;
100 L->nblocks += gcsize(nhash); 90 L->nblocks += gcsize(nhash);
101 return t; 91 return t;
102} 92}
103 93
104 94
95void luaH_free (Hash *t) {
96 L->nblocks -= gcsize(t->nhash);
97 luaM_free(nodevector(t));
98 luaM_free(t);
99}
100
101
105static int newsize (Hash *t) { 102static int newsize (Hash *t) {
106 Node *const v = t->node; 103 Node *const v = t->node;
107 const int size = nhash(t); 104 const int size = nhash(t);