ObjFW  Check-in [b83a3b4d9c]

Overview
Comment:Fix -[removeItemAtIndex:], -[removeNItems:atIndex:], -[removeObject:].
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: b83a3b4d9c82906973ef302017207e5a54bd996d9b87e74bd57a27745f6bb9e1
User & Date: js on 2009-12-01 17:45:56
Other Links: manifest | tags
Context
2009-12-02
09:29
Add -[addNItems:fromCArray:atIndex:] to OFDataArray. check-in: 806550f7ed user: js tags: trunk
2009-12-01
17:45
Fix -[removeItemAtIndex:], -[removeNItems:atIndex:], -[removeObject:]. check-in: b83a3b4d9c user: js tags: trunk
14:54
Update buildsys. check-in: bab351d9a5 user: js tags: trunk
Changes

Modified src/OFDataArray.m from [005260144b] to [229b2dc05e].

154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
- removeNItems: (size_t)nitems
       atIndex: (size_t)index
{
	if (nitems > count)
		@throw [OFOutOfRangeException newWithClass: isa];

	memmove(data + index * itemsize, data + (index + nitems) * itemsize,
	    nitems * itemsize);

	count -= nitems;
	@try {
		data = [self resizeMemory: data
				 toNItems: count
				 withSize: itemsize];
	} @catch (OFOutOfMemoryException *e) {







|







154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
- removeNItems: (size_t)nitems
       atIndex: (size_t)index
{
	if (nitems > count)
		@throw [OFOutOfRangeException newWithClass: isa];

	memmove(data + index * itemsize, data + (index + nitems) * itemsize,
	    (count - index - nitems) * itemsize);

	count -= nitems;
	@try {
		data = [self resizeMemory: data
				 toNItems: count
				 withSize: itemsize];
	} @catch (OFOutOfMemoryException *e) {
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
{
	size_t nsize;

	if (nitems > count)
		@throw [OFOutOfRangeException newWithClass: isa];

	memmove(data + index * itemsize, data + (index + nitems) * itemsize,
	    nitems * itemsize);

	count -= nitems;
	nsize = (count * itemsize + lastpagebyte) & ~lastpagebyte;

	if (size != nsize)
		data = [self resizeMemory: data
				   toSize: nsize];







|







320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
{
	size_t nsize;

	if (nitems > count)
		@throw [OFOutOfRangeException newWithClass: isa];

	memmove(data + index * itemsize, data + (index + nitems) * itemsize,
	    (count - index - nitems) * itemsize);

	count -= nitems;
	nsize = (count * itemsize + lastpagebyte) & ~lastpagebyte;

	if (size != nsize)
		data = [self resizeMemory: data
				   toSize: nsize];

Modified src/OFMutableArray.m from [1cec556c42] to [0fbd60e094].

46
47
48
49
50
51
52

53
54
55
56
57
58
59
	OFObject **objs = [array cArray];
	size_t i, count = [array count];

	for (i = 0; i < count; i++) {
		if ([objs[i] isEqual: obj]) {
			[objs[i] release];
			[array removeItemAtIndex: i];

		}
	}

	return self;
}

- removeObjectIdenticalTo: (id)obj







>







46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
	OFObject **objs = [array cArray];
	size_t i, count = [array count];

	for (i = 0; i < count; i++) {
		if ([objs[i] isEqual: obj]) {
			[objs[i] release];
			[array removeItemAtIndex: i];
			return self;
		}
	}

	return self;
}

- removeObjectIdenticalTo: (id)obj