mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-18 06:51:47 +00:00
Changed the Array class to use object ids instead of null pointers for easy
and safe freeing of elements when an Array is disposed.
This commit is contained in:
parent
30c4da3c76
commit
f9ff908157
2 changed files with 5 additions and 5 deletions
|
@ -7,7 +7,7 @@
|
|||
{
|
||||
integer count, size;
|
||||
integer incr;
|
||||
(void [])[]array;
|
||||
id [] array;
|
||||
}
|
||||
- (id) init;
|
||||
- (id) initWithIncrement: (integer) inc;
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
{
|
||||
count = 0;
|
||||
size = incr = inc;
|
||||
array = (void[][]) obj_malloc (inc * @sizeof (void []));
|
||||
array = (id []) obj_malloc (inc * @sizeof (id));
|
||||
return self;
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,7 @@
|
|||
{
|
||||
local integer i;
|
||||
for (i = 0; i < count; i++)
|
||||
obj_free (array[i]);
|
||||
[array[i] free];
|
||||
obj_free (array);
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@
|
|||
{
|
||||
if (count == size) {
|
||||
size += incr;
|
||||
array = (void[][])obj_realloc (array, size * @sizeof (void []));
|
||||
array = (id [])obj_realloc (array, size * @sizeof (id));
|
||||
}
|
||||
array[count++] = item;
|
||||
}
|
||||
|
@ -91,7 +91,7 @@
|
|||
return NIL;
|
||||
if (count == size) {
|
||||
size += incr;
|
||||
array = (void[][])obj_realloc (array, size * @sizeof (void []));
|
||||
array = (id [])obj_realloc (array, size * @sizeof (id));
|
||||
}
|
||||
for (i = count; i > index; i--)
|
||||
array[i] = array[i - 1];
|
||||
|
|
Loading…
Reference in a new issue