Riccardo Mottola a écrit :
(...)
David Chisnall wrote:
(...)
Yes, this appears to me the "least hurting" path. But I laready dislike.
If we really need, this should be the road.
If you make private ivars into a structure and make a pointer to this
an ivar, you add an extra malloc for every +alloc (expensive) and you
add an extra load for ever ivar access.
That is an abomination.
Another stupid question : the memory allocation function accepts an
'extraBytes' parameter. These bytes are allocated _after_ the instance
bytes by the same 'malloc' call. Couldn't this system be adapted to ivar
storage ? The extra storage is at self+1 : no need for an additional
pointer, and no extra load for ivar access.
@interface NSObject (ExtraMemory)
+ (id) allocWithZone: (NSZone*)zone extra: (size_t) extraBytes;
@end
---- Usage
typedef
struct _LibraryClass_ext_st
{
int ivar1;
int ivar2;
} _LibraryClass_ext;
#define LIBRARYCLASS_EXTRA(obj) ((_LibraryClass_ext*)((obj)+1)))
@implementation LibraryClass
- (id) allocWithZone: (NSZone*)z
{
return [self allocWithZone: z extra: sizeof(_LibraryClass_ext)];
}
- (int) var1
{
return LIBRARYCLASS_EXTRA(self)->ivar1;
}
@end
_______________________________________________
Gnustep-dev mailing list
Gnustep-dev@gnu.org
http://lists.gnu.org/mailman/listinfo/gnustep-dev