ObjFW  Check-in [044eee2ed9]

Overview
Comment:Don't care in OFDataArray if realloc failed if we only made it smaller.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 044eee2ed97cbbf947b0ecf82cd0a12b1e20536b554be121d972ff4d8de7d077
User & Date: js on 2009-11-28 20:44:10
Other Links: manifest | tags
Context
2009-11-28
20:48
Add -[removeObject:] and -[removeObjectIdenticalTo:] to OFMutableArray. check-in: bd9f5d90ae user: js tags: trunk
20:44
Don't care in OFDataArray if realloc failed if we only made it smaller. check-in: 044eee2ed9 user: js tags: trunk
20:29
Add -[indexOfObject:] and -[indexOfObjectIdenticalTo:] to OFArray. check-in: f1e3f965fc user: js tags: trunk
Changes

Modified src/OFDataArray.m from [a0d0c15800] to [005260144b].

135
136
137
138
139
140
141

142
143
144




145
146
147
148
149
150
151
152
153
154
155
156
157
158

159
160
161




162
163
164
165
166
167
168
- removeNItems: (size_t)nitems
{
	if (nitems > count)
		@throw [OFOutOfRangeException newWithClass: isa];


	count -= nitems;

	data = [self resizeMemory: data
			 toNItems: count
			 withSize: itemsize];





	return self;
}

- removeNItems: (size_t)nitems
       atIndex: (size_t)index
{
	if (nitems > count)
		@throw [OFOutOfRangeException newWithClass: isa];

	memmove(data + index * itemsize, data + (index + nitems) * itemsize,
	    nitems * itemsize);

	count -= nitems;

	data = [self resizeMemory: data
			 toNItems: count
			 withSize: itemsize];





	return self;
}

- (id)copy
{
	OFDataArray *new = [[OFDataArray alloc] initWithItemSize: itemsize];







>
|
|
|
>
>
>
>














>
|
|
|
>
>
>
>







135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
- removeNItems: (size_t)nitems
{
	if (nitems > count)
		@throw [OFOutOfRangeException newWithClass: isa];


	count -= nitems;
	@try {
		data = [self resizeMemory: data
				 toNItems: count
				 withSize: itemsize];
	} @catch (OFOutOfMemoryException *e) {
		/* We don't really care, as we only made it smaller */
		[e dealloc];
	}

	return self;
}

- removeNItems: (size_t)nitems
       atIndex: (size_t)index
{
	if (nitems > count)
		@throw [OFOutOfRangeException newWithClass: isa];

	memmove(data + index * itemsize, data + (index + nitems) * itemsize,
	    nitems * itemsize);

	count -= nitems;
	@try {
		data = [self resizeMemory: data
				 toNItems: count
				 withSize: itemsize];
	} @catch (OFOutOfMemoryException *e) {
		/* We don't really care, as we only made it smaller */
		[e dealloc];
	}

	return self;
}

- (id)copy
{
	OFDataArray *new = [[OFDataArray alloc] initWithItemSize: itemsize];