+
+ // If the newline wasn't the last character in the buffer. (I.e. there's extra data for the next call)
+ assert(newline - buf + 1 <= len);
+ if( newline - buf + 1 < len ) {
+ int extra_bytes = len - (newline - buf + 1);
+ // Copy `extra_bytes` from end of buffer down to start and set `bufValid` to `extra_bytes`?
+ memmove(&buf[0], newline + 1, extra_bytes);
+ bufValid = extra_bytes;
+
+ #if DEBUG_TRACE_SERVER > 1
+ printf("- Caching %i bytes '%.*s'\n", bufValid, bufValid, buf);
+ #endif
+ }