• 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: CF Types and AU
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CF Types and AU


  • Subject: Re: CF Types and AU
  • From: Pete Gontier <email@hidden>
  • Date: Tue, 5 Aug 2003 13:44:32 -0700

On Tuesday, Aug 5, 2003, at 01:14 US/Pacific, Bill Stewart wrote:

... (this new API) goes against the principles of CoreFoundation reference counting... [goes on to mention incorrect stuff about how CF works like Cocoa]

Core Foundation ... has no concept of auto-releasing pools, or any of the other abstractions of Cocoa's object model ...

I know next to nothing about AU, but I do know CF pretty well.

In CF, the result of a Copy or Create function must be (explicitly) released and the result of a Get function must not. (This is all quite independent of Cocoa except from the perspective of historical influence.) There are exceptions, but they are considered bugs.

I would predict that given a function whose name includes "Get" and which traffics in CF types, failure of that function to conform to the CF model will confuse clients. Requiring a call to CFRelease will produce leaks in client code.

Note that I haven't said anything about AU. And I don't intend to. I (sometimes) know better than to spout off about an API I don't know. Instead, I will write out a little story and let AU gurus decide whether it applies in this situation.

I once had a function whose name contained the word Get, took as a parameter a key describing the information to get, and produced a CF type. At some point in the program's evolution, I wanted the function to produce a value which would subsequently require release. I didn't want every call site to have to know whether to release the result on a key-by-key and/or circumstance-by-circumstance basis. For some keys under some circumstances, I had the function call CFRetain before returning the result. Then I changed the name of the function from Get to Copy, allowed the compiler to find all the call sites for me, and added calls to CFRelease as appropriate.

--

Pete Gontier
http://www.m-audio.com/
_______________________________________________
coreaudio-api mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/coreaudio-api
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: CF Types and AU
      • From: Pete Gontier <email@hidden>
References: 
 >Re: CF Types and AU (From: Bill Stewart <email@hidden>)

  • Prev by Date: Revised CF Types and AU (fixed I think)
  • Next by Date: Re: CF Types and AU
  • Previous by thread: Re: CF Types and AU
  • Next by thread: Re: CF Types and AU
  • Index(es):
    • Date
    • Thread