NSMutableArray *m_res = [NSMutableArray arrayWithCapacity:ticks];
double t = lo_t;
while (t <= hi_t) {
[m_res addObject:[NSDecimalNumber decimalNumberWithDecimal:
[[NSNumber numberWithDouble:t] decimalValue]
]];
t += delta_t;
}
return [[NSArray arrayWithArray:m_res] retain];
It is supposed to return a persistent NSArray containing some values. I plan to call release on it when it is no longer needed. Is it ok or there’s some bug, because when I call function containing this code my program stops working (and it’s a memory issue not endless loop).
The code is safe (ie won’t crash) but the last line is incorrect.
The arrayWithArray is doing nothing useful and the retain is a leak.
It should be
If you hava a crash the cause is elsewhere.