Clean previously created data when exiting in init_SDL()
This commit is contained in:
parent
3b0b343337
commit
53446c190b
10
src/main.c
10
src/main.c
@ -110,17 +110,23 @@ init_SDL(const char* path)
|
|||||||
|
|
||||||
if (!w) {
|
if (!w) {
|
||||||
fputs("ERROR: Failed to create a window\n", stderr);
|
fputs("ERROR: Failed to create a window\n", stderr);
|
||||||
|
SDL_Quit();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
s = SDL_GetWindowSurface(w);
|
s = SDL_GetWindowSurface(w);
|
||||||
if (!s) {
|
if (!s) {
|
||||||
fputs("ERROR: Failed to get window's surface\n", stderr);
|
fputs("ERROR: Failed to get window's surface\n", stderr);
|
||||||
|
SDL_DestroyWindow(w);
|
||||||
|
SDL_Quit();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 1, 1024)) {
|
if (Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 1, 1024)) {
|
||||||
fputs("ERROR: Failed to open audio\n", stderr);
|
fputs("ERROR: Failed to open audio\n", stderr);
|
||||||
|
SDL_FreeSurface(s);
|
||||||
|
SDL_DestroyWindow(w);
|
||||||
|
SDL_Quit();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,6 +136,10 @@ init_SDL(const char* path)
|
|||||||
buzzer = Mix_LoadWAV("resources/buzzer.wav");
|
buzzer = Mix_LoadWAV("resources/buzzer.wav");
|
||||||
if (!buzzer) {
|
if (!buzzer) {
|
||||||
fputs("ERROR: Failed to load sound effects\n", stderr);
|
fputs("ERROR: Failed to load sound effects\n", stderr);
|
||||||
|
Mix_Quit();
|
||||||
|
SDL_FreeSurface(s);
|
||||||
|
SDL_DestroyWindow(w);
|
||||||
|
SDL_Quit();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user