Skip to content

Commit

Permalink
Use tesseract::Serialize, tesseract::DeSerialize
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Weil <sw@weilnetz.de>
  • Loading branch information
stweil committed Jul 18, 2018
1 parent 16832f9 commit bdd2a7a
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/api/pdfrenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,7 @@ bool TessPDFRenderer::BeginDocumentHandler() {
}
fseek(fp, 0, SEEK_SET);
const std::unique_ptr<char[]> buffer(new char[size]);
if (fread(buffer.get(), 1, size, fp) != static_cast<size_t>(size)) {
if (!tesseract::DeSerialize(fp, buffer.get(), size)) {
fclose(fp);
return false;
}
Expand Down
3 changes: 1 addition & 2 deletions src/api/renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,7 @@ void TessResultRenderer::AppendString(const char* s) {
}

void TessResultRenderer::AppendData(const char* s, int len) {
int n = fwrite(s, 1, len, fout_);
if (n != len) happy_ = false;
if (!tesseract::Serialize(fout_, s, len)) happy_ = false;
}

bool TessResultRenderer::BeginDocumentHandler() {
Expand Down
3 changes: 1 addition & 2 deletions src/classify/blobclass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,8 @@ bool Classify::WriteTRFile(const STRING& filename) {
STRING tr_filename = filename + ".tr";
FILE* fp = fopen(tr_filename.string(), "wb");
if (fp) {
const size_t len = tr_file_data_.length();
result =
fwrite(&tr_file_data_[0], sizeof(tr_file_data_[0]), len, fp) == len;
tesseract::Serialize(fp, &tr_file_data_[0], tr_file_data_.length());
fclose(fp);
}
tr_file_data_.truncate_at(0);
Expand Down

0 comments on commit bdd2a7a

Please sign in to comment.