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
|
{
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];
@try {
[self readIntoBuffer: buffer
exactLength: count * itemSize];
ret = [OFData dataWithItemsNoCopy: buffer
itemSize: itemSize
count: count
freeWhenDone: true];
} @catch (id e) {
free(buffer);
@throw e;
}
return ret;
}
- (OFData *)readDataUntilEndOfStream
|
<
<
<
|
|
|
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];
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) {
of_free(buffer);
@throw e;
}
return ret;
}
- (OFData *)readDataUntilEndOfStream
|