Refactor node-addon C++ code. (#1768)

Use macros to delete pointers.
This commit is contained in:
Fangjun Kuang
2025-01-25 22:23:12 +08:00
committed by GitHub
parent 030aaa7bb9
commit 73c3695287
9 changed files with 64 additions and 243 deletions

View File

@@ -70,14 +70,8 @@ CreateSpeakerEmbeddingExtractorWrapper(const Napi::CallbackInfo &info) {
const SherpaOnnxSpeakerEmbeddingExtractor *extractor =
SherpaOnnxCreateSpeakerEmbeddingExtractor(&c);
#endif
if (c.model) {
delete[] c.model;
}
if (c.provider) {
delete[] c.provider;
}
SHERPA_ONNX_DELETE_C_STR(c.model);
SHERPA_ONNX_DELETE_C_STR(c.provider);
if (!extractor) {
Napi::TypeError::New(env, "Please check your config!")