Originally Posted by
matsp
I would also add an assert(buflen >= 0) (or if-statement with a printout, or similar) just above the line with the cast [if there are several casts on the same (unchanged) variable, you obviously only need one assert]. That way, _IF_ the bufLen is ever negative, you have a chance to catch it.
--
Mats