162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
|
{
if (data == NULL || count == 0)
return NULL;
return data + (count - 1) * itemSize;
}
- (void)addItem: (void*)item
{
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++;
}
- (void)addItem: (void*)item
atIndex: (size_t)index
{
[self addNItems: 1
fromCArray: item
atIndex: index];
}
- (void)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;
}
- (void)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
|
|
|
|
|
|
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
|
{
if (data == NULL || count == 0)
return NULL;
return data + (count - 1) * itemSize;
}
- (void)addItem: (const void*)item
{
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++;
}
- (void)addItem: (const void*)item
atIndex: (size_t)index
{
[self addNItems: 1
fromCArray: item
atIndex: index];
}
- (void)addNItems: (size_t)nitems
fromCArray: (const 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;
}
- (void)addNItems: (size_t)nitems
fromCArray: (const void*)carray
atIndex: (size_t)index
{
if (nitems > SIZE_MAX - count)
@throw [OFOutOfRangeException newWithClass: isa];
data = [self resizeMemory: data
toNItems: count + nitems
|
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
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
|
- (OFString*)stringByBase64Encoding
{
return of_base64_encode(data, count * itemSize);
}
@end
@implementation OFBigDataArray
- (void)addItem: (void*)item
{
size_t nsize, lastpagebyte;
if (SIZE_MAX - count < 1 || count + 1 > SIZE_MAX / itemSize)
@throw [OFOutOfRangeException newWithClass: isa];
lastpagebyte = of_pagesize - 1;
nsize = ((count + 1) * itemSize + lastpagebyte) & ~lastpagebyte;
if (size != nsize)
data = [self resizeMemory: data
toSize: nsize];
memcpy(data + count * itemSize, item, itemSize);
count++;
size = nsize;
}
- (void)addNItems: (size_t)nitems
fromCArray: (void*)carray
{
size_t nsize, lastpagebyte;
if (nitems > SIZE_MAX - count || count + nitems > SIZE_MAX / itemSize)
@throw [OFOutOfRangeException newWithClass: isa];
lastpagebyte = of_pagesize - 1;
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;
}
- (void)addNItems: (size_t)nitems
fromCArray: (void*)carray
atIndex: (size_t)index
{
size_t nsize, lastpagebyte;
if (nitems > SIZE_MAX - count || count + nitems > SIZE_MAX / itemSize)
@throw [OFOutOfRangeException newWithClass: isa];
|
|
|
|
|
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
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
|
- (OFString*)stringByBase64Encoding
{
return of_base64_encode(data, count * itemSize);
}
@end
@implementation OFBigDataArray
- (void)addItem: (const void*)item
{
size_t nsize, lastpagebyte;
if (SIZE_MAX - count < 1 || count + 1 > SIZE_MAX / itemSize)
@throw [OFOutOfRangeException newWithClass: isa];
lastpagebyte = of_pagesize - 1;
nsize = ((count + 1) * itemSize + lastpagebyte) & ~lastpagebyte;
if (size != nsize)
data = [self resizeMemory: data
toSize: nsize];
memcpy(data + count * itemSize, item, itemSize);
count++;
size = nsize;
}
- (void)addNItems: (size_t)nitems
fromCArray: (const void*)carray
{
size_t nsize, lastpagebyte;
if (nitems > SIZE_MAX - count || count + nitems > SIZE_MAX / itemSize)
@throw [OFOutOfRangeException newWithClass: isa];
lastpagebyte = of_pagesize - 1;
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;
}
- (void)addNItems: (size_t)nitems
fromCArray: (const void*)carray
atIndex: (size_t)index
{
size_t nsize, lastpagebyte;
if (nitems > SIZE_MAX - count || count + nitems > SIZE_MAX / itemSize)
@throw [OFOutOfRangeException newWithClass: isa];
|