ObjFW  Diff

Differences From Artifact [20a79e42c1]:

To Artifact [f4f38100bd]:


129
130
131
132
133
134
135
136
137
138
139

140
141
142
143
144
145
146
{
	self = [super init];

	@try {
		if (itemSize == 0)
			@throw [OFInvalidArgumentException exception];

		_items = [self allocMemoryWithSize: itemSize
					     count: count];
		_itemSize = itemSize;
		_count = count;


		memcpy(_items, items, count * itemSize);
	} @catch (id e) {
		[self release];
		@throw e;
	}








|
<


>







129
130
131
132
133
134
135
136

137
138
139
140
141
142
143
144
145
146
{
	self = [super init];

	@try {
		if (itemSize == 0)
			@throw [OFInvalidArgumentException exception];

		_items = of_malloc(count, itemSize);

		_itemSize = itemSize;
		_count = count;
		_freeWhenDone = true;

		memcpy(_items, items, count * itemSize);
	} @catch (id e) {
		[self release];
		@throw e;
	}

242
243
244
245
246
247
248

249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
			    exceptionWithURL: URL];

		stream = [URLHandler openItemAtURL: URL
					      mode: @"r"];

		_itemSize = 1;
		_count = 0;


		pageSize = [OFSystemInfo pageSize];
		buffer = of_malloc(1, pageSize);

		@try {
			while (!stream.atEndOfStream) {
				size_t length = [stream
				    readIntoBuffer: buffer
					    length: pageSize];

				if (SIZE_MAX - _count < length)
					@throw [OFOutOfRangeException
					    exception];

				_items = [self resizeMemory: _items
						       size: _count + length];
				memcpy(_items + _count, buffer, length);
				_count += length;
			}
		} @finally {
			free(buffer);
		}








>














<
|







242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263

264
265
266
267
268
269
270
271
			    exceptionWithURL: URL];

		stream = [URLHandler openItemAtURL: URL
					      mode: @"r"];

		_itemSize = 1;
		_count = 0;
		_freeWhenDone = true;

		pageSize = [OFSystemInfo pageSize];
		buffer = of_malloc(1, pageSize);

		@try {
			while (!stream.atEndOfStream) {
				size_t length = [stream
				    readIntoBuffer: buffer
					    length: pageSize];

				if (SIZE_MAX - _count < length)
					@throw [OFOutOfRangeException
					    exception];


				_items = of_realloc(_items, _count + length, 1);
				memcpy(_items + _count, buffer, length);
				_count += length;
			}
		} @finally {
			free(buffer);
		}

288
289
290
291
292
293
294
295
296
297

298
299
300
301
302
303
304
		const char *cString;

		if (count % 2 != 0)
			@throw [OFInvalidFormatException exception];

		count /= 2;

		_items = [self allocMemoryWithSize: count];
		_itemSize = 1;
		_count = count;


		cString = [string
		    cStringWithEncoding: OF_STRING_ENCODING_ASCII];

		for (size_t i = 0; i < count; i++) {
			uint8_t c1 = cString[2 * i];
			uint8_t c2 = cString[2 * i + 1];







|


>







288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
		const char *cString;

		if (count % 2 != 0)
			@throw [OFInvalidFormatException exception];

		count /= 2;

		_items = of_malloc(count, 1);
		_itemSize = 1;
		_count = count;
		_freeWhenDone = true;

		cString = [string
		    cStringWithEncoding: OF_STRING_ENCODING_ASCII];

		for (size_t i = 0; i < count; i++) {
			uint8_t c1 = cString[2 * i];
			uint8_t c2 = cString[2 * i + 1];