diff options
| author | Waldemar Celes <celes@tecgraf.puc-rio.br> | 1994-10-17 17:03:23 -0200 |
|---|---|---|
| committer | Waldemar Celes <celes@tecgraf.puc-rio.br> | 1994-10-17 17:03:23 -0200 |
| commit | f8c8159362f4bb8820908085adcb06900ef33b4c (patch) | |
| tree | 2cbe498f152dad434973e4b718ba04dd08ca3b83 /hash.c | |
| parent | d1c5f4294365e9c5dbcd7f57bd0e3d55b548329c (diff) | |
| download | lua-f8c8159362f4bb8820908085adcb06900ef33b4c.tar.gz lua-f8c8159362f4bb8820908085adcb06900ef33b4c.tar.bz2 lua-f8c8159362f4bb8820908085adcb06900ef33b4c.zip | |
adaptative garbage collection.
Diffstat (limited to 'hash.c')
| -rw-r--r-- | hash.c | 7 |
1 files changed, 4 insertions, 3 deletions
| @@ -3,7 +3,7 @@ | |||
| 3 | ** hash manager for lua | 3 | ** hash manager for lua |
| 4 | */ | 4 | */ |
| 5 | 5 | ||
| 6 | char *rcs_hash="$Id: hash.c,v 2.7 1994/09/08 15:27:10 celes Exp celes $"; | 6 | char *rcs_hash="$Id: hash.c,v 2.8 1994/10/11 12:59:49 celes Exp $"; |
| 7 | 7 | ||
| 8 | #include <string.h> | 8 | #include <string.h> |
| 9 | #include <stdlib.h> | 9 | #include <stdlib.h> |
| @@ -52,7 +52,7 @@ static int redimension (int nhash) | |||
| 52 | return nhash*2+1; | 52 | return nhash*2+1; |
| 53 | } | 53 | } |
| 54 | 54 | ||
| 55 | static int index (Hash *t, Object *ref) /* hash function */ | 55 | static int hashindex (Hash *t, Object *ref) /* hash function */ |
| 56 | { | 56 | { |
| 57 | switch (tag(ref)) | 57 | switch (tag(ref)) |
| 58 | { | 58 | { |
| @@ -97,7 +97,7 @@ static int equalObj (Object *t1, Object *t2) | |||
| 97 | 97 | ||
| 98 | static int present (Hash *t, Object *ref) | 98 | static int present (Hash *t, Object *ref) |
| 99 | { | 99 | { |
| 100 | int h = index(t, ref); | 100 | int h = hashindex(t, ref); |
| 101 | if (h < 0) return h; | 101 | if (h < 0) return h; |
| 102 | while (tag(ref(node(t, h))) != T_NIL) | 102 | while (tag(ref(node(t, h))) != T_NIL) |
| 103 | { | 103 | { |
| @@ -195,6 +195,7 @@ void lua_hashcollector (void) | |||
| 195 | if (prev == NULL) listhead = next; | 195 | if (prev == NULL) listhead = next; |
| 196 | else prev->next = next; | 196 | else prev->next = next; |
| 197 | hashdelete(curr_array); | 197 | hashdelete(curr_array); |
| 198 | ++lua_recovered; | ||
| 198 | } | 199 | } |
| 199 | else | 200 | else |
| 200 | { | 201 | { |
