Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6880743
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:00:47+00:00 2026-05-27T05:00:47+00:00

I found an implementation of a priority queue that primarily uses CFBinaryHeap to work.

  • 0

I found an implementation of a priority queue that primarily uses CFBinaryHeap to work.

I’m currently using the -fno-objc-arc compiler flag to skip the usage of ARC while compiling these files. I attempted to update this code to take advantage of ARC, though I’ve run into a few snags of understanding.

Is there anyone here who has updated code similar to this for use with ARC?

How do you handle things like free(), and CFRelease()? Can we just get rid of them?

What do you do with the retain and release methods you create for CFBinaryHeapCallBacks?

Do you use __bride or __bridge_transfer to reference the const void * into Objective-C objects? Likewise should you use (__bridge_retained void *) or obj_unretainedPointer() to do the reverse?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T05:00:48+00:00Added an answer on May 27, 2026 at 5:00 am

    ARC basically is a compiler technology that automatically inserts calls to -retain, -release, and -autorelease as needed. It does not remove the need for retains and releases, it just makes them automatic (in the process, optimizing out many that are not required, and playing other tricks to make various common patterns much more efficient than if you did it by hand).

    ARC knows nothing about Core Foundation, nor about void* objects, malloc, free, or anything other than ObjC memory management.

    This means that as long as you use Core Foundation objects, you should continue to use CFRelease. And if you malloc memory, you should continue to free it.

    But…. what if you want to take memory that was created by Core Foundation and transfer it to Cocoa via a toll-free bridge? That’s where __bridge* comes in. One of the best sources of information is the clang docs themselves. A great blog article is Everything you need to know about ARC. It includes many useful links to the definitive information.

    But here’s the short answer (from Transitioning to ARC)

    NSString   *c = (__bridge_transfer NSString*)my_cfref; // -1 on the CFRef
    CFStringRef d = (__bridge_retained CFStringRef)my_id;  // returned CFRef is +1
    

    Using __bridge_transfer logically moves a CF object into Cocoa. Using __bridge_retained logically moves a Cocoa object into CF. You use these when you are really transferring ownership of the object. In the above example, you generally shouldn’t continue using the my_ variables in my opinion. These are particularly useful in cases where you are returning the result out of the function. These should be used for their logical ownership functionality only. Don’t use them as a way to “fake” a manual call to retain or release.

    If you just want to have a temporary “bridged” pointer to the object so you can use it in CF or Cocoa without transferring it, then use __bridge. That’s a no-op that says “don’t do any memory management, just let me pretend for the moment that it’s the other kind of object.” If you do a lot of toll-free bridging, you’ll wind up using __bridge quite a lot (making it seem like a small toll…. :D)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a priority queue implementation in C# that I want to add a
i'm using this example implementation found at http://tangentsoft.net/wskfaq/examples/basics/select-server.html This is doing most of what
It looks easy, but I found the implementation tricky. I need that for a
How can I multipy two integers using bitwise operators? I found an implementation here
The Priority Queue implementation in the Java standard library appears to be a min
I'm currently building an JavaScript project that uses NodeJS and some objects are shared
I've found that the implementation of the GetBytes function in .net framework is something
I was recently checking implementation of the j.u.c.CopyOnWriteArrayList in OpenJDK's sources and found that
I was looking at C# collection initializers and found the implementation to be very
Trying to get my mind around google protobuf. I found some implementation of protobuf

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.