Skip to content

Commit 38f14b9

Browse files
committed
Fix mismatched-new-delete warning in compression.hpp
1 parent 864038a commit 38f14b9

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

sycl/source/detail/compression.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class ZSTDCompressor {
4141
public:
4242
// Blob (de)compression do not assume format/structure of the input buffer.
4343
// This function can be used in future for compression in on-disk cache.
44-
static std::unique_ptr<char> CompressBlob(const char *src, size_t srcSize,
44+
static std::unique_ptr<char[]> CompressBlob(const char *src, size_t srcSize,
4545
size_t &dstSize, int level) {
4646
auto &instance = GetSingletonInstance();
4747

@@ -61,7 +61,7 @@ class ZSTDCompressor {
6161

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

6666
if (!dstBuffer)
6767
throw sycl::exception(sycl::make_error_code(sycl::errc::runtime),
@@ -79,7 +79,7 @@ class ZSTDCompressor {
7979
ZSTD_getErrorName(dstSize));
8080

8181
// Pass ownership of the buffer to the caller.
82-
return dstBuffer;
82+
return std::move(dstBuffer);
8383
}
8484

8585
static size_t GetDecompressedSize(const char *src, size_t srcSize) {
@@ -93,7 +93,7 @@ class ZSTDCompressor {
9393
return dstBufferSize;
9494
}
9595

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

@@ -116,7 +116,7 @@ class ZSTDCompressor {
116116
auto dstBufferSize = GetDecompressedSize(src, srcSize);
117117

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

121121
if (!dstBuffer)
122122
throw sycl::exception(sycl::make_error_code(sycl::errc::runtime),
@@ -135,7 +135,7 @@ class ZSTDCompressor {
135135
}
136136

137137
// Pass ownership of the buffer to the caller.
138-
return dstBuffer;
138+
return std::move(dstBuffer);
139139
}
140140

141141
// Data fields

sycl/source/detail/device_binary_image.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ class CompressedRTDeviceBinaryImage : public RTDeviceBinaryImage {
306306
}
307307

308308
private:
309-
std::unique_ptr<char> m_DecompressedData;
309+
std::unique_ptr<char[]> m_DecompressedData;
310310
size_t m_ImageSize;
311311
};
312312
#endif // SYCL_RT_ZSTD_NOT_AVAIABLE

0 commit comments

Comments
 (0)