Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'intern/cycles/util/util_array.h')
-rw-r--r--intern/cycles/util/util_array.h13
1 files changed, 10 insertions, 3 deletions
diff --git a/intern/cycles/util/util_array.h b/intern/cycles/util/util_array.h
index 1d7e39344f6..db80ab474e0 100644
--- a/intern/cycles/util/util_array.h
+++ b/intern/cycles/util/util_array.h
@@ -63,7 +63,9 @@ template<typename T, size_t alignment = MIN_ALIGNMENT_CPU_DATA_TYPES> class arra
}
else {
data_ = mem_allocate(from.datasize_);
- memcpy(data_, from.data_, from.datasize_ * sizeof(T));
+ if (from.datasize_ > 0) {
+ memcpy(data_, from.data_, from.datasize_ * sizeof(T));
+ }
datasize_ = from.datasize_;
capacity_ = datasize_;
}
@@ -73,7 +75,9 @@ template<typename T, size_t alignment = MIN_ALIGNMENT_CPU_DATA_TYPES> class arra
{
if (this != &from) {
resize(from.size());
- memcpy((void *)data_, from.data_, datasize_ * sizeof(T));
+ if (datasize_ > 0) {
+ memcpy((void *)data_, from.data_, datasize_ * sizeof(T));
+ }
}
return *this;
@@ -83,7 +87,7 @@ template<typename T, size_t alignment = MIN_ALIGNMENT_CPU_DATA_TYPES> class arra
{
resize(from.size());
- if (from.size() > 0) {
+ if (from.size() > 0 && datasize_ > 0) {
memcpy(data_, &from[0], datasize_ * sizeof(T));
}
@@ -100,6 +104,9 @@ template<typename T, size_t alignment = MIN_ALIGNMENT_CPU_DATA_TYPES> class arra
if (datasize_ != other.datasize_) {
return false;
}
+ if (datasize_ == 0) {
+ return true;
+ }
return memcmp(data_, other.data_, datasize_ * sizeof(T)) == 0;
}