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
|
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
|
-
+
-
+
|
- (void*)last
{
return data + (items - 1) * itemsize;
}
- add: (void*)item
{
if (SIZE_MAX - items < 1)
if (SIZE_MAX - items < 1 || items + 1 > SIZE_MAX / itemsize)
@throw [OFOutOfRangeException newWithClass: [self class]];
data = [self resizeMem: data
toNItems: items + 1
ofSize: itemsize];
memcpy(data + items++ * itemsize, item, itemsize);
return self;
}
- addNItems: (size_t)nitems
fromCArray: (void*)carray
{
if (nitems > SIZE_MAX - items)
if (nitems > SIZE_MAX - items || items + nitems > SIZE_MAX / itemsize)
@throw [OFOutOfRangeException newWithClass: [self class]];
data = [self resizeMem: data
toNItems: items + nitems
ofSize: itemsize];
memcpy(data + items * itemsize, carray, nitems * itemsize);
|