mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 00:30:53 +00:00
garbage collecting fixes
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@27638 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
bf2cc9c7ed
commit
9c5d4cd19e
6 changed files with 275 additions and 156 deletions
|
@ -41,7 +41,6 @@
|
|||
* a collected observer removed.
|
||||
*/
|
||||
#if GS_WITH_GC
|
||||
#include <gc.h>
|
||||
#define purgeCollected(X) (X = listPurge(X, nil))
|
||||
#else
|
||||
#define purgeCollected(X) (X)
|
||||
|
@ -437,7 +436,7 @@ static void obsFree(Observation *o)
|
|||
NCTable *t = o->link;
|
||||
|
||||
#if GS_WITH_GC
|
||||
GC_unregister_disappearing_link((GC_PTR*)&o->observer);
|
||||
GSAssignZeroingWeakPointer((void**)&o->observer, 0);
|
||||
#endif
|
||||
o->link = (NCTable*)t->freeList;
|
||||
t->freeList = o;
|
||||
|
@ -705,23 +704,14 @@ static NSNotificationCenter *default_center = nil;
|
|||
o = obsNew(TABLE);
|
||||
o->selector = selector;
|
||||
o->method = method;
|
||||
#if GS_WITH_GC
|
||||
GSAssignZeroingWeakPointer((void**)&o->observer, (void*)observer);
|
||||
#else
|
||||
o->observer = observer;
|
||||
#endif
|
||||
o->retained = 0;
|
||||
o->next = 0;
|
||||
|
||||
#if GS_WITH_GC
|
||||
/* Ensure that if the observer is garbage collected, we clear the
|
||||
* oservation so that we don't end up sending notifications to the
|
||||
* deallocated object.
|
||||
* The observer must be a real GC-allocated object or this mechanism
|
||||
* can't be used.
|
||||
*/
|
||||
if (GC_base(observer) != 0)
|
||||
{
|
||||
GC_general_register_disappearing_link((GC_PTR*)&o->observer, observer);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (object != nil)
|
||||
{
|
||||
object = CHEATGC(object);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue