Using YAML::Emitter I sometimes get YAML::Emitter.size() to return a bigger size than strlen(YAML::Emitter.c_str()). e.g.
YAML::Emitter em;
em << something;
if (em.size() > strlen(em.c_str())
{
std::cout << "WOW " << em.size() << " > " << strlen(em.c_str());
}
This creates issues when writing the yaml text to a buffer:
char* buff = malloc(em.size());
memcpy(buff, em.c_str(), em.size());
because the extra characters at the end fail the yaml parser on the other side that reads this buffer.
Thanks!