RAII: *::GetUNLVText()

This commit is contained in:
Raf Schietekat 2017-05-10 13:13:02 +02:00
parent 1dab23916f
commit 8aa0a2dd48
3 changed files with 6 additions and 7 deletions

View File

@ -1757,8 +1757,8 @@ const int kLatinChs[] = {
/**
* The recognized text is returned as a char* which is coded
* as UNLV format Latin-1 with specific reject and suspect codes
* and must be freed with the delete [] operator.
* as UNLV format Latin-1 with specific reject and suspect codes.
* Returned string must be freed with the delete [] operator.
*/
char* TessBaseAPI::GetUNLVText() {
if (tesseract_ == NULL ||

View File

@ -621,8 +621,8 @@ class TESS_API TessBaseAPI {
/**
* The recognized text is returned as a char* which is coded
* as UNLV format Latin-1 with specific reject and suspect codes
* and must be freed with the delete [] operator.
* as UNLV format Latin-1 with specific reject and suspect codes.
* Returned string must be freed with the delete [] operator.
*/
char* GetUNLVText();

View File

@ -234,11 +234,10 @@ TessUnlvRenderer::TessUnlvRenderer(const char *outputbase)
}
bool TessUnlvRenderer::AddImageHandler(TessBaseAPI* api) {
char* unlv = api->GetUNLVText();
const std::unique_ptr<const char[]> unlv(api->GetUNLVText());
if (unlv == NULL) return false;
AppendString(unlv);
delete[] unlv;
AppendString(unlv.get());
return true;
}