Is it a bad idea to invoke "init..." over and over on the same object?
Is it a bad idea to invoke "init..." over and over on the same object?
- Subject: Is it a bad idea to invoke "init..." over and over on the same object?
- From: Andrei Tchijov <email@hidden>
- Date: Wed, 2 Nov 2005 09:57:13 -0500
What I am trying to achieve is to have NSData object which wraps IO
buffer. For example:
...
int bigIoBufferSize = xxx;
char* bigIoBuffer = (char*) malloc( bigIoBufferSize );
NSData* ioData = [ NSData alloc ];
...
- (NSData*) readData {
...
read data into bigIoBuffer
save number of bytes read in bytesRead
...
return [ ioData initWithBytesNoCopy: bigIoBuffer length: bytesRead ];
}
...
- (void) copyData {
NSData* dataIn = [ self readData ];
[ self writeData: dataIn ];
}
...
So questions are:
1) Is it legal to do initWithBytesNoCopy:length: more then once on
the same object?
2) If it is, will NSData just forget about "current" bytes and
change internal pointers to point to new one or will it try to free it?
You comments are greatly appreciated,
Andrei Tchijov
Leaping Bytes, LLC
web: www.leapingbytes.com
email: email@hidden
AIM: leapingbytes
Google: email@hidden
ICQ: 151229319
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden