62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
|
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
|
-
+
-
+
-
+
-
-
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
-
-
+
+
+
+
-
+
|
itemSize: (size_t)itemSize
count: (size_t)count
freeWhenDone: (bool)freeWhenDone
{
OF_UNRECOGNIZED_SELECTOR
}
- init
- (instancetype)init
{
self = [super of_init];
_itemSize = 1;
return self;
}
- initWithItemSize: (size_t)itemSize
- (instancetype)initWithItemSize: (size_t)itemSize
{
self = [super of_init];
@try {
if (itemSize == 0)
@throw [OFInvalidArgumentException exception];
_itemSize = itemSize;
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- initWithCapacity: (size_t)capacity
- (instancetype)initWithCapacity: (size_t)capacity
{
return [self initWithItemSize: 1
capacity: capacity];
}
- initWithItemSize: (size_t)itemSize
capacity: (size_t)capacity
- (instancetype)initWithItemSize: (size_t)itemSize
capacity: (size_t)capacity
{
self = [super of_init];
@try {
if (itemSize == 0)
@throw [OFInvalidArgumentException exception];
_items = [self allocMemoryWithSize: itemSize
count: capacity];
_itemSize = itemSize;
_capacity = capacity;
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- initWithItems: (const void *)items
itemSize: (size_t)itemSize
count: (size_t)count
- (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;
}
- initWithItemsNoCopy: (const void *)items
count: (size_t)count
freeWhenDone: (bool)freeWhenDone
- (instancetype)initWithItemsNoCopy: (const void *)items
count: (size_t)count
freeWhenDone: (bool)freeWhenDone
{
OF_INVALID_INIT_METHOD
}
- initWithItemsNoCopy: (const void *)items
itemSize: (size_t)itemSize
count: (size_t)count
freeWhenDone: (bool)freeWhenDone
- (instancetype)initWithItemsNoCopy: (const void *)items
itemSize: (size_t)itemSize
count: (size_t)count
freeWhenDone: (bool)freeWhenDone
{
OF_INVALID_INIT_METHOD
}
- initWithStringRepresentation: (OFString *)string
- (instancetype)initWithStringRepresentation: (OFString *)string
{
self = [super initWithStringRepresentation: string];
_capacity = _count;
return self;
}
|
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
|
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
|
-
+
|
[self freeMemory: _items];
_items = NULL;
_count = 0;
_capacity = 0;
}
- copy
- (id)copy
{
return [[OFData alloc] initWithItems: _items
itemSize: _itemSize
count: _count];
}
- (void)makeImmutable
{
object_setClass(self, [OFData class]);
}
@end
|