ObjFW  Diff

Differences From Artifact [6e7407d49b]:

To Artifact [5b6a2f3354]:


237
238
239
240
241
242
243
244

245
246
247
248
249
250
251
237
238
239
240
241
242
243

244
245
246
247
248
249
250
251







-
+







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

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

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

		return [[OFData dataWithItemsNoCopy: buffer
					      count: count
379
380
381
382
383
384
385
386

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

386
387
388
389
390
391
392
393







-
+







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

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

	buffer = of_malloc(range.length, sizeof(*buffer));
	buffer = of_alloc(range.length, sizeof(*buffer));
	@try {
		[self getObjects: buffer
			 inRange: range];

		ret = [OFArray arrayWithObjects: buffer
					  count: range.length];
	} @finally {
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
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







-
+




















-
+







}

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

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

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

	return ret;
}

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

	@try {
		__block size_t i = 0;

		[self enumerateObjectsUsingBlock: ^ (id object, size_t idx,
		    bool *stop) {
			if (block(object, idx))