Skip to content

Commit

Permalink
Removed some win32 symbols that weren't available with Clang
Browse files Browse the repository at this point in the history
  • Loading branch information
julianstorer committed Nov 2, 2024
1 parent 123d322 commit 2cfcc62
Showing 1 changed file with 29 additions and 31 deletions.
60 changes: 29 additions & 31 deletions containers/choc_Value.h
Original file line number Diff line number Diff line change
Expand Up @@ -2323,7 +2323,7 @@ inline std::string_view ValueView::getString() const
// from this function
if (stringDictionary == nullptr)
throwError ("No string dictionary supplied");

return stringDictionary->getStringForHandle (getStringHandle());
}

Expand Down Expand Up @@ -2430,43 +2430,41 @@ void ValueView::serialise (OutputStream& output) const
if (type.isVoid())
return;

auto dataSize = type.getValueDataSize();
check (dataSize > 0, "Invalid data size");

if (stringDictionary == nullptr || ! type.usesStrings())
{
output.write (data, dataSize);
return;
}

uint8_t* localCopy = nullptr;
auto dataSize = type.getValueDataSize();
check (dataSize > 0, "Invalid data size");

#if _MSC_VER
if (stringDictionary == nullptr || ! type.usesStrings())
{
output.write (data, dataSize);
return;
}

#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wlanguage-extension-token"
#endif
uint8_t* localCopy = nullptr;

__try
{
localCopy = (uint8_t*) _alloca (dataSize);
}
__except (GetExceptionCode() == STATUS_STACK_OVERFLOW)
{
throwError ("Stack overflow");
}
#if _MSC_VER
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wlanguage-extension-token"
#endif

#ifdef __clang__
#pragma clang diagnostic pop
#endif
__try
{
localCopy = (uint8_t*) _alloca (dataSize);
}
__except (1)
{
throwError ("Stack overflow");
}

#else
localCopy = (uint8_t*) alloca (dataSize);
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#else
localCopy = (uint8_t*) alloca (dataSize);
#endif

check (localCopy != nullptr, "Stack allocation failed");
std::memcpy (localCopy, data, dataSize);
check (localCopy != nullptr, "Stack allocation failed");
std::memcpy (localCopy, data, dataSize);

static constexpr uint32_t maxStrings = 128;
uint32_t numStrings = 0, stringDataSize = 0;
Expand Down

0 comments on commit 2cfcc62

Please sign in to comment.