Searching for a substring in a ring queue
There were few bugs in the function.
1. pStr should point to the start of the buffer once it reaches the end of the buffer.
2. A flag should be set when a character matches and unset the flag when next coming character doesn't match.
Here the modified version that I believe is correct:

bool Buffer::contains(const char *pcSubstr){

const char *pcCurrentSubstr = pcSubstr;
const char *pStr = buffer + head;
bool seen = false;
for (; *pStr != 0 &amp;&amp; *pcCurrentSubstr != 0; ++pStr){
    if(pStr == (buffer + MAX_BUFFER_SIZE)){
        pStr = buffer;
    }
    if(*pStr != *pcCurrentSubstr){
        pcCurrentSubstr = pcSubstr;
        if(seen){
            --pStr;
        }
        seen = false;
        continue;
    }
    seen = true;
    ++pcCurrentSubstr;
}
return (*pcCurrentSubstr == 0);
}