Index: src/OFMutableArray.h ================================================================== --- src/OFMutableArray.h +++ src/OFMutableArray.h @@ -13,11 +13,15 @@ /** * The OFMutableArray class is a class for storing, adding and removing objects * in an array. */ -@interface OFMutableArray: OFArray {} +@interface OFMutableArray: OFArray +{ + unsigned long mutations; +} + /** * Adds an object to the OFArray. * * \param obj An object to add */ Index: src/OFMutableArray.m ================================================================== --- src/OFMutableArray.m +++ src/OFMutableArray.m @@ -38,19 +38,23 @@ - addObject: (OFObject*)obj { [array addItem: &obj]; [obj retain]; + mutations++; + return self; } - addObject: (OFObject*)obj atIndex: (size_t)index { [array addItem: &obj atIndex: index]; [obj retain]; + + mutations++; return self; } - replaceObject: (OFObject*)old @@ -108,11 +112,14 @@ size_t i, count = [array count]; for (i = 0; i < count; i++) { if ([objs[i] isEqual: obj]) { OFObject *obj = objs[i]; + [array removeItemAtIndex: i]; + mutations++; + [obj release]; } } return self; @@ -124,10 +131,12 @@ size_t i, count = [array count]; for (i = 0; i < count; i++) { if (objs[i] == obj) { [array removeItemAtIndex: i]; + mutations++; + [obj release]; } } return self; @@ -151,10 +160,11 @@ withSize: sizeof(OFObject*)]; memcpy(copy, objs + (count - nobjects), nobjects * sizeof(OFObject*)); @try { [array removeNItems: nobjects]; + mutations++; for (i = 0; i < nobjects; i++) [copy[i] release]; } @finally { [self freeMemory: copy]; @@ -177,10 +187,11 @@ memcpy(copy, objs + index, nobjects * sizeof(OFObject*)); @try { [array removeNItems: nobjects atIndex: index]; + mutations++; for (i = 0; i < nobjects; i++) [copy[i] release]; } @finally { [self freeMemory: copy];