mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-23 04:42:32 +00:00
A little strictness: error out in some nasty conditions.
This commit is contained in:
parent
f86e933c6a
commit
4a8ff8aee8
1 changed files with 17 additions and 13 deletions
|
@ -161,9 +161,9 @@
|
||||||
|
|
||||||
- (id) objectAtIndex: (unsigned)index
|
- (id) objectAtIndex: (unsigned)index
|
||||||
{
|
{
|
||||||
if (index >= count) {
|
if (index >= count) // FIXME: need exceptions
|
||||||
return NIL; // FIXME: need exceptions
|
[self error: "-replaceObjectAtIndex:withObject: index out of range"];
|
||||||
}
|
|
||||||
return _objs[index];
|
return _objs[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -190,8 +190,11 @@
|
||||||
{
|
{
|
||||||
local unsigned i;
|
local unsigned i;
|
||||||
|
|
||||||
if (!array || array == self)
|
if (!array) // FIXME: need exceptions
|
||||||
return; // FIXME: need exceptions
|
[self error: "-addObjectsFromArray: passed nil argument"];
|
||||||
|
|
||||||
|
if (array == self) // FIXME: need exceptions
|
||||||
|
[self error: "-addObjectsFromArray: tried to add objects from self"]; // FIXME: need exceptions
|
||||||
|
|
||||||
for (i = 0; i < [array count]; i++) {
|
for (i = 0; i < [array count]; i++) {
|
||||||
[self addObject: [array objectAtIndex: i]];
|
[self addObject: [array objectAtIndex: i]];
|
||||||
|
@ -201,10 +204,10 @@
|
||||||
- (void) insertObject: (id)anObject
|
- (void) insertObject: (id)anObject
|
||||||
atIndex: (unsigned)index
|
atIndex: (unsigned)index
|
||||||
{
|
{
|
||||||
local integer i;
|
local unsigned i;
|
||||||
|
|
||||||
if (index >= count)
|
if (index >= count) // FIXME: need exceptions
|
||||||
return; // FIXME: need exceptions
|
[self error: "-insertObject:atIndex: index out of range"];
|
||||||
|
|
||||||
if (count == capacity) { // at capacity, expand
|
if (count == capacity) { // at capacity, expand
|
||||||
_objs = (id [])obj_realloc (_objs, capacity * @sizeof (id));
|
_objs = (id [])obj_realloc (_objs, capacity * @sizeof (id));
|
||||||
|
@ -230,9 +233,10 @@
|
||||||
{
|
{
|
||||||
local id tmp;
|
local id tmp;
|
||||||
|
|
||||||
if (!anObject || index >= count) {
|
if (!anObject) // FIXME: need exceptions
|
||||||
return; // FIXME: need exceptions
|
[self error: "-replaceObjectAtIndex:withObject: passed nil object"];
|
||||||
}
|
if (index >= count) // FIXME: need exceptions
|
||||||
|
[self error: "-replaceObjectAtIndex:withObject: index out of range"];
|
||||||
|
|
||||||
// retain before release
|
// retain before release
|
||||||
tmp = _objs[index];
|
tmp = _objs[index];
|
||||||
|
@ -299,8 +303,8 @@
|
||||||
local integer i;
|
local integer i;
|
||||||
local id temp;
|
local id temp;
|
||||||
|
|
||||||
if (index >= count)
|
if (index >= count) // FIXME: need exceptions
|
||||||
return; // FIXME: need exceptions
|
[self error: "-removeObjectAtIndex: index out of range"];
|
||||||
|
|
||||||
temp = _objs[index];
|
temp = _objs[index];
|
||||||
count--;
|
count--;
|
||||||
|
|
Loading…
Reference in a new issue