[fpc-pascal] How to free memory allocated by C++ library
Henry Vermaak
henry.vermaak at gmail.com
Thu Jun 2 10:35:35 CEST 2011
On 01/06/11 21:27, Malcolm Poole wrote:
> Working from the instructions in CinFreepascal.pdf (
> ftp://ftp.freepascal.org/pub/fpc/docs-pdf/CinFreePascal.pdf ) I have
> written an interface library to the C++ library libtesseract (
> http://code.google.com/p/tesseract-ocr ).
>
> Everything appears to work well but I am unsure about how to free memory
> which has been reserved by a libtesseract function and returned as a
> result. The original documentation states that "The calling function
> must delete [] after use", but the application crashes with an Access
> Violation if I try to free the memory with Dispose or Freemem. I can
> confirm that the array of Integer pointed to by the result of
> tesseract_AllWordConfidences contains valid data.
If you add cmem to the start of your uses list, all the memory
operations are routed through the c memory manager. You should then be
able to use Free safely for pointers that were allocated by your library.
I'm planning some ocr work in the near future, so let us know if this works!
Henry
More information about the fpc-pascal
mailing list