diff --git a/containers/choc_Value.h b/containers/choc_Value.h index d334849..db4c6f3 100644 --- a/containers/choc_Value.h +++ b/containers/choc_Value.h @@ -2319,7 +2319,11 @@ inline StringDictionary::Handle ValueView::getStringHandle() const inline std::string_view ValueView::getString() const { - check (stringDictionary != nullptr, "No string dictionary supplied"); + // To satisfy the MSVC code analyser this check needs to be handled directly + // from this function + if (stringDictionary == nullptr) + throwError ("No string dictionary supplied"); + return stringDictionary->getStringForHandle (getStringHandle()); } @@ -2426,21 +2430,32 @@ void ValueView::serialise (OutputStream& output) const if (type.isVoid()) return; - auto dataSize = type.getValueDataSize(); - - if (stringDictionary == nullptr || ! type.usesStrings()) - { - output.write (data, dataSize); - return; - } - - static constexpr uint32_t maximumSize = 16384; - - if (dataSize > maximumSize) - throwError ("Out of local scratch space"); - - uint8_t localCopy[maximumSize]; - std::memcpy (localCopy, data, dataSize); + auto dataSize = type.getValueDataSize(); + check (dataSize > 0, "Invalid data size"); + + if (stringDictionary == nullptr || ! type.usesStrings()) + { + output.write (data, dataSize); + return; + } + + uint8_t* localCopy = nullptr; + + #if _MSC_VER + __try + { + localCopy = (uint8_t*) _alloca (dataSize); + } + __except (GetExceptionCode() == STATUS_STACK_OVERFLOW) + { + throwError ("Stack overflow"); + } + #else + localCopy = (uint8_t*) alloca (dataSize); + #endif + + check (localCopy != nullptr, "Stack allocation failed"); + std::memcpy (localCopy, data, dataSize); static constexpr uint32_t maxStrings = 128; uint32_t numStrings = 0, stringDataSize = 0; diff --git a/javascript/choc_javascript_QuickJS.h b/javascript/choc_javascript_QuickJS.h index 3c49f78..9910123 100644 --- a/javascript/choc_javascript_QuickJS.h +++ b/javascript/choc_javascript_QuickJS.h @@ -219,18 +219,6 @@ static inline int clz32(unsigned int a) #endif } -/* WARNING: undefined if a = 0 */ -static inline int clz64(uint64_t a) -{ - #if _MSC_VER - unsigned long i; - _BitScanReverse64 (&i, a); - return 63 ^ i; - #else - return __builtin_clzll(a); - #endif -} - /* WARNING: undefined if a = 0 */ static inline int ctz32(unsigned int a) { @@ -243,18 +231,6 @@ static inline int ctz32(unsigned int a) #endif } -/* WARNING: undefined if a = 0 */ -static inline int ctz64(uint64_t a) -{ - #if _MSC_VER - unsigned long i; - _BitScanForward64 (&i, a); - return 63 ^ i; - #else - return __builtin_ctzll(a); - #endif -} - static inline uint64_t get_u64(const uint8_t *tab) { uint64_t v; diff --git a/platform/choc_DisableAllWarnings.h b/platform/choc_DisableAllWarnings.h index 1c7dba1..c9c26e0 100644 --- a/platform/choc_DisableAllWarnings.h +++ b/platform/choc_DisableAllWarnings.h @@ -73,6 +73,8 @@ #pragma GCC diagnostic ignored "-Wuse-after-free" #pragma GCC diagnostic ignored "-Warray-bounds" #pragma GCC diagnostic ignored "-Wvolatile" + #pragma GCC diagnostic ignored "-Wmissing-field-initializers" + #pragma GCC diagnostic ignored "-Wfloat-equal" #ifndef __MINGW32__ #pragma GCC diagnostic ignored "-Wredundant-move" #endif diff --git a/platform/choc_ObjectiveCHelpers.h b/platform/choc_ObjectiveCHelpers.h index 11e870d..f37b5bd 100644 --- a/platform/choc_ObjectiveCHelpers.h +++ b/platform/choc_ObjectiveCHelpers.h @@ -19,7 +19,7 @@ #ifndef CHOC_OBJC_HELPERS_HEADER_INCLUDED #define CHOC_OBJC_HELPERS_HEADER_INCLUDED -#include "../platform/choc_Platform.h" +#include "choc_Platform.h" #if CHOC_APPLE @@ -28,7 +28,7 @@ #include #include -#include "../platform/choc_Assert.h" +#include "choc_Assert.h" //==============================================================================