mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-03-21 18:01:15 +00:00
Bug fixes: initializes properly, releases overwritten elements, doesn't
try to free null pointers
This commit is contained in:
parent
4443ef50c8
commit
5378a850b4
1 changed files with 9 additions and 3 deletions
|
@ -4,6 +4,7 @@
|
|||
|
||||
- (id) init
|
||||
{
|
||||
self = [super init];
|
||||
count = size = 0;
|
||||
incr = 16;
|
||||
array = NIL;
|
||||
|
@ -21,9 +22,13 @@
|
|||
- (void) dealloc
|
||||
{
|
||||
local integer i;
|
||||
for (i = 0; i < count; i++)
|
||||
[array[i] release];
|
||||
obj_free (array);
|
||||
for (i = 0; i < count; i++) {
|
||||
if (array[i])
|
||||
[array[i] release];
|
||||
}
|
||||
if (array) {
|
||||
obj_free (array);
|
||||
}
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
|
@ -42,6 +47,7 @@
|
|||
index = count - 1;
|
||||
if (index < 0 || index >= count)
|
||||
return;
|
||||
[array[index] release];
|
||||
array[index] = item;
|
||||
[item retain];
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue