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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T05:31:17+00:00 2026-05-23T05:31:17+00:00

This is strange. In a technical Q & A , Apple says this: void

  • 0

This is strange. In a technical Q & A, Apple says this:

void *data = CGBitmapContextGetData (cgctx);
if (data != NULL)
{

    // **** You have a pointer to the image data ****

    // **** Do stuff with the data here ****

}

// When finished, release the context
CGContextRelease(cgctx); 
// Free image data memory for the context
if (data)
{
    free(data);
}

I looked up the documentation for CGBitmapContextGetData, and it does not mention that I am responsible for releasing the data when I call this. There is already the CGContextRelease call which cleans up the context.

What is the point of having to extra-release the data inside the context? It is just a pointer to that data, right? Why do they call free(data) here?

  • 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-23T05:31:17+00:00Added an answer on May 23, 2026 at 5:31 am

    Update: I neglected to read the entire code example. Apple allocates bitmapData in CreateARGBBitmapContext() but does not free it. Which is perfectly fine, since the context still needs to do draw into it.

    However, bitmapData will have to later be released when they’re done with the drawing, which is exactly what they do at the end of ManipulateImagePixelData(). So while it is unusual to release something that was obtained by a get function, it the sample code is correct.

    To avoid the confusion of freeing something that was returned from a get function, one might want to store the bitmap data in a global / instance variable and free() that when done.


    I would assume this to be a bug in the code example. The documentation of this function does not mention anything special, so there’s no reason why the Get Rule would not apply here. The Quartz 2D Documentation also specifically reiterates that the CoreFoundation memory management model applies to the Quartz 2D API.

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

Sidebar

Related Questions

I often find this strange CDATA tag in XML files: <![CDATA[some stuff]]> I have
I have this strange call stack and I am stumped to understand why. It
I have this strange issue with my web app. You see, I'm using jQuery
I've got this strange problem using py-amqp and the Flopsy module. I have written
I have this strange issue with some third party DLL's. The third party provider
I have somewhat of a strange question that is not really technical, but I
I have this really strange problem where my entity framework query isn't enumerating correctly.
I'm getting this strange error while processing a large number of data... Error Number:
I have this strange problem. I have this script: echo $comment_content = $_POST['comment_content']; echo
I'm having this strange issue with my ItemsControl grouping. I have the following setup:

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.