summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--compat/alloca.hpp10
-rw-r--r--loader/atlas.cpp7
-rw-r--r--loader/texture.cpp10
-rw-r--r--src/precomp.hpp1
-rw-r--r--userconfig-sthalik@Windows-GNU.cmake1
5 files changed, 9 insertions, 20 deletions
diff --git a/compat/alloca.hpp b/compat/alloca.hpp
deleted file mode 100644
index ac4b6996..00000000
--- a/compat/alloca.hpp
+++ /dev/null
@@ -1,10 +0,0 @@
-#pragma once
-
-#ifdef _WIN32
-#include <malloc.h>
-#ifdef _MSC_VER
-#define alloca _alloca
-#endif
-#else
-#include <alloca.h>
-#endif
diff --git a/loader/atlas.cpp b/loader/atlas.cpp
index 9057746f..be8a2d23 100644
--- a/loader/atlas.cpp
+++ b/loader/atlas.cpp
@@ -4,6 +4,7 @@
#include "src/emplacer.hpp"
#include "src/tile-atlas.hpp"
#include "src/anim-atlas.hpp"
+#include <cstdio>
#include <algorithm>
#include <Corrade/Containers/ArrayViewStl.h>
#include <Corrade/Containers/Pair.h>
@@ -43,10 +44,10 @@ ArrayView<String> loader_impl::anim_atlas_list()
std::shared_ptr<anim_atlas> loader_impl::anim_atlas(StringView name, StringView dir) noexcept(false)
{
- constexpr std::size_t bufsiz = PATH_MAX;
- char path_buf[PATH_MAX];
+ fm_assert(dir && dir[dir.size()-1] == '/');
+ char path_buf[FILENAME_MAX];
name = Path::splitExtension(name).first();
- fm_assert(dir.size() + name.size() + 1 < bufsiz);
+ fm_assert(dir.size() + name.size() + 1 + 1 < FILENAME_MAX);
std::memcpy(path_buf, dir.data(), dir.size());
path_buf[dir.size()] = '/';
std::memcpy(&path_buf[dir.size() + 1], name.data(), name.size());
diff --git a/loader/texture.cpp b/loader/texture.cpp
index 6ffcc5d8..e14d0f34 100644
--- a/loader/texture.cpp
+++ b/loader/texture.cpp
@@ -2,8 +2,8 @@
#include "compat/assert.hpp"
#include "compat/exception.hpp"
#include "compat/defs.hpp"
-#include "compat/alloca.hpp"
#include <cstring>
+#include <cstdio>
#include <Corrade/Containers/StringStlView.h>
#include <Corrade/Utility/Path.h>
#include <Magnum/Trade/ImageData.h>
@@ -15,18 +15,18 @@ Trade::ImageData2D loader_impl::texture(StringView prefix, StringView filename_)
{
ensure_plugins();
+ constexpr std::size_t max_extension_length = 16;
const auto N = prefix.size();
if (N > 0)
fm_assert(prefix[N-1] == '/');
- fm_soft_assert(filename_.size() < 512);
+ fm_soft_assert(filename_.size() + prefix.size() + max_extension_length + 1 < FILENAME_MAX);
fm_soft_assert(check_atlas_name(filename_));
fm_soft_assert(tga_importer);
- constexpr std::size_t max_extension_length = 16;
- char* const filename = (char*)alloca(filename_.size() + N + 1 + max_extension_length);
+ char filename[FILENAME_MAX];
if (N > 0)
std::memcpy(filename, prefix.data(), N);
- std::memcpy(filename + N, filename_.cbegin(), filename_.size());
+ std::memcpy(filename + N, filename_.data(), filename_.size());
std::size_t len = filename_.size() + N;
for (const auto& extension : std::initializer_list<StringView>{ ".tga", ".png", ".webp", })
diff --git a/src/precomp.hpp b/src/precomp.hpp
index 75c4f191..0abb304a 100644
--- a/src/precomp.hpp
+++ b/src/precomp.hpp
@@ -2,7 +2,6 @@
#include "compat/defs.hpp"
#include "compat/assert.hpp"
-#include "compat/alloca.hpp"
#ifdef __GNUG__
#pragma GCC system_header
diff --git a/userconfig-sthalik@Windows-GNU.cmake b/userconfig-sthalik@Windows-GNU.cmake
index a4a3d01f..0eb0b974 100644
--- a/userconfig-sthalik@Windows-GNU.cmake
+++ b/userconfig-sthalik@Windows-GNU.cmake
@@ -73,7 +73,6 @@ function(fm-userconfig-src)
-Wno-error=unused-variable
-Wno-error=unused-function
-Wno-error=unused-macros
- #-Wno-error=alloca
-Wno-error=double-promotion
-Wno-error=restrict
-Wno-error=unused-but-set-variable