|
|
|
|
|
by Someone
5065 days ago
|
|
I am not sure I grok the code, but I think something along the following lines would work: - a 'recovery' list of (object pointer, old refcount) pairs
- whenever you allocate something, add (object pointer, 0) to the list
- when you update a reference count, check whether the object is in the list.
If it is not, add it to the list, thus remembering the original refcount
- whenever the code decreases reference count to zero, add the object to a
'to be deleted' list (this could possibly be a linked list chained through
the 'refcount' fields; the old refcount will be in the recovery list)
- when the parser reaches toplevel without longjmp, clear the first list,
and delete any objects in the 'to be deleted' list.
- when a longjmp occurs, walk the list and reset reference counts. For
zero 'old refcounts', delete the object
Elegant? Not really, but with proper macros/functions, it should not be much less elegant than reference counting on its own. |
|