diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1997-05-05 17:21:23 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1997-05-05 17:21:23 -0300 |
| commit | 12d9731a49530c4190142da3621f8508a629ca88 (patch) | |
| tree | 5c1ca09c45de28d671bca371815e429316eb0a98 | |
| parent | 4aade854bb126b87907cf0d9da2ddc0b937e22d5 (diff) | |
| download | lua-12d9731a49530c4190142da3621f8508a629ca88.tar.gz lua-12d9731a49530c4190142da3621f8508a629ca88.tar.bz2 lua-12d9731a49530c4190142da3621f8508a629ca88.zip | |
bug: string table must be initialized.
| -rw-r--r-- | tree.c | 18 |
1 files changed, 15 insertions, 3 deletions
| @@ -3,7 +3,7 @@ | |||
| 3 | ** TecCGraf - PUC-Rio | 3 | ** TecCGraf - PUC-Rio |
| 4 | */ | 4 | */ |
| 5 | 5 | ||
| 6 | char *rcs_tree="$Id: tree.c,v 1.23 1997/03/31 14:02:58 roberto Exp roberto $"; | 6 | char *rcs_tree="$Id: tree.c,v 1.24 1997/03/31 14:17:09 roberto Exp roberto $"; |
| 7 | 7 | ||
| 8 | 8 | ||
| 9 | #include <string.h> | 9 | #include <string.h> |
| @@ -40,9 +40,22 @@ static unsigned long hash (char *buff, long size) | |||
| 40 | return h; | 40 | return h; |
| 41 | } | 41 | } |
| 42 | 42 | ||
| 43 | |||
| 44 | static void luaI_inittree (void) | ||
| 45 | { | ||
| 46 | int i; | ||
| 47 | for (i=0; i<NUM_HASHS; i++) { | ||
| 48 | string_root[i].size = 0; | ||
| 49 | string_root[i].nuse = 0; | ||
| 50 | string_root[i].hash = NULL; | ||
| 51 | } | ||
| 52 | } | ||
| 53 | |||
| 54 | |||
| 43 | static void initialize (void) | 55 | static void initialize (void) |
| 44 | { | 56 | { |
| 45 | initialized = 1; | 57 | initialized = 1; |
| 58 | luaI_inittree(); | ||
| 46 | luaI_addReserved(); | 59 | luaI_addReserved(); |
| 47 | luaI_initsymbol(); | 60 | luaI_initsymbol(); |
| 48 | luaI_initconstant(); | 61 | luaI_initconstant(); |
| @@ -60,8 +73,7 @@ static void grow (stringtable *tb) | |||
| 60 | /* rehash */ | 73 | /* rehash */ |
| 61 | tb->nuse = 0; | 74 | tb->nuse = 0; |
| 62 | for (i=0; i<tb->size; i++) | 75 | for (i=0; i<tb->size; i++) |
| 63 | if (tb->hash[i] != NULL && tb->hash[i] != &EMPTY) | 76 | if (tb->hash[i] != NULL && tb->hash[i] != &EMPTY) { |
| 64 | { | ||
| 65 | int h = tb->hash[i]->hash%newsize; | 77 | int h = tb->hash[i]->hash%newsize; |
| 66 | while (newhash[h]) | 78 | while (newhash[h]) |
| 67 | h = (h+1)%newsize; | 79 | h = (h+1)%newsize; |
