Release objects

This commit is contained in:
Gregory John Casamento 2019-06-10 11:02:48 -04:00
parent 30aea6e5ad
commit d66ad25b50

View file

@ -382,15 +382,14 @@ static SEL rlSel;
- (instancetype) initWithArray:(NSArray *)other copyItems:(BOOL)flag - (instancetype) initWithArray:(NSArray *)other copyItems:(BOOL)flag
{ {
unsigned count = [other count]; unsigned count = [other count];
unsigned j = count;
if (count == 0) if (count == 0)
{ {
return [self init]; return [self init];
} }
else
{
GS_BEGINIDBUF(objs, count);
GS_BEGINIDBUF(objs, count);
{ {
unsigned i; unsigned i;
@ -408,16 +407,24 @@ static SEL rlSel;
} }
self = [self initWithObjects: objs count: count]; self = [self initWithObjects: objs count: count];
if(flag == YES)
{
while(j--)
{
[objs[j] release];
}
}
GS_ENDIDBUF(); GS_ENDIDBUF();
return self; return self;
} }
}
- (instancetype) initWithArray:(NSArray *)other - (instancetype) initWithArray:(NSArray *)other
range:(NSRange)range range:(NSRange)range
copyItems:(BOOL)flag copyItems:(BOOL)flag
{ {
unsigned count = [other count]; unsigned count = [other count];
unsigned i = 0, j = 0;
if (count == 0) if (count == 0)
{ {
@ -426,10 +433,8 @@ static SEL rlSel;
GS_BEGINIDBUF(objs, range.length); GS_BEGINIDBUF(objs, range.length);
{ {
unsigned i = 0;
unsigned loc = range.location; unsigned loc = range.location;
unsigned len = range.length; unsigned len = range.length;
unsigned j = 0;
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
{ {
@ -453,6 +458,14 @@ static SEL rlSel;
} }
} }
self = [self initWithObjects: objs count: count]; self = [self initWithObjects: objs count: count];
if(flag == YES)
{
while(j--)
{
[objs[j] release];
}
}
GS_ENDIDBUF(); GS_ENDIDBUF();
return self; return self;