ObjFW  Check-in [6ba395bacb]

Overview
Comment:Only let - copy create an actual copy if necessary.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 6ba395bacb349e69a7d1e1d9c7ea0560e5f6d841e5062079649764a28405edfc
User & Date: js on 2009-05-18 18:45:35
Other Links: manifest | tags
Context
2009-05-18
18:52
- copy and - mutableCopy should never autorelease. check-in: 7fa61023b9 user: js tags: trunk
18:45
Only let - copy create an actual copy if necessary. check-in: 6ba395bacb user: js tags: trunk
18:42
A few more convenience methods for OFArray. check-in: b3a8c9c4dd user: js tags: trunk
Changes

Modified src/OFArray.m from [39b19454f4] to [89d75719ec].

125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145

146
147
148
149
150
151
152
125
126
127
128
129
130
131














132
133
134
135
136
137
138
139







-
-
-
-
-
-
-
-
-
-
-
-
-
-
+







- (id*)data
{
	return [array data];
}

- (id)copy
{
	OFArray *new = [OFArray array];
	OFObject **objs;
	size_t len, i;

	objs = [array data];
	len = [array count];

	[new->array addNItems: len
		   fromCArray: objs];

	for (i = 0; i < len; i++)
		[objs[i] retain];

	return new;
	return [self retain];
}

- (id)mutableCopy
{
	OFArray *new = [OFMutableArray array];
	OFObject **objs;
	size_t len, i;

Modified src/OFMutableArray.m from [b08a16685b] to [5eccddb360].

11
12
13
14
15
16
17


















18
19
20
21
22
23
24
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42







+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+








#import "config.h"

#import "OFMutableArray.h"
#import "OFExceptions.h"

@implementation OFMutableArray
- (id)copy
{
	OFArray *new = [OFArray array];
	OFObject **objs;
	size_t len, i;

	objs = [array data];
	len = [array count];

	[new->array addNItems: len
		   fromCArray: objs];

	for (i = 0; i < len; i++)
		[objs[i] retain];

	return new;
}

- add: (OFObject*)obj
{
	[array add: &obj];
	[obj retain];

	return self;
}

Modified src/OFMutableString.m from [61830ce984] to [91e1854508].

29
30
31
32
33
34
35





36
37
38
39
40
41
42
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47







+
+
+
+
+







#import "OFMacros.h"

#ifndef HAVE_ASPRINTF
#import "asprintf.h"
#endif

@implementation OFMutableString
- (id)copy
{
	return [OFString stringWithCString: string];
}

- setToCString: (const char*)str
{
	size_t len;

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

Modified src/OFString.m from [30c1114698] to [84fc7cbec8].

239
240
241
242
243
244
245
246

247
248
249
250
251
252
253
239
240
241
242
243
244
245

246
247
248
249
250
251
252
253







-
+







- (size_t)length
{
	return length;
}

- (id)copy
{
	return [OFString stringWithCString: string];
	return [self retain];
}

- (id)mutableCopy
{
	return [OFMutableString stringWithCString: string];
}