RAII: *::GetTSVText()

This commit is contained in:
Raf Schietekat 2017-05-10 13:03:07 +02:00
parent a1fff874b4
commit b7b68a65dd
3 changed files with 4 additions and 3 deletions

View File

@ -1577,6 +1577,7 @@ char* TessBaseAPI::GetHOCRText(ETEXT_DESC* monitor, int page_number) {
/**
* Make a TSV-formatted string from the internal data structures.
* page_number is 0-based but will appear in the output as 1-based.
* Returned string must be freed with the delete [] operator.
*/
char* TessBaseAPI::GetTSVText(int page_number) {
if (tesseract_ == NULL || (page_res_ == NULL && Recognize(NULL) < 0))

View File

@ -606,6 +606,7 @@ class TESS_API TessBaseAPI {
/**
* Make a TSV-formatted string from the internal data structures.
* page_number is 0-based but will appear in the output as 1-based.
* Returned string must be freed with the delete [] operator.
*/
char* GetTSVText(int page_number);

View File

@ -218,11 +218,10 @@ bool TessTsvRenderer::BeginDocumentHandler() {
bool TessTsvRenderer::EndDocumentHandler() { return true; }
bool TessTsvRenderer::AddImageHandler(TessBaseAPI* api) {
char* tsv = api->GetTSVText(imagenum());
const std::unique_ptr<const char[]> tsv(api->GetTSVText(imagenum()));
if (tsv == NULL) return false;
AppendString(tsv);
delete[] tsv;
AppendString(tsv.get());
return true;
}