• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSString array to -> char**
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Follow-Ups:
    • Re: NSString array to -> char**
      • From: Chris Ridd <email@hidden>
  • Prev by Date: Re: Finding an App by file id?
  • Next by Date: Re: Finding an App by file id?
  • Previous by thread: Re: NSString array to -> char**
  • Next by thread: Re: NSString array to -> char**
  • Index(es):
    • Date
    • Thread