<div dir="ltr">Thank you so much for your support allan. I will take note of this.<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Mar 9, 2016 at 8:17 PM, m. allan noah <span dir="ltr"><<a href="mailto:kitno455@gmail.com" target="_blank">kitno455@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Yes- the value of maxlen is determined by the frontend. You cannot<br>
change it, and you certainly cannot re-alloc. You should have your own<br>
buffer in the backend, and read bytes from it into the buffer provided<br>
by the frontend. This type of double buffering will allow you to read<br>
from the scanner in whatever block size is best, and then respond to<br>
the frontend however it wants. I recommend that you not make your<br>
backend buffer very large (to save memory), but you then have to be<br>
careful not to overflow it when the frontend is draining it slowly.<br>
<span class="HOEnZb"><font color="#888888"><br>
allan<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
On Wed, Mar 9, 2016 at 1:14 AM, ky gcp <<a href="mailto:kygcpsample@gmail.com">kygcpsample@gmail.com</a>> wrote:<br>
> Thank you for such quick response, allan. Do you mean to say that the value<br>
> of maxlen is determined by the frontend? On xsane application, maxlen value<br>
> is 8192 when using acquire preview and then value of maxlen is 65536 when<br>
> using scan function. Our external backend currently reads images by row on<br>
> sane_read(). Issue occurs when using acquire preview on colored A3 original<br>
> because the number of bytes per row is more than the value of maxlen. If I<br>
> reallocate the argument buf to a much bigger size, xsane closes and I get<br>
> this error message below:<br>
> *** stack smashing detected ***: xsane terminated<br>
> Aborted (core dumped)<br>
><br>
> Since our external backend currently reads images by row on sane_read(), is<br>
> it better to just change our implementation on sane_read() ?<br>
><br>
> On Wed, Mar 9, 2016 at 9:39 AM, m. allan noah <<a href="mailto:kitno455@gmail.com">kitno455@gmail.com</a>> wrote:<br>
>><br>
>> Because different frontends have different requirements. Some try to<br>
>> save memory, some try to maximize speed by using large buffers, some<br>
>> try to fill a network packet exactly. You can (and should expect) to<br>
>> get any value of maxlen from 1 byte to perhaps a 1M, maybe more.<br>
>><br>
>> allan<br>
>><br>
>> On Tue, Mar 8, 2016 at 8:23 PM, ky gcp <<a href="mailto:kygcpsample@gmail.com">kygcpsample@gmail.com</a>> wrote:<br>
>> > why does the value of maxlen vary from various frontends?<br>
>> ><br>
>> > On Tue, Mar 8, 2016 at 9:06 PM, m. allan noah <<a href="mailto:kitno455@gmail.com">kitno455@gmail.com</a>><br>
>> > wrote:<br>
>> >><br>
>> >> maxlen is provided by the caller of the function, to tell the backend<br>
>> >> how much memory the caller has allocated for image data.<br>
>> >><br>
>> >> allan<br>
>> >><br>
>> >> On Tue, Mar 8, 2016 at 3:09 AM, ky gcp <<a href="mailto:kygcpsample@gmail.com">kygcpsample@gmail.com</a>> wrote:<br>
>> >> > hi,<br>
>> >> ><br>
>> >> > how is the argument maxlen determined in sane_read() function?<br>
>> >> ><br>
>> >> > SANE_Status sane_read (SANE_Handle h, SANE_Byte * buf, SANE_Int<br>
>> >> > maxlen,<br>
>> >> > SANE_Int * len);<br>
>> >> ><br>
>> >> > Thanks for your help.<br>
>> >> ><br>
>> >> > --<br>
>> >> > sane-devel mailing list: <a href="mailto:sane-devel@lists.alioth.debian.org">sane-devel@lists.alioth.debian.org</a><br>
>> >> > <a href="http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/sane-devel" rel="noreferrer" target="_blank">http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/sane-devel</a><br>
>> >> > Unsubscribe: Send mail with subject "unsubscribe your_password"<br>
>> >> >              to <a href="mailto:sane-devel-request@lists.alioth.debian.org">sane-devel-request@lists.alioth.debian.org</a><br>
>> >><br>
>> >><br>
>> >><br>
>> >> --<br>
>> >> "well, I stand up next to a mountain- and I chop it down with the edge<br>
>> >> of my hand"<br>
>> ><br>
>> ><br>
>><br>
>><br>
>><br>
>> --<br>
>> "well, I stand up next to a mountain- and I chop it down with the edge<br>
>> of my hand"<br>
><br>
><br>
<br>
<br>
<br>
--<br>
"well, I stand up next to a mountain- and I chop it down with the edge<br>
of my hand"<br>
</div></div></blockquote></div><br></div>