ObjFW  Diff

Differences From Artifact [725da742e3]:

To Artifact [168c402c93]:


22
23
24
25
26
27
28


29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49


50
51
52
53
54
55
56
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49


50
51
52
53
54
55
56
57
58







+
+



















-
-
+
+







#import "OFArray_adjacent.h"
#import "OFDataArray.h"
#import "OFAutoreleasePool.h"

#import "OFEnumerationMutationException.h"
#import "OFInvalidArgumentException.h"
#import "OFOutOfRangeException.h"

#import "macros.h"

@implementation OFMutableArray_adjacent
+ (void)initialize
{
	if (self == [OFMutableArray_adjacent class])
		[self inheritMethodsFromClass: [OFArray_adjacent class]];
}

- (void)addObject: (id)object
{
	[array addItem: &object];
	[object retain];

	mutations++;
}

- (void)insertObject: (id)object
	     atIndex: (size_t)index
{
	[array addItem: &object
	       atIndex: index];
	[array insertItem: &object
		  atIndex: index];
	[object retain];

	mutations++;
}

- (void)replaceObject: (id)oldObject
	   withObject: (id)newObject
154
155
156
157
158
159
160
161


162
163
164
165
166
167
168
156
157
158
159
160
161
162

163
164
165
166
167
168
169
170
171







-
+
+







		@throw [OFOutOfRangeException exceptionWithClass: isa];

	copy = [self allocMemoryForNItems: nObjects
				   ofSize: sizeof(id)];
	memcpy(copy, objects + (count - nObjects), nObjects * sizeof(id));

	@try {
		[array removeNItems: nObjects];
		[array removeItemsInRange:
		    of_range(count - nObjects, nObjects)];
		mutations++;

		for (i = 0; i < nObjects; i++)
			[copy[i] release];
	} @finally {
		[self freeMemory: copy];
	}
188
189
190
191
192
193
194
195

196
197
198
199
200
201
202
203
191
192
193
194
195
196
197

198

199
200
201
202
203
204
205







-
+
-







		@throw [OFOutOfRangeException exceptionWithClass: isa];

	copy = [self allocMemoryForNItems: range.length
				   ofSize: sizeof(id)];
	memcpy(copy, objects + range.start, range.length * sizeof(id));

	@try {
		[array removeNItems: range.length
		[array removeItemsInRange: range];
			    atIndex: range.start];
		mutations++;

		for (i = 0; i < range.length; i++)
			[copy[i] release];
	} @finally {
		[self freeMemory: copy];
	}