Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: custom memory allocations



On Sep 30, 2005, at 1:09 AM, Niko Matsakis wrote:
1. Find out the size of the class object which received the message

Allocate ((Class)self)->instance_size bytes. In a class method like this, `self` is the class that received the message. You'll probably need to #include <objc/objc-runtime.h> to get the definition of struct objc_class.



2. Initialize the memory with whatever details ObjC needs to know what kind of object this is

Set newObject->isa = self; (i.e. the class being allocated). Zero out all other bytes belonging to newObject. That's all the runtime needs, and all other initialization is handled by whatever -init methods the class uses.



-- Greg Parker email@hidden Runtime Wrangler


_______________________________________________ Do not post admin requests to the list. They will be ignored. Objc-language mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/objc-language/email@hidden

This email sent to email@hidden
References: 
 >custom memory allocations (From: Niko Matsakis <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.