|
As the 2nd argument of function Stream::findUntil(char *target, char *terminator) is not being modified by the function's code, it is advised to use const here.
problem: if findUntil would modify the terminator string, the compiler would not complain and the programmer would be very surprised.
improvment: using const in such situations allows other classes to properly define this parameter as const where indicated, telling the compiler to complain if the terminator string is modified by a function (by mistake).
Proposed code the the findUntil() function header and implementation is, thus:
bool Stream::findUntil(char *target, const char *terminator) { return findUntil(target, strlen(target), terminator, strlen(terminator)); }
In the second function declaration for findUntil(), following changes would be adviced:
bool Stream::findUntil(char *target, size_t targetLen, const char *terminator, const size_t termLen) { size_t index = 0; // maximum target string length is 64k bytes! size_t termIndex = 0; int c; ...
|