ObjFW  Diff

Differences From Artifact [a923c5af53]:

To Artifact [489af893ca]:


38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
{
	[array addItem: &object];
	[object retain];

	mutations++;
}

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

	mutations++;
}

- (void)replaceObject: (id)oldObject
	   withObject: (id)newObject







|
|

|
|







38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
{
	[array addItem: &object];
	[object retain];

	mutations++;
}

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

	mutations++;
}

- (void)replaceObject: (id)oldObject
	   withObject: (id)newObject
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
	id object = [self objectAtIndex: index];
	[array removeItemAtIndex: index];
	[object release];

	mutations++;
}

- (void)removeNObjects: (size_t)nObjects
{
	id *objects = [array cArray], *copy;
	size_t i, count = [array count];

	if (nObjects > count)
		@throw [OFOutOfRangeException exceptionWithClass: isa];

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

	@try {
		[array removeNItems: nObjects];
		mutations++;

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

- (void)removeAllObjects
{
	id *objects = [array cArray];
	size_t i, count = [array count];

	for (i = 0; i < count; i++)
		[objects[i] release];

	[array removeAllItems];
}

- (void)removeObjectsInRange: (of_range_t)range
{
	id *objects = [array cArray], *copy;
	size_t i, count = [array count];

	if (range.length > count - range.start)
		@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
			    atIndex: range.start];
		mutations++;

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

- (void)removeLastObject
{
	id object = [self objectAtIndex: [array count] - 1];
	[array removeLastItem];
	[object release];

	mutations++;
}

- (void)swapObjectAtIndex: (size_t)index1
	withObjectAtIndex: (size_t)index2
{
	id *objects = [array cArray];
	size_t count = [array count];
	id tmp;

	if (index1 >= count || index2 >= count)
		@throw [OFOutOfRangeException exceptionWithClass: isa];







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<



















|
|



|
<


















|
|







141
142
143
144
145
146
147























148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172

173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
	id object = [self objectAtIndex: index];
	[array removeItemAtIndex: index];
	[object release];

	mutations++;
}
























- (void)removeAllObjects
{
	id *objects = [array cArray];
	size_t i, count = [array count];

	for (i = 0; i < count; i++)
		[objects[i] release];

	[array removeAllItems];
}

- (void)removeObjectsInRange: (of_range_t)range
{
	id *objects = [array cArray], *copy;
	size_t i, count = [array count];

	if (range.length > count - range.start)
		@throw [OFOutOfRangeException exceptionWithClass: isa];

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

	@try {
		[array removeItemsInRange: range];

		mutations++;

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

- (void)removeLastObject
{
	id object = [self objectAtIndex: [array count] - 1];
	[array removeLastItem];
	[object release];

	mutations++;
}

- (void)exchangeObjectAtIndex: (size_t)index1
	    withObjectAtIndex: (size_t)index2
{
	id *objects = [array cArray];
	size_t count = [array count];
	id tmp;

	if (index1 >= count || index2 >= count)
		@throw [OFOutOfRangeException exceptionWithClass: isa];