Index: src/OFArray.h ================================================================== --- src/OFArray.h +++ src/OFArray.h @@ -13,11 +13,11 @@ #import "OFDataArray.h" /** * The OFArray class provides a class for storing objects in an array. */ -@interface OFArray: OFObject +@interface OFArray: OFObject { OFDataArray *array; } /** Index: src/OFArray.m ================================================================== --- src/OFArray.m +++ src/OFArray.m @@ -52,10 +52,28 @@ - (id)copy { OFArray *new = [OFArray array]; OFObject **objs; size_t len, i; + + objs = [array data]; + len = [array count]; + + [new->array addNItems: len + fromCArray: objs]; + + for (i = 0; i < len; i++) + [objs[i] retain]; + + return new; +} + +- (id)mutableCopy +{ + OFArray *new = [OFMutableArray array]; + OFObject **objs; + size_t len, i; objs = [array data]; len = [array count]; [new->array addNItems: len Index: src/OFObject.h ================================================================== --- src/OFObject.h +++ src/OFObject.h @@ -220,5 +220,16 @@ /** * \return A copy of the object */ - (id)copy; @end + +/** + * This protocol is implemented by objects that can be mutable and immutable + * and allows returning a mutable copy. + */ +@protocol OFMutableCopying +/** + * \return A copy of the object + */ +- (id)mutableCopy; +@end Index: src/OFString.h ================================================================== --- src/OFString.h +++ src/OFString.h @@ -18,11 +18,11 @@ extern int of_string_check_utf8(const char *str, size_t len); /** * A class for managing strings. */ -@interface OFString: OFObject +@interface OFString: OFObject { char *string; #ifdef __objc_INCLUDE_GNU unsigned int length; #else Index: src/OFString.m ================================================================== --- src/OFString.m +++ src/OFString.m @@ -250,10 +250,15 @@ - (id)copy { return [OFString stringWithCString: string]; } + +- (id)mutableCopy +{ + return [OFMutableString stringWithCString: string]; +} - (BOOL)isEqual: (id)obj { if (![obj isKindOf: [OFString class]]) return NO;