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 977575
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T03:55:27+00:00 2026-05-16T03:55:27+00:00

I am not familiar with C. I have a method created by someone else

  • 0

I am not familiar with C. I have a method created by someone else that has a CFDicionary that was created like this

touchBeginPoints = CFDictionaryCreateMutable(NULL, 0, NULL, NULL);

point = (CGPoint *)malloc(sizeof(CGPoint));
CFDictionarySetValue(touchBeginPoints, touch, point);

I would like to dealloc the dictionary now. As far as I understand, I have to go item by item on whatever number of entries the dictionary has and free each one.

something like

        free((void *)CFDictionaryGetValue(touchBeginPoints, ...));
        CFDictionaryRemoveValue(touchBeginPoints, ...);

So, how do I iterate thru this CFDictionary freeing each point stored there and removing each dictionary entry?

thanks for any help.

  • 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-16T03:55:28+00:00Added an answer on May 16, 2026 at 3:55 am

    You don’t.

    You read this page: http://developer.apple.com/mac/library/documentation/CoreFoundation/Reference/CFDictionaryRef/Reference/reference.html#//apple_ref/doc/c_ref/CFDictionaryValueCallBacks

    You recognise that by default, the standard dictionary will call CFRetain() to hold on to the value you pass it, and CFRelease() to let go of it. You think “…but CFRetain() is not appropriate to be called against CGPoint”. You realise that all those people who told you to just release the dictionary will be leaking at best and crashing at worst.

    You then create a structure like this:

    CFDictionaryValueCallBacks myValueCallbacks = {
      0,
      NULL,
      myRelease,
      NULL,
      NULL
    };
    

    and pass that as the valueCallbacks argument when creating the dictionary (the last argument). The myRelease function should look like this:

    void myRelease ( CFAllocatorRef allocator, const void *value )
    {
        free(value);
    }
    

    Now, whenever the dictionary releases the values, it will call free() on them for you.

    Having said all that, if you’re a newcomer to C, this is not the place to start.

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

Sidebar

Related Questions

I am not familiar with this website but I am desperately seeking help with
I am not familiar with this, and can use a kick start. I am
I believe there is a way to do this, but I'm not familiar with
I'm not overly familiar with Tomcat, but my team has inherited a complex project
I am not as familiar with Oracle as I would like to be. I
I am not that familiar with Javascript, and am looking for the function that
For those of you not familiar with interpolation search, it is method to search
I'm wondering if this is possible. I have html like so: <p> <font face=Georgia>
So I have a model called Image that belongs_to :user. Each user has a
I'm not all that familiar with how garbage collection works and what causes memory

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.