160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
|
{
if (_items == NULL || _count == 0)
return NULL;
return _items + (_count - 1) * _itemSize;
}
- (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
|
|
|
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
|
{
if (_items == NULL || _count == 0)
return NULL;
return _items + (_count - 1) * _itemSize;
}
- (OFData *)subdataWithRange: (OFRange)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
|
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
|
memset(_items + _count * _itemSize, '\0', count * _itemSize);
_count += count;
}
- (void)removeItemAtIndex: (size_t)idx
{
[self removeItemsInRange: of_range(idx, 1)];
}
- (void)removeItemsInRange: (of_range_t)range
{
if (range.length > SIZE_MAX - range.location ||
range.location + range.length > _count)
@throw [OFOutOfRangeException exception];
memmove(_items + range.location * _itemSize,
_items + (range.location + range.length) * _itemSize,
|
|
|
|
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
|
memset(_items + _count * _itemSize, '\0', count * _itemSize);
_count += count;
}
- (void)removeItemAtIndex: (size_t)idx
{
[self removeItemsInRange: OFRangeMake(idx, 1)];
}
- (void)removeItemsInRange: (OFRange)range
{
if (range.length > SIZE_MAX - range.location ||
range.location + range.length > _count)
@throw [OFOutOfRangeException exception];
memmove(_items + range.location * _itemSize,
_items + (range.location + range.length) * _itemSize,
|