Differences From Artifact [c516ce707c]:
- File
src/OFMutableData.m
— part of check-in
[bae49c5580]
at
2020-11-06 01:34:43
on branch trunk
— OFMutableData: Resize in -[makeImmutable]
There is no point in keeping the unused capacity when items can no
longer be added. (user: js, size: 6657) [annotate] [blame] [check-ins using]
To Artifact [7f5853c182]:
- File src/OFMutableData.m — part of check-in [9d74d1b74e] at 2020-11-06 02:12:39 on branch trunk — OFData: Make parameter order more consistent (user: js, size: 6657) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
103 104 105 106 107 108 109 | @throw e; } return self; } - (instancetype)initWithItems: (const void *)items | < > > | < < > > | < | 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 | @throw e; } return self; } - (instancetype)initWithItems: (const void *)items count: (size_t)count itemSize: (size_t)itemSize { self = [super initWithItems: items count: count itemSize: itemSize]; _capacity = _count; return self; } - (instancetype)initWithItemsNoCopy: (void *)items count: (size_t)count itemSize: (size_t)itemSize freeWhenDone: (bool)freeWhenDone { self = [self initWithItems: items count: count itemSize: itemSize]; if (freeWhenDone) free(items); return self; } |
︙ | ︙ | |||
175 176 177 178 179 180 181 | - (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) | > | < | 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 | - (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) count: range.length itemSize: _itemSize]; } - (void)addItem: (const void *)item { if (SIZE_MAX - _count < 1) @throw [OFOutOfRangeException exception]; |
︙ | ︙ | |||
299 300 301 302 303 304 305 | _count = 0; _capacity = 0; } - (id)copy { return [[OFData alloc] initWithItems: _items | > | < | 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 | _count = 0; _capacity = 0; } - (id)copy { return [[OFData alloc] initWithItems: _items count: _count itemSize: _itemSize]; } - (void)makeImmutable { if (_capacity != _count) { @try { _items = of_realloc(_items, _count, _itemSize); |
︙ | ︙ |