aboutsummaryrefslogtreecommitdiff
path: root/src/serialization.cpp
diff options
context:
space:
mode:
authorsfan5 <sfan5@live.de>2022-02-03 21:35:08 +0100
committersfan5 <sfan5@live.de>2022-05-12 11:36:50 +0200
commit25373ad294398b752ad0ef4a52a5585a0b957f0b (patch)
tree01a280c12329d4c811c565125c99734c471beb03 /src/serialization.cpp
parent26d0c0fd8d06fcb3d2cdf4efadfcf993772a8e87 (diff)
downloadminetest-25373ad294398b752ad0ef4a52a5585a0b957f0b.tar.gz
minetest-25373ad294398b752ad0ef4a52a5585a0b957f0b.tar.bz2
minetest-25373ad294398b752ad0ef4a52a5585a0b957f0b.zip
Remove awful Mingw32 workarounds
Instead a warning is triggered if an affected compiler is detected. closes #12022
Diffstat (limited to 'src/serialization.cpp')
-rw-r--r--src/serialization.cpp28
1 files changed, 2 insertions, 26 deletions
diff --git a/src/serialization.cpp b/src/serialization.cpp
index d4d7b5f6e..d3009bc83 100644
--- a/src/serialization.cpp
+++ b/src/serialization.cpp
@@ -208,30 +208,11 @@ struct ZSTD_Deleter {
}
};
-#if defined(__MINGW32__) && !defined(__MINGW64__)
-/*
- * This is exactly as dumb as it looks.
- * Yes, this is a memory leak. No, we don't have better solution right now.
- */
-template<typename T> class leaky_ptr
-{
- T *value;
-public:
- leaky_ptr(T *value) : value(value) {};
- T *get() { return value; }
-};
-#endif
-
void compressZstd(const u8 *data, size_t data_size, std::ostream &os, int level)
{
-#if defined(__MINGW32__) && !defined(__MINGW64__)
- // leaks one context per thread but doesn't crash :shrug:
- thread_local leaky_ptr<ZSTD_CStream> stream(ZSTD_createCStream());
-#else
// reusing the context is recommended for performance
- // it will destroyed when the thread ends
+ // it will be destroyed when the thread ends
thread_local std::unique_ptr<ZSTD_CStream, ZSTD_Deleter> stream(ZSTD_createCStream());
-#endif
ZSTD_initCStream(stream.get(), level);
@@ -276,14 +257,9 @@ void compressZstd(const std::string &data, std::ostream &os, int level)
void decompressZstd(std::istream &is, std::ostream &os)
{
-#if defined(__MINGW32__) && !defined(__MINGW64__)
- // leaks one context per thread but doesn't crash :shrug:
- thread_local leaky_ptr<ZSTD_DStream> stream(ZSTD_createDStream());
-#else
// reusing the context is recommended for performance
- // it will destroyed when the thread ends
+ // it will be destroyed when the thread ends
thread_local std::unique_ptr<ZSTD_DStream, ZSTD_Deleter> stream(ZSTD_createDStream());
-#endif
ZSTD_initDStream(stream.get());