ObjFW  Diff

Differences From Artifact [c516ce707c]:

To Artifact [7f5853c182]:


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
		     itemSize: (size_t)itemSize
			count: (size_t)count

{
	self = [super initWithItems: items

			   itemSize: itemSize
			      count: count];

	_capacity = _count;

	return self;
}

- (instancetype)initWithItemsNoCopy: (void *)items
			   itemSize: (size_t)itemSize
			      count: (size_t)count

		       freeWhenDone: (bool)freeWhenDone
{
	self = [self initWithItems: items

			  itemSize: itemSize
			     count: count];

	if (freeWhenDone)
		free(items);

	return self;
}








<

>


>
|
<







<

>



>
|
<







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

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)

			    itemSize: _itemSize
			       count: range.length];
}

- (void)addItem: (const void *)item
{
	if (SIZE_MAX - _count < 1)
		@throw [OFOutOfRangeException exception];








>
|
<







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

306
307
308
309
310
311
312
313
314
	_count = 0;
	_capacity = 0;
}

- (id)copy
{
	return [[OFData alloc] initWithItems: _items

				    itemSize: _itemSize
				       count: _count];
}

- (void)makeImmutable
{
	if (_capacity != _count) {
		@try {
			_items = of_realloc(_items, _count, _itemSize);







>
|
<







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);