Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 17 additions & 15 deletions src/weakptr.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,32 +200,34 @@ Obj FuncWeakPointerObj( Obj self, Obj list ) {
** trailing items may evaporate.
**
** Any identifiers of trailing objects that have evaporated in a garbage
** collection are cleaned up by this function
** collection are cleaned up by this function, if we have exclusive
** write access, otherwise they stay around.
*/

Int LengthWPObj(Obj wp)
{
Int len;
Obj elm;
Int changed = 0;
len = STORED_LEN_WPOBJ(wp);
if (CheckExclusiveWriteAccess(wp)) {
#ifndef BOEHM_GC
for (len = STORED_LEN_WPOBJ(wp);
len > 0 &&
(!(elm = ELM_WPOBJ(wp,len)) ||
IS_WEAK_DEAD_BAG(elm));
len --)
{
for (; len > 0 &&
(!(elm = ELM_WPOBJ(wp,len)) ||
IS_WEAK_DEAD_BAG(elm));
len --)
{
changed = 1;
if (elm)
ELM_WPOBJ(wp,len) = 0;
}
#else
while (len > 0 && !ELM_WPOBJ(wp, len)) {
changed = 1;
if (elm)
ELM_WPOBJ(wp,len) = 0;
len--;
}
#else
len = STORED_LEN_WPOBJ(wp);
while (len > 0 && !ELM_WPOBJ(wp, len)) {
changed = 1;
len--;
}
#endif
}
if (changed)
STORE_LEN_WPOBJ(wp,len);
return len;
Expand Down