| 258 | } |
| 259 | |
| 260 | const char* CLoopBuffer::_FindStrInMem(const char* buffer, const char* ch, int buffer_len, int ch_len) const { |
| 261 | if (!buffer) { |
| 262 | return nullptr; |
| 263 | } |
| 264 | |
| 265 | const char* buff = buffer; |
| 266 | const char* find = nullptr; |
| 267 | int finded = 0; |
| 268 | while(true) { |
| 269 | find = (char*)memchr(buff, *ch, buffer_len - finded); |
| 270 | if (!find) { |
| 271 | break; |
| 272 | } |
| 273 | if (memcmp(find, ch, ch_len) == 0) { |
| 274 | return find; |
| 275 | } |
| 276 | finded += find - buff + 1; |
| 277 | if (buffer_len - finded < ch_len) { |
| 278 | break; |
| 279 | } |
| 280 | buff = ++find; |
| 281 | } |
| 282 | return nullptr; |
| 283 | } |
| 284 | |
| 285 | int CLoopBuffer::_Read(char* res, int len, bool clear) { |
| 286 | std::unique_lock<std::mutex> lock(_mutex); |
nothing calls this directly
no outgoing calls
no test coverage detected