Re: NSString array to -> char**
Re: NSString array to -> char**
- Subject: Re: NSString array to -> char**
- From: Seth Delackner <email@hidden>
- Date: Sat, 15 Mar 2003 21:02:13 -0800
On Saturday, March 15, 2003, at 08:48 PM, Randy Zauhar wrote:
Seth, you malloc a block of characters and set cargs[i] equal to the
pointer to the block, and then immediately overwrite cargs[i] with the
pointer returned by [arg cString]. Did you mean to do a strcpy?
Now that I think of it, I malloc some space, then instead of using that
space, use [arg cString]'s space, which is a big leak.
Could I just do
cargs[i] = (char*)[arg cString], and never bother to free cargs[i],
since [arg cString] is producing a (const char*)? I could later on
just free cargs, which is malloc'd as an array of pointers.
cargs[i] = (char*)malloc(sizeof(char) * [arg length] + 1);
cargs[i] = (char*)[arg cString];
_______________________________________________
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.