From 32ece7d6041d48fa779e8613eb3240f074446cea Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Wed, 19 Jun 2024 20:11:48 +0200 Subject: [PATCH] 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 --- intern/guardedalloc/MEM_guardedalloc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/intern/guardedalloc/MEM_guardedalloc.h b/intern/guardedalloc/MEM_guardedalloc.h index 76d1b60ee2b..c02ff5371bb 100644 --- a/intern/guardedalloc/MEM_guardedalloc.h +++ b/intern/guardedalloc/MEM_guardedalloc.h @@ -353,7 +353,7 @@ template inline T *MEM_cnew_array(const size_t length, const char *a template inline T *MEM_cnew(const char *allocation_name, const T &other) { static_assert(std::is_trivial_v, "For non-trivial types, MEM_new should be used."); - T *new_object = static_cast(MEM_mallocN(sizeof(T), allocation_name)); + T *new_object = static_cast(MEM_mallocN_aligned(sizeof(T), alignof(T), allocation_name)); if (new_object) { memcpy(new_object, &other, sizeof(T)); }