ObjFW  Diff

Differences From Artifact [fc3aaeaea9]:

To Artifact [c47726834e]:


46
47
48
49
50
51
52
53

54
55
56
57
58
59
60
46
47
48
49
50
51
52

53
54
55
56
57
58
59
60







-
+







#import "autorelease.h"
#import "base64.h"
#import "macros.h"

/* References for static linking */
void _references_to_categories_of_OFDataArray(void)
{
	_OFDataArray_BinaryPackValue_reference = 1;
	_OFDataArray_MessagePackValue_reference = 1;
	_OFDataArray_Hashing_reference = 1;
}

@implementation OFDataArray
+ (instancetype)dataArray
{
	return [[[self alloc] init] autorelease];
624
625
626
627
628
629
630
631

632
633
634
635
636
637
638
639
640
641

642
643
644
645
646
647
648
649
650

651
652
653
654
655
656
657
658
659
660

661
662
663
664
665
666
667
624
625
626
627
628
629
630

631
632
633
634
635
636
637
638
639
640

641
642
643
644
645
646
647
648
649

650
651
652
653
654
655
656
657
658
659

660
661
662
663
664
665
666
667







-
+









-
+








-
+









-
+







	[element retain];

	objc_autoreleasePoolPop(pool);

	return [element autorelease];
}

- (OFDataArray*)binaryPackRepresentation
- (OFDataArray*)messagePackRepresentation
{
	OFDataArray *data;

	if (_itemSize != 1)
		@throw [OFInvalidArgumentException
		    exceptionWithClass: [self class]
			      selector: _cmd];

	if (_count <= UINT8_MAX) {
		uint8_t type = 0xD5;
		uint8_t type = 0xC4;
		uint8_t tmp = (uint8_t)_count;

		data = [OFDataArray dataArrayWithItemSize: 1
						 capacity: _count + 2];

		[data addItem: &type];
		[data addItem: &tmp];
	} else if (_count <= UINT16_MAX) {
		uint8_t type = 0xD6;
		uint8_t type = 0xC5;
		uint16_t tmp = OF_BSWAP16_IF_LE((uint16_t)_count);

		data = [OFDataArray dataArrayWithItemSize: 1
						 capacity: _count + 3];

		[data addItem: &type];
		[data addItems: &tmp
			 count: sizeof(tmp)];
	} else if (_count <= UINT32_MAX) {
		uint8_t type = 0xD7;
		uint8_t type = 0xC6;
		uint32_t tmp = OF_BSWAP32_IF_LE((uint32_t)_count);

		data = [OFDataArray dataArrayWithItemSize: 1
						 capacity: _count + 5];

		[data addItem: &type];
		[data addItems: &tmp