• 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: UInt8 > NSString
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: UInt8 > NSString


  • Subject: Re: UInt8 > NSString
  • From: "Clark Cox" <email@hidden>
  • Date: Mon, 5 Mar 2007 16:52:43 -0800

On 3/5/07, arri <email@hidden> wrote:
On Mar 5, 2007, at 21:22 31, Bob Smith wrote:

> The suggestion from others to return an NSString * instead is the
> better solution.  But just so you know, the problem here is a basic
> C memory management error.  Your function is returning an automatic
> variable, which becomes undefined out of scope of the function.
> What you need to do is change:
>
> char addr[12]
>
> to
>
> static char addr[12]
>
> and it would work.

i guess that that is why i was getting getting this --function
returns address of local variable-- warning?

> However this is not thread-safe since the same static space would
> be used in any thread calling the function.
> Hope this helps!

yes, it helps:) as i wrote, i implemented the main-function as an obj-
c method
of the class that was calling the function. this methods then calls
the statically declared functions
and creates an NSString from the returned bytes. seems perfectly
threadsafe.

It isn't. In fact, it is pretty much the textbook example of non-threadsafe code.

--
Clark S. Cox III
email@hidden
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >shortcut for selecting in NSPopUpButton (From: email@hidden)
 >UInt8 > NSString (From: arri <email@hidden>)
 >Re: UInt8 > NSString (From: Bob Smith <email@hidden>)
 >Re: UInt8 > NSString (From: arri <email@hidden>)

  • Prev by Date: Question about Cocoa-Java Application
  • Next by Date: Cocoa windows in carbon App
  • Previous by thread: Re: UInt8 > NSString
  • Next by thread: Re: UInt8 > NSString
  • Index(es):
    • Date
    • Thread