Differences From Artifact [d98f273881]:
- File
src/OFData.m
— part of check-in
[6cf7d6c33e]
at
2017-11-26 14:29:40
on branch trunk
— OFData: Change no copy handling
OFMutableData supports no copy now by just copying anyway and freeing if
required. (user: js, size: 12403) [annotate] [blame] [check-ins using]
To Artifact [9c40edc919]:
- File src/OFData.m — part of check-in [99cb9ac6f9] at 2018-01-03 00:42:15 on branch trunk — -[initWithContentsOfURL:]: Use OFURLHandler (user: js, size: 12899) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
18 19 20 21 22 23 24 | #include <stdlib.h> #include <string.h> #include <limits.h> #import "OFData.h" #import "OFData+Private.h" | | | | | | > > | 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | #include <stdlib.h> #include <string.h> #include <limits.h> #import "OFData.h" #import "OFData+Private.h" #import "OFDictionary.h" #ifdef OF_HAVE_FILES # import "OFFile.h" # import "OFFileManager.h" #endif #import "OFStream.h" #import "OFString.h" #import "OFSystemInfo.h" #import "OFURL.h" #import "OFURLHandler.h" #import "OFXMLElement.h" #import "OFInvalidArgumentException.h" #import "OFInvalidFormatException.h" #import "OFInvalidServerReplyException.h" #import "OFOutOfMemoryException.h" #import "OFOutOfRangeException.h" #import "OFTruncatedDataException.h" |
︙ | ︙ | |||
229 230 231 232 233 234 235 | @throw e; } return self; } #endif | < < | > | > > > > > > | > > | < > | | > > > | | | > > > > > > | > > > | > < | 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 | @throw e; } return self; } #endif - (instancetype)initWithContentsOfURL: (OFURL *)URL { self = [super init]; @try { void *pool = objc_autoreleasePoolPush(); OFURLHandler *URLHandler; OFStream *stream; size_t pageSize; unsigned char *buffer; if ((URLHandler = [OFURLHandler handlerForURL: URL]) == nil) @throw [OFUnsupportedProtocolException exceptionWithURL: URL]; _itemSize = 1; _count = 0; pageSize = [OFSystemInfo pageSize]; buffer = [self allocMemoryWithSize: pageSize]; while (![stream isAtEndOfStream]) { size_t length = [stream readIntoBuffer: buffer length: pageSize]; if (SIZE_MAX - _count < length) @throw [OFOutOfRangeException exception]; _items = [self resizeMemory: _items size: _count + length]; memcpy(_items + _count, buffer, length); _count += length; } objc_autoreleasePoolPop(pool); } @catch (id e) { [self release]; @throw e; } return self; } - (instancetype)initWithStringRepresentation: (OFString *)string { self = [super init]; @try { size_t count = [string |
︙ | ︙ |