ObjFW  Check-in [8a194de51c]

Overview
Comment:OFMapTable: Minor corrections.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 8a194de51c9259bbb1b1b4e0b19a1a05b016259868c9b73bc357e755969924c2
User & Date: js on 2013-05-04 10:05:50
Other Links: manifest | tags
Context
2013-05-04
12:04
OFSet: Add -[allObjects] and -[anyObject]. check-in: d1a7509701 user: js tags: trunk
10:05
OFMapTable: Minor corrections. check-in: 8a194de51c user: js tags: trunk
2013-05-01
21:05
OFRunLoop: Work correctly for threads && !sockets. check-in: 56ec27cbdf user: js tags: trunk
Changes

Modified src/OFMapTable.m from [9fc4f60d3b] to [e861c4b211].

313
314
315
316
317
318
319
320
321

322
323
324
325
326
327
328
313
314
315
316
317
318
319


320
321
322
323
324
325
326
327







-
-
+







	 */
	if ((capacity < _capacity && count > _count) || capacity < MIN_CAPACITY)
		return;

	buckets = [self allocMemoryWithSize: sizeof(*buckets)
				      count: capacity];

	for (i = 0; i < capacity; i++)
		buckets[i] = NULL;
	memset(buckets, 0, capacity * sizeof(*buckets));

	for (i = 0; i < _capacity; i++) {
		if (_buckets[i] != NULL && _buckets[i] != &deleted) {
			uint32_t j, last;

			last = capacity;

380
381
382
383
384
385
386
387

388
389
390
391
392
393
394
379
380
381
382
383
384
385

386
387
388
389
390
391
392
393







-
+







				continue;

			if (_keyFunctions.equal(_buckets[i]->key, key))
				break;
		}
	}

	/* Key not in dictionary */
	/* Key not in map table */
	if (i >= last || _buckets[i] == NULL || _buckets[i] == &deleted ||
	    !_keyFunctions.equal(_buckets[i]->key, key)) {
		struct of_map_table_bucket *bucket;

		[self OF_resizeForCount: _count + 1];

		_mutations++;
417
418
419
420
421
422
423
424

425
426
427
428
429
430
431
416
417
418
419
420
421
422

423
424
425
426
427
428
429
430







-
+







			[self freeMemory: bucket];
			@throw e;
		}

		@try {
			bucket->value = _valueFunctions.retain(value);
		} @catch (id e) {
			_keyFunctions.release(key);
			_keyFunctions.release(bucket->key);
			[self freeMemory: bucket];
			@throw e;
		}

		bucket->hash = hash;

		_buckets[i] = bucket;

Modified src/macros.h from [03ac2254d3] to [533552d659].

321
322
323
324
325
326
327
328
329
330
331
332
333






334
335
336
337
338
339
340
321
322
323
324
325
326
327






328
329
330
331
332
333
334
335
336
337
338
339
340







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







 * We define it here and not in objfw-defs.h, as it would be theoretically
 * possible to build a universal binary for Mac OS X and iOS.
 */
#if defined(__APPLE__) && defined(__arm__)
# define OF_IOS
#endif

#define OF_ROL(value, bits)						\
	(((value) << ((bits) % (sizeof(value) * 8))) |			\
	(value) >> (sizeof(value) * 8 - ((bits) % (sizeof(value) * 8))))
#define OF_ROR(value, bits)						\
	(((value) >> ((bits) % (sizeof(value) * 8))) |			\
	(value) << (sizeof(value) * 8 - ((bits) % (sizeof(value) * 8))))
#define OF_ROL(value, bits)						   \
	(((value) << ((bits) % (sizeof(value) * 8))) |			   \
	((value) >> (sizeof(value) * 8 - ((bits) % (sizeof(value) * 8)))))
#define OF_ROR(value, bits)						   \
	(((value) >> ((bits) % (sizeof(value) * 8))) |			   \
	((value) << (sizeof(value) * 8 - ((bits) % (sizeof(value) * 8)))))

#define OF_HASH_INIT(hash) hash = of_hash_seed
#define OF_HASH_ADD(hash, byte)			\
	{					\
		hash += (uint8_t)(byte);	\
		hash += (hash << 10);		\
		hash ^= (hash >> 6);		\