fsp_srv: Use std::string_view's copy() function instead of strncpy()

Given elements inserted into a vector are zeroed out, we can just copy
MAX_LEN - 1 elements and the data will already be properly null
terminated.
This commit is contained in:
Lioncash 2018-08-08 17:49:57 -04:00
parent 4afb05d0cc
commit 7353cfc781
2 changed files with 10 additions and 8 deletions

View file

@ -196,11 +196,7 @@ static void BuildEntryIndex(std::vector<FileSys::Entry>& entries, const std::vec
entries.reserve(entries.size() + new_data.size());
for (const auto& new_entry : new_data) {
auto& entry = entries.emplace_back();
entry.filename[0] = '\0';
std::strncat(entry.filename, new_entry->GetName().c_str(), FileSys::FILENAME_LENGTH - 1);
entry.type = type;
entry.file_size = new_entry->GetSize();
entries.emplace_back(new_entry->GetName(), type, new_entry->GetSize());
}
}