aboutsummaryrefslogtreecommitdiff
path: root/tree.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>1996-02-22 17:34:33 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>1996-02-22 17:34:33 -0300
commit8c1a9899d4460aa19780919f4245c08d7ebba0e9 (patch)
tree685817907f64133330011eb7db845830c9327a3e /tree.c
parent05caf09a36cadaab401bc9a24e29e2cd6e4126d4 (diff)
downloadlua-8c1a9899d4460aa19780919f4245c08d7ebba0e9.tar.gz
lua-8c1a9899d4460aa19780919f4245c08d7ebba0e9.tar.bz2
lua-8c1a9899d4460aa19780919f4245c08d7ebba0e9.zip
functions "luaI_free" and "luaI_realloc" (or macro "growvector") may be
called with NULL.
Diffstat (limited to 'tree.c')
-rw-r--r--tree.c28
1 files changed, 13 insertions, 15 deletions
diff --git a/tree.c b/tree.c
index 8f0c08b4..fa708c9d 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.17 1996/02/14 13:35:51 roberto Exp roberto $"; 6char *rcs_tree="$Id: tree.c,v 1.18 1996/02/14 19:11:09 roberto Exp roberto $";
7 7
8 8
9#include <string.h> 9#include <string.h>
@@ -55,20 +55,18 @@ static void grow (stringtable *tb)
55 int i; 55 int i;
56 for (i=0; i<newsize; i++) 56 for (i=0; i<newsize; i++)
57 newhash[i] = NULL; 57 newhash[i] = NULL;
58 if (tb->size > 0) 58 /* rehash */
59 { /* rehash */ 59 tb->nuse = 0;
60 tb->nuse = 0; 60 for (i=0; i<tb->size; i++)
61 for (i=0; i<tb->size; i++) 61 if (tb->hash[i] != NULL && tb->hash[i] != &EMPTY)
62 if (tb->hash[i] != NULL && tb->hash[i] != &EMPTY) 62 {
63 { 63 int h = tb->hash[i]->hash%newsize;
64 int h = tb->hash[i]->hash%newsize; 64 while (newhash[h])
65 while (newhash[h]) 65 h = (h+1)%newsize;
66 h = (h+1)%newsize; 66 newhash[h] = tb->hash[i];
67 newhash[h] = tb->hash[i]; 67 tb->nuse++;
68 tb->nuse++; 68 }
69 } 69 luaI_free(tb->hash);
70 luaI_free(tb->hash);
71 }
72 tb->size = newsize; 70 tb->size = newsize;
73 tb->hash = newhash; 71 tb->hash = newhash;
74} 72}