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:
Brian Koropoff 2003-05-23 04:27:30 +00:00
parent 30c4da3c76
commit f9ff908157
2 changed files with 5 additions and 5 deletions

View file

@ -7,7 +7,7 @@
{
integer count, size;
integer incr;
(void [])[]array;
id [] array;
}
- (id) init;
- (id) initWithIncrement: (integer) inc;

View file

@ -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];