summaryrefslogtreecommitdiffhomepage
path: root/loader/atlas.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2023-03-18 21:18:37 +0100
committerStanislaw Halik <sthalik@misaki.pl>2023-03-18 21:18:37 +0100
commit98fb8aec8d1ba98342488096d1a2fcb3d58d9462 (patch)
tree7e787a230a5abf8a43e584c960a006cc2bedb5ff /loader/atlas.cpp
parent6aaa28ef62e0ebc2b4c2ced4d457c91d36e8a311 (diff)
loader: less alloca(3), more FILENAME_MAX
Diffstat (limited to 'loader/atlas.cpp')
-rw-r--r--loader/atlas.cpp7
1 files changed, 4 insertions, 3 deletions
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());