ObjFW  Diff

Differences From Artifact [fd7ae0376c]:

To Artifact [905c436919]:


171
172
173
174
175
176
177
178

179
180
181

182
183
184
185
186
187
188
171
172
173
174
175
176
177

178
179
180

181
182
183
184
185
186
187
188







-
+


-
+








	memcpy(_items + _count * _itemSize, item, _itemSize);

	_count++;
}

- (void)insertItem: (const void *)item
	   atIndex: (size_t)index
	   atIndex: (size_t)idx
{
	[self insertItems: item
		  atIndex: index
		  atIndex: idx
		    count: 1];
}

- (void)addItems: (const void *)items
	   count: (size_t)count
{
	if (count > SIZE_MAX - _count)
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

224
225

226
227
228
229
230
231
232
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
224

225
226
227
228
229
230
231
232







-
+


-
+









-
-
-
+
+
+




-
+

-
+







	}

	memcpy(_items + _count * _itemSize, items, count * _itemSize);
	_count += count;
}

- (void)insertItems: (const void *)items
	    atIndex: (size_t)index
	    atIndex: (size_t)idx
	      count: (size_t)count
{
	if (count > SIZE_MAX - _count || index > _count)
	if (count > SIZE_MAX - _count || idx > _count)
		@throw [OFOutOfRangeException exception];

	if (_count + count > _capacity) {
		_items = [self resizeMemory: _items
				       size: _itemSize
				      count: _count + count];
		_capacity = _count + count;
	}

	memmove(_items + (index + count) * _itemSize,
	    _items + index * _itemSize, (_count - index) * _itemSize);
	memcpy(_items + index * _itemSize, items, count * _itemSize);
	memmove(_items + (idx + count) * _itemSize, _items + idx * _itemSize,
	   (_count - idx) * _itemSize);
	memcpy(_items + idx * _itemSize, items, count * _itemSize);

	_count += count;
}

- (void)removeItemAtIndex: (size_t)index
- (void)removeItemAtIndex: (size_t)idx
{
	[self removeItemsInRange: of_range(index, 1)];
	[self removeItemsInRange: of_range(idx, 1)];
}

- (void)removeItemsInRange: (of_range_t)range
{
	if (range.length > SIZE_MAX - range.location ||
	    range.location + range.length > _count)
		@throw [OFOutOfRangeException exception];