More tweaks for garbage collection mode, including making NSNotificationCenter use weak pointers (things are never removed if it uses strong pointers because they remove themselves in the -dealloc method, which is never called, and can't remove themselves in the -finalize method because the -finalize method would not be called until after they have been removed - this is consistent with Apple behaviour).

Gorm now works correctly when built with GC enabled.



git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@33109 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
theraven 2011-05-25 11:15:08 +00:00
parent cf144e76f1
commit 485d23c7c7
7 changed files with 20 additions and 26 deletions

View file

@ -390,11 +390,7 @@ fixBOM(unsigned char **bytes, NSUInteger*length, BOOL *owned,
len -= sizeof(unichar);
memcpy(&u, from, sizeof(unichar));
from += sizeof(unichar);
#if GS_WITH_GC
to = NSAllocateCollectable(len, 0);
#else
to = NSZoneMalloc(NSDefaultMallocZone(), len);
#endif
if (u == 0xFEFF)
{
// Native byte order
@ -443,11 +439,7 @@ fixBOM(unsigned char **bytes, NSUInteger*length, BOOL *owned,
// Got a byte order marker ... remove it.
len -= 3;
from += 3;
#if GS_WITH_GC
to = NSAllocateCollectable(len, 0);
#else
to = NSZoneMalloc(NSDefaultMallocZone(), len);
#endif
memcpy(to, from, len);
if (*owned == YES)
{
@ -485,7 +477,7 @@ fixBOM(unsigned char **bytes, NSUInteger*length, BOOL *owned,
*/
if (original == bytes)
{
#if GS_WITH_GC
#if GS_WITH_GC || __OBJC_GC__
chars = NSAllocateCollectable(length, 0);
#else
chars = NSZoneMalloc([self zone], length);