further fast enumeration bugfixes from david.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@27774 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2009-02-04 05:30:39 +00:00
parent d64071198b
commit a885b64dba
3 changed files with 16 additions and 6 deletions

View file

@ -1,6 +1,12 @@
2009-02-04 David Chisnall <csdavec@swansea.ac.uk>
* Source/GSArray.m: Firther fast enumeration bugfixes.
* Source/GSEnumerator.m: ditto.
2009-02-03 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSZone.m: restore binary compatibility with earlier code.
Thanks to David Chisnall for the idea.
2009-01-30 Richard Frith-Macdonald <rfm@gnu.org>

View file

@ -373,8 +373,11 @@ static Class GSInlineArrayClass;
count: (NSUInteger)len
{
/* For immutable arrays we can return the contents pointer directly. */
state->itemsPtr = _contents_array;
return _count;
NSUInteger count = _count - state->state;
state->mutationsPtr = (unsigned long *)self;
state->itemsPtr = _contents_array + state->state;
state->state += count;
return count;
}
@end
@ -903,15 +906,15 @@ static Class GSInlineArrayClass;
* iteration. If it changes during the iteration then
* objc_enumerationMutation() will be called, throwing an exception.
*/
state->mutationsPtr = (unsigned long*)_version;
state->mutationsPtr = (unsigned long *)&_version;
count = MIN(len, _count - state->state);
/* If a mutation has occurred then it's possible that we are being asked to
* get objects from after the end of the array. Don't pass negative values
* to memcpy.
*/
if (count <= 0)
if (count >= 0)
{
memcpy(stackbuf, _contents_array, count);
memcpy(stackbuf, _contents_array + state->state, count * sizeof(id));
state->state += count;
}
else

View file

@ -81,6 +81,8 @@
IMP nextObject = [self methodForSelector: @selector(nextObject)];
int i;
state->itemsPtr = stackbuf;
state->mutationsPtr = (unsigned long*)self;
for (i = 0; i < len; i++)
{
id next = nextObject(self, @selector(nextObject));
@ -91,7 +93,6 @@
}
*(stackbuf+i) = next;
}
state->itemsPtr = stackbuf;
return len;
}
@end