is a bit awkward with the <= limit -1 . Just use the strictly less than comparison to the actual array size (or limit of valid elements), as in
for ( int index = 0; index < limit ; index++ )
It is more than a bit awkward I have seen program errors introduced by this <= limit -1 construct that are not possible with < limit .
It needs a slightly different situation but imagine that
index has type unsigned rather than int
limit is not a constant it is a variable of the program which has a value >= 0
I found this exact bug in a digital television receiver where presumably the original coder hadn't thought of the possibility of a channel having no audio streams at all although that is perfectly valid.
So if everything is unsigned and limit is 0 then limit - 1 is a very large number, 0xFFFFFFFF on a 32bit system and suddenly you have an infinite loop.