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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T08:27:30+00:00 2026-05-30T08:27:30+00:00

I use SDL_Surface pointers, and I’m wondering if this: SDL_Surface* Images[8][7]; where some of

  • 0

I use SDL_Surface pointers, and I’m wondering if this:

SDL_Surface* Images[8][7];

where some of the individual surface pointers are initialized to NULL in its class constructor and then never used, will take up more memory than if those were kept separate. As you can imagine, using an enumeration would make accessing these surface pointers easier and require no if or switch statements. For example, Images[0][3] to Images[0][7] may all be NULL, NULL, etc. Thanks in advance for replies!

Edit: “kept separate” meaning have a pointer variable name and a smaller array to avoid having NULL as a value for some of the images of which there are less than 7.

Addendum: Thanks everyone for the lightning replies, it’s clear to me now; I’ll go forward with my 2-dimensional array and there will be other arrays as well for other image groups.

  • 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-30T08:27:31+00:00Added an answer on May 30, 2026 at 8:27 am

    Whether you declare your pointers in an array, or individually, one by one, the same amount of memory will be consumed. Of course, if you can declare fewer pointers by declaring them individually, then less space will be consumed.

    So the following two lines both reserve space for 3 pointers:

    SDL_Surface* surfaces[3];
    SDL_Surface *surface1, *surface2, *surface3;
    

    Given the small number of pointers involved in your code sample, you should opt for the approach that results in the most readable code. Only if your array was huge and had only a small proportion of pointers non-null would it be worth getting concerned about the overhead of the unused pointers in the array.

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

Sidebar

Related Questions

I want to use XmCreate{Error|Warning|Info}Dialog to display some message in screen in my SDL
I wrote this function that I want to use in a program, but for
I use threads in C as follows: pthread_t thread; if (pthread_create (& thread, NULL,
I'm trying to use SDL in C++ with Visual Studio 2008 Express. The following
When I try to use SDL in my c++ program, I get the following:
I'm trying to learn to use SDL for a little game I'm writing ,
I'm trying to use the SDL_Image library and I've added the .so to the
'''use Jython''' import shutil print dir(shutil) There is no, shutil.move, how does one move
Use case: A does something on his box and gots stuck. He asks B
Use case: 3rd party application wants to programatically monitor a text file being generated

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.