ObjFW  Check-in [879ff84d38]

Overview
Comment:Fix a bug in OFMutableArray's -[removeObject(IdenticalTo):].
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 879ff84d38e02c3b5e51fdc02371d09b58b742ebe47e823dec420b6080a176da
User & Date: js on 2010-01-14 19:40:18
Other Links: manifest | tags
Context
2010-01-15
13:03
Update ChangeLog in default branch as well. check-in: 3cbb7bfcbc user: js tags: trunk
2010-01-14
19:40
Fix a bug in OFMutableArray's -[removeObject(IdenticalTo):]. check-in: 879ff84d38 user: js tags: trunk
2010-01-08
15:26
Generate and use smaller Unicode tables. check-in: be4c0f34c5 user: js tags: trunk
Changes

Modified src/OFMutableArray.m from [6b6d81b49f] to [f72d5b6aa0].

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
		if ([objs[i] isEqual: obj]) {
			OFObject *obj = objs[i];

			[array removeItemAtIndex: i];
			mutations++;

			[obj release];












		}
	}

	return self;
}

- removeObjectIdenticalTo: (OFObject*)obj
{
	OFObject **objs = [array cArray];
	size_t i, count = [array count];

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

			[obj release];












		}
	}

	return self;
}

- removeObjectAtIndex: (size_t)index







>
>
>
>
>
>
>
>
>
>
>
>

















>
>
>
>
>
>
>
>
>
>
>
>







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
161
162
163
164
165
166
167
168
169
		if ([objs[i] isEqual: obj]) {
			OFObject *obj = objs[i];

			[array removeItemAtIndex: i];
			mutations++;

			[obj release];

			/*
			 * We need to get the C array again as it might have
			 * been relocated. We also need to adjust the count
			 * as otherwise we would have an out of bounds access.
			 * As another object will be at the current index now,
			 * we also need to handle the same index again, thus we
			 * decrease it.
			 */
			objs = [array cArray];
			count--;
			i--;
		}
	}

	return self;
}

- removeObjectIdenticalTo: (OFObject*)obj
{
	OFObject **objs = [array cArray];
	size_t i, count = [array count];

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

			[obj release];

			/*
			 * We need to get the C array again as it might have
			 * been relocated. We also need to adjust the count
			 * as otherwise we would have an out of bounds access.
			 * As another object will be at the current index now,
			 * we also need to handle the same index again, thus we
			 * decrease it.
			 */
			objs = [array cArray];
			count--;
			i--;
		}
	}

	return self;
}

- removeObjectAtIndex: (size_t)index