mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-11 00:30:49 +00:00
Tidied a little, removing redundant code.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@20154 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
2a49f09265
commit
d5460c236d
2 changed files with 41 additions and 79 deletions
|
@ -1,3 +1,8 @@
|
|||
2004-09-27 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSDebug.m: Remove checks for existence of lock ... it always
|
||||
exists, so the checks are useless.
|
||||
|
||||
2004-09-24 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/GSArray.m: Make perform methods enumerate forwards.
|
||||
|
|
|
@ -58,7 +58,7 @@ static table_entry* the_table = 0;
|
|||
|
||||
static BOOL debug_allocation = NO;
|
||||
|
||||
static NSLock *uniqueLock;
|
||||
static NSLock *uniqueLock = nil;
|
||||
|
||||
static const char* _GSDebugAllocationList(BOOL difference);
|
||||
static const char* _GSDebugAllocationListAll(void);
|
||||
|
@ -88,10 +88,7 @@ void
|
|||
GSSetDebugAllocationFunctions(void (*newAddObjectFunc)(Class c, id o),
|
||||
void (*newRemoveObjectFunc)(Class c, id o))
|
||||
{
|
||||
if (uniqueLock != nil)
|
||||
{
|
||||
[uniqueLock lock];
|
||||
}
|
||||
|
||||
if (newAddObjectFunc && newRemoveObjectFunc)
|
||||
{
|
||||
|
@ -105,10 +102,7 @@ GSSetDebugAllocationFunctions(void (*newAddObjectFunc)(Class c, id o),
|
|||
_GSDebugAllocationRemoveFunc = _GSDebugAllocationRemove;
|
||||
}
|
||||
|
||||
if (uniqueLock != nil)
|
||||
{
|
||||
[uniqueLock unlock];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -129,7 +123,7 @@ GSDebugAllocationActive(BOOL active)
|
|||
BOOL old = debug_allocation;
|
||||
|
||||
[GSDebugAlloc class]; /* Ensure thread support is working */
|
||||
debug_allocation = active;
|
||||
debug_allocation = active ? YES : NO;
|
||||
return old;
|
||||
}
|
||||
|
||||
|
@ -160,15 +154,12 @@ GSDebugAllocationActiveRecordingObjects(Class c)
|
|||
{
|
||||
if (the_table[i].class == c)
|
||||
{
|
||||
if (uniqueLock != nil)
|
||||
[uniqueLock lock];
|
||||
the_table[i].is_recording = YES;
|
||||
if (uniqueLock != nil)
|
||||
[uniqueLock unlock];
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (uniqueLock != nil)
|
||||
[uniqueLock lock];
|
||||
if (num_classes >= table_size)
|
||||
{
|
||||
|
@ -179,7 +170,6 @@ GSDebugAllocationActiveRecordingObjects(Class c)
|
|||
|
||||
if (tmp == 0)
|
||||
{
|
||||
if (uniqueLock != nil)
|
||||
[uniqueLock unlock];
|
||||
return;
|
||||
}
|
||||
|
@ -202,7 +192,6 @@ GSDebugAllocationActiveRecordingObjects(Class c)
|
|||
the_table[num_classes].num_recorded_objects = 0;
|
||||
the_table[num_classes].stack_size = 0;
|
||||
num_classes++;
|
||||
if (uniqueLock != nil)
|
||||
[uniqueLock unlock];
|
||||
}
|
||||
|
||||
|
@ -215,7 +204,7 @@ GSDebugAllocationAdd(Class c, id o)
|
|||
void
|
||||
_GSDebugAllocationAdd(Class c, id o)
|
||||
{
|
||||
if (debug_allocation)
|
||||
if (debug_allocation == YES)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
|
@ -223,7 +212,6 @@ _GSDebugAllocationAdd(Class c, id o)
|
|||
{
|
||||
if (the_table[i].class == c)
|
||||
{
|
||||
if (uniqueLock != nil)
|
||||
[uniqueLock lock];
|
||||
the_table[i].count++;
|
||||
the_table[i].total++;
|
||||
|
@ -244,7 +232,6 @@ _GSDebugAllocationAdd(Class c, id o)
|
|||
more * sizeof(id));
|
||||
if (tmp == 0)
|
||||
{
|
||||
if (uniqueLock != nil)
|
||||
[uniqueLock unlock];
|
||||
return;
|
||||
}
|
||||
|
@ -254,7 +241,6 @@ _GSDebugAllocationAdd(Class c, id o)
|
|||
if (tmp1 == 0)
|
||||
{
|
||||
NSZoneFree(NSDefaultMallocZone(), tmp);
|
||||
if (uniqueLock != nil)
|
||||
[uniqueLock unlock];
|
||||
return;
|
||||
}
|
||||
|
@ -284,12 +270,10 @@ _GSDebugAllocationAdd(Class c, id o)
|
|||
[the_table[i].num_recorded_objects] = nil;
|
||||
the_table[i].num_recorded_objects++;
|
||||
}
|
||||
if (uniqueLock != nil)
|
||||
[uniqueLock unlock];
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (uniqueLock != nil)
|
||||
[uniqueLock lock];
|
||||
if (num_classes >= table_size)
|
||||
{
|
||||
|
@ -300,7 +284,6 @@ _GSDebugAllocationAdd(Class c, id o)
|
|||
|
||||
if (tmp == 0)
|
||||
{
|
||||
if (uniqueLock != nil)
|
||||
[uniqueLock unlock];
|
||||
return; /* Argh */
|
||||
}
|
||||
|
@ -323,7 +306,6 @@ _GSDebugAllocationAdd(Class c, id o)
|
|||
the_table[num_classes].num_recorded_objects = 0;
|
||||
the_table[num_classes].stack_size = 0;
|
||||
num_classes++;
|
||||
if (uniqueLock != nil)
|
||||
[uniqueLock unlock];
|
||||
}
|
||||
}
|
||||
|
@ -441,7 +423,6 @@ GSDebugAllocationClassList()
|
|||
size_t siz;
|
||||
unsigned int i;
|
||||
|
||||
if (uniqueLock != nil)
|
||||
[uniqueLock lock];
|
||||
|
||||
siz = sizeof(Class) * (num_classes + 1);
|
||||
|
@ -453,7 +434,6 @@ GSDebugAllocationClassList()
|
|||
}
|
||||
ans[num_classes] = NULL;
|
||||
|
||||
if (uniqueLock != nil)
|
||||
[uniqueLock unlock];
|
||||
|
||||
return ans;
|
||||
|
@ -479,16 +459,10 @@ GSDebugAllocationList(BOOL changeFlag)
|
|||
{
|
||||
return "Debug allocation system is not active!\n";
|
||||
}
|
||||
if (uniqueLock != nil)
|
||||
{
|
||||
[uniqueLock lock];
|
||||
}
|
||||
ans = _GSDebugAllocationList(changeFlag);
|
||||
d = [NSData dataWithBytes: ans length: strlen(ans) + 1];
|
||||
if (uniqueLock != nil)
|
||||
{
|
||||
[uniqueLock unlock];
|
||||
}
|
||||
return (const char*)[d bytes];
|
||||
}
|
||||
|
||||
|
@ -583,16 +557,10 @@ GSDebugAllocationListAll()
|
|||
{
|
||||
return "Debug allocation system is not active!\n";
|
||||
}
|
||||
if (uniqueLock != nil)
|
||||
{
|
||||
[uniqueLock lock];
|
||||
}
|
||||
ans = _GSDebugAllocationListAll();
|
||||
d = [NSData dataWithBytes: ans length: strlen(ans)+1];
|
||||
if (uniqueLock != nil)
|
||||
{
|
||||
[uniqueLock unlock];
|
||||
}
|
||||
return (const char*)[d bytes];
|
||||
}
|
||||
|
||||
|
@ -659,7 +627,7 @@ GSDebugAllocationRemove(Class c, id o)
|
|||
void
|
||||
_GSDebugAllocationRemove(Class c, id o)
|
||||
{
|
||||
if (debug_allocation)
|
||||
if (debug_allocation == YES)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
|
@ -669,7 +637,6 @@ _GSDebugAllocationRemove(Class c, id o)
|
|||
{
|
||||
id tag = nil;
|
||||
|
||||
if (uniqueLock != nil)
|
||||
[uniqueLock lock];
|
||||
the_table[i].count--;
|
||||
if (the_table[i].is_recording)
|
||||
|
@ -705,7 +672,6 @@ _GSDebugAllocationRemove(Class c, id o)
|
|||
;
|
||||
}
|
||||
}
|
||||
if (uniqueLock != nil)
|
||||
[uniqueLock unlock];
|
||||
RELEASE(tag);
|
||||
return;
|
||||
|
@ -733,7 +699,6 @@ GSDebugAllocationTagRecordedObject(id object, id tag)
|
|||
{
|
||||
return nil;
|
||||
}
|
||||
if (uniqueLock != nil)
|
||||
[uniqueLock lock];
|
||||
|
||||
for (i = 0; i < num_classes; i++)
|
||||
|
@ -748,7 +713,6 @@ GSDebugAllocationTagRecordedObject(id object, id tag)
|
|||
|| the_table[i].is_recording == NO
|
||||
|| the_table[i].num_recorded_objects == 0)
|
||||
{
|
||||
if (uniqueLock != nil)
|
||||
[uniqueLock unlock];
|
||||
return nil;
|
||||
}
|
||||
|
@ -763,7 +727,6 @@ GSDebugAllocationTagRecordedObject(id object, id tag)
|
|||
}
|
||||
}
|
||||
|
||||
if (uniqueLock != nil)
|
||||
[uniqueLock unlock];
|
||||
return AUTORELEASE(o);
|
||||
}
|
||||
|
@ -790,7 +753,6 @@ GSDebugAllocationListRecordedObjects(Class c)
|
|||
return nil;
|
||||
}
|
||||
|
||||
if (uniqueLock != nil)
|
||||
[uniqueLock lock];
|
||||
|
||||
for (i = 0; i < num_classes; i++)
|
||||
|
@ -803,21 +765,18 @@ GSDebugAllocationListRecordedObjects(Class c)
|
|||
|
||||
if (i == num_classes)
|
||||
{
|
||||
if (uniqueLock != nil)
|
||||
[uniqueLock unlock];
|
||||
return nil;
|
||||
}
|
||||
|
||||
if (the_table[i].is_recording == NO)
|
||||
{
|
||||
if (uniqueLock != nil)
|
||||
[uniqueLock unlock];
|
||||
return nil;
|
||||
}
|
||||
|
||||
if (the_table[i].num_recorded_objects == 0)
|
||||
{
|
||||
if (uniqueLock != nil)
|
||||
[uniqueLock unlock];
|
||||
return [NSArray array];
|
||||
}
|
||||
|
@ -826,7 +785,6 @@ GSDebugAllocationListRecordedObjects(Class c)
|
|||
the_table[i].num_recorded_objects * sizeof(id));
|
||||
if (tmp == 0)
|
||||
{
|
||||
if (uniqueLock != nil)
|
||||
[uniqueLock unlock];
|
||||
return nil;
|
||||
}
|
||||
|
@ -843,7 +801,6 @@ GSDebugAllocationListRecordedObjects(Class c)
|
|||
}
|
||||
|
||||
/* Then, we bravely unlock the lock */
|
||||
if (uniqueLock != nil)
|
||||
[uniqueLock unlock];
|
||||
|
||||
/* Only then we create an array with them - this is now safe as we
|
||||
|
|
Loading…
Reference in a new issue