Description
config_strerror() in config_util.cc returns its error string as a C-style string (allocated with malloc via strdup).
This is undesirable for a number of reasons:
- char* is a non-owning type (C-style string), so users must remember to free() it or memory will be leaked (owning types, e.g. std::string are preferred).
- To allow us to accurately track memory, we have our own cb_malloc API when we need to use C-style allocation. In this case, using the normal (non-CB) malloc is potentially confusing, as the caller needs to remember to use plain free() and not cb_free() in this case.
We should therefore change config_strerror() to use C++ string objects instead of C-style allocation:
- Change the return type of config_strerror to std::string, and update all call-sites.
- Change the string manipulation from C-style snprintf / strdup to methods on std::string.