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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:51:50+00:00 2026-05-26T07:51:50+00:00

When using SDL_Surface s to handle images, I run into the problem that running

  • 0

When using SDL_Surfaces to handle images, I run into the problem that running SDL_FreeSurface(SDL_Surface *) (doc) twice on the same pointer yields a segmentation fault.

I understand why that happens, but I need to know how I can avoid that. I’d like to check the state of the pointer (find out if its pointing to an existing surface) and then Free the surface only if necessary.

How can I do that?

  • 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-26T07:51:50+00:00Added an answer on May 26, 2026 at 7:51 am

    You write a class that encapsulates an SDL_Surface pointer which frees the surface in it’s destructor. Also, make sure you properly implement or disable the copy constructor and the assignment operator. (see The rule of 3)Then, you never work directly with SDL_Surface pointers again.

    Here’s an example of a wrapper around SDL that I was working on a while ago.

    I stopped work once I learned about SFML.

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

Sidebar

Related Questions

I am using SDL for an OpenGL application, running on Linux. My problem is
I'm using SDL with FASM, and have code that's minimally like the following: format
I have a function which loads an image/text into my game.I'm using gluBuild2DMipmaps() to
I wrote a script that decodes aydio using FFmpeg. Here's the code: JNIEXPORT jint
I am playing around with some OpenGL, using SDL to handle the window /
I'm using Windows and I need the SDL Library to start using SDL with
My situation is Using .NET 3.5 Using SDL.NET Need to make a friendly installer
As I stated in this question , I am using SDL for a small
I'm using the SDL library to try to create a rendering context in a
I've created this basic 3D Demo using OpenGL/SDL. I handled the keyboard callback so

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.