ObjFW  Diff

Differences From Artifact [dd10e2b21b]:

To Artifact [b34f9f0d7d]:


632
633
634
635
636
637
638
639
640
641
642

643
644
645
646
647
648
649
650
651
652

653
654
655
656
657
658
659
632
633
634
635
636
637
638




639
640
641
642
643
644
645
646
647
648

649
650
651
652
653
654
655
656







-
-
-
-
+









-
+







{
	OFData *ret;
	char *buffer;

	if OF_UNLIKELY (count > SIZE_MAX / itemSize)
		@throw [OFOutOfRangeException exception];

	if OF_UNLIKELY ((buffer = malloc(count * itemSize)) == NULL)
		@throw [OFOutOfMemoryException
		    exceptionWithRequestedSize: count * itemSize];

	buffer = of_malloc(count, itemSize);
	@try {
		[self readIntoBuffer: buffer
			 exactLength: count * itemSize];

		ret = [OFData dataWithItemsNoCopy: buffer
					 itemSize: itemSize
					    count: count
				     freeWhenDone: true];
	} @catch (id e) {
		free(buffer);
		of_free(buffer);
		@throw e;
	}

	return ret;
}

- (OFData *)readDataUntilEndOfStream