mirror of
https://github.com/esphome/esphome.git
synced 2026-03-02 10:48:22 -07:00
Refactor multipart utility functions to work with const char* + length instead of std::string to eliminate temporary heap allocations during header parsing. The original implementations used std::string for convenience when the OTA multipart support was first added, but these can be avoided since the multipart parser already provides raw pointers and lengths in its callbacks. - extract_header_param: takes (const char*, size_t, const char*, std::string&) instead of (const std::string&, const std::string&) -> std::string. Assigns directly to destination, avoiding intermediate string construction. - str_startswith_case_insensitive: takes (const char*, size_t, const char*) instead of (const std::string&, const std::string&) - str_trim: takes (const char*, size_t, std::string&) instead of (const std::string&) -> std::string - Rename stristr to strcasestr_n with explicit haystack length parameter to make the relationship to POSIX strcasestr clear and fix a latent buffer over-read risk (stristr relied on null-termination which the multipart parser does not guarantee for its callback data) - process_header_ no longer creates a std::string copy of the raw parser buffer before calling utility functions Saves ~350 bytes of flash.