Skip to content
Open
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
14 changes: 8 additions & 6 deletions blingfiretools/blingfiretokdll/blingfiretokdll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

#include "blingfiretokdll.h"

#include <memory>

/*
This library provides easy interface to sentence and word-breaking functionality
which can be used in C#, Python, Perl, etc.
Expand Down Expand Up @@ -1055,8 +1057,8 @@ void* SetModelData(FAModelData * pNewModelData, const unsigned char * pImgBytes)
extern "C"
void* SetModel(const unsigned char * pImgBytes, int ModelByteCount)
{
FAModelData * pNewModelData = new FAModelData();
if (NULL == pNewModelData) {
std::unique_ptr<FAModelData> pNewModelData(new FAModelData());
if (NULL == pNewModelData.get()) {
return 0;
}

Expand All @@ -1066,7 +1068,7 @@ void* SetModel(const unsigned char * pImgBytes, int ModelByteCount)
}

// return the initialized model handle
return SetModelData(pNewModelData, pImgBytes);
return SetModelData(pNewModelData.release(), pImgBytes);
}


Expand All @@ -1077,8 +1079,8 @@ void* SetModel(const unsigned char * pImgBytes, int ModelByteCount)
extern "C"
void* LoadModel(const char * pszLdbFileName)
{
FAModelData * pNewModelData = new FAModelData();
if (NULL == pNewModelData) {
std::unique_ptr<FAModelData> pNewModelData(new FAModelData());
if (NULL == pNewModelData.get()) {
return 0;
}

Expand All @@ -1090,7 +1092,7 @@ void* LoadModel(const char * pszLdbFileName)
}

// return the initialized model handle
return SetModelData(pNewModelData, pImgBytes);
return SetModelData(pNewModelData.release(), pImgBytes);
}


Expand Down