diff options
author | Steve Bennett <steveb@workware.net.au> | 2021-07-08 22:15:07 +1000 |
---|---|---|
committer | Steve Bennett <steveb@workware.net.au> | 2021-07-08 22:36:50 +1000 |
commit | 500866719dde1cb03d87b550cc8998b31d9e1316 (patch) | |
tree | 32dbb05cdf3318090ff697790c3139ad8dbbbf92 /jim.c | |
parent | 40298deee7cd1e72cb5e34ef98e07bc6adff2573 (diff) | |
download | jimtcl-500866719dde1cb03d87b550cc8998b31d9e1316.zip jimtcl-500866719dde1cb03d87b550cc8998b31d9e1316.tar.gz jimtcl-500866719dde1cb03d87b550cc8998b31d9e1316.tar.bz2 |
collect: correctly handle references as globally scoped names
When a reference is used as a command name (e.g. in oo.tcl) it
is created in the global namespace as ::<reference...
The current check for references that are commands with a reference
count of 1 doesn't take this into account so these references
were not being garbage collected.
Signed-off-by: Steve Bennett <steveb@workware.net.au>
Diffstat (limited to 'jim.c')
-rw-r--r-- | jim.c | 14 |
1 files changed, 11 insertions, 3 deletions
@@ -5505,6 +5505,14 @@ int Jim_Collect(Jim_Interp *interp) continue; } + /* If the string is ::<reference we need to skip over the :: when doing the + * comparison + */ + if (str[0] == ':' && str[1] == ':') { + str +=2; + len -= 2; + } + /* Extract references from the object string repr. */ while (1) { int i; @@ -5526,9 +5534,9 @@ int Jim_Collect(Jim_Interp *interp) /* Ok, a reference for the given ID * was found. Mark it. */ - /* But if this is a command in the command table with refCount 1 - * don't mark it since it can be deleted. - */ + /* But if this is a command in the command table with refCount 1 + * don't mark it since it can be deleted. + */ if (p == str && objPtr->refCount == 1 && Jim_FindHashEntry(&interp->commands, objPtr)) { #ifdef JIM_DEBUG_GC printf("No MARK: %lu - command with refcount=1\n", id); |