ObjFW  Check-in [648d29a33e]

Overview
Comment:OFAllocObject: Fix calculation of extra alignment

While at it, also migrate to using OFRoundUpToPowerOf2, which is much
more readable.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 648d29a33e5498ff4797fc15f26b07f9c3350e087861b68ba7b51f6f636097cc
User & Date: js on 2023-11-04 14:43:59
Other Links: manifest | tags
Context
2023-11-05
10:20
Add +[OFSystemInfo supportsFusedMultiplyAdd] check-in: dfe5d16047 user: js tags: trunk
2023-11-04
14:44
OFAllocObject: Fix calculation of extra alignment check-in: 973574d1bd user: js tags: 1.0
14:43
OFAllocObject: Fix calculation of extra alignment check-in: 648d29a33e user: js tags: trunk
13:13
Make GCC happy again check-in: 998478014d user: js tags: trunk
Changes

Modified src/OFObject.m from [663f9433ab] to [399d8957d0].

332
333
334
335
336
337
338
339
340

341
342
343
344
345
346
347
{
	OFObject *instance;
	size_t instanceSize;

	instanceSize = class_getInstanceSize(class);

	if OF_UNLIKELY (extraAlignment > 1)
		extraAlignment = ((instanceSize + extraAlignment - 1) &
		    ~(extraAlignment - 1)) - extraAlignment;


	instance = calloc(1, PRE_IVARS_ALIGN + instanceSize +
	    extraAlignment + extraSize);

	if OF_UNLIKELY (instance == nil) {
		object_setClass((id)&allocFailedException,
		    [OFAllocFailedException class]);







|
|
>







332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
{
	OFObject *instance;
	size_t instanceSize;

	instanceSize = class_getInstanceSize(class);

	if OF_UNLIKELY (extraAlignment > 1)
		extraAlignment = OFRoundUpToPowerOf2(extraAlignment,
		    PRE_IVARS_ALIGN + instanceSize) -
		    PRE_IVARS_ALIGN - instanceSize;

	instance = calloc(1, PRE_IVARS_ALIGN + instanceSize +
	    extraAlignment + extraSize);

	if OF_UNLIKELY (instance == nil) {
		object_setClass((id)&allocFailedException,
		    [OFAllocFailedException class]);