ObjFW  Check-in [bc012259a9]

Overview
Comment:Correctly handle lastObject / lastItem if the array is empty.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: bc012259a9356628ae30aaf4613bfffd0360868e5bbafdfc7c665ca06f95da0c
User & Date: js on 2009-08-10 18:25:15
Other Links: manifest | tags
Context
2009-08-10
18:37
More checking for malformed/invalid XML. check-in: a70d90b09e user: js tags: trunk
18:25
Correctly handle lastObject / lastItem if the array is empty. check-in: bc012259a9 user: js tags: trunk
2009-07-24
22:44
RTLD_LAZY makes more sense, as we only need a few symbols looked up. check-in: e549c515e0 user: js tags: trunk
Changes

Modified src/OFArray.m from [2201996b2e] to [3bf6c09d87].

169
170
171
172
173
174
175
176



177
178
179
180
181
182
183
169
170
171
172
173
174
175

176
177
178
179
180
181
182
183
184
185







-
+
+
+







- (id)objectAtIndex: (size_t)index
{
	return *((OFObject**)[array itemAtIndex: index]);
}

- (id)lastObject
{
	return *((OFObject**)[array lastItem]);
	void *last = [array lastItem];

	return (last != NULL ? *((id*)last) : nil);
}

- (BOOL)isEqual: (id)obj
{
	OFObject **objs, **objs2;
	size_t i, len, len2;

Modified src/OFDataArray.m from [f70a5505ca] to [c9dcd66730].

78
79
80
81
82
83
84



85
86
87
88
89
90
91
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94







+
+
+







		@throw [OFOutOfRangeException newWithClass: isa];

	return data + index * itemsize;
}

- (void*)lastItem
{
	if (data == NULL || count == 0)
		return NULL;

	return data + (count - 1) * itemsize;
}

- addItem: (void*)item
{
	if (SIZE_MAX - count < 1)
		@throw [OFOutOfRangeException newWithClass: isa];