Allow control over authorization String allocation by paulocsanz · Pull Request #8225 · esp8266/Arduino (original) (raw)
Fixes #8224
It seems one allocation is inevitable here, but allowing the user to control it solves the non-null terminated string-view problem. That currently needs two allocations to fix.
This replace(String('\n'), ...) doesn't seem ideal, should I implement String::replace(char, String&), or String::remove(char) to avoid allocating here needlessly? Of course this virtually has no impact since it's immediately freed, it won't cause heap fragmentation, so it seems overkill. But this kind of API bothers me a lot, where allocation is not needed but happens. It makes everything less deterministic.