ObjFW  Diff

Differences From Artifact [39b88703df]:

To Artifact [518f441548]:


578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
}

- initWithString: (OFString*)string
{
	self = [super init];

	@try {
		const char *cString;

		s = [self allocMemoryWithSize: sizeof(*s)];
		memset(s, 0, sizeof(*s));

		cString = [string cString];
		s->cStringLength = [string cStringLength];

		switch (of_string_check_utf8(cString, s->cStringLength)) {
		case 1:
			s->isUTF8 = YES;
			break;
		case -1:;
			@throw [OFInvalidEncodingException newWithClass: isa];
		}

		if ((s->cString = strdup(cString)) == NULL)
			@throw [OFOutOfMemoryException
			     newWithClass: isa
			    requestedSize: s->cStringLength + 1];

		@try {
			[self addMemoryToPool: s->cString];
		} @catch (id e) {
			free(s->cString);
			@throw e;
		}
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}







<
<



<

<
<
<
|
<
<
<
|
<
<
<
<
|
|
<
<
<
<
<
<







578
579
580
581
582
583
584


585
586
587

588



589



590




591
592






593
594
595
596
597
598
599
}

- initWithString: (OFString*)string
{
	self = [super init];

	@try {


		s = [self allocMemoryWithSize: sizeof(*s)];
		memset(s, 0, sizeof(*s));


		s->cStringLength = [string cStringLength];



		s->isUTF8 = string->s->isUTF8;








		s->cString = [self allocMemoryWithSize: s->cStringLength + 1];
		memcpy(s->cString, [string cString], s->cStringLength + 1);






	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}