ObjFW  Diff

Differences From Artifact [1c1ae2a28e]:

To Artifact [fb3d19ec1b]:


8
9
10
11
12
13
14

15
16
17
18
19
20
21
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22







+







 * Q Public License 1.0, which can be found in the file LICENSE included in
 * the packaging of this file.
 */

#import <stdlib.h>
#import <string.h>
#import "OFString.h"
#import "OFExceptions.h"

@implementation OFString
+ new: (const char*)str
{
	return [[OFString alloc] init: str];
}

90
91
92
93
94
95
96
97
98
99


100
101
102
103
104
105
106
107
108
109
91
92
93
94
95
96
97



98
99

100
101
102
103
104
105
106
107
108







-
-
-
+
+
-










	if (str == NULL)
		return [self setTo:str];

	strlength = strlen(str);
	newlen = length + strlength;

	/* FIXME: Add error handling */
	if ((newstr = [self resizeMem: string
			       toSize: newlen + 1]) == NULL)
	newstr = [self resizeMem: string
			  toSize: newlen + 1];
		return nil;

	memcpy(newstr + length, str, strlength + 1);

	length = newlen;
	string = newstr;

	return self;
}
@end