ObjFW  Check-in [cc6d2d3987]

Overview
Comment:Fix error handling in init methods in OFArray.

Actually, directly retaining them is required, as dealloc will release
them.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: cc6d2d398758178baf3cea0fe9011f180622aaafe25c16858281001bc135f3b8
User & Date: js on 2009-05-18 22:09:42
Other Links: manifest | tags
Context
2009-05-18
22:21
Add a new convenience method for OFDictionary. check-in: b02800172f user: js tags: trunk
22:09
Fix error handling in init methods in OFArray. check-in: cc6d2d3987 user: js tags: trunk
20:53
Split OFDictionary into OFDictionary and OFMutableDictionary. check-in: 71abb030af user: js tags: trunk
Changes

Modified src/OFArray.m from [9f48848034] to [47830eac24].

93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108


109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
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
	return ret;
}

- initWithObject: (OFObject*)first
      andArgList: (va_list)args
{
	id obj;
	OFObject **objs;
	size_t len, i;

	self = [self init];

	@try {
		[array add: &first];
		while ((obj = va_arg(args, id)) != nil)
			[array add: &obj];


	} @catch (OFException *e) {
		[self dealloc];
		@throw e;
	}

	/* Retain objects after adding them for the case adding failed */
	objs = [array data];
	len = [array count];

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

	return self;
}

- initWithCArray: (OFObject**)objs
{
	id *obj;

	self = [self init];

	@try {
		for (obj = objs; *obj != nil; obj++)
			[array add: obj];


	} @catch (OFException *e) {
		[self dealloc];
		@throw e;
	}

	/* Retain objects after adding them for the case adding failed */
	for (obj = objs; *obj != nil; obj++)
		[*obj retain];

	return self;
}

- (size_t)count
{
	return [array count];
}







<
<





|

>
>





<
<
<
<
<
<
<
<










|

>
>





<
<
<
<







93
94
95
96
97
98
99


100
101
102
103
104
105
106
107
108
109
110
111
112
113








114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132




133
134
135
136
137
138
139
	return ret;
}

- initWithObject: (OFObject*)first
      andArgList: (va_list)args
{
	id obj;



	self = [self init];

	@try {
		[array add: &first];
		while ((obj = va_arg(args, id)) != nil) {
			[array add: &obj];
			[obj retain];
		}
	} @catch (OFException *e) {
		[self dealloc];
		@throw e;
	}









	return self;
}

- initWithCArray: (OFObject**)objs
{
	id *obj;

	self = [self init];

	@try {
		for (obj = objs; *obj != nil; obj++) {
			[array add: obj];
			[*obj retain];
		}
	} @catch (OFException *e) {
		[self dealloc];
		@throw e;
	}





	return self;
}

- (size_t)count
{
	return [array count];
}