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
|
if (SIZE_MAX - count < 1)
@throw [OFOutOfRangeException newWithClass: isa];
data = [self resizeMemory: data
toNItems: count + 1
withSize: itemsize];
memcpy(data + count++ * itemsize, item, itemsize);
return self;
}
- addNItems: (size_t)nitems
fromCArray: (void*)carray
{
if (nitems > SIZE_MAX - count)
@throw [OFOutOfRangeException newWithClass: isa];
data = [self resizeMemory: data
toNItems: count + nitems
withSize: itemsize];
memcpy(data + count * itemsize, carray, nitems * itemsize);
count += nitems;
return self;
}
- removeItemAtIndex: (size_t)index
{
|
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
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
159
160
|
if (SIZE_MAX - count < 1)
@throw [OFOutOfRangeException newWithClass: isa];
data = [self resizeMemory: data
toNItems: count + 1
withSize: itemsize];
memcpy(data + count * itemsize, item, itemsize);
count++;
return self;
}
- addItem: (void*)item
atIndex: (size_t)index
{
return [self addNItems: 1
fromCArray: item
atIndex: index];
}
- addNItems: (size_t)nitems
fromCArray: (void*)carray
{
if (nitems > SIZE_MAX - count)
@throw [OFOutOfRangeException newWithClass: isa];
data = [self resizeMemory: data
toNItems: count + nitems
withSize: itemsize];
memcpy(data + count * itemsize, carray, nitems * itemsize);
count += nitems;
return self;
}
- addNItems: (size_t)nitems
fromCArray: (void*)carray
atIndex: (size_t)index
{
if (nitems > SIZE_MAX - count)
@throw [OFOutOfRangeException newWithClass: isa];
data = [self resizeMemory: data
toNItems: count + nitems
withSize: itemsize];
memmove(data + (index + nitems) * itemsize, data + index * itemsize,
(count - index) * itemsize);
memcpy(data + index * itemsize, carray, nitems * itemsize);
count += nitems;
return self;
}
- removeItemAtIndex: (size_t)index
{
|
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
|
nsize = ((count + 1) * itemsize + lastpagebyte) & ~lastpagebyte;
if (size != nsize)
data = [self resizeMemory: data
toSize: nsize];
memcpy(data + count++ * itemsize, item, itemsize);
size = nsize;
return self;
}
- addNItems: (size_t)nitems
fromCArray: (void*)carray
{
size_t nsize;
if (nitems > SIZE_MAX - count || count + nitems > SIZE_MAX / itemsize)
@throw [OFOutOfRangeException newWithClass: isa];
nsize = ((count + nitems) * itemsize + lastpagebyte) & ~lastpagebyte;
if (size != nsize)
data = [self resizeMemory: data
toSize: nsize];
memcpy(data + count * itemsize, carray, nitems * itemsize);
count += nitems;
size = nsize;
return self;
}
- removeNItems: (size_t)nitems
|
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
|
nsize = ((count + 1) * itemsize + lastpagebyte) & ~lastpagebyte;
if (size != nsize)
data = [self resizeMemory: data
toSize: nsize];
memcpy(data + count * itemsize, item, itemsize);
count++;
size = nsize;
return self;
}
- addNItems: (size_t)nitems
fromCArray: (void*)carray
{
size_t nsize;
if (nitems > SIZE_MAX - count || count + nitems > SIZE_MAX / itemsize)
@throw [OFOutOfRangeException newWithClass: isa];
nsize = ((count + nitems) * itemsize + lastpagebyte) & ~lastpagebyte;
if (size != nsize)
data = [self resizeMemory: data
toSize: nsize];
memcpy(data + count * itemsize, carray, nitems * itemsize);
count += nitems;
size = nsize;
return self;
}
- addNItems: (size_t)nitems
fromCArray: (void*)carray
atIndex: (size_t)index
{
size_t nsize;
if (nitems > SIZE_MAX - count || count + nitems > SIZE_MAX / itemsize)
@throw [OFOutOfRangeException newWithClass: isa];
nsize = ((count + nitems) * itemsize + lastpagebyte) & ~lastpagebyte;
if (size != nsize)
data = [self resizeMemory: data
toNItems: nsize
withSize: itemsize];
memmove(data + (index + nitems) * itemsize, data + index * itemsize,
(count - index) * itemsize);
memcpy(data + index * itemsize, carray, nitems * itemsize);
count += nitems;
size = nsize;
return self;
}
- removeNItems: (size_t)nitems
|