ObjFW  Diff

Differences From Artifact [cb54da3d31]:

To Artifact [9af5fde103]:


252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
- (void)addItem: (const void*)item
{
	if (SIZE_MAX - count < 1)
		@throw [OFOutOfRangeException newWithClass: isa];

	data = [self resizeMemory: data
			 toNItems: count + 1
			 withSize: itemSize];

	memcpy(data + count * itemSize, item, itemSize);

	count++;
}

- (void)addItem: (const void*)item







|







252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
- (void)addItem: (const void*)item
{
	if (SIZE_MAX - count < 1)
		@throw [OFOutOfRangeException newWithClass: isa];

	data = [self resizeMemory: data
			 toNItems: count + 1
			   ofSize: itemSize];

	memcpy(data + count * itemSize, item, itemSize);

	count++;
}

- (void)addItem: (const void*)item
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
       fromCArray: (const void*)cArray
{
	if (nItems > SIZE_MAX - count)
		@throw [OFOutOfRangeException newWithClass: isa];

	data = [self resizeMemory: data
			 toNItems: count + nItems
			 withSize: itemSize];

	memcpy(data + count * itemSize, cArray, nItems * itemSize);
	count += nItems;
}

- (void)addNItems: (size_t)nItems
       fromCArray: (const void*)cArray
	  atIndex: (size_t)index
{
	if (nItems > SIZE_MAX - count)
		@throw [OFOutOfRangeException newWithClass: isa];

	data = [self resizeMemory: data
			 toNItems: count + nItems
			 withSize: itemSize];

	memmove(data + (index + nItems) * itemSize, data + index * itemSize,
	    (count - index) * itemSize);
	memcpy(data + index * itemSize, cArray, nItems * itemSize);

	count += nItems;
}







|














|







275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
       fromCArray: (const void*)cArray
{
	if (nItems > SIZE_MAX - count)
		@throw [OFOutOfRangeException newWithClass: isa];

	data = [self resizeMemory: data
			 toNItems: count + nItems
			   ofSize: itemSize];

	memcpy(data + count * itemSize, cArray, nItems * itemSize);
	count += nItems;
}

- (void)addNItems: (size_t)nItems
       fromCArray: (const void*)cArray
	  atIndex: (size_t)index
{
	if (nItems > SIZE_MAX - count)
		@throw [OFOutOfRangeException newWithClass: isa];

	data = [self resizeMemory: data
			 toNItems: count + nItems
			   ofSize: itemSize];

	memmove(data + (index + nItems) * itemSize, data + index * itemSize,
	    (count - index) * itemSize);
	memcpy(data + index * itemSize, cArray, nItems * itemSize);

	count += nItems;
}
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
		@throw [OFOutOfRangeException newWithClass: isa];


	count -= nItems;
	@try {
		data = [self resizeMemory: data
				 toNItems: count
				 withSize: itemSize];
	} @catch (OFOutOfMemoryException *e) {
		/* We don't really care, as we only made it smaller */
		[e release];
	}
}

- (void)removeNItems: (size_t)nItems
	     atIndex: (size_t)index
{
	if (nItems > count)
		@throw [OFOutOfRangeException newWithClass: isa];

	memmove(data + index * itemSize, data + (index + nItems) * itemSize,
	    (count - index - nItems) * itemSize);

	count -= nItems;
	@try {
		data = [self resizeMemory: data
				 toNItems: count
				 withSize: itemSize];
	} @catch (OFOutOfMemoryException *e) {
		/* We don't really care, as we only made it smaller */
		[e release];
	}
}

- (void)removeLastItem
{
	count--;
	@try {
		data = [self resizeMemory: data
				 toNItems: count
				 withSize: itemSize];
	} @catch (OFOutOfMemoryException *e) {
		/* We don't care, as we only made it smaller */
		[e release];
	}
}

- copy







|



















|












|







315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
		@throw [OFOutOfRangeException newWithClass: isa];


	count -= nItems;
	@try {
		data = [self resizeMemory: data
				 toNItems: count
				   ofSize: itemSize];
	} @catch (OFOutOfMemoryException *e) {
		/* We don't really care, as we only made it smaller */
		[e release];
	}
}

- (void)removeNItems: (size_t)nItems
	     atIndex: (size_t)index
{
	if (nItems > count)
		@throw [OFOutOfRangeException newWithClass: isa];

	memmove(data + index * itemSize, data + (index + nItems) * itemSize,
	    (count - index - nItems) * itemSize);

	count -= nItems;
	@try {
		data = [self resizeMemory: data
				 toNItems: count
				   ofSize: itemSize];
	} @catch (OFOutOfMemoryException *e) {
		/* We don't really care, as we only made it smaller */
		[e release];
	}
}

- (void)removeLastItem
{
	count--;
	@try {
		data = [self resizeMemory: data
				 toNItems: count
				   ofSize: itemSize];
	} @catch (OFOutOfMemoryException *e) {
		/* We don't care, as we only made it smaller */
		[e release];
	}
}

- copy
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541

	lastPageByte = of_pagesize - 1;
	newSize = ((count + nItems) * itemSize + lastPageByte) & ~lastPageByte;

	if (size != newSize)
		data = [self resizeMemory: data
				 toNItems: newSize
				 withSize: itemSize];

	memmove(data + (index + nItems) * itemSize, data + index * itemSize,
	    (count - index) * itemSize);
	memcpy(data + index * itemSize, cArray, nItems * itemSize);

	count += nItems;
	size = newSize;







|







527
528
529
530
531
532
533
534
535
536
537
538
539
540
541

	lastPageByte = of_pagesize - 1;
	newSize = ((count + nItems) * itemSize + lastPageByte) & ~lastPageByte;

	if (size != newSize)
		data = [self resizeMemory: data
				 toNItems: newSize
				   ofSize: itemSize];

	memmove(data + (index + nItems) * itemSize, data + index * itemSize,
	    (count - index) * itemSize);
	memcpy(data + index * itemSize, cArray, nItems * itemSize);

	count += nItems;
	size = newSize;