mirror of
https://github.com/esphome/esphome.git
synced 2026-06-24 12:17:23 +00:00
[core] Replace strnlen in buf_append_str for Zephyr compatibility (#15892)
This commit is contained in:
@@ -1117,7 +1117,10 @@ inline size_t buf_append_str(char *buf, size_t size, size_t pos, const char *str
|
||||
return size;
|
||||
}
|
||||
size_t remaining = size - pos - 1; // reserve space for null terminator
|
||||
size_t len = strnlen(str, remaining);
|
||||
size_t len = 0;
|
||||
while (len < remaining && str[len] != '\0') {
|
||||
len++;
|
||||
}
|
||||
memcpy(buf + pos, str, len);
|
||||
pos += len;
|
||||
buf[pos] = '\0';
|
||||
|
||||
Reference in New Issue
Block a user