52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
#import "OFNotImplementedException.h"
#import "OFOutOfMemoryException.h"
#import "OFOutOfRangeException.h"
#import "OFSetOptionFailedException.h"
#import "OFTruncatedDataException.h"
#import "OFWriteFailedException.h"
#define MIN_READ_SIZE 512
@implementation OFStream
@synthesize buffersWrites = _buffersWrites;
@synthesize of_waitingForDelimiter = _waitingForDelimiter, delegate = _delegate;
#if defined(SIGPIPE) && defined(SIG_IGN)
+ (void)initialize
|
|
|
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
#import "OFNotImplementedException.h"
#import "OFOutOfMemoryException.h"
#import "OFOutOfRangeException.h"
#import "OFSetOptionFailedException.h"
#import "OFTruncatedDataException.h"
#import "OFWriteFailedException.h"
#define minReadSize 512
@implementation OFStream
@synthesize buffersWrites = _buffersWrites;
@synthesize of_waitingForDelimiter = _waitingForDelimiter, delegate = _delegate;
#if defined(SIGPIPE) && defined(SIG_IGN)
+ (void)initialize
|
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
|
{
if (_readBufferLength == 0) {
/*
* For small sizes, it is cheaper to read more and cache the
* remainder - even if that means more copying of data - than
* to do a syscall for every read.
*/
if (length < MIN_READ_SIZE) {
char tmp[MIN_READ_SIZE], *readBuffer;
size_t bytesRead;
bytesRead = [self
lowlevelReadIntoBuffer: tmp
length: MIN_READ_SIZE];
if (bytesRead > length) {
memcpy(buffer, tmp, length);
readBuffer = OFAllocMemory(bytesRead - length,
1);
memcpy(readBuffer, tmp + length,
|
|
|
|
<
|
|
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
|
{
if (_readBufferLength == 0) {
/*
* For small sizes, it is cheaper to read more and cache the
* remainder - even if that means more copying of data - than
* to do a syscall for every read.
*/
if (length < minReadSize) {
char tmp[minReadSize], *readBuffer;
size_t bytesRead;
bytesRead = [self lowlevelReadIntoBuffer: tmp
length: minReadSize];
if (bytesRead > length) {
memcpy(buffer, tmp, length);
readBuffer = OFAllocMemory(bytesRead - length,
1);
memcpy(readBuffer, tmp + length,
|