You can also say expect FF FF or FF FF FF or FF FF FF FF each getting more unlikely than the next, or you scan all of you data and find a magic combo that is not used at all. But FF seems to be used by a lot of things as an end markernesrocks wrote:Is what I said totally a bad idea? Or doesn't it apply? The advantage is that the list of objects can be any size. The disadvantage is that it can't have one specific byte value (or bit) at a certain point in the data array. You do need to check for that #FF byte on every item, but when using a counter you need to check against it, so I guess it's the same on that aspect, optimization-wise.
And in the OP case, I imagine it's one big object of 500 bytes? In that case you could reserve #FF to be the end of the data.
Or you make an escape byte
FE FE = FE
FE FF = FF
FF XX = End