@@ -1,7 +1,7 @@ /* - * Copyright (c) 2008-2023 Jonathan Schleifer + * Copyright (c) 2008-2024 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -334,12 +334,13 @@ size_t instanceSize; instanceSize = class_getInstanceSize(class); if OF_UNLIKELY (extraAlignment > 1) - extraAlignment = ((instanceSize + extraAlignment - 1) & - ~(extraAlignment - 1)) - extraAlignment; + 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) {