[web_server_idf] Reduce heap allocations by using stack buffers

This commit is contained in:
J. Nick Koston
2026-01-25 23:55:11 -10:00
parent 1c9a9c7536
commit c15bfd243a
2 changed files with 13 additions and 15 deletions
+2 -5
View File
@@ -78,11 +78,8 @@ optional<std::string> query_key_value(const std::string &query_url, const std::s
return {};
}
auto val = std::unique_ptr<char[]>(new char[query_url.size()]);
if (!val) {
ESP_LOGE(TAG, "Not enough memory to the query key value");
return {};
}
// Use stack buffer for typical query strings, heap fallback for large ones
SmallBufferWithHeapFallback<256, char> val(query_url.size());
if (httpd_query_key_value(query_url.c_str(), key.c_str(), val.get(), query_url.size()) != ESP_OK) {
return {};