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:
-rw-r--r--intern/cycles/util/array.h18
1 files changed, 11 insertions, 7 deletions
diff --git a/intern/cycles/util/array.h b/intern/cycles/util/array.h
index 4c905b09138..1c5e3e8d4ec 100644
--- a/intern/cycles/util/array.h
+++ b/intern/cycles/util/array.h
@@ -64,7 +64,7 @@ template<typename T, size_t alignment = MIN_ALIGNMENT_CPU_DATA_TYPES> class arra
else {
data_ = mem_allocate(from.datasize_);
if (from.datasize_ > 0) {
- memcpy(data_, from.data_, from.datasize_ * sizeof(T));
+ mem_copy(data_, from.data_, from.datasize_);
}
datasize_ = from.datasize_;
capacity_ = datasize_;
@@ -76,7 +76,7 @@ template<typename T, size_t alignment = MIN_ALIGNMENT_CPU_DATA_TYPES> class arra
if (this != &from) {
resize(from.size());
if (datasize_ > 0) {
- memcpy((void *)data_, from.data_, datasize_ * sizeof(T));
+ mem_copy(data_, from.data_, datasize_);
}
}
@@ -88,7 +88,7 @@ template<typename T, size_t alignment = MIN_ALIGNMENT_CPU_DATA_TYPES> class arra
resize(from.size());
if (from.size() > 0 && datasize_ > 0) {
- memcpy(data_, &from[0], datasize_ * sizeof(T));
+ mem_copy(data_, from.data(), datasize_);
}
return *this;
@@ -161,8 +161,7 @@ template<typename T, size_t alignment = MIN_ALIGNMENT_CPU_DATA_TYPES> class arra
return NULL;
}
else if (data_ != NULL) {
- memcpy(
- (void *)newdata, data_, ((datasize_ < newsize) ? datasize_ : newsize) * sizeof(T));
+ mem_copy(newdata, data_, ((datasize_ < newsize) ? datasize_ : newsize));
mem_free(data_, capacity_);
}
data_ = newdata;
@@ -246,7 +245,7 @@ template<typename T, size_t alignment = MIN_ALIGNMENT_CPU_DATA_TYPES> class arra
if (newcapacity > capacity_) {
T *newdata = mem_allocate(newcapacity);
if (data_ != NULL) {
- memcpy(newdata, data_, ((datasize_ < newcapacity) ? datasize_ : newcapacity) * sizeof(T));
+ mem_copy(newdata, data_, ((datasize_ < newcapacity) ? datasize_ : newcapacity));
mem_free(data_, capacity_);
}
data_ = newdata;
@@ -280,7 +279,7 @@ template<typename T, size_t alignment = MIN_ALIGNMENT_CPU_DATA_TYPES> class arra
if (from.size()) {
size_t old_size = size();
resize(old_size + from.size());
- memcpy(data_ + old_size, from.data(), sizeof(T) * from.size());
+ mem_copy(data_ + old_size, from.data(), from.size());
}
}
@@ -308,6 +307,11 @@ template<typename T, size_t alignment = MIN_ALIGNMENT_CPU_DATA_TYPES> class arra
}
}
+ inline void mem_copy(T *mem_to, const T *mem_from, const size_t N)
+ {
+ memcpy((void *)mem_to, mem_from, sizeof(T) * N);
+ }
+
T *data_;
size_t datasize_;
size_t capacity_;