mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-31 05:00:35 +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 count, size;
|
||||||
integer incr;
|
integer incr;
|
||||||
(void [])[]array;
|
id [] array;
|
||||||
}
|
}
|
||||||
- (id) init;
|
- (id) init;
|
||||||
- (id) initWithIncrement: (integer) inc;
|
- (id) initWithIncrement: (integer) inc;
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
{
|
{
|
||||||
count = 0;
|
count = 0;
|
||||||
size = incr = inc;
|
size = incr = inc;
|
||||||
array = (void[][]) obj_malloc (inc * @sizeof (void []));
|
array = (id []) obj_malloc (inc * @sizeof (id));
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@
|
||||||
{
|
{
|
||||||
local integer i;
|
local integer i;
|
||||||
for (i = 0; i < count; i++)
|
for (i = 0; i < count; i++)
|
||||||
obj_free (array[i]);
|
[array[i] free];
|
||||||
obj_free (array);
|
obj_free (array);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@
|
||||||
{
|
{
|
||||||
if (count == size) {
|
if (count == size) {
|
||||||
size += incr;
|
size += incr;
|
||||||
array = (void[][])obj_realloc (array, size * @sizeof (void []));
|
array = (id [])obj_realloc (array, size * @sizeof (id));
|
||||||
}
|
}
|
||||||
array[count++] = item;
|
array[count++] = item;
|
||||||
}
|
}
|
||||||
|
@ -91,7 +91,7 @@
|
||||||
return NIL;
|
return NIL;
|
||||||
if (count == size) {
|
if (count == size) {
|
||||||
size += incr;
|
size += incr;
|
||||||
array = (void[][])obj_realloc (array, size * @sizeof (void []));
|
array = (id [])obj_realloc (array, size * @sizeof (id));
|
||||||
}
|
}
|
||||||
for (i = count; i > index; i--)
|
for (i = count; i > index; i--)
|
||||||
array[i] = array[i - 1];
|
array[i] = array[i - 1];
|
||||||
|
|
Loading…
Reference in a new issue