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

  • SEARCH
  • Home
  • 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 have this question because I am not familiar latest generation of MS VS
For anyone familiar with lambdaj (not I) you will have seen this stacktrace, or
I have a DLL library, but I am not familiar with it. How can
I visited Avis.com, and I notice the web pages have *.ac extension. Not familiar
I have not used jquery much yet and not very familiar with it. Trying
I am not too familiar with python and have to write a script to
I have been using emacs for a while but not so familiar with lisp
I am not terribly familiar with either tech, so bear with me. I have
I have not used Twitter enough to become familiar with its terminology or the
I am already familiar with Silverlight programming but not have any experience with GIS.

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.