ObjFW  Check-in [7aa23887d0]

Overview
Comment:Make GCC happy again
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 7aa23887d0d53a9e79278447f27f12744a58465f9020ae7fd3b4878e72df641e
User & Date: js on 2020-11-07 10:38:49
Other Links: manifest | tags
Context
2020-11-07
20:23
OFObject: Remove -[allocMemoryWithSize:] check-in: 4fbdca698c user: js tags: trunk
10:38
Make GCC happy again check-in: 7aa23887d0 user: js tags: trunk
2020-11-06
02:37
OFString: Make freeWhenDone behave like in OFData check-in: 0f260e0fd5 user: js tags: trunk
Changes

Modified src/OFArray.m from [a1c992248d] to [6e7407d49b].

243
244
245
246
247
248
249
250
251
252
253




254
255
256
257
258
259
260
243
244
245
246
247
248
249




250
251
252
253
254
255
256
257
258
259
260







-
-
-
-
+
+
+
+







	size_t count = self.count;
	id *buffer = of_malloc(count, sizeof(id));

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

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

- (id)copy

Modified src/OFMutableData.m from [7f5853c182] to [8aa04f6052].

267
268
269
270
271
272
273
274

275
276
277
278
279
280
281
267
268
269
270
271
272
273

274
275
276
277
278
279
280
281







-
+








	memmove(_items + range.location * _itemSize,
	    _items + (range.location + range.length) * _itemSize,
	    (_count - range.location - range.length) * _itemSize);

	_count -= range.length;
	@try {
		_items = of_realloc(_items, _count, _itemSize);;
		_items = of_realloc(_items, _count, _itemSize);
		_capacity = _count;
	} @catch (OFOutOfMemoryException *e) {
		/* We don't really care, as we only made it smaller */
	}
}

- (void)removeLastItem

Modified src/OFString.m from [7044157852] to [3f36b9543e].

1429
1430
1431
1432
1433
1434
1435
1436
1437
1438



1439
1440
1441
1442
1443
1444
1445
1429
1430
1431
1432
1433
1434
1435



1436
1437
1438
1439
1440
1441
1442
1443
1444
1445







-
-
-
+
+
+








		break;
	default:
		@throw [OFInvalidEncodingException exception];
	}

	@try {
		return [OFData dataWithItemsNoCopy: cString
					     count: cStringLength + 1
				      freeWhenDone: true].items;
		return [[OFData dataWithItemsNoCopy: cString
					      count: cStringLength + 1
				       freeWhenDone: true] items];
	} @catch (id e) {
		free(cString);
		@throw e;
	}
}

- (const char *)cStringWithEncoding: (of_string_encoding_t)encoding
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514




2515
2516
2517
2518
2519
2520
2521
2504
2505
2506
2507
2508
2509
2510




2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521







-
-
-
-
+
+
+
+







	of_unichar_t *buffer;

	buffer = of_malloc(length, sizeof(of_unichar_t));
	@try {
		[self getCharacters: buffer
			    inRange: of_range(0, length)];

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

- (const of_char16_t *)UTF16String
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577




2578
2579
2580
2581
2582
2583
2584
2567
2568
2569
2570
2571
2572
2573




2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584







-
-
-
-
+
+
+
+







	} @catch (OFOutOfMemoryException *e) {
		/* We don't care, as we only tried to make it smaller */
	}

	objc_autoreleasePoolPop(pool);

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

- (size_t)UTF16StringLength
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621




2622
2623
2624
2625
2626
2627
2628
2611
2612
2613
2614
2615
2616
2617




2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628







-
-
-
-
+
+
+
+







			    inRange: of_range(0, length)];
		buffer[length] = 0;

		if (byteOrder != OF_BYTE_ORDER_NATIVE)
			for (size_t i = 0; i < length; i++)
				buffer[i] = OF_BSWAP32(buffer[i]);

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

- (OFData *)dataWithEncoding: (of_string_encoding_t)encoding