Page 1 of 1

BQ_BUFFER_SIZE macro correct?

Posted: Tue Jan 12, 2016 3:08 pm
by flabbergast
In hal/include/hal_buffers.h there's this definition:

Code: Select all

#define BQ_BUFFER_SIZE(n, size)                                             \
  ((size_t)(size) + ((sizeof (size_t)) * (size_t)(n)))

From what I could understand from the documentation of buffers queue, I thought it should compute how many bytes should be allocated for n buffers, each of size size. It does not do this (the parentheses are wrong for this); it looks like it allocates one buffer of size size plus a little bit.
Is this a bug, or do I understand the buffers queue wrong?

Re: BQ_BUFFER_SIZE macro correct?

Posted: Tue Jan 12, 2016 4:59 pm
by Giovanni
The buffers should be long "size + sizeof(size)" because a size field is attached to each buffer.

Said that, the macro looks wrong... looks like a huge bug. Worth an update during weekend.

Giovanni

Re: BQ_BUFFER_SIZE macro correct?

Posted: Tue Jan 12, 2016 8:16 pm
by flabbergast
Thanks, that's what I thought it should do. Yes, it would be good to fix :)