From patchwork Wed Dec 15 01:35:39 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: =?UTF-8?Q?libobjc:=20small=20bugfix=20in=20class=5FaddIvar()?= Date: Tue, 14 Dec 2010 15:35:39 -0000 From: Nicola Pero X-Patchwork-Id: 75598 Message-Id: <1292376939.152930973@192.168.2.228> To: "gcc-patches@gnu.org" This patch fixes a small bug in class_addIvar() which was ignoring the supplied instance variable size argument and would call objc_sizeof_type() to calculate it from the type argument. Committed to trunk. Thanks 2010-12-15 Nicola Pero * ivars.c (class_addIvar): Use the 'size' argument instead of trying to calculate it using objc_sizeof_type(). * objc/runtime.h (class_addIvar): Updated comments. Index: ChangeLog =================================================================== --- ChangeLog (revision 167835) +++ ChangeLog (working copy) @@ -1,5 +1,11 @@ 2010-12-15 Nicola Pero + * ivars.c (class_addIvar): Use the 'size' argument instead of + trying to calculate it using objc_sizeof_type(). + * objc/runtime.h (class_addIvar): Updated comments. + +2010-12-15 Nicola Pero + * sendmsg.c: Reindented some code and tidied up comments. No actual code changes. Index: ivars.c =================================================================== --- ivars.c (revision 167819) +++ ivars.c (working copy) @@ -296,7 +296,7 @@ class_addIvar (Class class_, const char * ivar_nam else ivar->ivar_offset = class_->instance_size - misalignment + alignment; - class_->instance_size = ivar->ivar_offset + objc_sizeof_type (ivar->ivar_type); + class_->instance_size = ivar->ivar_offset + size; } return YES; Index: objc/runtime.h =================================================================== --- objc/runtime.h (revision 167819) +++ objc/runtime.h (working copy) @@ -319,11 +319,10 @@ objc_EXPORT Ivar * class_copyIvarList (Class class instance variables to classes already registered with the runtime. 'size' is the size of the instance variable, 'alignment' the alignment, and 'type' the type encoding of the variable type. You - can use objc_sizeof_type() (or sizeof()), objc_alignof_type() (or - __alignof__()) and @encode() to determine the right 'size', - 'alignment' and 'type' for your instance variable. For example, to - add an instance variable name "my_variable" and of type 'id', you - can use: + can use sizeof(), __alignof__() and @encode() to determine the + right 'size', 'alignment' and 'type' for your instance variable. + For example, to add an instance variable name "my_variable" and of + type 'id', you can use: class_addIvar (class, "my_variable", sizeof (id), __alignof__ (id), @encode (id));