Fix (unreported) 'copy' version of MEM_cnew not handling alignment.
Almost certainly not an issue in current codebase (this 'copy' version of `MEM_cnew` does not seem much used in the first place), but better be consistent with the 'allocating' version. Pull Request: https://projects.blender.org/blender/blender/pulls/123445
This commit is contained in:
@@ -353,7 +353,7 @@ template<typename T> inline T *MEM_cnew_array(const size_t length, const char *a
|
||||
template<typename T> inline T *MEM_cnew(const char *allocation_name, const T &other)
|
||||
{
|
||||
static_assert(std::is_trivial_v<T>, "For non-trivial types, MEM_new should be used.");
|
||||
T *new_object = static_cast<T *>(MEM_mallocN(sizeof(T), allocation_name));
|
||||
T *new_object = static_cast<T *>(MEM_mallocN_aligned(sizeof(T), alignof(T), allocation_name));
|
||||
if (new_object) {
|
||||
memcpy(new_object, &other, sizeof(T));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user