ObjFW  Check-in [1463432132]

Overview
Comment:Fix -[removeLastItem] in OFDataArray and OFBigDataArray.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 1463432132d8204402561e57e707e486d1be333b0909c47643e30bd1b5a7f149
User & Date: js on 2012-01-31 13:53:58
Other Links: manifest | tags
Context
2012-01-31
13:55
Remove forgotten debug output. check-in: 2fd13b0adf user: js tags: trunk
13:53
Fix -[removeLastItem] in OFDataArray and OFBigDataArray. check-in: 1463432132 user: js tags: trunk
13:39
Rename a few variables that were forgotten in the past. check-in: aef0a226d8 user: js tags: trunk
Changes

Modified src/OFDataArray.m from [59a049af1b] to [8afbccd334].

344
345
346
347
348
349
350



351
352
353
354
355
356
357
	} @catch (OFOutOfMemoryException *e) {
		/* We don't really care, as we only made it smaller */
	}
}

- (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 */







>
>
>







344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
	} @catch (OFOutOfMemoryException *e) {
		/* We don't really care, as we only made it smaller */
	}
}

- (void)removeLastItem
{
	if (count < 1)
		@throw [OFOutOfRangeException exceptionWithClass: isa];

	count--;
	@try {
		data = [self resizeMemory: data
				 toNItems: count
				   ofSize: itemSize];
	} @catch (OFOutOfMemoryException *e) {
		/* We don't care, as we only made it smaller */
573
574
575
576
577
578
579
























580
	newSize = (count * itemSize + lastPageByte) & ~lastPageByte;

	if (size != newSize)
		data = [self resizeMemory: data
				   toSize: newSize];
	size = newSize;
}
























@end







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
	newSize = (count * itemSize + lastPageByte) & ~lastPageByte;

	if (size != newSize)
		data = [self resizeMemory: data
				   toSize: newSize];
	size = newSize;
}

- (void)removeLastItem
{
	size_t newSize, lastPageByte;

	if (count < 1)
		@throw [OFOutOfRangeException exceptionWithClass: isa];

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

	if (size != newSize) {
		@try {
			data = [self resizeMemory: data
					 toNItems: count
					   ofSize: newSize];
		} @catch (OFOutOfMemoryException *e) {
			/* We don't care, as we only made it smaller */
		}

		size = newSize;
	}
}
@end