File tree 2 files changed +13
-5
lines changed
2 files changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -621,8 +621,7 @@ static void Mark_Series(REBSER *series, REBCNT depth);
621
621
if (IS_MARK_HOB (hob ))
622
622
UNMARK_HOB (hob );
623
623
else {
624
- Free_Hob (hob );
625
- count ++ ;
624
+ count += Free_Hob (hob );
626
625
}
627
626
}
628
627
hob ++ ;
Original file line number Diff line number Diff line change @@ -604,7 +604,7 @@ const REBPOOLSPEC Mem_Pool_Spec[MAX_POOLS] =
604
604
605
605
/***********************************************************************
606
606
**
607
- */ void Free_Hob (REBHOB * hob )
607
+ */ int Free_Hob (REBHOB * hob )
608
608
/*
609
609
** Free a hob, returning its memory for reuse.
610
610
**
@@ -613,19 +613,28 @@ const REBPOOLSPEC Mem_Pool_Spec[MAX_POOLS] =
613
613
REBHSP spec ;
614
614
REBCNT idx = hob -> index ;
615
615
616
- if ( !IS_USED_HOB (hob ) || hob -> data == NULL ) return ;
616
+ if ( !IS_USED_HOB (hob ) || hob -> data == NULL ) return 0 ;
617
617
618
618
spec = PG_Handles [idx ];
619
619
//printf("HOB %p free mem: %p %i\n", hob, hob->data, spec.flags);
620
620
621
621
if (spec .free ) {
622
- spec .free (spec .flags & HANDLE_REQUIRES_HOB_ON_FREE ? (void * )hob : (void * )hob -> data );
622
+ if (spec .flags & HANDLE_REQUIRES_HOB_ON_FREE ) {
623
+ spec .free ((void * )hob );
624
+ // Although there are no references, the extension may still need the handle.
625
+ // If extension marks the hob, do not free it now.
626
+ if (IS_MARK_HOB (hob )) return 0 ;
627
+ }
628
+ else {
629
+ spec .free (hob -> data );
630
+ }
623
631
}
624
632
625
633
CLEAR (hob -> data , spec .size );
626
634
FREE_MEM (hob -> data );
627
635
UNUSE_HOB (hob );
628
636
Free_Node (HOB_POOL , (REBNOD * )hob );
637
+ return 1 ;
629
638
}
630
639
631
640
You can’t perform that action at this time.
0 commit comments