[liblouis-liblouisxml] Re: Python bindings and output buffer size for lou_translate*

  • From: "John J. Boyer" <john.boyer@xxxxxxxxxxxxxxxxx>
  • To: liblouis-liblouisxml@xxxxxxxxxxxxx
  • Date: Tue, 27 Jul 2010 06:25:46 -0500

liblouisxml just provides big buffers, since it has no way of knowing 
how long the text content of an xml element might be. If it is longer 
than the size of the input bufer, it breakes it up with a buffer 
overflow routine. If the translation is longer than the output bufferr 
it is simply truncated. This has never happened.

John

On Tue, Jul 27, 2010 at 07:06:50PM +1000, James Teh wrote:
> On 27/07/2010 7:00 PM, John J. Boyer wrote:
> >I don't know much about Python, but couldn't the calling program provide
> >the buffers and buffer sizes?
> You're not supposed to have to worry about buffer sizes in Python. It 
> should just give you the whole thing.
> 
> >inlen and outlen are supposed to be
> >independent.
> They aren't independent, though, because you need to know how long to 
> make the output buffer so as to fit the entire translated input buffer. 
> Unless you allocate a ridiculously huge output buffer all the time (and 
> check that your input buffer never exceeds this), you have to try to 
> guess how big to make outlen based on inlen.
> 
> How does liblouisxml determine the size of outlen?
> 
> Jamie
> 
> -- 
> James Teh
> Vice President
> NV Access Inc, ABN 61773362390
> Email: jamie@xxxxxxxxxxxx
> Web site: http://www.nvaccess.org/
> For a description of the software and to download it go to
> http://www.jjb-software.com

-- 
John J. Boyer; President, Chief Software Developer
Abilitiessoft, Inc.
http://www.abilitiessoft.com
Madison, Wisconsin USA
Developing software for people with disabilities

For a description of the software and to download it go to
http://www.jjb-software.com

Other related posts: