Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gcode issue1199 p2 #12

Closed
wants to merge 2 commits into from

Conversation

jimregan
Copy link
Contributor

Split commits; builds on -p1, so includes that patch. Updated to current version

1. memry removal.

This should be no-brainer. These functions never seemed to do anything useful. The only oddity was with alloc_string which rounded the allocation upwards to nearest multiple of 4. Based on my review of code, I could not identify any value in this feature, so even alloc_string was simply transformed to malloc.

memry.* are removed. All code is adjusted to simply call malloc and free instead.

listio.* are removed. The list reading function in these files appears to have been unused, and contained the only invocation of strsave define, which was one of the alloc_string users, so I removed both of them.

https://code.google.com/p/tesseract-ocr/issues/detail?id=1199
…. memry and emalloc removal.

2. memry and emalloc removal.

As above, but also removes emalloc* and replaces all uses of E{malloc,realloc,free} with the standard versions.

This is somewhat more controversial, because the E variants bothered to check the return value from the respective function, and would perform DoError if it determined it to have failed, which terminates in message to console and err_exit(). This is arguably nicer than crashing on null pointer value, but large parts of the code have never cared about malloc's potential NULL values, so I'd say it doesn't really help that parts of it now do.

Perhaps the real plan for moving forwards is to also replace malloc/free, and instead start using new/delete operators, and allow them to throw exceptions if the object construction fails due to memory allocation error. In this sense, the second patch may be considered as a stepping stone on the path towards such future version of Tesseract.

Conflicts:
	classify/flexfx.cpp
@tfmorris
Copy link
Contributor

Internet Archive copy of discussion in original issue: https://web.archive.org/web/20151128081631/http://code.google.com/p/tesseract-ocr/issues/detail?id=1199

@jimregan
Copy link
Contributor Author

I think this one can be safely closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants