ObjFW  Diff

Differences From Artifact [76b22a5fc0]:

To Artifact [6e7407d49b]:


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







-
-
-
+
+

-
-
-
-
-
-
-
+
+
+

+
+
+
+
+
-
+
+
+







{
	for (size_t i = 0; i < range.length; i++)
		buffer[i] = [self objectAtIndex: range.location + i];
}

- (id const *)objects
{
	OFObject *container;
	size_t count;
	id *buffer;
	size_t count = self.count;
	id *buffer = of_malloc(count, sizeof(id));

	container = [[[OFObject alloc] init] autorelease];
	count = self.count;
	buffer = [container allocMemoryWithSize: sizeof(*buffer)
					  count: count];

	[self getObjects: buffer
		 inRange: of_range(0, count)];
	@try {
		[self getObjects: buffer
			 inRange: of_range(0, count)];

		return [[OFData dataWithItemsNoCopy: buffer
					      count: count
					   itemSize: sizeof(id)
				       freeWhenDone: true] items];
	} @catch (id e) {
	return buffer;
		free(buffer);
		@throw e;
	}
}

- (id)copy
{
	return [self retain];
}

377
378
379
380
381
382
383
384
385

386
387
388
389
390
391
392
393
394

395
396
397
398
399
400
401
379
380
381
382
383
384
385


386

387
388
389
390
391
392
393

394
395
396
397
398
399
400
401







-
-
+
-







-
+







	    range.location + range.length < self.count)
		@throw [OFOutOfRangeException exception];

	if (![self isKindOfClass: [OFMutableArray class]])
		return [OFSubarray arrayWithArray: self
					    range: range];

	buffer = [self allocMemoryWithSize: sizeof(*buffer)
				     count: range.length];
	buffer = of_malloc(range.length, sizeof(*buffer));

	@try {
		[self getObjects: buffer
			 inRange: range];

		ret = [OFArray arrayWithObjects: buffer
					  count: range.length];
	} @finally {
		[self freeMemory: buffer];
		free(buffer);
	}

	return ret;
}

- (OFString *)componentsJoinedByString: (OFString *)separator
{
511
512
513
514
515
516
517
518

519
520
521
522
523
524
525
511
512
513
514
515
516
517

518
519
520
521
522
523
524
525







-
+







		if (![[self objectAtIndex: i] isEqual:
		    [otherArray objectAtIndex: i]])
			return false;

	return true;
}

- (uint32_t)hash
- (unsigned long)hash
{
	uint32_t hash;

	OF_HASH_INIT(hash);

	for (id object in self)
		OF_HASH_ADD_HASH(hash, [object hash]);
854
855
856
857
858
859
860
861

862
863
864
865
866
867
868
869
870
871
872
873

874
875
876
877
878
879
880
881
882
883

884
885
886
887
888
889
890
891
892
893
894
895
896
897
898

899
900
901
902
903
904
905
854
855
856
857
858
859
860

861

862
863
864
865
866
867
868
869
870
871

872
873
874
875
876
877
878
879
880
881

882

883
884
885
886
887
888
889
890
891
892
893
894
895

896
897
898
899
900
901
902
903







-
+
-










-
+









-
+
-













-
+







}

#ifdef OF_HAVE_BLOCKS
- (OFArray *)mappedArrayUsingBlock: (of_array_map_block_t)block
{
	OFArray *ret;
	size_t count = self.count;
	id *tmp = [self allocMemoryWithSize: sizeof(id)
	id *tmp = of_malloc(count, sizeof(id));
				      count: count];

	@try {
		[self enumerateObjectsUsingBlock: ^ (id object, size_t idx,
		    bool *stop) {
			tmp[idx] = block(object, idx);
		}];

		ret = [OFArray arrayWithObjects: tmp
					  count: count];
	} @finally {
		[self freeMemory: tmp];
		free(tmp);
	}

	return ret;
}

- (OFArray *)filteredArrayUsingBlock: (of_array_filter_block_t)block
{
	OFArray *ret;
	size_t count = self.count;
	id *tmp = [self allocMemoryWithSize: sizeof(id)
	id *tmp = of_malloc(count, sizeof(id));
				      count: count];

	@try {
		__block size_t i = 0;

		[self enumerateObjectsUsingBlock: ^ (id object, size_t idx,
		    bool *stop) {
			if (block(object, idx))
				tmp[i++] = object;
		}];

		ret = [OFArray arrayWithObjects: tmp
					  count: i];
	} @finally {
		[self freeMemory: tmp];
		free(tmp);
	}

	return ret;
}

- (id)foldUsingBlock: (of_array_fold_block_t)block
{