From 71dffd6eb30c1f4b5cf800307de845072ce33262 Mon Sep 17 00:00:00 2001 From: Carlos Fernandez Date: Mon, 23 Jan 2017 16:05:05 -0800 Subject: [PATCH] Use TessDeleteText to delete strings received from Tesseract --- src/lib_ccx/ocr.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lib_ccx/ocr.c b/src/lib_ccx/ocr.c index 5d38f006..ebd76194 100644 --- a/src/lib_ccx/ocr.c +++ b/src/lib_ccx/ocr.c @@ -434,7 +434,7 @@ char* ocr_bitmap(void* arg, png_color *palette,png_byte *alpha, unsigned char* i if(strstr(text_out,word)) { char *text_out_copy = strdup(text_out); - free(text_out); + TessDeleteText(text_out); text_out = malloc(strlen(text_out_copy)+strlen(substr)+1); memset(text_out,0,strlen(text_out_copy)+strlen(substr)+1); int pos = (int)(strstr(text_out_copy,word)-text_out_copy); @@ -448,7 +448,7 @@ char* ocr_bitmap(void* arg, png_color *palette,png_byte *alpha, unsigned char* i else if(!written_tag) { char *text_out_copy = strdup(text_out); - free(text_out); + TessDeleteText(text_out); text_out = malloc(strlen(text_out_copy)+strlen(substr)+1); memset(text_out,0,strlen(text_out_copy)+strlen(substr)+1); strcpy(text_out,substr); @@ -464,7 +464,7 @@ char* ocr_bitmap(void* arg, png_color *palette,png_byte *alpha, unsigned char* i freep(&histogram); freep(&mcit); freep(&iot); - + TessDeleteText(word); } while (TessPageIteratorNext((TessPageIterator *)ri,level)); //Write closing at the end of the line @@ -473,7 +473,7 @@ char* ocr_bitmap(void* arg, png_color *palette,png_byte *alpha, unsigned char* i { char *substr = ""; char *text_out_copy = strdup(text_out); - free(text_out); + TessDeleteText(text_out); text_out = malloc(strlen(text_out_copy)+strlen(substr)+1); memset(text_out,0,strlen(text_out_copy)+strlen(substr)+1); char *str = strtok(text_out_copy,"\n");