ObjFW  Diff

Differences From Artifact [c1cd16a470]:

To Artifact [1029a1bdaf]:


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
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







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










-
-
+
+











-
-
-
-
+











-
+







	objCType = self.objCType;

	if (strcmp([object objCType], objCType) != 0)
		return false;

	size = of_sizeof_type_encoding(objCType);

	if ((value = malloc(size)) == NULL)
	value = of_malloc(1, size);
		@throw [OFOutOfMemoryException
		    exceptionWithRequestedSize: size];

	if ((otherValue = malloc(size)) == NULL) {
		free(value);
		@throw [OFOutOfMemoryException
	@try {
		otherValue = of_malloc(1, size);
	} @catch (id e) {
		of_free(value);
		@throw e;
		    exceptionWithRequestedSize: size];
	}

	@try {
		[self getValue: value
			  size: size];
		[object getValue: otherValue
			    size: size];

		ret = (memcmp(value, otherValue, size) == 0);
	} @finally {
		free(value);
		free(otherValue);
		of_free(value);
		of_free(otherValue);
	}

	return ret;
}

- (unsigned long)hash
{
	size_t size = of_sizeof_type_encoding(self.objCType);
	unsigned char *value;
	uint32_t hash;

	if ((value = malloc(size)) == NULL)
		@throw [OFOutOfMemoryException
		    exceptionWithRequestedSize: size];

	value = of_malloc(1, size);
	@try {
		[self getValue: value
			  size: size];

		OF_HASH_INIT(hash);

		for (size_t i = 0; i < size; i++)
			OF_HASH_ADD(hash, value[i]);

		OF_HASH_FINALIZE(hash);
	} @finally {
		free(value);
		of_free(value);
	}

	return hash;
}

- (id)copy
{
314
315
316
317
318
319
320
321
322
323
324

325
326
327
328
329
330
331
332
333
334
335
336

337
338
339
340
341
342
343
344
309
310
311
312
313
314
315




316
317
318
319
320
321
322
323
324
325
326
327

328
329
330
331
332
333
334
335
336







-
-
-
-
+











-
+








- (OFString *)description
{
	OFMutableString *ret =
	    [OFMutableString stringWithString: @"<OFValue: "];
	size_t size = of_sizeof_type_encoding(self.objCType);
	unsigned char *value;

	if ((value = malloc(size)) == NULL)
		@throw [OFOutOfMemoryException
		    exceptionWithRequestedSize: size];

	value = of_malloc(1, size);
	@try {
		[self getValue: value
			  size: size];

		for (size_t i = 0; i < size; i++) {
			if (i > 0)
				[ret appendString: @" "];

			[ret appendFormat: @"%02x", value[i]];
		}
	} @finally {
		free(value);
		of_free(value);
	}

	[ret appendString: @">"];

	[ret makeImmutable];
	return ret;
}
@end