mirror of
https://git.h3cjp.net/H3cJP/yuzu.git
synced 2024-11-15 20:12:47 +00:00
Merge pull request #6145 from lat9nq/nvhost_empty_memcpy
nvhost_nvdec_common: Avoid memcpy with null pointers
This commit is contained in:
commit
dfac2e2d25
|
@ -23,17 +23,22 @@ namespace {
|
||||||
template <typename T>
|
template <typename T>
|
||||||
std::size_t SpliceVectors(const std::vector<u8>& input, std::vector<T>& dst, std::size_t count,
|
std::size_t SpliceVectors(const std::vector<u8>& input, std::vector<T>& dst, std::size_t count,
|
||||||
std::size_t offset) {
|
std::size_t offset) {
|
||||||
|
if (!dst.empty()) {
|
||||||
std::memcpy(dst.data(), input.data() + offset, count * sizeof(T));
|
std::memcpy(dst.data(), input.data() + offset, count * sizeof(T));
|
||||||
offset += count * sizeof(T);
|
}
|
||||||
return offset;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write vectors will write data to the output buffer
|
// Write vectors will write data to the output buffer
|
||||||
template <typename T>
|
template <typename T>
|
||||||
std::size_t WriteVectors(std::vector<u8>& dst, const std::vector<T>& src, std::size_t offset) {
|
std::size_t WriteVectors(std::vector<u8>& dst, const std::vector<T>& src, std::size_t offset) {
|
||||||
|
if (src.empty()) {
|
||||||
|
return 0;
|
||||||
|
} else {
|
||||||
std::memcpy(dst.data() + offset, src.data(), src.size() * sizeof(T));
|
std::memcpy(dst.data() + offset, src.data(), src.size() * sizeof(T));
|
||||||
offset += src.size() * sizeof(T);
|
offset += src.size() * sizeof(T);
|
||||||
return offset;
|
return offset;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} // Anonymous namespace
|
} // Anonymous namespace
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue