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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T05:46:03+00:00 2026-06-02T05:46:03+00:00

(Note: I’m coding in Pascal) In the creator of a class TQuest , I

  • 0

(Note: I’m coding in Pascal)

In the creator of a class TQuest, I initialize some objects with a pSDL_Surface given as a parameter as follows :

quests.Add( CPopuQuest.create('Get money ! ','Get more than $10,000', IMG_LOAD(MONEY_ICON), 1000, 10) );
(The interesting part is IMG_LOAD(MONEY_ICON) with MONEY_ICON the path to an image.

When I end my program, I get an error at the destructor of this CPopuQuest object in this line:

if badge<>nil then SDL_FreeSurface(badge)

(badge is the attribute where the pSDL_Surface instantiated by IMG_LOAD(MONEY_ICON) is copied)

It works most of the time, but from time a time I still get an error when closing the program … If anyone can help 🙂 (as you can see I’m quite confused with how IMG_LOAD works, what it returns, and how memory is allocated when its called).

  • 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-06-02T05:46:04+00:00Added an answer on June 2, 2026 at 5:46 am

    Anything that IMG_Load returns will be safe to pass to SDL_FreeSurface, even if it returns a null pointer. (Thus, you don’t need to check badge <> nil before calling SDL_FreeSurface(badge).)

    If your program crashes when you call SDL_FreeSurface, then it’s due to other problems in your program. That function is the correct way to free anything that IMG_Load loads. Everything shown in this question is right.

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

Sidebar

Related Questions

Note my wordpress version is 3.3.1 some hooks and function is not the same
Note : Although in some similar cases BackgroundWorker is recommended I prefer to do
NOTE: I have updated this since originally asking the question to reflect some of
Note The question below was asked in 2008 about some code from 2003. As
NOTE : UPDATED MY QUESTION Some times, we have to overwrite the css file
Note: I am mixing some C & C++ but it shouldn't be too confusing.
Note: this was inspired by WebBrowser Event Properties? Why am I able to access
NOTE: I added my new solution at the UPDATE answer below. I try to
Note: Although my particular context is Objective-C, my question actually transcends programming language choice.
Note this question was originally posted in 2009, before C++11 was ratified and before

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.