Fix warning c26409 (#14079)

We should avoid using `new` and `delete` in C/C++ code whenever possible
as suggested by VC compiler.
This commit is contained in:
Wei-Sheng Chin 2023-01-26 15:43:53 -08:00 committed by GitHub
parent de11527d76
commit 4ef64f3681
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -73,7 +73,7 @@ struct KernelTwo {
struct CustomOpOne : Ort::CustomOpBase<CustomOpOne, KernelOne> {
void* CreateKernel(const OrtApi& /* api */, const OrtKernelInfo* /* info */) const {
return new KernelOne();
return std::make_unique<KernelOne>().release();
};
const char* GetName() const { return "CustomOpOne"; };
@ -92,7 +92,7 @@ struct CustomOpOne : Ort::CustomOpBase<CustomOpOne, KernelOne> {
struct CustomOpTwo : Ort::CustomOpBase<CustomOpTwo, KernelTwo> {
void* CreateKernel(const OrtApi& /* api */, const OrtKernelInfo* /* info */) const {
return new KernelTwo();
return std::make_unique<CustomOpTwo>().release();
};
const char* GetName() const { return "CustomOpTwo"; };