add sdl_deleter.h for RAII SDL resources
This commit is contained in:
26
src/app/core/utils/sdl_deleter.h
Normal file
26
src/app/core/utils/sdl_deleter.h
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
#ifndef YAZE_APP_CORE_UTILS_SDL_DELETER_H_
|
||||||
|
#define YAZE_APP_CORE_UTILS_SDL_DELETER_H_
|
||||||
|
|
||||||
|
namespace yaze {
|
||||||
|
namespace app {
|
||||||
|
namespace core {
|
||||||
|
|
||||||
|
struct sdl_deleter {
|
||||||
|
void operator()(SDL_Window *p) const {
|
||||||
|
if (p) {
|
||||||
|
SDL_DestroyWindow(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void operator()(SDL_Renderer *p) const {
|
||||||
|
if (p) {
|
||||||
|
SDL_DestroyRenderer(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void operator()(SDL_Texture *p) const { SDL_DestroyTexture(p); }
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace core
|
||||||
|
} // namespace app
|
||||||
|
} // namespace yaze
|
||||||
|
|
||||||
|
#endif // YAZE_APP_CORE_UTILS_SDL_DELETER_H_
|
||||||
@@ -5,10 +5,6 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
#include "absl/status/status.h"
|
|
||||||
#include "absl/strings/str_format.h"
|
|
||||||
#include "imgui/imgui.h"
|
|
||||||
#include "imgui_memory_editor.h"
|
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
@@ -25,25 +21,14 @@
|
|||||||
#include "absl/status/status.h"
|
#include "absl/status/status.h"
|
||||||
#include "absl/status/statusor.h"
|
#include "absl/status/statusor.h"
|
||||||
#include "absl/strings/str_format.h"
|
#include "absl/strings/str_format.h"
|
||||||
|
#include "app/core/utils/sdl_deleter.h"
|
||||||
#include "app/emu/snes.h"
|
#include "app/emu/snes.h"
|
||||||
#include "app/rom.h"
|
#include "app/rom.h"
|
||||||
|
#include "imgui/imgui.h"
|
||||||
|
#include "imgui_memory_editor.h"
|
||||||
|
|
||||||
using namespace yaze::app;
|
using namespace yaze::app;
|
||||||
|
|
||||||
struct sdl_deleter {
|
|
||||||
void operator()(SDL_Window *p) const {
|
|
||||||
if (p) {
|
|
||||||
SDL_DestroyWindow(p);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void operator()(SDL_Renderer *p) const {
|
|
||||||
if (p) {
|
|
||||||
SDL_DestroyRenderer(p);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void operator()(SDL_Texture *p) const { SDL_DestroyTexture(p); }
|
|
||||||
};
|
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
absl::InitializeSymbolizer(argv[0]);
|
absl::InitializeSymbolizer(argv[0]);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user