ObjFW  Diff

Differences From Artifact [80de30a57f]:

To Artifact [7c3c7d8b0c]:


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




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
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
210
211
212

213
214
215
216
217
218

219
220
221
222
223
224
225
226

227
228
229
230
231
232
233
234
235


236
237
238


239
240
241

242
243
244
245




246
247
248
249
250




251
252

253
254

255
256
257

258
259
260
261

262
263

264
265
266
267
268
269
270
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
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
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
210
211
212
213
214

215
216
217
218
219
220

221
222
223
224
225
226
227
228

229
230
231
232
233
234
235
236


237
238
239


240
241
242
243
244
245




246
247
248
249
250




251
252
253
254
255

256
257

258
259
260

261
262
263
264

265
266

267
268
269
270
271
272
273
274







-
+

-
+

-
-
-
-
+
+
+
+


-
+

-
+

-
+




-
+


-
+

-
+

-
-
-
-
+
+
+
+


-
+

-
+

-
+




-
+


-
-
+
+

-
+

-
-
-
-
+
+
+
+

-
+
-
+

-
+

-
-
+
+




-
+


-
-
+
+

-
+

-
-
-
-
+
+
+
+

-
-
+
+

-
+

-
-
+
+




-
+


-
+

-
-
-
-
+
+
+
+

-
-
-
-
+
+
+
+




-
+

-
+







-
+

+


-
+


+
+
-
+


-
+











-
+







-
+





-
+







-
+







-
-
+
+

-
-
+
+



+
-
-
-
-
+
+
+
+

-
-
-
-
+
+
+
+

-
+

-
+


-
+



-
+

-
+







}

- (of_list_object_t*)lastListObject;
{
	return lastListObject;
}

- (of_list_object_t*)appendObject: (id)obj
- (of_list_object_t*)appendObject: (id)object
{
	of_list_object_t *o;
	of_list_object_t *listObject;

	o = [self allocMemoryWithSize: sizeof(of_list_object_t)];
	o->object = [obj retain];
	o->next = NULL;
	o->prev = lastListObject;
	listObject = [self allocMemoryWithSize: sizeof(of_list_object_t)];
	listObject->object = [object retain];
	listObject->next = NULL;
	listObject->previous = lastListObject;

	if (lastListObject != NULL)
		lastListObject->next = o;
		lastListObject->next = listObject;

	lastListObject = o;
	lastListObject = listObject;
	if (firstListObject == NULL)
		firstListObject = o;
		firstListObject = listObject;

	count++;
	mutations++;

	return o;
	return listObject;
}

- (of_list_object_t*)prependObject: (id)obj
- (of_list_object_t*)prependObject: (id)object
{
	of_list_object_t *o;
	of_list_object_t *listObject;

	o = [self allocMemoryWithSize: sizeof(of_list_object_t)];
	o->object = [obj retain];
	o->next = firstListObject;
	o->prev = NULL;
	listObject = [self allocMemoryWithSize: sizeof(of_list_object_t)];
	listObject->object = [object retain];
	listObject->next = firstListObject;
	listObject->previous = NULL;

	if (firstListObject != NULL)
		firstListObject->prev = o;
		firstListObject->previous = listObject;

	firstListObject = o;
	firstListObject = listObject;
	if (lastListObject == NULL)
		lastListObject = o;
		lastListObject = listObject;

	count++;
	mutations++;

	return o;
	return listObject;
}

- (of_list_object_t*)insertObject: (id)obj
		 beforeListObject: (of_list_object_t*)listobj
- (of_list_object_t*)insertObject: (id)object
		 beforeListObject: (of_list_object_t*)listObject
{
	of_list_object_t *o;
	of_list_object_t *newListObject;

	o = [self allocMemoryWithSize: sizeof(of_list_object_t)];
	o->object = [obj retain];
	o->next = listobj;
	o->prev = listobj->prev;
	newListObject = [self allocMemoryWithSize: sizeof(of_list_object_t)];
	newListObject->object = [object retain];
	newListObject->next = listObject;
	newListObject->previous = listObject->previous;

	if (listobj->prev != NULL)
	if (listObject->previous != NULL)
		listobj->prev->next = o;
		listObject->previous->next = newListObject;

	listobj->prev = o;
	listObject->previous = newListObject;

	if (listobj == firstListObject)
		firstListObject = o;
	if (listObject == firstListObject)
		firstListObject = newListObject;

	count++;
	mutations++;

	return o;
	return newListObject;
}

- (of_list_object_t*)insertObject: (id)obj
		  afterListObject: (of_list_object_t*)listobj
- (of_list_object_t*)insertObject: (id)object
		  afterListObject: (of_list_object_t*)listObject
{
	of_list_object_t *o;
	of_list_object_t *newListObject;

	o = [self allocMemoryWithSize: sizeof(of_list_object_t)];
	o->object = [obj retain];
	o->next = listobj->next;
	o->prev = listobj;
	newListObject = [self allocMemoryWithSize: sizeof(of_list_object_t)];
	newListObject->object = [object retain];
	newListObject->next = listObject->next;
	newListObject->previous = listObject;

	if (listobj->next != NULL)
		listobj->next->prev = o;
	if (listObject->next != NULL)
		listObject->next->previous = newListObject;

	listobj->next = o;
	listObject->next = newListObject;

	if (listobj == lastListObject)
		lastListObject = o;
	if (listObject == lastListObject)
		lastListObject = newListObject;

	count++;
	mutations++;

	return o;
	return newListObject;
}

- (void)removeListObject: (of_list_object_t*)listobj
- (void)removeListObject: (of_list_object_t*)listObject
{
	if (listobj->prev != NULL)
		listobj->prev->next = listobj->next;
	if (listobj->next != NULL)
		listobj->next->prev = listobj->prev;
	if (listObject->previous != NULL)
		listObject->previous->next = listObject->next;
	if (listObject->next != NULL)
		listObject->next->previous = listObject->previous;

	if (firstListObject == listobj)
		firstListObject = listobj->next;
	if (lastListObject == listobj)
		lastListObject = listobj->prev;
	if (firstListObject == listObject)
		firstListObject = listObject->next;
	if (lastListObject == listObject)
		lastListObject = listObject->previous;

	count--;
	mutations++;

	[listobj->object release];
	[listObject->object release];

	[self freeMemory: listobj];
	[self freeMemory: listObject];
}

- (size_t)count
{
	return count;
}

- (BOOL)isEqual: (id)obj
- (BOOL)isEqual: (id)object
{
	OFList *otherList;
	of_list_object_t *iter, *iter2;

	if (![obj isKindOfClass: [OFList class]])
	if (![object isKindOfClass: [OFList class]])
		return NO;

	otherList = (OFList*)object;

	if ([(OFList*)obj count] != count)
	if ([otherList count] != count)
		return NO;

	for (iter = firstListObject, iter2 = [(OFList*)obj firstListObject];
	for (iter = firstListObject, iter2 = [otherList firstListObject];
	    iter != NULL && iter2 != NULL;
	    iter = iter->next, iter2 = iter2->next)
		if (![iter->object isEqual: iter2->object])
			return NO;

	/* One is bigger than the other although we checked the count */
	assert(iter == NULL && iter2 == NULL);

	return YES;
}

- (BOOL)containsObject: (id)obj
- (BOOL)containsObject: (id)object
{
	of_list_object_t *iter;

	if (count == 0)
		return NO;

	for (iter = firstListObject; iter != NULL; iter = iter->next)
		if ([iter->object isEqual: obj])
		if ([iter->object isEqual: object])
			return YES;

	return NO;
}

- (BOOL)containsObjectIdenticalTo: (id)obj
- (BOOL)containsObjectIdenticalTo: (id)object
{
	of_list_object_t *iter;

	if (count == 0)
		return NO;

	for (iter = firstListObject; iter != NULL; iter = iter->next)
		if (iter->object == obj)
		if (iter->object == object)
			return YES;

	return NO;
}

- copy
{
	OFList *new = [[OFList alloc] init];
	of_list_object_t *iter, *o, *prev;
	OFList *copy = [[OFList alloc] init];
	of_list_object_t *iter, *listObject, *previous;

	o = NULL;
	prev = NULL;
	listObject = NULL;
	previous = NULL;

	@try {
		for (iter = firstListObject; iter != NULL; iter = iter->next) {
			listObject = [copy allocMemoryWithSize:
			o = [new allocMemoryWithSize: sizeof(of_list_object_t)];
			o->object = [iter->object retain];
			o->next = NULL;
			o->prev = prev;
			    sizeof(of_list_object_t)];
			listObject->object = [iter->object retain];
			listObject->next = NULL;
			listObject->previous = previous;

			if (new->firstListObject == NULL)
				new->firstListObject = o;
			if (prev != NULL)
				prev->next = o;
			if (copy->firstListObject == NULL)
				copy->firstListObject = listObject;
			if (previous != NULL)
				previous->next = listObject;

			new->count++;
			copy->count++;

			prev = o;
			previous = listObject;
		}
	} @catch (id e) {
		[new release];
		[copy release];
		@throw e;
	}

	new->lastListObject = o;
	copy->lastListObject = listObject;

	return new;
	return copy;
}

- (uint32_t)hash
{
	of_list_object_t *iter;
	uint32_t hash;