destroying/deleting buffers at exit

I'm experimenting with OpenAL and SDL. In OpenAL, you create buffers and Sources, and there is a function to delete them. This might be a stupid question.

When you exit, should you first delete your buffers and sources, or do you only need to delete them when you want to free up memory within your program?

As far as I know so far, SDL_Quit(), is all you need to do at exit for SDL.

I'm new to programming, and thought I could have a function to call when I want to exit. And in that function, I would delete my sources and buffers, quit SDL, and then return 0;. The problem is my variables are declared and initialized in the main function, and when I try and do something to them in the exit function, the compiler says they're undeclared.

Is there a way that I can make this work, or do you think I am approaching this wrong?
Last edited on
When you exit, should you first delete your buffers and sources, or do you only need to delete them when you want to free up memory within your program?


"It depends". Whether or not internally allocated resources are freed automatically on program exit can depend on the OS. You probably don't have to manually clean up, but it certainly doesn't hurt to do so.

when I try and do something to them in the exit function, the compiler says they're undeclared.


Either pass the variables as a parameter to the exit function, or give the variables a larger scope so they exist outside of main.
Topic archived. No new replies allowed.