diff options
| author | Ellie Hermaszewska <ellieh@nvidia.com> | 2024-10-29 14:49:26 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-10-29 14:49:26 +0800 |
| commit | f65d756bff8d4c5cbc15bd0322a2ae8e6b896a21 (patch) | |
| tree | ea1d61342cd29368e19135000ec2948813096205 /source/slang-record-replay/replay/decoder-helper.cpp | |
| parent | a729c15e9dce9f5116a38afc66329ab2ca4cea54 (diff) | |
format
* format
* Minor test fixes
* enable checking cpp format in ci
Diffstat (limited to 'source/slang-record-replay/replay/decoder-helper.cpp')
| -rw-r--r-- | source/slang-record-replay/replay/decoder-helper.cpp | 91 |
1 files changed, 47 insertions, 44 deletions
diff --git a/source/slang-record-replay/replay/decoder-helper.cpp b/source/slang-record-replay/replay/decoder-helper.cpp index c9252bbc6..0c8240617 100644 --- a/source/slang-record-replay/replay/decoder-helper.cpp +++ b/source/slang-record-replay/replay/decoder-helper.cpp @@ -1,60 +1,63 @@ -#include <cstdlib> -#include <vector> #include "decoder-helper.h" + #include "parameter-decoder.h" +#include <cstdlib> +#include <vector> + namespace SlangRecord { - DecoderAllocatorSingleton* DecoderAllocatorSingleton::getInstance() - { - thread_local DecoderAllocatorSingleton instance; - return &instance; - } - - void* DecoderAllocatorSingleton::allocate(size_t size) - { - void* data = calloc(1, size); - - if (!data) - { - slangRecordLog(LogLevel::Error, "Failed to allocate memory\n"); - std::abort(); - } +DecoderAllocatorSingleton* DecoderAllocatorSingleton::getInstance() +{ + thread_local DecoderAllocatorSingleton instance; + return &instance; +} - m_allocations.add(data); - return data; - } +void* DecoderAllocatorSingleton::allocate(size_t size) +{ + void* data = calloc(1, size); - DecoderAllocatorSingleton::~DecoderAllocatorSingleton() + if (!data) { - for (auto allocation : m_allocations) - { - free(allocation); - } + slangRecordLog(LogLevel::Error, "Failed to allocate memory\n"); + std::abort(); } - template <typename T, typename U> - size_t StructDecoder<T, U>::decode(const uint8_t* buffer, int64_t bufferSize) + m_allocations.add(data); + return data; +} + +DecoderAllocatorSingleton::~DecoderAllocatorSingleton() +{ + for (auto allocation : m_allocations) { - return ParameterDecoder::decodeStruct(buffer, bufferSize, *this); + free(allocation); } +} - size_t BlobDecoder::decode(const uint8_t* buffer, int64_t bufferSize) +template<typename T, typename U> +size_t StructDecoder<T, U>::decode(const uint8_t* buffer, int64_t bufferSize) +{ + return ParameterDecoder::decodeStruct(buffer, bufferSize, *this); +} + +size_t BlobDecoder::decode(const uint8_t* buffer, int64_t bufferSize) +{ + size_t readByte = 0; + readByte = ParameterDecoder::decodeAddress(buffer, bufferSize, m_address); + + if (!m_address) { - size_t readByte = 0; - readByte = ParameterDecoder::decodeAddress(buffer, bufferSize, m_address); - - if (!m_address) - { - readByte += ParameterDecoder::decodePointer(buffer + readByte, bufferSize - readByte, m_blobData); - } - return readByte; + readByte += + ParameterDecoder::decodePointer(buffer + readByte, bufferSize - readByte, m_blobData); } - - template class StructDecoder<slang::SessionDesc>; - template class StructDecoder<slang::PreprocessorMacroDesc>; - template class StructDecoder<slang::CompilerOptionEntry>; - template class StructDecoder<slang::CompilerOptionValue>; - template class StructDecoder<slang::TargetDesc>; - template class StructDecoder<slang::SpecializationArg>; + return readByte; } + +template class StructDecoder<slang::SessionDesc>; +template class StructDecoder<slang::PreprocessorMacroDesc>; +template class StructDecoder<slang::CompilerOptionEntry>; +template class StructDecoder<slang::CompilerOptionValue>; +template class StructDecoder<slang::TargetDesc>; +template class StructDecoder<slang::SpecializationArg>; +} // namespace SlangRecord |
