ObjFW  Diff

Differences From Artifact [3d87632f9d]:

To Artifact [9ef8d3d479]:


29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
{
	if ((self = [super init])) {
		if (wstr == NULL) {
			length = 0;
			wstring = NULL;
		} else {
			length = wcslen(wstr);
			if ((wstring =
			    [self getMem: length * sizeof(wchar_t)]) == NULL)
				return NULL;
			memcpy(wstring, wstr, length * sizeof(wchar_t));
		}
	}
	return self;
}

- (wchar_t*)wcString
{







|
|

|







29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
{
	if ((self = [super init])) {
		if (wstr == NULL) {
			length = 0;
			wstring = NULL;
		} else {
			length = wcslen(wstr);
			if (NULL == (wstring =
			    [self getMem: (length + 1) * sizeof(wchar_t)]))
				return NULL;
			memcpy(wstring, wstr, (length + 1) * sizeof(wchar_t));
		}
	}
	return self;
}

- (wchar_t*)wcString
{
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
		length = 0;
		wstring = NULL;

		return self;
	}

	newlen = wcslen(wstr);
	if ((newstr = [self getMem: newlen * sizeof(wchar_t)]) == NULL)
		return nil;
	memcpy(newstr, wstr, newlen * sizeof(wchar_t));

	if (wstring != NULL)
		[self freeMem: wstring];

	length = newlen;
	wstring = newstr;








|

|







63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
		length = 0;
		wstring = NULL;

		return self;
	}

	newlen = wcslen(wstr);
	if ((newstr = [self getMem: (newlen + 1) * sizeof(wchar_t)]) == NULL)
		return nil;
	memcpy(newstr, wstr, (newlen + 1) * sizeof(wchar_t));

	if (wstring != NULL)
		[self freeMem: wstring];

	length = newlen;
	wstring = newstr;

94
95
96
97
98
99
100
101

102
103
104
105
106
107
108
109
110

111
112
113
114
		return [self setTo: wstr];

	strlength = wcslen(wstr);
	newlen = length + strlength;

	/* FIXME: Add error handling */
	if ((newstr = [self resizeMem: wstring
			       toSize: newlen  * sizeof(wchar_t) + 2]) == NULL)

		return nil;

	wstring = newstr;

	memcpy(wstring + length * sizeof(wchar_t), wstr,
	    strlength * sizeof(wchar_t));
	wstring[newlen] = '\0';

	length = newlen;


	return self;
}
@end







|
>


<
<
|
|
<


>




94
95
96
97
98
99
100
101
102
103
104


105
106

107
108
109
110
111
112
113
		return [self setTo: wstr];

	strlength = wcslen(wstr);
	newlen = length + strlength;

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



	memcpy(newstr + length * sizeof(wchar_t), wstr,
	    (strlength + 1) * sizeof(wchar_t));


	length = newlen;
	wstring = newstr;

	return self;
}
@end