mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 00:41:02 +00:00
GC tweaks
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@28063 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
8afbc2fcb7
commit
d2e2eda24c
2 changed files with 25 additions and 0 deletions
|
@ -241,7 +241,12 @@ add_to_queue(NSNotificationQueueList *queue, NSNotification *notification,
|
|||
{
|
||||
NSNotificationQueueRegistration *item;
|
||||
|
||||
#if GS_WITH_GC
|
||||
item = NSAllocateCollectable(sizeof(NSNotificationQueueRegistration),
|
||||
NSScannedOption);
|
||||
#else
|
||||
item = NSZoneCalloc(_zone, 1, sizeof(NSNotificationQueueRegistration));
|
||||
#endif
|
||||
if (item == 0)
|
||||
{
|
||||
[NSException raise: NSMallocException
|
||||
|
@ -334,8 +339,15 @@ add_to_queue(NSNotificationQueueList *queue, NSNotification *notification,
|
|||
|
||||
// init queue
|
||||
_center = RETAIN(notificationCenter);
|
||||
#if GS_WITH_GC
|
||||
_asapQueue = NSAllocateCollectable(sizeof(NSNotificationQueueList),
|
||||
NSScannedOption);
|
||||
_idleQueue = NSAllocateCollectable(sizeof(NSNotificationQueueList),
|
||||
NSScannedOption);
|
||||
#else
|
||||
_asapQueue = NSZoneCalloc(_zone, 1, sizeof(NSNotificationQueueList));
|
||||
_idleQueue = NSZoneCalloc(_zone, 1, sizeof(NSNotificationQueueList));
|
||||
#endif
|
||||
if (_asapQueue == 0 || _idleQueue == 0)
|
||||
{
|
||||
DESTROY(self);
|
||||
|
|
|
@ -811,6 +811,18 @@ GSDescriptionForClassMethod(pcl self, SEL aSel)
|
|||
}
|
||||
}
|
||||
|
||||
#if GS_WITH_GC
|
||||
/* Function to turn Boehm GC warnings into NSLog warnings.
|
||||
*/
|
||||
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);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* This message is sent to a class once just before it is used for the first
|
||||
* time. If class has a superclass, its implementation of +initialize is
|
||||
|
@ -827,6 +839,7 @@ GSDescriptionForClassMethod(pcl self, SEL aSel)
|
|||
* This is not necessary on most platforms, but is good practice.
|
||||
*/
|
||||
GC_init();
|
||||
GC_set_warn_proc(warn_proc);
|
||||
#endif
|
||||
|
||||
#ifdef __MINGW32__
|
||||
|
|
Loading…
Reference in a new issue