Differences From Artifact [489af893ca]:
- File
src/OFMutableArray_adjacent.m
— part of check-in
[f7576a66ce]
at
2012-06-06 13:47:52
on branch trunk
— Slightly change the memory management API.
Also fix a bug where OFBigDataArray would waste memory. (user: js, size: 6049) [annotate] [blame] [check-ins using] [more...]
To Artifact [e388818b36]:
- File
src/OFMutableArray_adjacent.m
— part of check-in
[95e8e1e486]
at
2012-06-10 16:03:01
on branch trunk
— Add a few array methods.
OFArray:
* +[arrayByAddingObject:]
* +[arrayByAddingObjectsFromArray:]OFMutableArray:
* -[addObjectsFromArray:]
* -[insertObjectsFromArray:atIndex:] (user: js, size: 6351) [annotate] [blame] [check-ins using] [more...]
| ︙ | ︙ | |||
47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
{
[array insertItem: &object
atIndex: index];
[object retain];
mutations++;
}
- (void)replaceObject: (id)oldObject
withObject: (id)newObject
{
id *objects = [array cArray];
size_t i, count = [array count];
| > > > > > > > > > > > > > > > > | 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
{
[array insertItem: &object
atIndex: index];
[object retain];
mutations++;
}
- (void)insertObjectsFromArray: (OFArray*)array_
atIndex: (size_t)index
{
id *objects = [array_ objects];
size_t i, count = [array_ count];
[array insertItemsFromCArray: objects
atIndex: index
count: count];
for (i = 0; i < count; i++)
[objects[i] retain];
mutations++;
}
- (void)replaceObject: (id)oldObject
withObject: (id)newObject
{
id *objects = [array cArray];
size_t i, count = [array count];
|
| ︙ | ︙ | |||
160 161 162 163 164 165 166 |
{
id *objects = [array cArray], *copy;
size_t i, count = [array count];
if (range.length > count - range.start)
@throw [OFOutOfRangeException exceptionWithClass: isa];
| | | | 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 |
{
id *objects = [array cArray], *copy;
size_t i, count = [array count];
if (range.length > count - range.start)
@throw [OFOutOfRangeException exceptionWithClass: isa];
copy = [self allocMemoryWithSize: sizeof(*copy)
count: range.length];
memcpy(copy, objects + range.start, range.length * sizeof(id));
@try {
[array removeItemsInRange: range];
mutations++;
for (i = 0; i < range.length; i++)
|
| ︙ | ︙ |