Overview
Comment: | Add -[OFData subdataWithRange:] |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
4075c3beaf56a959170108affeba18d8 |
User & Date: | js on 2018-10-13 21:39:23 |
Other Links: | manifest | tags |
Context
2018-10-13
| ||
21:40 | Initial ASN.1 DER parsing support check-in: d276166f70 user: js tags: trunk | |
21:39 | Add -[OFData subdataWithRange:] check-in: 4075c3beaf user: js tags: trunk | |
13:43 | OFData+MessagePackValue: More precise exceptions check-in: f28731c106 user: js tags: trunk | |
Changes
Modified src/OFData.h from [1b99b6d639] to [666bc4047e].
︙ | |||
38 39 40 41 42 43 44 45 46 47 48 49 50 51 | 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | + | */ @interface OFData: OFObject <OFCopying, OFMutableCopying, OFComparing, OFSerialization, OFMessagePackRepresentation> { unsigned char *_items; size_t _count, _itemSize; bool _freeWhenDone; OFData *_parentData; } /*! * @brief The size of a single item in the OFData in bytes. */ @property (readonly, nonatomic) size_t itemSize; |
︙ | |||
275 276 277 278 279 280 281 282 283 284 285 286 287 288 | 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 | + + + + + + + + | * @brief Returns a specific item of the OFData. * * @param index The number of the item to return * @return The specified item of the OFData */ - (const void *)itemAtIndex: (size_t)index OF_RETURNS_INNER_POINTER; /*! * @brief Returns the data in the specified range as a new OFData. * * @param range The range of the data for the new data * @return The data in the specified range as a new OFData */ - (OFData *)subdataWithRange: (of_range_t)range; /*! * @brief Returns the range of the data. * * @param data The data to search for * @param options Options modifying search behavior.@n * Possible values are: * Value | Description |
︙ |
Modified src/OFData.m from [b6b253b742] to [183d3ab057].
︙ | |||
380 381 382 383 384 385 386 387 388 389 390 391 392 393 | 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 | + + | } - (void)dealloc { if (_freeWhenDone) free(_items); [_parentData release]; [super dealloc]; } - (size_t)count { return _count; } |
︙ | |||
495 496 497 498 499 500 501 502 503 504 505 506 507 508 | 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 | + + + + + + + + + + + + + + + + + | for (size_t i = 0; i < _count * _itemSize; i++) OF_HASH_ADD(hash, ((uint8_t *)_items)[i]); OF_HASH_FINALIZE(hash); return hash; } - (OFData *)subdataWithRange: (of_range_t)range { OFData *ret; if (range.length > SIZE_MAX - range.location || range.location + range.length > _count) @throw [OFOutOfRangeException exception]; ret = [OFData dataWithItemsNoCopy: _items + (range.location * _itemSize) itemSize: _itemSize count: range.length freeWhenDone: false]; ret->_parentData = [(_parentData != nil ? _parentData : self) copy]; return ret; } - (OFString *)description { OFMutableString *ret = [OFMutableString stringWithString: @"<"]; for (size_t i = 0; i < _count; i++) { if (i > 0) |
︙ |
Modified src/OFMutableData.m from [e5870d8b2c] to [ecfbf31129].
︙ | |||
137 138 139 140 141 142 143 144 145 146 147 148 149 150 | 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 | + + + + + + + + + + + | { self = [super initWithStringRepresentation: string]; _capacity = _count; return self; } - (OFData *)subdataWithRange: (of_range_t)range { if (range.length > SIZE_MAX - range.location || range.location + range.length > _count) @throw [OFOutOfRangeException exception]; return [OFData dataWithItems: _items + (range.location * _itemSize) itemSize: _itemSize count: range.length]; } - (void)addItem: (const void *)item { if (SIZE_MAX - _count < 1) @throw [OFOutOfRangeException exception]; if (_count + 1 > _capacity) { |
︙ |
Modified tests/OFDataTests.m from [06989343f9] to [17d65e124d].
︙ | |||
146 147 148 149 150 151 152 | 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 | - + + + + + + + + + + + + + + + + | [immutable rangeOfData: [OFData dataWithItems: "aaa" itemSize: 3 count: 1] options: 0 range: of_range(0, 1)]) EXPECT_EXCEPTION( |
︙ |