@@ -102,18 +102,16 @@ - (bool)lowlevelIsAtEndOfStream { OF_UNRECOGNIZED_SELECTOR } -- (size_t)lowlevelReadIntoBuffer: (void *)buffer - length: (size_t)length +- (size_t)lowlevelReadIntoBuffer: (void *)buffer length: (size_t)length { OF_UNRECOGNIZED_SELECTOR } -- (size_t)lowlevelWriteBuffer: (const void *)buffer - length: (size_t)length +- (size_t)lowlevelWriteBuffer: (const void *)buffer length: (size_t)length { OF_UNRECOGNIZED_SELECTOR } - (id)copy @@ -161,12 +159,11 @@ memcpy(buffer, tmp, bytesRead); return bytesRead; } } - return [self lowlevelReadIntoBuffer: buffer - length: length]; + return [self lowlevelReadIntoBuffer: buffer length: length]; } if (length >= _readBufferLength) { size_t ret = _readBufferLength; memcpy(buffer, _readBuffer, _readBufferLength); @@ -184,12 +181,11 @@ return length; } } -- (void)readIntoBuffer: (void *)buffer - exactLength: (size_t)length +- (void)readIntoBuffer: (void *)buffer exactLength: (size_t)length { size_t readLength = 0; while (readLength < length) { if (self.atEndOfStream) @@ -199,12 +195,11 @@ length: length - readLength]; } } #ifdef OF_HAVE_SOCKETS -- (void)asyncReadIntoBuffer: (void *)buffer - length: (size_t)length +- (void)asyncReadIntoBuffer: (void *)buffer length: (size_t)length { [self asyncReadIntoBuffer: buffer length: length runLoopMode: of_run_loop_mode_default]; } @@ -224,12 +219,11 @@ block: NULL # endif delegate: _delegate]; } -- (void)asyncReadIntoBuffer: (void *)buffer - exactLength: (size_t)length +- (void)asyncReadIntoBuffer: (void *)buffer exactLength: (size_t)length { [self asyncReadIntoBuffer: buffer exactLength: length runLoopMode: of_run_loop_mode_default]; } @@ -307,163 +301,135 @@ #endif - (uint8_t)readInt8 { uint8_t ret; - - [self readIntoBuffer: (char *)&ret - exactLength: 1]; - + [self readIntoBuffer: (char *)&ret exactLength: 1]; return ret; } - (uint16_t)readBigEndianInt16 { uint16_t ret; - - [self readIntoBuffer: (char *)&ret - exactLength: 2]; - + [self readIntoBuffer: (char *)&ret exactLength: 2]; return OF_BSWAP16_IF_LE(ret); } - (uint32_t)readBigEndianInt32 { uint32_t ret; - - [self readIntoBuffer: (char *)&ret - exactLength: 4]; - + [self readIntoBuffer: (char *)&ret exactLength: 4]; return OF_BSWAP32_IF_LE(ret); } - (uint64_t)readBigEndianInt64 { uint64_t ret; - - [self readIntoBuffer: (char *)&ret - exactLength: 8]; - + [self readIntoBuffer: (char *)&ret exactLength: 8]; return OF_BSWAP64_IF_LE(ret); } - (float)readBigEndianFloat { float ret; - - [self readIntoBuffer: (char *)&ret - exactLength: 4]; - + [self readIntoBuffer: (char *)&ret exactLength: 4]; return OF_BSWAP_FLOAT_IF_LE(ret); } - (double)readBigEndianDouble { double ret; - - [self readIntoBuffer: (char *)&ret - exactLength: 8]; - + [self readIntoBuffer: (char *)&ret exactLength: 8]; return OF_BSWAP_DOUBLE_IF_LE(ret); } -- (size_t)readBigEndianInt16sIntoBuffer: (uint16_t *)buffer - count: (size_t)count +- (size_t)readBigEndianInt16sIntoBuffer: (uint16_t *)buffer count: (size_t)count { size_t size; if OF_UNLIKELY (count > SIZE_MAX / sizeof(uint16_t)) @throw [OFOutOfRangeException exception]; size = count * sizeof(uint16_t); - [self readIntoBuffer: buffer - exactLength: size]; + [self readIntoBuffer: buffer exactLength: size]; #ifndef OF_BIG_ENDIAN for (size_t i = 0; i < count; i++) buffer[i] = OF_BSWAP16(buffer[i]); #endif return size; } -- (size_t)readBigEndianInt32sIntoBuffer: (uint32_t *)buffer - count: (size_t)count +- (size_t)readBigEndianInt32sIntoBuffer: (uint32_t *)buffer count: (size_t)count { size_t size; if OF_UNLIKELY (count > SIZE_MAX / sizeof(uint32_t)) @throw [OFOutOfRangeException exception]; size = count * sizeof(uint32_t); - [self readIntoBuffer: buffer - exactLength: size]; + [self readIntoBuffer: buffer exactLength: size]; #ifndef OF_BIG_ENDIAN for (size_t i = 0; i < count; i++) buffer[i] = OF_BSWAP32(buffer[i]); #endif return size; } -- (size_t)readBigEndianInt64sIntoBuffer: (uint64_t *)buffer - count: (size_t)count +- (size_t)readBigEndianInt64sIntoBuffer: (uint64_t *)buffer count: (size_t)count { size_t size; if OF_UNLIKELY (count > SIZE_MAX / sizeof(uint64_t)) @throw [OFOutOfRangeException exception]; size = count * sizeof(uint64_t); - [self readIntoBuffer: buffer - exactLength: size]; + [self readIntoBuffer: buffer exactLength: size]; #ifndef OF_BIG_ENDIAN for (size_t i = 0; i < count; i++) buffer[i] = OF_BSWAP64(buffer[i]); #endif return size; } -- (size_t)readBigEndianFloatsIntoBuffer: (float *)buffer - count: (size_t)count +- (size_t)readBigEndianFloatsIntoBuffer: (float *)buffer count: (size_t)count { size_t size; if OF_UNLIKELY (count > SIZE_MAX / sizeof(float)) @throw [OFOutOfRangeException exception]; size = count * sizeof(float); - [self readIntoBuffer: buffer - exactLength: size]; + [self readIntoBuffer: buffer exactLength: size]; #ifndef OF_FLOAT_BIG_ENDIAN for (size_t i = 0; i < count; i++) buffer[i] = OF_BSWAP_FLOAT(buffer[i]); #endif return size; } -- (size_t)readBigEndianDoublesIntoBuffer: (double *)buffer - count: (size_t)count +- (size_t)readBigEndianDoublesIntoBuffer: (double *)buffer count: (size_t)count { size_t size; if OF_UNLIKELY (count > SIZE_MAX / sizeof(double)) @throw [OFOutOfRangeException exception]; size = count * sizeof(double); - [self readIntoBuffer: buffer - exactLength: size]; + [self readIntoBuffer: buffer exactLength: size]; #ifndef OF_FLOAT_BIG_ENDIAN for (size_t i = 0; i < count; i++) buffer[i] = OF_BSWAP_DOUBLE(buffer[i]); #endif @@ -472,54 +438,39 @@ } - (uint16_t)readLittleEndianInt16 { uint16_t ret; - - [self readIntoBuffer: (char *)&ret - exactLength: 2]; - + [self readIntoBuffer: (char *)&ret exactLength: 2]; return OF_BSWAP16_IF_BE(ret); } - (uint32_t)readLittleEndianInt32 { uint32_t ret; - - [self readIntoBuffer: (char *)&ret - exactLength: 4]; - + [self readIntoBuffer: (char *)&ret exactLength: 4]; return OF_BSWAP32_IF_BE(ret); } - (uint64_t)readLittleEndianInt64 { uint64_t ret; - - [self readIntoBuffer: (char *)&ret - exactLength: 8]; - + [self readIntoBuffer: (char *)&ret exactLength: 8]; return OF_BSWAP64_IF_BE(ret); } - (float)readLittleEndianFloat { float ret; - - [self readIntoBuffer: (char *)&ret - exactLength: 4]; - + [self readIntoBuffer: (char *)&ret exactLength: 4]; return OF_BSWAP_FLOAT_IF_BE(ret); } - (double)readLittleEndianDouble { double ret; - - [self readIntoBuffer: (char *)&ret - exactLength: 8]; - + [self readIntoBuffer: (char *)&ret exactLength: 8]; return OF_BSWAP_DOUBLE_IF_BE(ret); } - (size_t)readLittleEndianInt16sIntoBuffer: (uint16_t *)buffer count: (size_t)count @@ -529,12 +480,11 @@ if OF_UNLIKELY (count > SIZE_MAX / sizeof(uint16_t)) @throw [OFOutOfRangeException exception]; size = count * sizeof(uint16_t); - [self readIntoBuffer: buffer - exactLength: size]; + [self readIntoBuffer: buffer exactLength: size]; #ifdef OF_BIG_ENDIAN for (size_t i = 0; i < count; i++) buffer[i] = OF_BSWAP16(buffer[i]); #endif @@ -550,12 +500,11 @@ if OF_UNLIKELY (count > SIZE_MAX / sizeof(uint32_t)) @throw [OFOutOfRangeException exception]; size = count * sizeof(uint32_t); - [self readIntoBuffer: buffer - exactLength: size]; + [self readIntoBuffer: buffer exactLength: size]; #ifdef OF_BIG_ENDIAN for (size_t i = 0; i < count; i++) buffer[i] = OF_BSWAP32(buffer[i]); #endif @@ -571,12 +520,11 @@ if OF_UNLIKELY (count > SIZE_MAX / sizeof(uint64_t)) @throw [OFOutOfRangeException exception]; size = count * sizeof(uint64_t); - [self readIntoBuffer: buffer - exactLength: size]; + [self readIntoBuffer: buffer exactLength: size]; #ifdef OF_BIG_ENDIAN for (size_t i = 0; i < count; i++) buffer[i] = OF_BSWAP64(buffer[i]); #endif @@ -592,12 +540,11 @@ if OF_UNLIKELY (count > SIZE_MAX / sizeof(float)) @throw [OFOutOfRangeException exception]; size = count * sizeof(float); - [self readIntoBuffer: buffer - exactLength: size]; + [self readIntoBuffer: buffer exactLength: size]; #ifdef OF_FLOAT_BIG_ENDIAN for (size_t i = 0; i < count; i++) buffer[i] = OF_BSWAP_FLOAT(buffer[i]); #endif @@ -613,12 +560,11 @@ if OF_UNLIKELY (count > SIZE_MAX / sizeof(double)) @throw [OFOutOfRangeException exception]; size = count * sizeof(double); - [self readIntoBuffer: buffer - exactLength: size]; + [self readIntoBuffer: buffer exactLength: size]; #ifdef OF_FLOAT_BIG_ENDIAN for (size_t i = 0; i < count; i++) buffer[i] = OF_BSWAP_DOUBLE(buffer[i]); #endif @@ -626,28 +572,24 @@ return size; } - (OFData *)readDataWithCount: (size_t)count { - return [self readDataWithItemSize: 1 - count: count]; + return [self readDataWithItemSize: 1 count: count]; } -- (OFData *)readDataWithItemSize: (size_t)itemSize - count: (size_t)count +- (OFData *)readDataWithItemSize: (size_t)itemSize count: (size_t)count { OFData *ret; char *buffer; if OF_UNLIKELY (count > SIZE_MAX / itemSize) @throw [OFOutOfRangeException exception]; buffer = of_alloc(count, itemSize); @try { - [self readIntoBuffer: buffer - exactLength: count * itemSize]; - + [self readIntoBuffer: buffer exactLength: count * itemSize]; ret = [OFData dataWithItemsNoCopy: buffer count: count itemSize: itemSize freeWhenDone: true]; } @catch (id e) { @@ -664,16 +606,13 @@ size_t pageSize = [OFSystemInfo pageSize]; char *buffer = of_alloc(1, pageSize); @try { while (!self.atEndOfStream) { - size_t length; - - length = [self readIntoBuffer: buffer - length: pageSize]; - [data addItems: buffer - count: length]; + size_t length = + [self readIntoBuffer: buffer length: pageSize]; + [data addItems: buffer count: length]; } } @finally { free(buffer); } @@ -694,15 +633,12 @@ OFString *ret; char *buffer = of_alloc(length + 1, 1); buffer[length] = 0; @try { - [self readIntoBuffer: buffer - exactLength: length]; - - ret = [OFString stringWithCString: buffer - encoding: encoding]; + [self readIntoBuffer: buffer exactLength: length]; + ret = [OFString stringWithCString: buffer encoding: encoding]; } @finally { free(buffer); } return ret; @@ -1125,12 +1061,11 @@ - (void)flushWriteBuffer { if (_writeBuffer == NULL) return; - [self lowlevelWriteBuffer: _writeBuffer - length: _writeBufferLength]; + [self lowlevelWriteBuffer: _writeBuffer length: _writeBufferLength]; free(_writeBuffer); _writeBuffer = NULL; _writeBufferLength = 0; } @@ -1161,12 +1096,11 @@ } #ifdef OF_HAVE_SOCKETS - (void)asyncWriteData: (OFData *)data { - [self asyncWriteData: data - runLoopMode: of_run_loop_mode_default]; + [self asyncWriteData: data runLoopMode: of_run_loop_mode_default]; } - (void)asyncWriteData: (OFData *)data runLoopMode: (of_run_loop_mode_t)runLoopMode { @@ -1274,196 +1208,170 @@ # endif #endif - (void)writeInt8: (uint8_t)int8 { - [self writeBuffer: (char *)&int8 - length: 1]; + [self writeBuffer: (char *)&int8 length: 1]; } - (void)writeBigEndianInt16: (uint16_t)int16 { int16 = OF_BSWAP16_IF_LE(int16); - - [self writeBuffer: (char *)&int16 - length: 2]; + [self writeBuffer: (char *)&int16 length: 2]; } - (void)writeBigEndianInt32: (uint32_t)int32 { int32 = OF_BSWAP32_IF_LE(int32); - - [self writeBuffer: (char *)&int32 - length: 4]; + [self writeBuffer: (char *)&int32 length: 4]; } - (void)writeBigEndianInt64: (uint64_t)int64 { int64 = OF_BSWAP64_IF_LE(int64); - - [self writeBuffer: (char *)&int64 - length: 8]; + [self writeBuffer: (char *)&int64 length: 8]; } - (void)writeBigEndianFloat: (float)float_ { float_ = OF_BSWAP_FLOAT_IF_LE(float_); - - [self writeBuffer: (char *)&float_ - length: 4]; + [self writeBuffer: (char *)&float_ length: 4]; } - (void)writeBigEndianDouble: (double)double_ { double_ = OF_BSWAP_DOUBLE_IF_LE(double_); - - [self writeBuffer: (char *)&double_ - length: 8]; + [self writeBuffer: (char *)&double_ length: 8]; } -- (size_t)writeBigEndianInt16s: (const uint16_t *)buffer - count: (size_t)count +- (size_t)writeBigEndianInt16s: (const uint16_t *)buffer count: (size_t)count { size_t size; if OF_UNLIKELY (count > SIZE_MAX / sizeof(uint16_t)) @throw [OFOutOfRangeException exception]; size = count * sizeof(uint16_t); #ifdef OF_BIG_ENDIAN - [self writeBuffer: buffer - length: size]; + [self writeBuffer: buffer length: size]; #else uint16_t *tmp = of_alloc(count, sizeof(uint16_t)); @try { for (size_t i = 0; i < count; i++) tmp[i] = OF_BSWAP16(buffer[i]); - [self writeBuffer: tmp - length: size]; + [self writeBuffer: tmp length: size]; } @finally { free(tmp); } #endif return size; } -- (size_t)writeBigEndianInt32s: (const uint32_t *)buffer - count: (size_t)count +- (size_t)writeBigEndianInt32s: (const uint32_t *)buffer count: (size_t)count { size_t size; if OF_UNLIKELY (count > SIZE_MAX / sizeof(uint32_t)) @throw [OFOutOfRangeException exception]; size = count * sizeof(uint32_t); #ifdef OF_BIG_ENDIAN - [self writeBuffer: buffer - length: size]; + [self writeBuffer: buffer length: size]; #else uint32_t *tmp = of_alloc(count, sizeof(uint32_t)); @try { for (size_t i = 0; i < count; i++) tmp[i] = OF_BSWAP32(buffer[i]); - [self writeBuffer: tmp - length: size]; + [self writeBuffer: tmp length: size]; } @finally { free(tmp); } #endif return size; } -- (size_t)writeBigEndianInt64s: (const uint64_t *)buffer - count: (size_t)count +- (size_t)writeBigEndianInt64s: (const uint64_t *)buffer count: (size_t)count { size_t size; if OF_UNLIKELY (count > SIZE_MAX / sizeof(uint64_t)) @throw [OFOutOfRangeException exception]; size = count * sizeof(uint64_t); #ifdef OF_BIG_ENDIAN - [self writeBuffer: buffer - length: size]; + [self writeBuffer: buffer length: size]; #else uint64_t *tmp = of_alloc(count, sizeof(uint64_t)); @try { for (size_t i = 0; i < count; i++) tmp[i] = OF_BSWAP64(buffer[i]); - [self writeBuffer: tmp - length: size]; + [self writeBuffer: tmp length: size]; } @finally { free(tmp); } #endif return size; } -- (size_t)writeBigEndianFloats: (const float *)buffer - count: (size_t)count +- (size_t)writeBigEndianFloats: (const float *)buffer count: (size_t)count { size_t size; if OF_UNLIKELY (count > SIZE_MAX / sizeof(float)) @throw [OFOutOfRangeException exception]; size = count * sizeof(float); #ifdef OF_FLOAT_BIG_ENDIAN - [self writeBuffer: buffer - length: size]; + [self writeBuffer: buffer length: size]; #else float *tmp = of_alloc(count, sizeof(float)); @try { for (size_t i = 0; i < count; i++) tmp[i] = OF_BSWAP_FLOAT(buffer[i]); - [self writeBuffer: tmp - length: size]; + [self writeBuffer: tmp length: size]; } @finally { free(tmp); } #endif return size; } -- (size_t)writeBigEndianDoubles: (const double *)buffer - count: (size_t)count +- (size_t)writeBigEndianDoubles: (const double *)buffer count: (size_t)count { size_t size; if OF_UNLIKELY (count > SIZE_MAX / sizeof(double)) @throw [OFOutOfRangeException exception]; size = count * sizeof(double); #ifdef OF_FLOAT_BIG_ENDIAN - [self writeBuffer: buffer - length: size]; + [self writeBuffer: buffer length: size]; #else double *tmp = of_alloc(count, sizeof(double)); @try { for (size_t i = 0; i < count; i++) tmp[i] = OF_BSWAP_DOUBLE(buffer[i]); - [self writeBuffer: tmp - length: size]; + [self writeBuffer: tmp length: size]; } @finally { free(tmp); } #endif @@ -1471,189 +1379,164 @@ } - (void)writeLittleEndianInt16: (uint16_t)int16 { int16 = OF_BSWAP16_IF_BE(int16); - - [self writeBuffer: (char *)&int16 - length: 2]; + [self writeBuffer: (char *)&int16 length: 2]; } - (void)writeLittleEndianInt32: (uint32_t)int32 { int32 = OF_BSWAP32_IF_BE(int32); - - [self writeBuffer: (char *)&int32 - length: 4]; + [self writeBuffer: (char *)&int32 length: 4]; } - (void)writeLittleEndianInt64: (uint64_t)int64 { int64 = OF_BSWAP64_IF_BE(int64); - - [self writeBuffer: (char *)&int64 - length: 8]; + [self writeBuffer: (char *)&int64 length: 8]; } - (void)writeLittleEndianFloat: (float)float_ { float_ = OF_BSWAP_FLOAT_IF_BE(float_); - - [self writeBuffer: (char *)&float_ - length: 4]; + [self writeBuffer: (char *)&float_ length: 4]; } - (void)writeLittleEndianDouble: (double)double_ { double_ = OF_BSWAP_DOUBLE_IF_BE(double_); - - [self writeBuffer: (char *)&double_ - length: 8]; + [self writeBuffer: (char *)&double_ length: 8]; } -- (size_t)writeLittleEndianInt16s: (const uint16_t *)buffer - count: (size_t)count +- (size_t)writeLittleEndianInt16s: (const uint16_t *)buffer count: (size_t)count { size_t size; if OF_UNLIKELY (count > SIZE_MAX / sizeof(uint16_t)) @throw [OFOutOfRangeException exception]; size = count * sizeof(uint16_t); #ifndef OF_BIG_ENDIAN - [self writeBuffer: buffer - length: size]; + [self writeBuffer: buffer length: size]; #else uint16_t *tmp = of_alloc(count, sizeof(uint16_t)); @try { for (size_t i = 0; i < count; i++) tmp[i] = OF_BSWAP16(buffer[i]); - [self writeBuffer: tmp - length: size]; + [self writeBuffer: tmp length: size]; } @finally { free(tmp); } #endif return size; } -- (size_t)writeLittleEndianInt32s: (const uint32_t *)buffer - count: (size_t)count +- (size_t)writeLittleEndianInt32s: (const uint32_t *)buffer count: (size_t)count { size_t size; if OF_UNLIKELY (count > SIZE_MAX / sizeof(uint32_t)) @throw [OFOutOfRangeException exception]; size = count * sizeof(uint32_t); #ifndef OF_BIG_ENDIAN - [self writeBuffer: buffer - length: size]; + [self writeBuffer: buffer length: size]; #else uint32_t *tmp = of_alloc(count, sizeof(uint32_t)); @try { for (size_t i = 0; i < count; i++) tmp[i] = OF_BSWAP32(buffer[i]); - [self writeBuffer: tmp - length: size]; + [self writeBuffer: tmp length: size]; } @finally { free(tmp); } #endif return size; } -- (size_t)writeLittleEndianInt64s: (const uint64_t *)buffer - count: (size_t)count +- (size_t)writeLittleEndianInt64s: (const uint64_t *)buffer count: (size_t)count { size_t size; if OF_UNLIKELY (count > SIZE_MAX / sizeof(uint64_t)) @throw [OFOutOfRangeException exception]; size = count * sizeof(uint64_t); #ifndef OF_BIG_ENDIAN - [self writeBuffer: buffer - length: size]; + [self writeBuffer: buffer length: size]; #else uint64_t *tmp = of_alloc(count, sizeof(uint64_t)); @try { for (size_t i = 0; i < count; i++) tmp[i] = OF_BSWAP64(buffer[i]); - [self writeBuffer: tmp - length: size]; + [self writeBuffer: tmp length: size]; } @finally { free(tmp); } #endif return size; } -- (size_t)writeLittleEndianFloats: (const float *)buffer - count: (size_t)count +- (size_t)writeLittleEndianFloats: (const float *)buffer count: (size_t)count { size_t size; if OF_UNLIKELY (count > SIZE_MAX / sizeof(float)) @throw [OFOutOfRangeException exception]; size = count * sizeof(float); #ifndef OF_FLOAT_BIG_ENDIAN - [self writeBuffer: buffer - length: size]; + [self writeBuffer: buffer length: size]; #else float *tmp = of_alloc(count, sizeof(float)); @try { for (size_t i = 0; i < count; i++) tmp[i] = OF_BSWAP_FLOAT(buffer[i]); - [self writeBuffer: tmp - length: size]; + [self writeBuffer: tmp length: size]; } @finally { free(tmp); } #endif return size; } -- (size_t)writeLittleEndianDoubles: (const double *)buffer - count: (size_t)count +- (size_t)writeLittleEndianDoubles: (const double *)buffer count: (size_t)count { size_t size; if OF_UNLIKELY (count > SIZE_MAX / sizeof(double)) @throw [OFOutOfRangeException exception]; size = count * sizeof(double); #ifndef OF_FLOAT_BIG_ENDIAN - [self writeBuffer: buffer - length: size]; + [self writeBuffer: buffer length: size]; #else double *tmp = of_alloc(count, sizeof(double)); @try { for (size_t i = 0; i < count; i++) tmp[i] = OF_BSWAP_DOUBLE(buffer[i]); - [self writeBuffer: tmp - length: size]; + [self writeBuffer: tmp length: size]; } @finally { free(tmp); } #endif @@ -1667,24 +1550,22 @@ if (data == nil) @throw [OFInvalidArgumentException exception]; pool = objc_autoreleasePoolPush(); + length = data.count * data.itemSize; - - [self writeBuffer: data.items - length: length]; + [self writeBuffer: data.items length: length]; objc_autoreleasePoolPop(pool); return length; } - (size_t)writeString: (OFString *)string { - return [self writeString: string - encoding: OF_STRING_ENCODING_UTF_8]; + return [self writeString: string encoding: OF_STRING_ENCODING_UTF_8]; } - (size_t)writeString: (OFString *)string encoding: (of_string_encoding_t)encoding { @@ -1705,16 +1586,14 @@ return length; } - (size_t)writeLine: (OFString *)string { - return [self writeLine: string - encoding: OF_STRING_ENCODING_UTF_8]; + return [self writeLine: string encoding: OF_STRING_ENCODING_UTF_8]; } -- (size_t)writeLine: (OFString *)string - encoding: (of_string_encoding_t)encoding +- (size_t)writeLine: (OFString *)string encoding: (of_string_encoding_t)encoding { size_t stringLength = [string cStringLengthWithEncoding: encoding]; char *buffer; buffer = of_alloc(stringLength + 1, 1); @@ -1722,12 +1601,11 @@ @try { memcpy(buffer, [string cStringWithEncoding: encoding], stringLength); buffer[stringLength] = '\n'; - [self writeBuffer: buffer - length: stringLength + 1]; + [self writeBuffer: buffer length: stringLength + 1]; } @finally { free(buffer); } return stringLength + 1; @@ -1737,19 +1615,17 @@ { va_list arguments; size_t ret; va_start(arguments, format); - ret = [self writeFormat: format - arguments: arguments]; + ret = [self writeFormat: format arguments: arguments]; va_end(arguments); return ret; } -- (size_t)writeFormat: (OFConstantString *)format - arguments: (va_list)arguments +- (size_t)writeFormat: (OFConstantString *)format arguments: (va_list)arguments { char *UTF8String; int length; if (format == nil) @@ -1758,12 +1634,11 @@ if ((length = of_vasprintf(&UTF8String, format.UTF8String, arguments)) == -1) @throw [OFInvalidFormatException exception]; @try { - [self writeBuffer: UTF8String - length: length]; + [self writeBuffer: UTF8String length: length]; } @finally { free(UTF8String); } return length; @@ -1862,12 +1737,11 @@ [OFRunLoop of_cancelAsyncRequestsForObject: self mode: of_run_loop_mode_default]; } #endif -- (void)unreadFromBuffer: (const void *)buffer - length: (size_t)length +- (void)unreadFromBuffer: (const void *)buffer length: (size_t)length { char *readBuffer; if (length > SIZE_MAX - _readBufferLength) @throw [OFOutOfRangeException exception];