NSCopyObject
NSCopyObject
- Subject: NSCopyObject
- From: Robert Lee Dotson <email@hidden>
- Date: Thu, 25 Apr 2002 12:08:13 -0400
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Okay, I'm back to implementing a deep copy for my matrix object, and I
have some questions about the Foundation functions NSAllocateObject(),
NSCopyObject(), and NSDeallocateObject().
Here's a quick version of my class:
@interface LCVMatrix : NSObject {
int rows,
columns;
float *values;
}
Where *values is an array of floats that is rows * columns long.
My question concerns the extrabytes input variables in the NS...()
methods. Should I implement +alloc: as
NSAllocateObject([LCVmatrix class], (sizeof(float) * (rows * columns)),
NULL);? or do I also need to add memory for the two ints as well? I'm
not sure if NSAllocateObject malloc's memory for pointers only, or if it
also allocates memory for static variables as well.
And during my init method, should I:
*values = malloc(sizeof(float) * rows * columns);
or
*values = realloc(sizeof(float) * rows * columns);
And finally, If I want to perform a deep copy, can I use the vanilla
NSCopyObject() function, or do I need to pass the extrabytes variable
here as well?
- -- Robert Lee Dotson
"Make it idiot proof and someone will make a better idiot."
-----BEGIN PGP SIGNATURE-----
Comment: For info see
http://www.gnupg.org
iD8DBQE8yCnwnK/PA6kJIZsRAp86AKC0oJAeTAc7jCY9/HKvUxFzAQ6JZgCfWf4q
zeNKxFNARL8wG7Te5vf4Nao=
=FV5O
-----END PGP SIGNATURE-----
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.