ObjFW  Diff

Differences From Artifact [70534fd085]:

To Artifact [1e877ea8dd]:


297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312


313
314
315
316
317
318
319
	return count * size;
}

size_t
sizeofStruct(const char **type, size_t *length)
{
	size_t size = 0;
#if defined(OF_POWERPC) && defined(OF_MACOS)
	bool first = true;
	size_t alignment;

	{
		const char *typeCopy = *type;
		size_t lengthCopy = *length;
		alignment = alignofStruct(&typeCopy, &lengthCopy);
	}


#endif

	assert(*length > 0);

	(*type)++;
	(*length)--;








<
<
<
<
<
|
|
|
<
>
>







297
298
299
300
301
302
303





304
305
306

307
308
309
310
311
312
313
314
315
	return count * size;
}

size_t
sizeofStruct(const char **type, size_t *length)
{
	size_t size = 0;





	const char *typeCopy = *type;
	size_t lengthCopy = *length;
	size_t alignment = alignofStruct(&typeCopy, &lengthCopy);

#if defined(OF_POWERPC) && defined(OF_MACOS)
	bool first = true;
#endif

	assert(*length > 0);

	(*type)++;
	(*length)--;

327
328
329
330
331
332
333


334
335
336
337
338
339
340
341
342
343
344
		@throw [OFInvalidFormatException exception];

	/* Skip '=' */
	(*type)++;
	(*length)--;

	while (*length > 0 && **type != '}') {


		const char *typeCopy = *type;
		size_t lengthCopy = *length;
		size_t fieldSize = sizeofEncoding(type, length);
		size_t fieldAlign = alignofEncoding(&typeCopy, &lengthCopy);

#if defined(OF_POWERPC) && defined(OF_MACOS)
		if (!first && fieldAlign > 4)
			fieldAlign = 4;

		first = false;
#endif







>
>
|
|
|
|







323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
		@throw [OFInvalidFormatException exception];

	/* Skip '=' */
	(*type)++;
	(*length)--;

	while (*length > 0 && **type != '}') {
		size_t fieldSize, fieldAlign;

		typeCopy = *type;
		lengthCopy = *length;
		fieldSize = sizeofEncoding(type, length);
		fieldAlign = alignofEncoding(&typeCopy, &lengthCopy);

#if defined(OF_POWERPC) && defined(OF_MACOS)
		if (!first && fieldAlign > 4)
			fieldAlign = 4;

		first = false;
#endif
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383

	if (*length == 0 || **type != '}')
		@throw [OFInvalidFormatException exception];

	(*type)++;
	(*length)--;

#if defined(OF_POWERPC) && defined(OF_MACOS)
	if (size % alignment != 0) {
		size_t padding = alignment - (size % alignment);

		if (SIZE_MAX - size < padding)
			@throw [OFOutOfRangeException exception];

		size += padding;
	}
#endif

	return size;
}

size_t
sizeofUnion(const char **type, size_t *length)
{







<








<







358
359
360
361
362
363
364

365
366
367
368
369
370
371
372

373
374
375
376
377
378
379

	if (*length == 0 || **type != '}')
		@throw [OFInvalidFormatException exception];

	(*type)++;
	(*length)--;


	if (size % alignment != 0) {
		size_t padding = alignment - (size % alignment);

		if (SIZE_MAX - size < padding)
			@throw [OFOutOfRangeException exception];

		size += padding;
	}


	return size;
}

size_t
sizeofUnion(const char **type, size_t *length)
{