use weak pointers for siblings

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@28128 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2009-03-24 10:53:38 +00:00
parent 346052f64d
commit 057818ab06
4 changed files with 15 additions and 3 deletions

View file

@ -3,6 +3,7 @@
* Source/GSSocketStream.h:
* Source/GSSocketStream.m:
Avoid unnecessary memory allocation.
Use weak pointers to break finalisation cycles.
2009-03-21 Richard Frith-Macdonald <rfm@gnu.org>

View file

@ -111,6 +111,12 @@ GSPrivateSockaddrLength(struct sockaddr *addr)
@implementation GSStreamHandler
+ (void) initialize
{
GSMakeWeakPointer(self, "istream");
GSMakeWeakPointer(self, "ostream");
}
+ (void) tryInput: (GSSocketInputStream*)i output: (GSSocketOutputStream*)o
{
[self subclassResponsibility: _cmd];
@ -1577,6 +1583,7 @@ setNonBlocking(SOCKET fd)
+ (void) initialize
{
GSMakeWeakPointer(self, "_sibling");
if (self == [GSSocketInputStream class])
{
GSObjCAddClassBehavior(self, [GSSocketStream class]);
@ -1990,6 +1997,7 @@ setNonBlocking(SOCKET fd)
+ (void) initialize
{
GSMakeWeakPointer(self, "_sibling");
if (self == [GSSocketOutputStream class])
{
GSObjCAddClassBehavior(self, [GSSocketStream class]);
@ -2400,6 +2408,7 @@ setNonBlocking(SOCKET fd)
+ (void) initialize
{
GSMakeWeakPointer(self, "_sibling");
if (self == [GSSocketServerStream class])
{
GSObjCAddClassBehavior(self, [GSSocketStream class]);

View file

@ -156,7 +156,7 @@ static RunLoopEventType typeForStream(NSStream *aStream)
}
[self _unschedule];
[self _setStatus: NSStreamStatusClosed];
/* We don't want to send any events the the delegate after the
/* We don't want to send any events to the delegate after the
* stream has been closed.
*/
_delegateValid = NO;

View file

@ -812,14 +812,16 @@ GSDescriptionForClassMethod(pcl self, SEL aSel)
}
#if GS_WITH_GC
/* Function to turn Boehm GC warnings into NSLog warnings.
/* Function to log Boehm GC warnings
* NB. This must not allocate any collectable memory as it may result
* in a deadlock in the garbage collecting library.
*/
static void
warn_proc(char *msg, GC_word arg)
{
char buf[strlen(msg)+1024];
sprintf(buf, msg, (unsigned long)arg);
NSLog(@"Garbage collector: %s", buf);
fprintf(stderr, "Garbage collector: %s", buf);
}
#endif