Do retain/release/autorelease of contents as appropriate.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@129 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
mccallum 1995-03-15 23:36:56 +00:00
parent ea46c82291
commit ab87e0700d
2 changed files with 13 additions and 3 deletions

View file

@ -195,6 +195,7 @@
- appendElement: (elt)newElement
{
incrementCount(self);
RETAIN_ELT(newElement);
_contents_array[_count-1] = newElement;
return self;
}
@ -202,6 +203,7 @@
- prependElement: (elt)newElement
{
incrementCount(self);
RETAIN_ELT(newElement);
makeHoleAt(self, 0);
_contents_array[0] = newElement;
return self;
@ -211,6 +213,7 @@
{
CHECK_INDEX_RANGE_ERROR(index, _count+1);
incrementCount(self);
RETAIN_ELT(newElement);
makeHoleAt(self, index);
_contents_array[index] = newElement;
return self;
@ -227,7 +230,7 @@
ret = _contents_array[index];
fillHoleAt(self, index);
decrementCount(self);
return ret;
return AUTORELEASE_ELT(ret);
}
/* We could be more efficient if we override these also.
@ -240,9 +243,10 @@
elt ret;
CHECK_INDEX_RANGE_ERROR(index, _count);
RETAIN_ELT(newElement);
ret = _contents_array[index];
_contents_array[index] = newElement;
return ret;
return AUTORELEASE_ELT(ret);
}
- swapAtIndeces: (unsigned)index1 : (unsigned)index2

View file

@ -81,6 +81,8 @@
else
coll_hash_add(&_contents_hash, newElement, count);
_count += count;
while (count--)
RETAIN_ELT(newElement);
return self;
}
@ -120,7 +122,9 @@
coll_hash_remove(_contents_hash, oldElement);
}
_count -= count;
return oldElement;
while (count-- > 0)
RELEASE_ELT(oldElement);
return AUTORELEASE_ELT(oldElement);
}
- (elt) removeElement: (elt)oldElement ifAbsentCall: (elt(*)(arglist_t))excFunc
@ -136,6 +140,8 @@
_count = 0;
while ((node = coll_hash_next(_contents_hash, &state)))
{
while ((node->value.unsigned_int_u)-- > 0)
RELEASE_ELT(node->key);
node->value.unsigned_int_u = 1;
_count++;
}