mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 00:30:53 +00:00
Fixed memory leak. Tidied up to match coding style.
This commit is contained in:
parent
8363a7f3a1
commit
e8354c57f0
1 changed files with 24 additions and 16 deletions
|
@ -177,7 +177,8 @@ static SEL appSel;
|
||||||
GS_DISPATCH_CREATE_QUEUE_AND_GROUP_FOR_ENUMERATION(enumQueue, opts)
|
GS_DISPATCH_CREATE_QUEUE_AND_GROUP_FOR_ENUMERATION(enumQueue, opts)
|
||||||
FOR_IN(id, key, enumerator)
|
FOR_IN(id, key, enumerator)
|
||||||
obj = (*objectForKey)(self, objectForKeySelector, key);
|
obj = (*objectForKey)(self, objectForKeySelector, key);
|
||||||
GS_DISPATCH_SUBMIT_BLOCK(enumQueueGroup, enumQueue, if (shouldStop){return;};, return;, aBlock, key, obj, &shouldStop);
|
GS_DISPATCH_SUBMIT_BLOCK(enumQueueGroup, enumQueue,
|
||||||
|
if (shouldStop){return;};, return;, aBlock, key, obj, &shouldStop);
|
||||||
if (YES == shouldStop)
|
if (YES == shouldStop)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
|
@ -861,10 +862,10 @@ static SEL appSel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)getObjects: (__unsafe_unretained id[])objects
|
- (void) getObjects: (__unsafe_unretained id[])objects
|
||||||
andKeys: (__unsafe_unretained id<NSCopying>[])keys
|
andKeys: (__unsafe_unretained id<NSCopying>[])keys
|
||||||
{
|
{
|
||||||
NSUInteger i=0;
|
NSUInteger i = 0;
|
||||||
FOR_IN(id, key, self)
|
FOR_IN(id, key, self)
|
||||||
if (keys != NULL) keys[i] = key;
|
if (keys != NULL) keys[i] = key;
|
||||||
if (objects != NULL) objects[i] = [self objectForKey: key];
|
if (objects != NULL) objects[i] = [self objectForKey: key];
|
||||||
|
@ -950,22 +951,29 @@ compareIt(id o1, id o2, void* context)
|
||||||
return k;
|
return k;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSArray *)keysSortedByValueUsingComparator: (NSComparator)cmptr
|
- (NSArray *) keysSortedByValueUsingComparator: (NSComparator)cmptr
|
||||||
{
|
{
|
||||||
return [self keysSortedByValueWithOptions:0
|
return [self keysSortedByValueWithOptions: 0
|
||||||
usingComparator:cmptr];
|
usingComparator: cmptr];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSArray *)keysSortedByValueWithOptions: (NSSortOptions)opts
|
- (NSArray *) keysSortedByValueWithOptions: (NSSortOptions)opts
|
||||||
usingComparator: (NSComparator)cmptr
|
usingComparator: (NSComparator)cmptr
|
||||||
{
|
{
|
||||||
NSArray* sortedValues = [[self allValues] sortedArrayWithOptions: opts usingComparator: cmptr];
|
CREATE_AUTORELEASE_POOL(arp);
|
||||||
NSArray* noDuplicates = [[NSOrderedSet orderedSetWithArray:sortedValues] array];
|
NSArray *sortedValues;
|
||||||
NSMutableArray* result = [[NSMutableArray alloc] initWithCapacity:[sortedValues count]];
|
NSArray *noDuplicates;
|
||||||
for (NSObject* value in noDuplicates) {
|
NSMutableArray *result;
|
||||||
[result addObjectsFromArray:[self allKeysForObject:value]];
|
|
||||||
}
|
sortedValues = [[self allValues] sortedArrayWithOptions: opts
|
||||||
return result;
|
usingComparator: cmptr];
|
||||||
|
noDuplicates = [[NSOrderedSet orderedSetWithArray: sortedValues] array];
|
||||||
|
result = [[NSMutableArray alloc] initWithCapacity: [sortedValues count]];
|
||||||
|
FOR_IN(NSObject*, value, noDuplicates)
|
||||||
|
[result addObjectsFromArray: [self allKeysForObject: value]];
|
||||||
|
END_FOR_IN(noDuplicates)
|
||||||
|
RELEASE(arp);
|
||||||
|
return AUTORELEASE(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue