#include #include #include "util.h" #include "WeaponObject.h" #include "ArmorObject.h" template <> void safe_free(void ** ptr) { if (*ptr == nullptr) return; free(*ptr); *ptr = nullptr; } template <> void safe_free(const char ** ptr) { // wow c++ casts so readable auto a = const_cast(ptr); auto b = static_cast(a); auto c = reinterpret_cast(b); safe_free(c); } template <> void safe_free(WeaponObject ** ptr) { delete *ptr; *ptr = nullptr; } template <> void safe_free(ArmorObject ** ptr) { delete *ptr; *ptr = nullptr; } template void safe_free(T ** ptr) { auto a = static_cast(ptr); auto b = reinterpret_cast(ptr); safe_free(b); } template void safe_free(char **); template void safe_free(FILE **);