ObjFW  Check-in [ab270674db]

Overview
Comment:Fix OFBigDataArray's initWithStringRepresentation:
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: ab270674db96caec78094120ecdf5ad5b13750131bbabc78dc720697a7257b8f
User & Date: js on 2014-09-10 22:09:50
Other Links: manifest | tags
Context
2014-10-04
19:24
threading: WinAPI's CriticalSection is recursive check-in: be99da0c09 user: js tags: trunk
2014-09-10
22:09
Fix OFBigDataArray's initWithStringRepresentation: check-in: ab270674db user: js tags: trunk
21:51
OFDataArray: Handle exceptions in init check-in: c79d076e58 user: js tags: trunk
Changes

Modified src/OFDataArray.m from [e60942ae0f] to [eb19be5b1d].

255
256
257
258
259
260
261
262
263
264
265
266

267
268
269

270
271
272

273
274
275




276
277
278
279
280

281
282
283
284
285
286
287
255
256
257
258
259
260
261


262
263

264
265


266
267
268

269
270
271

272
273
274
275
276
277

278

279
280
281
282
283
284
285
286







-
-


-
+

-
-
+


-
+


-
+
+
+
+


-

-
+







	objc_autoreleasePoolPop(pool);

	return self;
}

- initWithStringRepresentation: (OFString*)string
{
	self = [super init];

	@try {
		const char *cString;
		size_t i;
		size_t i, count;

		_itemSize = 1;
		_count = [string
		count = [string
		    cStringLengthWithEncoding: OF_STRING_ENCODING_ASCII];

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

		_count /= 2;
		count /= 2;

		self = [self initWithCapacity: count];

		cString = [string
		    cStringWithEncoding: OF_STRING_ENCODING_ASCII];
		_items = [self allocMemoryWithSize: _count];

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

			if (c1 >= '0' && c1 <= '9')
				byte = (c1 - '0') << 4;
			else if (c1 >= 'a' && c1 <= 'f')
296
297
298
299
300
301
302
303

304
305
306
307
308
309
310
295
296
297
298
299
300
301

302
303
304
305
306
307
308
309







-
+







			else if (c2 >= 'a' && c2 <= 'f')
				byte |= c2 - 'a' + 10;
			else if (c2 >= 'A' && c2 <= 'F')
				byte |= c2 - 'A' + 10;
			else
				@throw [OFInvalidFormatException exception];

			_items[i] = byte;
			[self addItem: &byte];
		}
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;