ObjFW  Diff

Differences From Artifact [c1712cbaa7]:

To Artifact [3a8b86073d]:


32
33
34
35
36
37
38
39

40
41
42
43
44
45

46
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

77
78
79


80
81

82
83
84
85
86
87
88


89
90

91
92
93
94


95
96
97
98
99
100
101
102
103
104
105
106

107
108

109
110

111
112
113
114
115
116
117
32
33
34
35
36
37
38

39
40
41
42
43
44

45


46



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
77
78
79
80



81
82
83

84
85
86


87
88
89
90
91
92
93
94
95
96
97
98
99

100


101


102
103
104
105
106
107
108
109







-
+





-
+
-
-
+
-
-
-
+
+






-
+
-
-
+
-
-
-
+
+











-
+
-
-
+
-
-
-
+
+


+




-
-
-
+
+

-
+


-
-
+
+











-
+
-
-
+
-
-
+








	for (i = 0; i < count; i++)
		[objs[i] retain];

	return new;
}

- addObject: (OFObject*)obj
- (void)addObject: (OFObject*)obj
{
	[array addItem: &obj];
	[obj retain];

	mutations++;

}
	return self;
}


- addObject: (OFObject*)obj
    atIndex: (size_t)index
- (void)addObject: (OFObject*)obj
	  atIndex: (size_t)index
{
	[array addItem: &obj
	       atIndex: index];
	[obj retain];

	mutations++;

}
	return self;
}


- replaceObject: (OFObject*)old
     withObject: (OFObject*)new
- (void)replaceObject: (OFObject*)old
	   withObject: (OFObject*)new
{
	OFObject **objs = [array cArray];
	size_t i, count = [array count];

	for (i = 0; i < count; i++) {
		if ([objs[i] isEqual: old]) {
			[new retain];
			[objs[i] release];
			objs[i] = new;
		}
	}

}
	return self;
}


- replaceObjectAtIndex: (size_t)index
	    withObject: (OFObject*)obj
- (id)replaceObjectAtIndex: (size_t)index
		withObject: (OFObject*)obj
{
	OFObject **objs = [array cArray];
	id old;

	if (index >= [array count])
		@throw [OFOutOfRangeException newWithClass: isa];

	[obj retain];
	[objs[index] release];
	objs[index] = obj;
	old = objs[index];
	objs[index] = [obj retain];

	return self;
	return [old autorelease];
}

- replaceObjectIdenticalTo: (OFObject*)old
		withObject: (OFObject*)new
- (void)replaceObjectIdenticalTo: (OFObject*)old
		      withObject: (OFObject*)new
{
	OFObject **objs = [array cArray];
	size_t i, count = [array count];

	for (i = 0; i < count; i++) {
		if (objs[i] == old) {
			[new retain];
			[objs[i] release];
			objs[i] = new;
		}
	}

}
	return self;
}


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

	for (i = 0; i < count; i++) {
		if ([objs[i] isEqual: obj]) {
			OFObject *obj = objs[i];
130
131
132
133
134
135
136
137

138
139

140
141

142
143
144
145
146
147
148
122
123
124
125
126
127
128

129


130


131
132
133
134
135
136
137
138







-
+
-
-
+
-
-
+







			 * decrease it.
			 */
			objs = [array cArray];
			count--;
			i--;
		}
	}

}
	return self;
}


- removeObjectIdenticalTo: (OFObject*)obj
- (void)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];
159
160
161
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
149
150
151
152
153
154
155

156










157
158
159
160
161
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







-
+
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+




















-
+
-
-
+
-
-
-
+
+







			 * decrease it.
			 */
			objs = [array cArray];
			count--;
			i--;
		}
	}

}
	return self;
}

- removeObjectAtIndex: (size_t)index
{
	return [self removeNObjects: 1
			    atIndex: index];
}

- removeNObjects: (size_t)nobjects

- (id)removeObjectAtIndex: (size_t)index
{
	id old = [self objectAtIndex: index];

	[self removeNObjects: 1
		     atIndex: index];

	return old;
}

- (void)removeNObjects: (size_t)nobjects
{
	OFObject **objs = [array cArray], **copy;
	size_t i, count = [array count];

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

	copy = [self allocMemoryForNItems: nobjects
				 withSize: sizeof(OFObject*)];
	memcpy(copy, objs + (count - nobjects), nobjects * sizeof(OFObject*));

	@try {
		[array removeNItems: nobjects];
		mutations++;

		for (i = 0; i < nobjects; i++)
			[copy[i] release];
	} @finally {
		[self freeMemory: copy];
	}

}
	return self;
}


- removeNObjects: (size_t)nobjects
	 atIndex: (size_t)index
- (void)removeNObjects: (size_t)nobjects
	       atIndex: (size_t)index
{
	OFObject **objs = [array cArray], **copy;
	size_t i, count = [array count];

	if (nobjects > count - index)
		@throw [OFOutOfRangeException newWithClass: isa];

217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
207
208
209
210
211
212
213


214
215
216
217
218
219
220







-
-







		mutations++;

		for (i = 0; i < nobjects; i++)
			[copy[i] release];
	} @finally {
		[self freeMemory: copy];
	}

	return self;
}

- (int)countByEnumeratingWithState: (of_fast_enumeration_state_t*)state
			   objects: (id*)objects
			     count: (int)count_
{
	size_t count = [array count];