- From: Dan Christian <dchristian_at_mail.arc.nasa.gov>
- Date: Thu, 25 Jul 2002 08:55:14 -0700
On Wednesday 24 July 2002 17:23, David Schleef wrote:
> On Wed, Jul 24, 2002 at 04:39:42PM -0700, Dan Christian wrote:
> > Never mind. I forgot that comedi_buf_put_array is obsolete.
>
> It's not obsolete, it's just not recommended (by me).
In CVS, its "#if 0" in driver.c, and I don't see it any where else.
>
> There's a problem: comedi_buf_write_alloc() will give you
> allocations that wrap around the end of a buffer. At one point,
> it did do this, so you might need to update CVS.
>
> Instead, comedi_buf_memcpy_to() correctly handles wraparounds when
> copying to a buffer. So you want something like:
>
> n = comedi_buf_write_alloc (s->async, ii * sizeof (s16));
> if(n<ii * sizeof (s16)){
> /* this is a buffer overflow error condition */
> /* big flames should erupt */
> }
> comedi_buf_memcpy_to (s->async, 0, dp, n);
> comedi_buf_write_free (s->async, n);
That's even easier. Thanks!
-Dan
Received on 2002-07-25Z14:55:14