Refactor: Replace malloc msgbuf with std::string