- char *tmp = bprintf("Cannot create process '%s': host '%s' does not exist\nExisting hosts: '",process->function, process->host);
- xbt_strbuff_t msg = xbt_strbuff_new_from(tmp);
- free(tmp);
- xbt_dynar_t all_hosts = xbt_dynar_sort_strings(sg_hosts_as_dynar());
- simgrid::s4u::Host* host;
- unsigned int cursor;
- xbt_dynar_foreach(all_hosts,cursor, host) {
- xbt_strbuff_append(msg, host->cname());
- xbt_strbuff_append(msg,"', '");
- if (msg->used > 1024) {
- msg->data[msg->used-3]='\0';
- msg->used -= 3;
-
- xbt_strbuff_append(msg," ...(list truncated)......");// That will be shortened by 3 chars when existing the loop
+ std::string msg = std::string("Cannot create process '") + process->function + "': host '" + process->host +
+ "' does not exist\nExisting hosts: '";
+ for (auto kv : simgrid::s4u::host_list) {
+ simgrid::s4u::Host* host = kv.second;
+ msg += host->name();
+ msg += "', '";
+ if (msg.length() > 1024) {
+ msg.pop_back(); // remove trailing quote
+ msg += "...(list truncated)......";