diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1994-11-17 11:58:57 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1994-11-17 11:58:57 -0200 |
commit | b234da1cc2053b8919a9b27af67291e48fdf9703 (patch) | |
tree | b32559df54e0d9c79fe271260f69238244ae2fc7 /tree.c | |
parent | d6a1699e37257c0b3d4651a481ce0bf597bc4e45 (diff) | |
download | lua-b234da1cc2053b8919a9b27af67291e48fdf9703.tar.gz lua-b234da1cc2053b8919a9b27af67291e48fdf9703.tar.bz2 lua-b234da1cc2053b8919a9b27af67291e48fdf9703.zip |
changes in garbage collection control
Diffstat (limited to 'tree.c')
-rw-r--r-- | tree.c | 15 |
1 files changed, 8 insertions, 7 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.6 1994/11/16 17:38:08 roberto Exp roberto $"; | 6 | char *rcs_tree="$Id: tree.c,v 1.7 1994/11/16 18:09:11 roberto Exp roberto $"; |
7 | 7 | ||
8 | 8 | ||
9 | #include <string.h> | 9 | #include <string.h> |
@@ -55,14 +55,13 @@ static TreeNode *tree_create (TreeNode **node, char *str) | |||
55 | 55 | ||
56 | char *lua_strcreate (char *str) | 56 | char *lua_strcreate (char *str) |
57 | { | 57 | { |
58 | StringNode *newString = (StringNode *)luaI_malloc(sizeof(StringNode)+ | 58 | StringNode *newString; |
59 | strlen(str)); | 59 | lua_pack(); |
60 | newString = (StringNode *)luaI_malloc(sizeof(StringNode)+strlen(str)); | ||
60 | newString->mark = UNMARKED_STRING; | 61 | newString->mark = UNMARKED_STRING; |
61 | strcpy(newString->str, str); | 62 | strcpy(newString->str, str); |
62 | newString->next = string_root; | 63 | newString->next = string_root; |
63 | string_root = newString; | 64 | string_root = newString; |
64 | if (lua_nentity == lua_block) lua_pack (); | ||
65 | lua_nentity++; | ||
66 | return newString->str; | 65 | return newString->str; |
67 | } | 66 | } |
68 | 67 | ||
@@ -77,9 +76,10 @@ TreeNode *lua_constcreate (char *str) | |||
77 | ** Garbage collection function. | 76 | ** Garbage collection function. |
78 | ** This function traverse the string list freeing unindexed strings | 77 | ** This function traverse the string list freeing unindexed strings |
79 | */ | 78 | */ |
80 | void lua_strcollector (void) | 79 | int lua_strcollector (void) |
81 | { | 80 | { |
82 | StringNode *curr = string_root, *prev = NULL; | 81 | StringNode *curr = string_root, *prev = NULL; |
82 | int counter = 0; | ||
83 | while (curr) | 83 | while (curr) |
84 | { | 84 | { |
85 | StringNode *next = curr->next; | 85 | StringNode *next = curr->next; |
@@ -88,7 +88,7 @@ void lua_strcollector (void) | |||
88 | if (prev == NULL) string_root = next; | 88 | if (prev == NULL) string_root = next; |
89 | else prev->next = next; | 89 | else prev->next = next; |
90 | luaI_free(curr); | 90 | luaI_free(curr); |
91 | ++lua_recovered; | 91 | ++counter; |
92 | } | 92 | } |
93 | else | 93 | else |
94 | { | 94 | { |
@@ -97,6 +97,7 @@ void lua_strcollector (void) | |||
97 | } | 97 | } |
98 | curr = next; | 98 | curr = next; |
99 | } | 99 | } |
100 | return counter; | ||
100 | } | 101 | } |
101 | 102 | ||
102 | /* | 103 | /* |