AnsweredAssumed Answered

circptr/circindex() need better documentation/implementation

Question asked by fvpetrov on May 21, 2012
Latest reply on May 21, 2012 by MikeP

circptr/circindex()'s documentation shall explicitly state that a pointer increment greater than buffer's length is not allowed

or change implementation to allow arbitrary increments.


I use circptr() for buffer accesses replacing "buffer [ index % buffer_length ]" -like constructs.

In the modulo case I am always on the safe side, that means, the reminder cannot be greater than buffer's length and the code works as expected,

even for indexes way over buffer's length (as long as the compiler does not use a buggy circular indexing).

Unfortunately, a direct translation to circptr() is not possible when the increment is over buffer's length.

The workaround I found is to use modulo in circptr as follows: circptr ( pointer, increment % length, base, length ), but this isn't "clean code".

This issue was found the hard way, using VisualDSP++ 5.0 Update 10, Debug build on Win7 64 bit.