ObjFW  Diff

Differences From Artifact [228c900b27]:

To Artifact [35583b4857]:


14
15
16
17
18
19
20
21

22
23
24
25
26

27
28
29
30
31
32
33
14
15
16
17
18
19
20

21
22
23
24
25

26
27
28
29
30
31
32
33







-
+




-
+







 */

#include "config.h"

#include <limits.h>
#include <string.h>

#import "OFConcreteData.h"
#import "OFAdjacentData.h"

#import "OFInvalidArgumentException.h"
#import "OFOutOfRangeException.h"

@implementation OFConcreteData
@implementation OFAdjacentData
- (instancetype)init
{
	return [self initWithItemSize: 1];
}

- (instancetype)initWithItemSize: (size_t)itemSize
{
116
117
118
119
120
121
122
123

124
125
126
127
128
129

130
131
132
133
134
135
136
137
138
116
117
118
119
120
121
122

123
124
125
126
127
128

129
130
131
132
133
134
135
136
137
138







-
+





-
+









- (const void *)items
{
	return _items;
}

- (OFData *)subdataWithRange: (OFRange)range
{
	OFConcreteData *ret;
	OFAdjacentData *ret;

	if (range.length > SIZE_MAX - range.location ||
	    range.location + range.length > _count)
		@throw [OFOutOfRangeException exception];

	ret = [OFConcreteData
	ret = [OFAdjacentData
	    dataWithItemsNoCopy: _items + (range.location * _itemSize)
			  count: range.length
		       itemSize: _itemSize
		   freeWhenDone: false];
	ret->_parentData = [(_parentData != nil ? _parentData : self) copy];

	return ret;
}
@end