[Openmcl-devel] Using CFStrings in OpenMCL

Gary Byers gb at clozure.com
Fri Dec 17 15:35:58 PST 2004



On Fri, 17 Dec 2004, Dan Knapp wrote:

> > Is the above reasonable code, or am I making work for myself?  I went
> > to the trouble because I don't want memory leaks.
>
>    It's reasonable code, but there's an easier way.  See
>
> http://www.openmcl.com/Doc/re112.html
>
> -- Dan Knapp
>

The code that Dan mentions deals with NSSTRINGs (and may only be
available in the "bleeding edge" version of the Cocoa sources, where
it's quite likely defined in an obscure place ...)

NSSTRINGs and CFSTRINGs are pretty much interchangeable, but David
Steuber's (reasonable-looking) code will work in Carbon as well as
Cocoa.  (You might consider doing the #_CFRelease in an UNWIND-PROTECT
cleanup.)

It's also worth looking at what the CFSTR C macro expands into; it's
generally used to create a constant string (sort of like @"FOO" in
Objective-C, or #@"FOO" in the Cocoa bridge.)  A constant NSString
never gets released (its -release method is a no-op), and I assume
that that's true of constant CFStrings as well.  When trying to
translate C Carbon code to Lisp, that may be an important consideration.




More information about the Openmcl-devel mailing list