Skip to content

[SYCL] Fix mismatched-new-delete warning in compression.hpp #17607

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions sycl/source/detail/compression.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ class ZSTDCompressor {
public:
// Blob (de)compression do not assume format/structure of the input buffer.
// This function can be used in future for compression in on-disk cache.
static std::unique_ptr<char> CompressBlob(const char *src, size_t srcSize,
size_t &dstSize, int level) {
static std::unique_ptr<char[]> CompressBlob(const char *src, size_t srcSize,
size_t &dstSize, int level) {
auto &instance = GetSingletonInstance();

// Lazy initialize compression context.
Expand All @@ -61,7 +61,7 @@ class ZSTDCompressor {

// Get maximum size of the compressed buffer and allocate it.
auto dstBufferSize = ZSTD_compressBound(srcSize);
auto dstBuffer = std::unique_ptr<char>(new char[dstBufferSize]);
auto dstBuffer = std::make_unique<char[]>(dstBufferSize);

if (!dstBuffer)
throw sycl::exception(sycl::make_error_code(sycl::errc::runtime),
Expand Down Expand Up @@ -93,8 +93,8 @@ class ZSTDCompressor {
return dstBufferSize;
}

static std::unique_ptr<char> DecompressBlob(const char *src, size_t srcSize,
size_t &dstSize) {
static std::unique_ptr<char[]> DecompressBlob(const char *src, size_t srcSize,
size_t &dstSize) {
auto &instance = GetSingletonInstance();

// Lazy initialize decompression context.
Expand All @@ -116,7 +116,7 @@ class ZSTDCompressor {
auto dstBufferSize = GetDecompressedSize(src, srcSize);

// Allocate buffer for decompressed data.
auto dstBuffer = std::unique_ptr<char>(new char[dstBufferSize]);
auto dstBuffer = std::make_unique<char[]>(dstBufferSize);

if (!dstBuffer)
throw sycl::exception(sycl::make_error_code(sycl::errc::runtime),
Expand Down
2 changes: 1 addition & 1 deletion sycl/source/detail/device_binary_image.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ class CompressedRTDeviceBinaryImage : public RTDeviceBinaryImage {
}

private:
std::unique_ptr<char> m_DecompressedData;
std::unique_ptr<char[]> m_DecompressedData;
size_t m_ImageSize;
};
#endif // SYCL_RT_ZSTD_NOT_AVAIABLE
Expand Down
Loading