I am implementing a function which searches through a ring queue for a given substring. The function returns true if the substring is found, otherwise false. There is a cell containing null between the tail and head to signify the end of string. Please give feedback on this implementation.
bool SoftwareSerial::contains(const char *substr){
char *pBuffer =_receive_buffer + _receive_buffer_head;
char *pSubstr = substr;
for(; *pBuffer != 0 && *pSubstr != 0; ++pBuffer ){
if(pBuffer == (_receive_buffer + _SS_MAX_RX_BUFF)){
pBuffer = _receive_buffer + _receive_buffer_head;
}
if(*pBuffer != *pSubstr){
pSubstr = substr;
continue;
}
++pSubstr;
}
return (*pSubstr == 0);
}