diff --git a/intern/guardedalloc/MEM_guardedalloc.h b/intern/guardedalloc/MEM_guardedalloc.h index 295e511a228..36eee8f8ef5 100644 --- a/intern/guardedalloc/MEM_guardedalloc.h +++ b/intern/guardedalloc/MEM_guardedalloc.h @@ -52,7 +52,7 @@ extern "C" { extern size_t (*MEM_allocN_len)(const void *vmemh) ATTR_WARN_UNUSED_RESULT; /** - * Release memory previously allocated by the C-style and #MEM_cnew functions of this module. + * Release memory previously allocated by the C-style functions of this module. * * It is illegal to call this function with data allocated by #MEM_new. */ @@ -69,7 +69,7 @@ extern short (*MEM_testN)(void *vmemh); * Duplicates a block of memory, and returns a pointer to the * newly allocated block. * NULL-safe; will return NULL when receiving a NULL pointer. */ -extern void *(*MEM_dupallocN)(const void *vmemh) /* ATTR_MALLOC */ ATTR_WARN_UNUSED_RESULT; +void *MEM_dupallocN(const void *vmemh) /* ATTR_MALLOC */ ATTR_WARN_UNUSED_RESULT; /** * Reallocates a block of memory, and returns pointer to the newly @@ -97,17 +97,17 @@ extern void *(*MEM_recallocN_id)(void *vmemh, * memory is cleared. The name must be static, because only a * pointer to it is stored! */ -extern void *(*MEM_callocN)(size_t len, const char *str) /* ATTR_MALLOC */ ATTR_WARN_UNUSED_RESULT - ATTR_ALLOC_SIZE(1) ATTR_NONNULL(2); +void *MEM_callocN(size_t len, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1) + ATTR_NONNULL(2); /** * Allocate a block of memory of size (len * size), with tag name * str, aborting in case of integer overflows to prevent vulnerabilities. * The memory is cleared. The name must be static, because only a * pointer to it is stored! */ -extern void *(*MEM_calloc_arrayN)(size_t len, - size_t size, - const char *str) /* ATTR_MALLOC */ ATTR_WARN_UNUSED_RESULT +void *MEM_calloc_arrayN(size_t len, + size_t size, + const char *str) /* ATTR_MALLOC */ ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1, 2) ATTR_NONNULL(3); /** @@ -325,8 +325,8 @@ inline T *MEM_new(const char *allocation_name, Args &&...args) * * As with the `delete` C++ operator, passing in `nullptr` is allowed and does nothing. * - * It is illegal to call this function with data allocated by #MEM_cnew or the C-style allocation - * functions of this module. + * It is illegal to call this function with data allocated by the C-style allocation functions of + * this module. */ template inline void MEM_delete(const T *ptr) { @@ -356,23 +356,49 @@ template inline void MEM_delete(const T *ptr) /** * Allocate zero-initialized memory for an object of type #T. The constructor of #T is not called, - * therefore this should only be used with trivial types (like all C types). + * therefore this must only be used with trivial types (like all C types). + * + * When allocating an enforced specific amount of bytes, the C version of this function should be + * used instead. While this should be avoided in C++ code, it is still required in some cases, e.g. + * for ID allocation based on #IDTypeInfo::struct_size. * * #MEM_freeN must be used to free a pointer returned by this call. Calling #MEM_delete on it is * illegal. */ -template inline T *MEM_cnew(const char *allocation_name) +template inline T *MEM_callocN(const char *allocation_name) { +# ifdef _MSC_VER + /* MSVC considers C-style types using the DNA_DEFINE_CXX_METHODS as non-trivial (more + * specifically, non-trivially copyable, likely because the default copy constructors are + * deleted). GCC and clang (both on linux, OSX, and clang-cl on Windows on Arm) do not. + * + * So for now, use a more restricted check on MSVC, should still catch most of actual invalid + * cases. */ + static_assert(std::is_trivially_constructible_v, + "For non-trivial types, MEM_new must be used."); +# else static_assert(std::is_trivial_v, "For non-trivial types, MEM_new must be used."); +# endif return static_cast(MEM_calloc_arrayN_aligned(1, sizeof(T), alignof(T), allocation_name)); } /** - * Same as MEM_cnew but for arrays, better alternative to #MEM_calloc_arrayN. + * Type-safe version of #MEM_calloc_arrayN/#MEM_calloc_array_alignedN. */ -template inline T *MEM_cnew_array(const size_t length, const char *allocation_name) +template inline T *MEM_calloc_arrayN(const size_t length, const char *allocation_name) { +# ifdef _MSC_VER + /* MSVC considers C-style types using the DNA_DEFINE_CXX_METHODS as non-trivial (more + * specifically, non-trivially copyable, likely because the default copy constructors are + * deleted). GCC and clang (both on linux, OSX, and clang-cl on Windows on Arm) do not. + * + * So for now, use a more restricted check on MSVC, should still catch most of actual invalid + * cases. */ + static_assert(std::is_trivially_constructible_v, + "For non-trivial types, MEM_new must be used."); +# else static_assert(std::is_trivial_v, "For non-trivial types, MEM_new must be used."); +# endif return static_cast( MEM_calloc_arrayN_aligned(length, sizeof(T), alignof(T), allocation_name)); } @@ -385,11 +411,23 @@ template inline T *MEM_cnew_array(const size_t length, const char *a * deprecated fields: some compilers will generate access deprecated field warnings in implicitly * defined copy constructors. * - * This is a better alternative to #MEM_dupallocN. + * This is a better alternative to the C-style implementation of #MEM_dupallocN, unless the source + * is an array or of a non-fully-defined type. */ -template inline T *MEM_cnew(const char *allocation_name, const T &other) +template inline T *MEM_dupallocN(const char *allocation_name, const T &other) { +# ifdef _MSC_VER + /* MSVC considers C-style types using the DNA_DEFINE_CXX_METHODS as non-trivial (more + * specifically, non-trivially copyable, likely because the default copy constructors are + * deleted). GCC and clang (both on linux, OSX, and clang-cl on Windows on Arm) do not. + * + * So for now, use a more restricted check on MSVC, should still catch most of actual invalid + * cases. */ + static_assert(std::is_trivially_constructible_v, + "For non-trivial types, MEM_new must be used."); +# else static_assert(std::is_trivial_v, "For non-trivial types, MEM_new must be used."); +# endif T *new_object = static_cast(MEM_mallocN_aligned(sizeof(T), alignof(T), allocation_name)); if (new_object) { memcpy(new_object, &other, sizeof(T)); diff --git a/intern/guardedalloc/intern/mallocn.cc b/intern/guardedalloc/intern/mallocn.cc index 7080ac070e1..6394ee62411 100644 --- a/intern/guardedalloc/intern/mallocn.cc +++ b/intern/guardedalloc/intern/mallocn.cc @@ -36,11 +36,13 @@ const char *malloc_conf = size_t (*MEM_allocN_len)(const void *vmemh) = MEM_lockfree_allocN_len; void (*mem_guarded::internal::mem_freeN_ex)(void *vmemh, AllocationType allocation_type) = MEM_lockfree_freeN; -void *(*MEM_dupallocN)(const void *vmemh) = MEM_lockfree_dupallocN; +void *(*mem_guarded::internal::mem_dupallocN)(const void *vmemh) = MEM_lockfree_dupallocN; void *(*MEM_reallocN_id)(void *vmemh, size_t len, const char *str) = MEM_lockfree_reallocN_id; void *(*MEM_recallocN_id)(void *vmemh, size_t len, const char *str) = MEM_lockfree_recallocN_id; -void *(*MEM_callocN)(size_t len, const char *str) = MEM_lockfree_callocN; -void *(*MEM_calloc_arrayN)(size_t len, size_t size, const char *str) = MEM_lockfree_calloc_arrayN; +void *(*mem_guarded::internal::mem_callocN)(size_t len, const char *str) = MEM_lockfree_callocN; +void *(*mem_guarded::internal::mem_calloc_arrayN)(size_t len, + size_t size, + const char *str) = MEM_lockfree_calloc_arrayN; void *(*MEM_mallocN)(size_t len, const char *str) = MEM_lockfree_mallocN; void *(*MEM_malloc_arrayN)(size_t len, size_t size, const char *str) = MEM_lockfree_malloc_arrayN; void *(*mem_guarded::internal::mem_mallocN_aligned_ex)(size_t len, @@ -111,11 +113,26 @@ void MEM_freeN(void *vmemh) mem_freeN_ex(vmemh, AllocationType::ALLOC_FREE); } +void *MEM_callocN(size_t len, const char *str) +{ + return mem_callocN(len, str); +} + +void *MEM_calloc_arrayN(size_t len, size_t size, const char *str) +{ + return mem_calloc_arrayN(len, size, str); +} + void *MEM_mallocN_aligned(size_t len, size_t alignment, const char *str) { return mem_mallocN_aligned_ex(len, alignment, str, AllocationType::ALLOC_FREE); } +void *MEM_dupallocN(const void *vmemh) +{ + return mem_dupallocN(vmemh); +} + /** * Perform assert checks on allocator type change. * @@ -142,11 +159,11 @@ void MEM_use_lockfree_allocator() MEM_allocN_len = MEM_lockfree_allocN_len; mem_freeN_ex = MEM_lockfree_freeN; - MEM_dupallocN = MEM_lockfree_dupallocN; + mem_dupallocN = MEM_lockfree_dupallocN; MEM_reallocN_id = MEM_lockfree_reallocN_id; MEM_recallocN_id = MEM_lockfree_recallocN_id; - MEM_callocN = MEM_lockfree_callocN; - MEM_calloc_arrayN = MEM_lockfree_calloc_arrayN; + mem_callocN = MEM_lockfree_callocN; + mem_calloc_arrayN = MEM_lockfree_calloc_arrayN; MEM_mallocN = MEM_lockfree_mallocN; MEM_malloc_arrayN = MEM_lockfree_malloc_arrayN; mem_mallocN_aligned_ex = MEM_lockfree_mallocN_aligned; @@ -178,11 +195,11 @@ void MEM_use_guarded_allocator() MEM_allocN_len = MEM_guarded_allocN_len; mem_freeN_ex = MEM_guarded_freeN; - MEM_dupallocN = MEM_guarded_dupallocN; + mem_dupallocN = MEM_guarded_dupallocN; MEM_reallocN_id = MEM_guarded_reallocN_id; MEM_recallocN_id = MEM_guarded_recallocN_id; - MEM_callocN = MEM_guarded_callocN; - MEM_calloc_arrayN = MEM_guarded_calloc_arrayN; + mem_callocN = MEM_guarded_callocN; + mem_calloc_arrayN = MEM_guarded_calloc_arrayN; MEM_mallocN = MEM_guarded_mallocN; MEM_malloc_arrayN = MEM_guarded_malloc_arrayN; mem_mallocN_aligned_ex = MEM_guarded_mallocN_aligned; diff --git a/intern/guardedalloc/intern/mallocn_guarded_impl.cc b/intern/guardedalloc/intern/mallocn_guarded_impl.cc index e888b50987f..d8208ada944 100644 --- a/intern/guardedalloc/intern/mallocn_guarded_impl.cc +++ b/intern/guardedalloc/intern/mallocn_guarded_impl.cc @@ -720,7 +720,7 @@ static void *mem_guarded_malloc_arrayN_aligned(const size_t len, return nullptr; } if (alignment <= MEM_MIN_CPP_ALIGNMENT) { - return MEM_callocN(r_bytes_num, str); + return mem_callocN(r_bytes_num, str); } return MEM_mallocN_aligned(r_bytes_num, alignment, str); } diff --git a/intern/guardedalloc/intern/mallocn_intern_function_pointers.hh b/intern/guardedalloc/intern/mallocn_intern_function_pointers.hh index 064ded635d0..f91b74c425d 100644 --- a/intern/guardedalloc/intern/mallocn_intern_function_pointers.hh +++ b/intern/guardedalloc/intern/mallocn_intern_function_pointers.hh @@ -20,6 +20,22 @@ enum class AllocationType { /** Internal implementation of #MEM_freeN, exposed because #MEM_delete needs access to it. */ extern void (*mem_freeN_ex)(void *vmemh, AllocationType allocation_type); +/** + * Internal implementation of #MEM_callocN, exposed because public #MEM_callocN cannot be a + * function pointer, to allow its overload by C++ template version. + */ +extern void *(*mem_callocN)(size_t len, const char *str) /* ATTR_MALLOC */ ATTR_WARN_UNUSED_RESULT + ATTR_ALLOC_SIZE(1) ATTR_NONNULL(2); + +/** + * Internal implementation of #MEM_calloc_arrayN, exposed because public #MEM_calloc_arrayN cannot + * be a function pointer, to allow its overload by C++ template version. + */ +extern void *(*mem_calloc_arrayN)(size_t len, + size_t size, + const char *str) /* ATTR_MALLOC */ ATTR_WARN_UNUSED_RESULT + ATTR_ALLOC_SIZE(1, 2) ATTR_NONNULL(3); + /** Internal implementation of #MEM_mallocN_aligned, exposed because #MEM_new needs access to it. */ extern void *(*mem_mallocN_aligned_ex)(size_t len, @@ -27,6 +43,12 @@ extern void *(*mem_mallocN_aligned_ex)(size_t len, const char *str, AllocationType allocation_type); +/** + * Internal implementation of #MEM_dupallocN, exposed because public #MEM_dupallocN cannot be a + * function pointer, to allow its overload by C++ template version. + */ +extern void *(*mem_dupallocN)(const void *vmemh) /* ATTR_MALLOC */ ATTR_WARN_UNUSED_RESULT; + /** * Store a std::any into a static opaque storage vector. The only purpose of this call is to * control the lifetime of the given data, there is no way to access it from here afterwards. User diff --git a/intern/guardedalloc/intern/mallocn_lockfree_impl.cc b/intern/guardedalloc/intern/mallocn_lockfree_impl.cc index 096924f93bf..e6057e8eec4 100644 --- a/intern/guardedalloc/intern/mallocn_lockfree_impl.cc +++ b/intern/guardedalloc/intern/mallocn_lockfree_impl.cc @@ -474,7 +474,7 @@ static void *mem_lockfree_malloc_arrayN_aligned(const size_t len, return nullptr; } if (alignment <= MEM_MIN_CPP_ALIGNMENT) { - return MEM_mallocN(r_bytes_num, str); + return mem_callocN(r_bytes_num, str); } void *ptr = MEM_mallocN_aligned(r_bytes_num, alignment, str); return ptr; diff --git a/intern/opencolorio/fallback_impl.cc b/intern/opencolorio/fallback_impl.cc index 9fe68ff824e..539000dbb38 100644 --- a/intern/opencolorio/fallback_impl.cc +++ b/intern/opencolorio/fallback_impl.cc @@ -512,7 +512,7 @@ OCIO_PackedImageDesc *FallbackImpl::createOCIO_PackedImageDesc(float *data, long xStrideBytes, long yStrideBytes) { - OCIO_PackedImageDescription *desc = MEM_cnew( + OCIO_PackedImageDescription *desc = MEM_callocN( "OCIO_PackedImageDescription"); desc->data = data; desc->width = width; diff --git a/source/blender/animrig/intern/action.cc b/source/blender/animrig/intern/action.cc index a2b929334b9..288f0910119 100644 --- a/source/blender/animrig/intern/action.cc +++ b/source/blender/animrig/intern/action.cc @@ -83,7 +83,7 @@ template static void grow_array(T **array, int *num, const int add_n { BLI_assert(add_num > 0); const int new_array_num = *num + add_num; - T *new_array = MEM_cnew_array(new_array_num, "animrig::action/grow_array"); + T *new_array = MEM_calloc_arrayN(new_array_num, "animrig::action/grow_array"); blender::uninitialized_relocate_n(*array, *num, new_array); MEM_SAFE_FREE(*array); @@ -103,7 +103,7 @@ static void grow_array_and_insert(T **array, int *num, const int index, T item) { BLI_assert(index >= 0 && index <= *num); const int new_array_num = *num + 1; - T *new_array = MEM_cnew_array(new_array_num, __func__); + T *new_array = MEM_calloc_arrayN(new_array_num, __func__); blender::uninitialized_relocate_n(*array, index, new_array); new_array[index] = item; @@ -119,7 +119,7 @@ template static void shrink_array(T **array, int *num, const int shr { BLI_assert(shrink_num > 0); const int new_array_num = *num - shrink_num; - T *new_array = MEM_cnew_array(new_array_num, __func__); + T *new_array = MEM_calloc_arrayN(new_array_num, __func__); blender::uninitialized_move_n(*array, new_array_num, new_array); MEM_freeN(*array); @@ -132,7 +132,7 @@ template static void shrink_array_and_remove(T **array, int *num, co { BLI_assert(index >= 0 && index < *num); const int new_array_num = *num - 1; - T *new_array = MEM_cnew_array(new_array_num, __func__); + T *new_array = MEM_calloc_arrayN(new_array_num, __func__); blender::uninitialized_move_n(*array, index, new_array); blender::uninitialized_move_n(*array + index + 1, *num - index - 1, new_array + index); @@ -151,7 +151,7 @@ template static void shrink_array_and_swap_remove(T **array, int *nu { BLI_assert(index >= 0 && index < *num); const int new_array_num = *num - 1; - T *new_array = MEM_cnew_array(new_array_num, __func__); + T *new_array = MEM_calloc_arrayN(new_array_num, __func__); blender::uninitialized_move_n(*array, index, new_array); if (index < new_array_num) { @@ -913,12 +913,12 @@ static float2 get_frame_range_of_fcurves(Span fcurves, Layer *Layer::duplicate_with_shallow_strip_copies(const StringRefNull allocation_name) const { - ActionLayer *copy = MEM_cnew(allocation_name.c_str()); + ActionLayer *copy = MEM_callocN(allocation_name.c_str()); *copy = *reinterpret_cast(this); /* Make a shallow copy of the Strips, without copying their data. */ - copy->strip_array = MEM_cnew_array(this->strip_array_num, - allocation_name.c_str()); + copy->strip_array = MEM_calloc_arrayN(this->strip_array_num, + allocation_name.c_str()); for (int i : this->strips().index_range()) { Strip *strip_copy = MEM_new(allocation_name.c_str(), *this->strip(i)); copy->strip_array[i] = strip_copy; @@ -1634,7 +1634,7 @@ std::optional> get_action_slot_pair(ID &animated_id) Strip &Strip::create(Action &owning_action, const Strip::Type type) { /* Create the strip. */ - ActionStrip *strip = MEM_cnew(__func__); + ActionStrip *strip = MEM_callocN(__func__); memcpy(strip, DNA_struct_default_get(ActionStrip), sizeof(*strip)); strip->strip_type = int8_t(type); @@ -1712,8 +1712,8 @@ StripKeyframeData::StripKeyframeData(const StripKeyframeData &other) { memcpy(this, &other, sizeof(*this)); - this->channelbag_array = MEM_cnew_array(other.channelbag_array_num, - __func__); + this->channelbag_array = MEM_calloc_arrayN(other.channelbag_array_num, + __func__); Span channelbags_src = other.channelbags(); for (int i : channelbags_src.index_range()) { this->channelbag_array[i] = MEM_new(__func__, *other.channelbag(i)); @@ -2138,14 +2138,14 @@ Channelbag::Channelbag(const Channelbag &other) this->slot_handle = other.slot_handle; this->fcurve_array_num = other.fcurve_array_num; - this->fcurve_array = MEM_cnew_array(other.fcurve_array_num, __func__); + this->fcurve_array = MEM_calloc_arrayN(other.fcurve_array_num, __func__); for (int i = 0; i < other.fcurve_array_num; i++) { const FCurve *fcu_src = other.fcurve_array[i]; this->fcurve_array[i] = BKE_fcurve_copy(fcu_src); } this->group_array_num = other.group_array_num; - this->group_array = MEM_cnew_array(other.group_array_num, __func__); + this->group_array = MEM_calloc_arrayN(other.group_array_num, __func__); for (int i = 0; i < other.group_array_num; i++) { const bActionGroup *group_src = other.group_array[i]; this->group_array[i] = static_cast(MEM_dupallocN(group_src)); @@ -3032,7 +3032,7 @@ Action *convert_to_layered_action(Main &bmain, const Action &legacy_action) Channelbag *bag = &strip.data(converted_action).channelbag_for_slot_add(slot); const int fcu_count = BLI_listbase_count(&legacy_action.curves); - bag->fcurve_array = MEM_cnew_array(fcu_count, "Convert to layered action"); + bag->fcurve_array = MEM_calloc_arrayN(fcu_count, "Convert to layered action"); bag->fcurve_array_num = fcu_count; int i = 0; diff --git a/source/blender/animrig/intern/action_test.cc b/source/blender/animrig/intern/action_test.cc index 1261933664e..5a3fd2f3c95 100644 --- a/source/blender/animrig/intern/action_test.cc +++ b/source/blender/animrig/intern/action_test.cc @@ -1253,7 +1253,7 @@ TEST_F(ActionLayersTest, action_move_slot) /* Allocate fcu->bezt, and also return a unique_ptr to it for easily freeing the memory. */ static void allocate_keyframes(FCurve &fcu, const size_t num_keyframes) { - fcu.bezt = MEM_cnew_array(num_keyframes, __func__); + fcu.bezt = MEM_calloc_arrayN(num_keyframes, __func__); } /* Append keyframe, assumes that fcu->bezt is allocated and has enough space. */ @@ -1328,7 +1328,7 @@ TEST_F(ActionQueryTest, BKE_action_frame_range_calc) /* One curve with one key. */ { - FCurve &fcu = *MEM_cnew(__func__); + FCurve &fcu = *MEM_callocN(__func__); allocate_keyframes(fcu, 1); add_keyframe(fcu, 1.0f, 2.0f); @@ -1342,8 +1342,8 @@ TEST_F(ActionQueryTest, BKE_action_frame_range_calc) /* Two curves with one key each on different frames. */ { - FCurve &fcu1 = *MEM_cnew(__func__); - FCurve &fcu2 = *MEM_cnew(__func__); + FCurve &fcu1 = *MEM_callocN(__func__); + FCurve &fcu2 = *MEM_callocN(__func__); allocate_keyframes(fcu1, 1); allocate_keyframes(fcu2, 1); add_keyframe(fcu1, 1.0f, 2.0f); @@ -1360,7 +1360,7 @@ TEST_F(ActionQueryTest, BKE_action_frame_range_calc) /* One curve with two keys. */ { - FCurve &fcu = *MEM_cnew(__func__); + FCurve &fcu = *MEM_callocN(__func__); allocate_keyframes(fcu, 2); add_keyframe(fcu, 1.0f, 2.0f); add_keyframe(fcu, 1.5f, 2.0f); diff --git a/source/blender/animrig/intern/bone_collections.cc b/source/blender/animrig/intern/bone_collections.cc index e1b6ad635dc..7b7e1a075ef 100644 --- a/source/blender/animrig/intern/bone_collections.cc +++ b/source/blender/animrig/intern/bone_collections.cc @@ -58,7 +58,7 @@ BoneCollection *ANIM_bonecoll_new(const char *name) /* NOTE: the collection name may change after the collection is added to an * armature, to ensure it is unique within the armature. */ - BoneCollection *bcoll = MEM_cnew(__func__); + BoneCollection *bcoll = MEM_callocN(__func__); STRNCPY_UTF8(bcoll->name, name); bcoll->flags = default_flags; @@ -87,7 +87,7 @@ void ANIM_bonecoll_free(BoneCollection *bcoll, const bool do_id_user_count) static void add_reverse_pointers(BoneCollection *bcoll) { LISTBASE_FOREACH (BoneCollectionMember *, member, &bcoll->bones) { - BoneCollectionReference *ref = MEM_cnew(__func__); + BoneCollectionReference *ref = MEM_callocN(__func__); ref->bcoll = bcoll; BLI_addtail(&member->bone->runtime.collections, ref); } @@ -866,14 +866,14 @@ void ANIM_armature_bonecoll_is_expanded_set(BoneCollection *bcoll, bool is_expan /* Store the bone's membership on the collection. */ static void add_membership(BoneCollection *bcoll, Bone *bone) { - BoneCollectionMember *member = MEM_cnew(__func__); + BoneCollectionMember *member = MEM_callocN(__func__); member->bone = bone; BLI_addtail(&bcoll->bones, member); } /* Store reverse membership on the bone. */ static void add_reference(Bone *bone, BoneCollection *bcoll) { - BoneCollectionReference *ref = MEM_cnew(__func__); + BoneCollectionReference *ref = MEM_callocN(__func__); ref->bcoll = bcoll; BLI_addtail(&bone->runtime.collections, ref); } @@ -905,7 +905,7 @@ bool ANIM_armature_bonecoll_assign_editbone(BoneCollection *bcoll, EditBone *ebo /* Store membership on the edit bone. Bones will be rebuilt when the armature * goes out of edit mode, and by then the newly created bones will be added to * the actual collection on the Armature. */ - BoneCollectionReference *ref = MEM_cnew(__func__); + BoneCollectionReference *ref = MEM_callocN(__func__); ref->bcoll = bcoll; BLI_addtail(&ebone->bone_collections, ref); diff --git a/source/blender/animrig/intern/versioning.cc b/source/blender/animrig/intern/versioning.cc index 90ad814720f..9f916ce14ab 100644 --- a/source/blender/animrig/intern/versioning.cc +++ b/source/blender/animrig/intern/versioning.cc @@ -115,9 +115,9 @@ void convert_legacy_animato_action(bAction &dna_action) Channelbag &bag = strip.data(action).channelbag_for_slot_ensure(slot); const int fcu_count = BLI_listbase_count(&action.curves); const int group_count = BLI_listbase_count(&action.groups); - bag.fcurve_array = MEM_cnew_array(fcu_count, "Action versioning - fcurves"); + bag.fcurve_array = MEM_calloc_arrayN(fcu_count, "Action versioning - fcurves"); bag.fcurve_array_num = fcu_count; - bag.group_array = MEM_cnew_array(group_count, "Action versioning - groups"); + bag.group_array = MEM_calloc_arrayN(group_count, "Action versioning - groups"); bag.group_array_num = group_count; int group_index = 0; diff --git a/source/blender/blenkernel/intern/action.cc b/source/blender/blenkernel/intern/action.cc index 91f2a5750f3..6420eb74cf7 100644 --- a/source/blender/blenkernel/intern/action.cc +++ b/source/blender/blenkernel/intern/action.cc @@ -176,13 +176,13 @@ static void action_copy_data(Main * /*bmain*/, action_dst.last_slot_handle = action_src.last_slot_handle; /* Layers, and (recursively) Strips. */ - action_dst.layer_array = MEM_cnew_array(action_src.layer_array_num, __func__); + action_dst.layer_array = MEM_calloc_arrayN(action_src.layer_array_num, __func__); for (int i : action_src.layers().index_range()) { action_dst.layer_array[i] = action_src.layer(i)->duplicate_with_shallow_strip_copies(__func__); } /* Strip data. */ - action_dst.strip_keyframe_data_array = MEM_cnew_array( + action_dst.strip_keyframe_data_array = MEM_calloc_arrayN( action_src.strip_keyframe_data_array_num, __func__); for (int i : action_src.strip_keyframe_data().index_range()) { action_dst.strip_keyframe_data_array[i] = MEM_new( @@ -190,7 +190,7 @@ static void action_copy_data(Main * /*bmain*/, } /* Slots. */ - action_dst.slot_array = MEM_cnew_array(action_src.slot_array_num, __func__); + action_dst.slot_array = MEM_calloc_arrayN(action_src.slot_array_num, __func__); for (int i : action_src.slots().index_range()) { action_dst.slot_array[i] = MEM_new(__func__, *action_src.slot(i)); } diff --git a/source/blender/blenkernel/intern/asset_weak_reference.cc b/source/blender/blenkernel/intern/asset_weak_reference.cc index a7a4731df3d..fbf5e0f89ea 100644 --- a/source/blender/blenkernel/intern/asset_weak_reference.cc +++ b/source/blender/blenkernel/intern/asset_weak_reference.cc @@ -137,7 +137,7 @@ ListBase BKE_asset_catalog_path_list_duplicate(const ListBase &catalog_path_list ListBase duplicated_list = {nullptr}; LISTBASE_FOREACH (AssetCatalogPathLink *, catalog_path, &catalog_path_list) { - AssetCatalogPathLink *copied_path = MEM_cnew(__func__); + AssetCatalogPathLink *copied_path = MEM_callocN(__func__); copied_path->path = BLI_strdup(catalog_path->path); BLI_addtail(&duplicated_list, copied_path); @@ -173,7 +173,7 @@ bool BKE_asset_catalog_path_list_has_path(const ListBase &catalog_path_list, void BKE_asset_catalog_path_list_add_path(ListBase &catalog_path_list, const char *catalog_path) { - AssetCatalogPathLink *new_path = MEM_cnew(__func__); + AssetCatalogPathLink *new_path = MEM_callocN(__func__); new_path->path = BLI_strdup(catalog_path); BLI_addtail(&catalog_path_list, new_path); } diff --git a/source/blender/blenkernel/intern/bake_geometry_nodes_modifier_pack.cc b/source/blender/blenkernel/intern/bake_geometry_nodes_modifier_pack.cc index 1b7b336c194..ef8726d086d 100644 --- a/source/blender/blenkernel/intern/bake_geometry_nodes_modifier_pack.cc +++ b/source/blender/blenkernel/intern/bake_geometry_nodes_modifier_pack.cc @@ -60,14 +60,14 @@ NodesModifierPackedBake *pack_bake_from_disk(const BakePath &bake_path, ReportLi const Vector blob_bake_files = pack_files_from_directory( bake_path.blobs_dir, reports); - NodesModifierPackedBake *packed_bake = MEM_cnew(__func__); + NodesModifierPackedBake *packed_bake = MEM_callocN(__func__); packed_bake->meta_files_num = meta_bake_files.size(); packed_bake->blob_files_num = blob_bake_files.size(); - packed_bake->meta_files = MEM_cnew_array(packed_bake->meta_files_num, - __func__); - packed_bake->blob_files = MEM_cnew_array(packed_bake->blob_files_num, - __func__); + packed_bake->meta_files = MEM_calloc_arrayN(packed_bake->meta_files_num, + __func__); + packed_bake->blob_files = MEM_calloc_arrayN(packed_bake->blob_files_num, + __func__); uninitialized_copy_n(meta_bake_files.data(), meta_bake_files.size(), packed_bake->meta_files); uninitialized_copy_n(blob_bake_files.data(), blob_bake_files.size(), packed_bake->blob_files); diff --git a/source/blender/blenkernel/intern/bake_items.cc b/source/blender/blenkernel/intern/bake_items.cc index ee1e548e2f1..1d7c98f77a0 100644 --- a/source/blender/blenkernel/intern/bake_items.cc +++ b/source/blender/blenkernel/intern/bake_items.cc @@ -111,7 +111,7 @@ static void restore_materials(Material ***materials, } BLI_assert(*materials == nullptr); *materials_num = materials_list->size(); - *materials = MEM_cnew_array(materials_list->size(), __func__); + *materials = MEM_calloc_arrayN(materials_list->size(), __func__); if (!data_block_map) { return; } diff --git a/source/blender/blenkernel/intern/bake_items_serialize.cc b/source/blender/blenkernel/intern/bake_items_serialize.cc index f357a09f627..2a9aa49919d 100644 --- a/source/blender/blenkernel/intern/bake_items_serialize.cc +++ b/source/blender/blenkernel/intern/bake_items_serialize.cc @@ -865,7 +865,7 @@ static Mesh *try_load_mesh(const DictionaryValue &io_geometry, if (value->type() != io::serialize::eValueType::String) { return cancel(); } - bDeformGroup *defgroup = MEM_cnew(__func__); + bDeformGroup *defgroup = MEM_callocN(__func__); STRNCPY(defgroup->name, value->as_string_value()->value().c_str()); BLI_addtail(&mesh->vertex_group_names, defgroup); } diff --git a/source/blender/blenkernel/intern/blender_undo.cc b/source/blender/blenkernel/intern/blender_undo.cc index b56cfa23a74..ed318da43a5 100644 --- a/source/blender/blenkernel/intern/blender_undo.cc +++ b/source/blender/blenkernel/intern/blender_undo.cc @@ -98,7 +98,7 @@ bool BKE_memfile_undo_decode(MemFileUndoData *mfu, MemFileUndoData *BKE_memfile_undo_encode(Main *bmain, MemFileUndoData *mfu_prev) { - MemFileUndoData *mfu = MEM_cnew(__func__); + MemFileUndoData *mfu = MEM_callocN(__func__); /* This flag used to be set because the undo step was written as #BLENDER_QUIT_FILE. It's not * clear whether there are still good reasons to keep it. Undo can also be thought of as a kind diff --git a/source/blender/blenkernel/intern/blendfile.cc b/source/blender/blenkernel/intern/blendfile.cc index fe53891e538..b1ae813493e 100644 --- a/source/blender/blenkernel/intern/blendfile.cc +++ b/source/blender/blenkernel/intern/blendfile.cc @@ -1576,7 +1576,7 @@ UserDef *BKE_blendfile_userdef_from_defaults() bool BKE_blendfile_userdef_write(const char *filepath, ReportList *reports) { - Main *mainb = MEM_cnew
("empty main"); + Main *mainb = MEM_callocN
("empty main"); bool ok = false; BlendFileWriteParams params{}; @@ -1707,7 +1707,7 @@ WorkspaceConfigFileData *BKE_blendfile_workspace_config_read(const char *filepat } if (bfd) { - workspace_config = MEM_cnew(__func__); + workspace_config = MEM_callocN(__func__); workspace_config->main = bfd->main; /* Only 2.80+ files have actual workspaces, don't try to use screens diff --git a/source/blender/blenkernel/intern/brush.cc b/source/blender/blenkernel/intern/brush.cc index 652358a7e00..e6a7be79b3f 100644 --- a/source/blender/blenkernel/intern/brush.cc +++ b/source/blender/blenkernel/intern/brush.cc @@ -84,8 +84,8 @@ static void brush_copy_data(Main * /*bmain*/, brush_dst->automasking_cavity_curve = BKE_curvemapping_copy(brush_src->automasking_cavity_curve); if (brush_src->gpencil_settings != nullptr) { - brush_dst->gpencil_settings = MEM_cnew(__func__, - *(brush_src->gpencil_settings)); + brush_dst->gpencil_settings = MEM_dupallocN( + __func__, *(brush_src->gpencil_settings)); brush_dst->gpencil_settings->curve_sensitivity = BKE_curvemapping_copy( brush_src->gpencil_settings->curve_sensitivity); brush_dst->gpencil_settings->curve_strength = BKE_curvemapping_copy( @@ -107,7 +107,7 @@ static void brush_copy_data(Main * /*bmain*/, brush_src->gpencil_settings->curve_rand_value); } if (brush_src->curves_sculpt_settings != nullptr) { - brush_dst->curves_sculpt_settings = MEM_cnew( + brush_dst->curves_sculpt_settings = MEM_dupallocN( __func__, *(brush_src->curves_sculpt_settings)); brush_dst->curves_sculpt_settings->curve_parameter_falloff = BKE_curvemapping_copy( brush_src->curves_sculpt_settings->curve_parameter_falloff); @@ -548,7 +548,7 @@ Brush *BKE_brush_add(Main *bmain, const char *name, const eObjectMode ob_mode) void BKE_brush_init_gpencil_settings(Brush *brush) { if (brush->gpencil_settings == nullptr) { - brush->gpencil_settings = MEM_cnew("BrushGpencilSettings"); + brush->gpencil_settings = MEM_callocN("BrushGpencilSettings"); } brush->gpencil_settings->draw_smoothlvl = 1; @@ -590,7 +590,7 @@ bool BKE_brush_delete(Main *bmain, Brush *brush) void BKE_brush_init_curves_sculpt_settings(Brush *brush) { if (brush->curves_sculpt_settings == nullptr) { - brush->curves_sculpt_settings = MEM_cnew(__func__); + brush->curves_sculpt_settings = MEM_callocN(__func__); } BrushCurvesSculptSettings *settings = brush->curves_sculpt_settings; settings->flag = BRUSH_CURVES_SCULPT_FLAG_INTERPOLATE_RADIUS; @@ -1468,7 +1468,7 @@ static bool brush_gen_texture(const Brush *br, ImBuf *BKE_brush_gen_radial_control_imbuf(Brush *br, bool secondary, bool display_gradient) { - ImBuf *im = MEM_cnew("radial control texture"); + ImBuf *im = MEM_callocN("radial control texture"); int side = 512; int half = side / 2; diff --git a/source/blender/blenkernel/intern/cloth.cc b/source/blender/blenkernel/intern/cloth.cc index 236b7cc26f1..0b7801552b9 100644 --- a/source/blender/blenkernel/intern/cloth.cc +++ b/source/blender/blenkernel/intern/cloth.cc @@ -832,7 +832,8 @@ static void cloth_from_mesh(ClothModifierData *clmd, const Object *ob, Mesh *mes /* Allocate our vertices. */ clmd->clothObject->mvert_num = mvert_num; - clmd->clothObject->verts = MEM_cnew_array(clmd->clothObject->mvert_num, __func__); + clmd->clothObject->verts = MEM_calloc_arrayN(clmd->clothObject->mvert_num, + __func__); if (clmd->clothObject->verts == nullptr) { cloth_free_modifier(clmd); BKE_modifier_set_error(ob, &(clmd->modifier), "Out of memory on allocating vertices"); diff --git a/source/blender/blenkernel/intern/collection.cc b/source/blender/blenkernel/intern/collection.cc index 9d9c80d700f..fdfc7091bbc 100644 --- a/source/blender/blenkernel/intern/collection.cc +++ b/source/blender/blenkernel/intern/collection.cc @@ -1453,7 +1453,7 @@ static bool collection_object_remove( static void collection_exporter_copy(Collection *collection, CollectionExport *data) { - CollectionExport *new_data = MEM_cnew("CollectionExport"); + CollectionExport *new_data = MEM_callocN("CollectionExport"); STRNCPY(new_data->fh_idname, data->fh_idname); new_data->export_properties = IDP_CopyProperty(data->export_properties); new_data->flag = data->flag; diff --git a/source/blender/blenkernel/intern/collision.cc b/source/blender/blenkernel/intern/collision.cc index 2ecec439057..ed18351a71b 100644 --- a/source/blender/blenkernel/intern/collision.cc +++ b/source/blender/blenkernel/intern/collision.cc @@ -1230,7 +1230,7 @@ static void add_collision_object(ListBase *relations, ModifierData *cmd = BKE_modifiers_findby_type(ob, modifier_type); if (cmd) { - CollisionRelation *relation = MEM_cnew(__func__); + CollisionRelation *relation = MEM_callocN(__func__); relation->ob = ob; BLI_addtail(relations, relation); } @@ -1259,7 +1259,7 @@ ListBase *BKE_collision_relations_create(Depsgraph *depsgraph, const bool for_render = (DEG_get_mode(depsgraph) == DAG_EVAL_RENDER); const int base_flag = (for_render) ? BASE_ENABLED_RENDER : BASE_ENABLED_VIEWPORT; - ListBase *relations = MEM_cnew(__func__); + ListBase *relations = MEM_callocN(__func__); for (; base; base = base->next) { if (base->flag & base_flag) { @@ -1293,7 +1293,7 @@ Object **BKE_collision_objects_create(Depsgraph *depsgraph, int maxnum = BLI_listbase_count(relations); int num = 0; - Object **objects = MEM_cnew_array(maxnum, __func__); + Object **objects = MEM_calloc_arrayN(maxnum, __func__); LISTBASE_FOREACH (CollisionRelation *, relation, relations) { /* Get evaluated object. */ @@ -1347,10 +1347,10 @@ ListBase *BKE_collider_cache_create(Depsgraph *depsgraph, Object *self, Collecti ob, eModifierType_Collision); if (cmd && cmd->bvhtree) { if (cache == nullptr) { - cache = MEM_cnew(__func__); + cache = MEM_callocN(__func__); } - ColliderCache *col = MEM_cnew(__func__); + ColliderCache *col = MEM_callocN(__func__); col->ob = ob; col->collmd = cmd; /* make sure collider is properly set up */ @@ -1577,8 +1577,8 @@ int cloth_bvh_collision( eModifierType_Collision); if (collobjs) { - coll_counts_obj = MEM_cnew_array(numcollobj, "CollCounts"); - overlap_obj = MEM_cnew_array(numcollobj, "BVHOverlap"); + coll_counts_obj = MEM_calloc_arrayN(numcollobj, "CollCounts"); + overlap_obj = MEM_calloc_arrayN(numcollobj, "BVHOverlap"); for (i = 0; i < numcollobj; i++) { Object *collob = collobjs[i]; @@ -1618,7 +1618,7 @@ int cloth_bvh_collision( CollPair **collisions; bool collided = false; - collisions = MEM_cnew_array(numcollobj, "CollPair"); + collisions = MEM_calloc_arrayN(numcollobj, "CollPair"); for (i = 0; i < numcollobj; i++) { Object *collob = collobjs[i]; diff --git a/source/blender/blenkernel/intern/context.cc b/source/blender/blenkernel/intern/context.cc index 5ea4003a781..3d1b4884e32 100644 --- a/source/blender/blenkernel/intern/context.cc +++ b/source/blender/blenkernel/intern/context.cc @@ -103,14 +103,14 @@ struct bContext { bContext *CTX_create() { - bContext *C = MEM_cnew(__func__); + bContext *C = MEM_callocN(__func__); return C; } bContext *CTX_copy(const bContext *C) { - bContext *newC = MEM_cnew(__func__); + bContext *newC = MEM_callocN(__func__); *newC = *C; memset(&newC->wm.operator_poll_msg_dyn_params, 0, sizeof(newC->wm.operator_poll_msg_dyn_params)); @@ -609,7 +609,7 @@ static void data_dir_add(ListBase *lb, const char *member, const bool use_all) return; } - link = MEM_cnew(__func__); + link = MEM_callocN(__func__); link->data = (void *)member; BLI_addtail(lb, link); } diff --git a/source/blender/blenkernel/intern/cryptomatte.cc b/source/blender/blenkernel/intern/cryptomatte.cc index 2d26c7444eb..e89e24b9a16 100644 --- a/source/blender/blenkernel/intern/cryptomatte.cc +++ b/source/blender/blenkernel/intern/cryptomatte.cc @@ -309,13 +309,13 @@ void BKE_cryptomatte_matte_id_to_entries(NodeCryptomatte *node_storage, const ch token = token.substr(first, (last - first + 1)); if (*token.begin() == '<' && *(--token.end()) == '>') { float encoded_hash = atof(token.substr(1, token.length() - 2).c_str()); - entry = MEM_cnew(__func__); + entry = MEM_callocN(__func__); entry->encoded_hash = encoded_hash; } else { const char *name = token.c_str(); int name_len = token.length(); - entry = MEM_cnew(__func__); + entry = MEM_callocN(__func__); STRNCPY(entry->name, name); uint32_t hash = BKE_cryptomatte_hash(name, name_len); entry->encoded_hash = BKE_cryptomatte_hash_to_float(hash); diff --git a/source/blender/blenkernel/intern/curve.cc b/source/blender/blenkernel/intern/curve.cc index 6bc7f97700c..44c28a60c13 100644 --- a/source/blender/blenkernel/intern/curve.cc +++ b/source/blender/blenkernel/intern/curve.cc @@ -2609,7 +2609,7 @@ void BKE_curve_bevelList_make(Object *ob, const ListBase *nurbs, const bool for_ if (nu->type == CU_POLY) { len = nu->pntsu; - BevList *bl = MEM_cnew(__func__); + BevList *bl = MEM_callocN(__func__); bl->bevpoints = (BevPoint *)MEM_calloc_arrayN(len, sizeof(BevPoint), __func__); if (need_seglen && (nu->flagu & CU_NURB_CYCLIC) == 0) { bl->seglen = (float *)MEM_malloc_arrayN(segcount, sizeof(float), __func__); @@ -2659,7 +2659,7 @@ void BKE_curve_bevelList_make(Object *ob, const ListBase *nurbs, const bool for_ /* in case last point is not cyclic */ len = segcount * resolu + 1; - BevList *bl = MEM_cnew(__func__); + BevList *bl = MEM_callocN(__func__); bl->bevpoints = (BevPoint *)MEM_calloc_arrayN(len, sizeof(BevPoint), __func__); if (need_seglen && (nu->flagu & CU_NURB_CYCLIC) == 0) { bl->seglen = (float *)MEM_malloc_arrayN(segcount, sizeof(float), __func__); @@ -2795,7 +2795,7 @@ void BKE_curve_bevelList_make(Object *ob, const ListBase *nurbs, const bool for_ if (nu->pntsv == 1) { len = (resolu * segcount); - BevList *bl = MEM_cnew(__func__); + BevList *bl = MEM_callocN(__func__); bl->bevpoints = (BevPoint *)MEM_calloc_arrayN(len, sizeof(BevPoint), __func__); if (need_seglen && (nu->flagu & CU_NURB_CYCLIC) == 0) { bl->seglen = (float *)MEM_malloc_arrayN(segcount, sizeof(float), __func__); diff --git a/source/blender/blenkernel/intern/curveprofile.cc b/source/blender/blenkernel/intern/curveprofile.cc index c1e7caa90e3..1b6b3869ccd 100644 --- a/source/blender/blenkernel/intern/curveprofile.cc +++ b/source/blender/blenkernel/intern/curveprofile.cc @@ -32,7 +32,7 @@ CurveProfile *BKE_curveprofile_add(eCurveProfilePresets preset) { - CurveProfile *profile = MEM_cnew(__func__); + CurveProfile *profile = MEM_callocN(__func__); BKE_curveprofile_set_defaults(profile); profile->preset = preset; diff --git a/source/blender/blenkernel/intern/customdata.cc b/source/blender/blenkernel/intern/customdata.cc index 7a93a07ee0e..c795f051c59 100644 --- a/source/blender/blenkernel/intern/customdata.cc +++ b/source/blender/blenkernel/intern/customdata.cc @@ -4816,7 +4816,7 @@ void CustomData_external_add(CustomData *data, } if (!external) { - external = MEM_cnew(__func__); + external = MEM_callocN(__func__); data->external = external; } STRNCPY(external->filepath, filepath); diff --git a/source/blender/blenkernel/intern/data_transfer.cc b/source/blender/blenkernel/intern/data_transfer.cc index 32a2f79adc9..8ef4f9e06d2 100644 --- a/source/blender/blenkernel/intern/data_transfer.cc +++ b/source/blender/blenkernel/intern/data_transfer.cc @@ -468,7 +468,7 @@ void data_transfer_layersmapping_add_item(ListBase *r_map, cd_datatransfer_interp interp, void *interp_data) { - CustomDataTransferLayerMap *item = MEM_cnew(__func__); + CustomDataTransferLayerMap *item = MEM_callocN(__func__); BLI_assert(data_dst != nullptr); diff --git a/source/blender/blenkernel/intern/deform.cc b/source/blender/blenkernel/intern/deform.cc index 9f5d9941118..c0fc82a7fd1 100644 --- a/source/blender/blenkernel/intern/deform.cc +++ b/source/blender/blenkernel/intern/deform.cc @@ -49,7 +49,7 @@ bDeformGroup *BKE_object_defgroup_new(Object *ob, const StringRef name) BLI_assert(OB_TYPE_SUPPORT_VGROUP(ob->type)); - defgroup = MEM_cnew(__func__); + defgroup = MEM_callocN(__func__); name.copy_utf8_truncated(defgroup->name); @@ -84,7 +84,7 @@ bDeformGroup *BKE_defgroup_duplicate(const bDeformGroup *ingroup) return nullptr; } - bDeformGroup *outgroup = MEM_cnew(__func__); + bDeformGroup *outgroup = MEM_callocN(__func__); /* For now, just copy everything over. */ memcpy(outgroup, ingroup, sizeof(bDeformGroup)); diff --git a/source/blender/blenkernel/intern/displist.cc b/source/blender/blenkernel/intern/displist.cc index 6f9ca84dbd5..5bd1fb5c474 100644 --- a/source/blender/blenkernel/intern/displist.cc +++ b/source/blender/blenkernel/intern/displist.cc @@ -165,7 +165,7 @@ static void curve_to_displist(const Curve *cu, * and resolution > 1. */ const bool use_cyclic_sample = is_cyclic && (samples_len != 2); - DispList *dl = MEM_cnew(__func__); + DispList *dl = MEM_callocN(__func__); /* Add one to the length because of 'BKE_curve_forward_diff_bezier'. */ dl->verts = (float *)MEM_mallocN(sizeof(float[3]) * (samples_len + 1), __func__); BLI_addtail(r_dispbase, dl); @@ -220,7 +220,7 @@ static void curve_to_displist(const Curve *cu, } else if (nu->type == CU_NURBS) { const int len = (resolution * SEGMENTSU(nu)); - DispList *dl = MEM_cnew(__func__); + DispList *dl = MEM_callocN(__func__); dl->verts = (float *)MEM_mallocN(len * sizeof(float[3]), __func__); BLI_addtail(r_dispbase, dl); dl->parts = 1; @@ -233,7 +233,7 @@ static void curve_to_displist(const Curve *cu, } else if (nu->type == CU_POLY) { const int len = nu->pntsu; - DispList *dl = MEM_cnew(__func__); + DispList *dl = MEM_callocN(__func__); dl->verts = (float *)MEM_mallocN(len * sizeof(float[3]), __func__); BLI_addtail(r_dispbase, dl); dl->parts = 1; @@ -324,7 +324,7 @@ void BKE_displist_fill(const ListBase *dispbase, const int triangles_len = BLI_scanfill_calc_ex(&sf_ctx, scanfill_flag, normal_proj); if (totvert != 0 && triangles_len != 0) { - DispList *dlnew = MEM_cnew(__func__); + DispList *dlnew = MEM_callocN(__func__); dlnew->type = DL_INDEX3; dlnew->flag = (dl_flag_accum & (DL_BACK_CURVE | DL_FRONT_CURVE)); dlnew->rt = (dl_rt_accum & CU_SMOOTH); @@ -379,7 +379,7 @@ static void bevels_to_filledpoly(const Curve *cu, ListBase *dispbase) if (dl->type == DL_SURF) { if ((dl->flag & DL_CYCL_V) && (dl->flag & DL_CYCL_U) == 0) { if ((cu->flag & CU_BACK) && (dl->flag & DL_BACK_CURVE)) { - DispList *dlnew = MEM_cnew(__func__); + DispList *dlnew = MEM_callocN(__func__); BLI_addtail(&front, dlnew); dlnew->verts = (float *)MEM_mallocN(sizeof(float[3]) * dl->parts, __func__); dlnew->nr = dl->parts; @@ -398,7 +398,7 @@ static void bevels_to_filledpoly(const Curve *cu, ListBase *dispbase) } } if ((cu->flag & CU_FRONT) && (dl->flag & DL_FRONT_CURVE)) { - DispList *dlnew = MEM_cnew(__func__); + DispList *dlnew = MEM_callocN(__func__); BLI_addtail(&back, dlnew); dlnew->verts = (float *)MEM_mallocN(sizeof(float[3]) * dl->parts, __func__); dlnew->nr = dl->parts; @@ -820,7 +820,7 @@ static blender::bke::GeometrySet evaluate_surface_object(Depsgraph *depsgraph, if (nu->pntsv == 1) { const int len = SEGMENTSU(nu) * resolu; - DispList *dl = MEM_cnew(__func__); + DispList *dl = MEM_callocN(__func__); dl->verts = (float *)MEM_mallocN(len * sizeof(float[3]), __func__); BLI_addtail(r_dispbase, dl); @@ -843,7 +843,7 @@ static blender::bke::GeometrySet evaluate_surface_object(Depsgraph *depsgraph, else { const int len = (nu->pntsu * resolu) * (nu->pntsv * resolv); - DispList *dl = MEM_cnew(__func__); + DispList *dl = MEM_callocN(__func__); dl->verts = (float *)MEM_mallocN(len * sizeof(float[3]), __func__); BLI_addtail(r_dispbase, dl); @@ -945,7 +945,7 @@ static void fillBevelCap(const Nurb *nu, const float *prev_fp, ListBase *dispbase) { - DispList *dl = MEM_cnew(__func__); + DispList *dl = MEM_callocN(__func__); dl->verts = (float *)MEM_mallocN(sizeof(float[3]) * dlb->nr, __func__); memcpy(dl->verts, prev_fp, sizeof(float[3]) * dlb->nr); @@ -1147,7 +1147,7 @@ static blender::bke::GeometrySet evaluate_curve_type_object(Depsgraph *depsgraph /* exception handling; curve without bevel or extrude, with width correction */ if (BLI_listbase_is_empty(&dlbev)) { - DispList *dl = MEM_cnew("makeDispListbev"); + DispList *dl = MEM_callocN("makeDispListbev"); dl->verts = (float *)MEM_mallocN(sizeof(float[3]) * bl->nr, "dlverts"); BLI_addtail(r_dispbase, dl); @@ -1197,7 +1197,7 @@ static blender::bke::GeometrySet evaluate_curve_type_object(Depsgraph *depsgraph LISTBASE_FOREACH (DispList *, dlb, &dlbev) { /* For each part of the bevel use a separate display-block. */ - DispList *dl = MEM_cnew(__func__); + DispList *dl = MEM_callocN(__func__); dl->verts = data = (float *)MEM_mallocN(sizeof(float[3]) * dlb->nr * steps, __func__); BLI_addtail(r_dispbase, dl); @@ -1323,7 +1323,7 @@ void BKE_displist_make_curveTypes(Depsgraph *depsgraph, * which may reset the object data pointer in some cases. */ const Curve &original_curve = *static_cast(ob->data); - ob->runtime->curve_cache = MEM_cnew(__func__); + ob->runtime->curve_cache = MEM_callocN(__func__); ListBase *dispbase = &ob->runtime->curve_cache->disp; if (ob->type == OB_SURF) { diff --git a/source/blender/blenkernel/intern/dynamicpaint.cc b/source/blender/blenkernel/intern/dynamicpaint.cc index 171b53c3e84..764eb475cba 100644 --- a/source/blender/blenkernel/intern/dynamicpaint.cc +++ b/source/blender/blenkernel/intern/dynamicpaint.cc @@ -742,7 +742,7 @@ static void surfaceGenerateGrid(DynamicPaintSurface *surface) freeGrid(sData); } - bData->grid = MEM_cnew(__func__); + bData->grid = MEM_callocN(__func__); grid = bData->grid; { @@ -1036,7 +1036,7 @@ void dynamicPaint_Modifier_free(DynamicPaintModifierData *pmd) DynamicPaintSurface *dynamicPaint_createNewSurface(DynamicPaintCanvasSettings *canvas, Scene *scene) { - DynamicPaintSurface *surface = MEM_cnew(__func__); + DynamicPaintSurface *surface = MEM_callocN(__func__); if (!surface) { return nullptr; } @@ -1119,7 +1119,7 @@ bool dynamicPaint_createType(DynamicPaintModifierData *pmd, int type, Scene *sce dynamicPaint_freeCanvas(pmd); } - canvas = pmd->canvas = MEM_cnew(__func__); + canvas = pmd->canvas = MEM_callocN(__func__); if (!canvas) { return false; } @@ -1136,7 +1136,7 @@ bool dynamicPaint_createType(DynamicPaintModifierData *pmd, int type, Scene *sce dynamicPaint_freeBrush(pmd); } - brush = pmd->brush = MEM_cnew(__func__); + brush = pmd->brush = MEM_callocN(__func__); if (!brush) { return false; } @@ -1402,7 +1402,7 @@ static void dynamicPaint_initAdjacencyData(DynamicPaintSurface *surface, const b } /* allocate memory */ - ad = sData->adj_data = MEM_cnew(__func__); + ad = sData->adj_data = MEM_callocN(__func__); if (!ad) { return; } @@ -1765,7 +1765,7 @@ bool dynamicPaint_resetSurface(const Scene *scene, DynamicPaintSurface *surface) } /* allocate memory */ - surface->data = MEM_cnew(__func__); + surface->data = MEM_callocN(__func__); if (!surface->data) { return false; } @@ -2879,7 +2879,7 @@ int dynamicPaint_createUVSurface(Scene *scene, if (surface->data) { dynamicPaint_freeSurfaceData(surface); } - sData = surface->data = MEM_cnew(__func__); + sData = surface->data = MEM_callocN(__func__); if (!surface->data) { return setError(canvas, N_("Not enough free memory")); } @@ -3106,7 +3106,7 @@ int dynamicPaint_createUVSurface(Scene *scene, *do_update = true; /* Create final surface data without inactive points */ - ImgSeqFormatData *f_data = MEM_cnew(__func__); + ImgSeqFormatData *f_data = MEM_callocN(__func__); if (f_data) { f_data->uv_p = static_cast( MEM_callocN(active_points * sizeof(*f_data->uv_p), "PaintUVPoint")); diff --git a/source/blender/blenkernel/intern/fluid.cc b/source/blender/blenkernel/intern/fluid.cc index 2a83523b5c1..e04d7f291c6 100644 --- a/source/blender/blenkernel/intern/fluid.cc +++ b/source/blender/blenkernel/intern/fluid.cc @@ -4420,7 +4420,7 @@ void BKE_fluid_particle_system_create(Main *bmain, /* add particle system */ part = BKE_particlesettings_add(bmain, pset_name); - psys = MEM_cnew(__func__); + psys = MEM_callocN(__func__); part->type = psys_type; part->totpart = 0; diff --git a/source/blender/blenkernel/intern/grease_pencil.cc b/source/blender/blenkernel/intern/grease_pencil.cc index 7fdf8d3bdec..901b36dc929 100644 --- a/source/blender/blenkernel/intern/grease_pencil.cc +++ b/source/blender/blenkernel/intern/grease_pencil.cc @@ -1432,8 +1432,8 @@ void Layer::prepare_for_dna_write() const size_t frames_num = size_t(frames().size()); frames_storage.num = int(frames_num); - frames_storage.keys = MEM_cnew_array(frames_num, __func__); - frames_storage.values = MEM_cnew_array(frames_num, __func__); + frames_storage.keys = MEM_calloc_arrayN(frames_num, __func__); + frames_storage.values = MEM_calloc_arrayN(frames_num, __func__); const Span sorted_keys_data = sorted_keys(); for (const int64_t i : sorted_keys_data.index_range()) { frames_storage.keys[i] = sorted_keys_data[i]; @@ -2300,7 +2300,7 @@ void BKE_grease_pencil_duplicate_drawing_array(const GreasePencil *grease_pencil using namespace blender; grease_pencil_dst->drawing_array_num = grease_pencil_src->drawing_array_num; if (grease_pencil_dst->drawing_array_num > 0) { - grease_pencil_dst->drawing_array = MEM_cnew_array( + grease_pencil_dst->drawing_array = MEM_calloc_arrayN( grease_pencil_src->drawing_array_num, __func__); bke::greasepencil::copy_drawing_array(grease_pencil_src->drawings(), grease_pencil_dst->drawings()); @@ -2697,7 +2697,7 @@ template static void grow_array(T **array, int *num, const int add_n { BLI_assert(add_num > 0); const int new_array_num = *num + add_num; - T *new_array = MEM_cnew_array(new_array_num, __func__); + T *new_array = MEM_calloc_arrayN(new_array_num, __func__); blender::uninitialized_relocate_n(*array, *num, new_array); if (*array != nullptr) { @@ -2718,7 +2718,7 @@ template static void shrink_array(T **array, int *num, const int shr return; } - T *new_array = MEM_cnew_array(new_array_num, __func__); + T *new_array = MEM_calloc_arrayN(new_array_num, __func__); blender::uninitialized_move_n(*array, new_array_num, new_array); MEM_freeN(*array); diff --git a/source/blender/blenkernel/intern/grease_pencil_convert_legacy.cc b/source/blender/blenkernel/intern/grease_pencil_convert_legacy.cc index 81443f64a89..784c4d71762 100644 --- a/source/blender/blenkernel/intern/grease_pencil_convert_legacy.cc +++ b/source/blender/blenkernel/intern/grease_pencil_convert_legacy.cc @@ -1191,7 +1191,7 @@ static bNodeTree *offset_radius_node_tree_add(ConversionData &conversion_data, L &conversion_data.bmain, library, OFFSET_RADIUS_NODETREE_NAME, "GeometryNodeTree"); if (!group->geometry_node_asset_traits) { - group->geometry_node_asset_traits = MEM_cnew(__func__); + group->geometry_node_asset_traits = MEM_callocN(__func__); } group->geometry_node_asset_traits->flag |= GEO_NODE_ASSET_MODIFIER; @@ -1769,7 +1769,7 @@ static void legacy_object_modifier_dash(ConversionData &conversion_data, md_dash.segment_active_index = legacy_md_dash.segment_active_index; md_dash.segments_num = legacy_md_dash.segments_len; MEM_SAFE_FREE(md_dash.segments_array); - md_dash.segments_array = MEM_cnew_array( + md_dash.segments_array = MEM_calloc_arrayN( legacy_md_dash.segments_len, __func__); for (const int i : IndexRange(md_dash.segments_num)) { GreasePencilDashModifierSegment &dst_segment = md_dash.segments_array[i]; @@ -2481,7 +2481,7 @@ static void legacy_object_modifier_time(ConversionData &conversion_data, md_time.segment_active_index = legacy_md_time.segment_active_index; md_time.segments_num = legacy_md_time.segments_len; MEM_SAFE_FREE(md_time.segments_array); - md_time.segments_array = MEM_cnew_array( + md_time.segments_array = MEM_calloc_arrayN( legacy_md_time.segments_len, __func__); for (const int i : IndexRange(md_time.segments_num)) { GreasePencilTimeModifierSegment &dst_segment = md_time.segments_array[i]; diff --git a/source/blender/blenkernel/intern/grease_pencil_vertex_groups.cc b/source/blender/blenkernel/intern/grease_pencil_vertex_groups.cc index 0407b2ce8e4..1dd93aefd9f 100644 --- a/source/blender/blenkernel/intern/grease_pencil_vertex_groups.cc +++ b/source/blender/blenkernel/intern/grease_pencil_vertex_groups.cc @@ -56,7 +56,7 @@ int ensure_vertex_group(const StringRef name, ListBase &vertex_group_names) { int def_nr = BKE_defgroup_name_index(&vertex_group_names, name); if (def_nr < 0) { - bDeformGroup *defgroup = MEM_cnew(__func__); + bDeformGroup *defgroup = MEM_callocN(__func__); name.copy_utf8_truncated(defgroup->name); BLI_addtail(&vertex_group_names, defgroup); def_nr = BLI_listbase_count(&vertex_group_names) - 1; @@ -80,7 +80,7 @@ void assign_to_vertex_group_from_mask(bke::CurvesGeometry &curves, /* Lazily add the vertex group if any vertex is selected. */ if (def_nr < 0) { - bDeformGroup *defgroup = MEM_cnew(__func__); + bDeformGroup *defgroup = MEM_callocN(__func__); name.copy_utf8_truncated(defgroup->name); BLI_addtail(&vertex_group_names, defgroup); def_nr = BLI_listbase_count(&vertex_group_names) - 1; @@ -113,7 +113,7 @@ void assign_to_vertex_group(Drawing &drawing, const StringRef name, const float if (selection[i]) { /* Lazily add the vertex group if any vertex is selected. */ if (def_nr < 0) { - bDeformGroup *defgroup = MEM_cnew(__func__); + bDeformGroup *defgroup = MEM_callocN(__func__); name.copy_utf8_truncated(defgroup->name); BLI_addtail(&vertex_group_names, defgroup); diff --git a/source/blender/blenkernel/intern/image.cc b/source/blender/blenkernel/intern/image.cc index a6967a96fca..061039e02b6 100644 --- a/source/blender/blenkernel/intern/image.cc +++ b/source/blender/blenkernel/intern/image.cc @@ -671,7 +671,7 @@ void BKE_image_free_data(Image *ima) static ImageTile *imagetile_alloc(int tile_number) { - ImageTile *tile = MEM_cnew("Image Tile"); + ImageTile *tile = MEM_callocN("Image Tile"); tile->tile_number = tile_number; tile->gen_x = 1024; tile->gen_y = 1024; @@ -705,7 +705,7 @@ static void image_init(Image *ima, short source, short type) image_runtime_reset(ima); BKE_color_managed_colorspace_settings_init(&ima->colorspace_settings); - ima->stereo3d_format = MEM_cnew("Image Stereo Format"); + ima->stereo3d_format = MEM_callocN("Image Stereo Format"); } static Image *image_alloc(Main *bmain, @@ -2438,7 +2438,7 @@ void BKE_render_result_stamp_info(Scene *scene, } if (!rr->stamp_data) { - stamp_data = MEM_cnew("RenderResult.stamp_data"); + stamp_data = MEM_callocN("RenderResult.stamp_data"); } else { stamp_data = rr->stamp_data; @@ -2463,7 +2463,7 @@ StampData *BKE_stamp_info_from_scene_static(const Scene *scene) /* Memory is allocated here (instead of by the caller) so that the caller * doesn't have to know the size of the StampData struct. */ - stamp_data = MEM_cnew(__func__); + stamp_data = MEM_callocN(__func__); stampdata(scene, nullptr, stamp_data, 0, false); return stamp_data; @@ -2561,7 +2561,7 @@ void BKE_render_result_stamp_data(RenderResult *rr, const char *key, const char { StampData *stamp_data; if (rr->stamp_data == nullptr) { - rr->stamp_data = MEM_cnew("RenderResult.stamp_data"); + rr->stamp_data = MEM_callocN("RenderResult.stamp_data"); } stamp_data = rr->stamp_data; StampDataCustomField *field = static_cast( @@ -2639,7 +2639,7 @@ static void metadata_copy_custom_fields(const char *field, const char *value, vo void BKE_stamp_info_from_imbuf(RenderResult *rr, ImBuf *ibuf) { if (rr->stamp_data == nullptr) { - rr->stamp_data = MEM_cnew("RenderResult.stamp_data"); + rr->stamp_data = MEM_callocN("RenderResult.stamp_data"); } StampData *stamp_data = rr->stamp_data; IMB_metadata_ensure(&ibuf->metadata); @@ -3909,7 +3909,7 @@ static void image_init_multilayer_multiview(Image *ima, RenderResult *rr) if (rr) { LISTBASE_FOREACH (RenderView *, rv, &rr->views) { - ImageView *iv = MEM_cnew("Viewer Image View"); + ImageView *iv = MEM_callocN("Viewer Image View"); STRNCPY(iv->name, rv->name); BLI_addtail(&ima->views, iv); } @@ -4234,7 +4234,7 @@ static ImBuf *image_load_movie_file(Image *ima, ImageUser *iuser, int frame) for (int i = 0; i < tot_viewfiles; i++) { /* allocate the ImageAnim */ - ImageAnim *ia = MEM_cnew("Image Anim"); + ImageAnim *ia = MEM_callocN("Image Anim"); BLI_addtail(&ima->anims, ia); } } @@ -5038,7 +5038,7 @@ struct ImagePool { ImagePool *BKE_image_pool_new() { - ImagePool *pool = MEM_cnew("Image Pool"); + ImagePool *pool = MEM_callocN("Image Pool"); pool->memory_pool = BLI_mempool_create(sizeof(ImagePoolItem), 0, 128, BLI_MEMPOOL_NOP); BLI_mutex_init(&pool->mutex); @@ -5739,7 +5739,7 @@ static void image_update_views_format(Image *ima, ImageUser *iuser) RenderSlot *BKE_image_add_renderslot(Image *ima, const char *name) { - RenderSlot *slot = MEM_cnew("Image new Render Slot"); + RenderSlot *slot = MEM_callocN("Image new Render Slot"); if (name && name[0]) { STRNCPY(slot->name, name); } diff --git a/source/blender/blenkernel/intern/image_gpu.cc b/source/blender/blenkernel/intern/image_gpu.cc index ebfcf96320b..869225b8e0e 100644 --- a/source/blender/blenkernel/intern/image_gpu.cc +++ b/source/blender/blenkernel/intern/image_gpu.cc @@ -147,7 +147,7 @@ static GPUTexture *gpu_texture_create_tile_array(Image *ima, ImBuf *main_ibuf) ImBuf *ibuf = BKE_image_acquire_ibuf(ima, &iuser, nullptr); if (ibuf) { - PackTile *packtile = MEM_cnew(__func__); + PackTile *packtile = MEM_callocN(__func__); packtile->tile = tile; packtile->boxpack.w = ibuf->x; packtile->boxpack.h = ibuf->y; diff --git a/source/blender/blenkernel/intern/key.cc b/source/blender/blenkernel/intern/key.cc index 55fdc2e6032..5480c3d5e3f 100644 --- a/source/blender/blenkernel/intern/key.cc +++ b/source/blender/blenkernel/intern/key.cc @@ -1843,7 +1843,7 @@ KeyBlock *BKE_keyblock_add(Key *key, const char *name) curpos = kb->pos; } - kb = MEM_cnew("Keyblock"); + kb = MEM_callocN("Keyblock"); BLI_addtail(&key->block, kb); kb->type = KEY_LINEAR; diff --git a/source/blender/blenkernel/intern/layer.cc b/source/blender/blenkernel/intern/layer.cc index 208374124de..218e721034b 100644 --- a/source/blender/blenkernel/intern/layer.cc +++ b/source/blender/blenkernel/intern/layer.cc @@ -76,7 +76,7 @@ static void object_bases_iterator_next(BLI_Iterator *iter, const int flag); static LayerCollection *layer_collection_add(ListBase *lb_parent, Collection *collection) { - LayerCollection *lc = MEM_cnew("Collection Base"); + LayerCollection *lc = MEM_callocN("Collection Base"); lc->collection = collection; lc->local_collections_bits = ~(0); BLI_addtail(lb_parent, lc); @@ -99,7 +99,7 @@ static void layer_collection_free(ViewLayer *view_layer, LayerCollection *lc) static Base *object_base_new(Object *ob) { - Base *base = MEM_cnew("Object Base"); + Base *base = MEM_callocN("Object Base"); base->object = ob; base->local_view_bits = ~(0); if (ob->base_flag & BASE_SELECTED) { @@ -163,7 +163,7 @@ static ViewLayer *view_layer_add(const char *name) name = DATA_("ViewLayer"); } - ViewLayer *view_layer = MEM_cnew("View Layer"); + ViewLayer *view_layer = MEM_callocN("View Layer"); view_layer->flag = VIEW_LAYER_RENDER | VIEW_LAYER_FREESTYLE; STRNCPY_UTF8(view_layer->name, name); @@ -210,7 +210,7 @@ ViewLayer *BKE_view_layer_add(Scene *scene, } case VIEWLAYER_ADD_COPY: { /* Allocate and copy view layer data */ - view_layer_new = MEM_cnew("View Layer"); + view_layer_new = MEM_callocN("View Layer"); *view_layer_new = *view_layer_source; BKE_view_layer_copy_data(scene, scene, view_layer_new, view_layer_source, 0); BLI_addtail(&scene->view_layers, view_layer_new); @@ -2068,7 +2068,7 @@ static void object_bases_iterator_begin(BLI_Iterator *iter, void *data_in_v, con return; } - LayerObjectBaseIteratorData *data = MEM_cnew(__func__); + LayerObjectBaseIteratorData *data = MEM_callocN(__func__); iter->data = data; data->v3d = v3d; @@ -2530,7 +2530,7 @@ static void viewlayer_aov_active_set(ViewLayer *view_layer, ViewLayerAOV *aov) ViewLayerAOV *BKE_view_layer_add_aov(ViewLayer *view_layer) { ViewLayerAOV *aov; - aov = MEM_cnew(__func__); + aov = MEM_callocN(__func__); aov->type = AOV_TYPE_COLOR; STRNCPY_UTF8(aov->name, DATA_("AOV")); BLI_addtail(&view_layer->aovs, aov); @@ -2655,7 +2655,7 @@ static void viewlayer_lightgroup_active_set(ViewLayer *view_layer, ViewLayerLigh ViewLayerLightgroup *BKE_view_layer_add_lightgroup(ViewLayer *view_layer, const char *name) { ViewLayerLightgroup *lightgroup; - lightgroup = MEM_cnew(__func__); + lightgroup = MEM_callocN(__func__); STRNCPY_UTF8(lightgroup->name, (name && name[0]) ? name : DATA_("Lightgroup")); BLI_addtail(&view_layer->lightgroups, lightgroup); viewlayer_lightgroup_active_set(view_layer, lightgroup); @@ -2748,7 +2748,7 @@ void BKE_lightgroup_membership_set(LightgroupMembership **lgm, const char *name) { if (name[0] != '\0') { if (*lgm == nullptr) { - *lgm = MEM_cnew(__func__); + *lgm = MEM_callocN(__func__); } BLI_strncpy((*lgm)->name, name, sizeof((*lgm)->name)); } diff --git a/source/blender/blenkernel/intern/lib_override.cc b/source/blender/blenkernel/intern/lib_override.cc index 290fe63f0ec..2502ce4adfd 100644 --- a/source/blender/blenkernel/intern/lib_override.cc +++ b/source/blender/blenkernel/intern/lib_override.cc @@ -104,7 +104,7 @@ BLI_INLINE IDOverrideLibraryRuntime *override_library_runtime_ensure( IDOverrideLibrary *liboverride) { if (liboverride->runtime == nullptr) { - liboverride->runtime = MEM_cnew(__func__); + liboverride->runtime = MEM_callocN(__func__); } return liboverride->runtime; } @@ -168,7 +168,7 @@ IDOverrideLibrary *BKE_lib_override_library_init(ID *local_id, ID *reference_id) BLI_assert(local_id->override_library == nullptr); /* Else, generate new empty override. */ - local_id->override_library = MEM_cnew(__func__); + local_id->override_library = MEM_callocN(__func__); local_id->override_library->reference = reference_id; if (reference_id) { id_us_plus(local_id->override_library->reference); @@ -582,7 +582,7 @@ bool BKE_lib_override_library_create_from_tag(Main *bmain, if ((reference_id->tag & ID_TAG_DOIT) != 0 && reference_id->lib == reference_library && BKE_idtype_idcode_is_linkable(GS(reference_id->name))) { - todo_id_iter = MEM_cnew(__func__); + todo_id_iter = MEM_callocN(__func__); todo_id_iter->data = reference_id; BLI_addtail(&todo_ids, todo_id_iter); } @@ -3266,7 +3266,7 @@ static void lib_override_resync_tagging_finalize(Main *bmain, if (!BLI_ghash_ensure_p( id_roots, hierarchy_root, reinterpret_cast(&id_resync_roots_p))) { - *id_resync_roots_p = MEM_cnew(__func__); + *id_resync_roots_p = MEM_callocN(__func__); } BLI_linklist_append(*id_resync_roots_p, id_iter); } @@ -3906,7 +3906,7 @@ IDOverrideLibraryProperty *BKE_lib_override_library_property_get(IDOverrideLibra IDOverrideLibraryProperty *op = BKE_lib_override_library_property_find(liboverride, rna_path); if (op == nullptr) { - op = MEM_cnew(__func__); + op = MEM_callocN(__func__); op->rna_path = BLI_strdup(rna_path); BLI_addtail(&liboverride->properties, op); @@ -4197,7 +4197,7 @@ IDOverrideLibraryPropertyOperation *BKE_lib_override_library_property_operation_ r_strict); if (opop == nullptr) { - opop = MEM_cnew(__func__); + opop = MEM_callocN(__func__); opop->operation = operation; if (subitem_locname) { opop->subitem_local_name = BLI_strdup(subitem_locname); diff --git a/source/blender/blenkernel/intern/light_linking.cc b/source/blender/blenkernel/intern/light_linking.cc index 0723adc08b0..759d6a19646 100644 --- a/source/blender/blenkernel/intern/light_linking.cc +++ b/source/blender/blenkernel/intern/light_linking.cc @@ -98,7 +98,7 @@ void BKE_light_linking_collection_assign_only(Object *object, /* Allocate light linking on demand. */ if (new_collection && !object->light_linking) { - object->light_linking = MEM_cnew(__func__); + object->light_linking = MEM_callocN(__func__); } if (object->light_linking) { diff --git a/source/blender/blenkernel/intern/main.cc b/source/blender/blenkernel/intern/main.cc index 1a90e058c86..f45db94325e 100644 --- a/source/blender/blenkernel/intern/main.cc +++ b/source/blender/blenkernel/intern/main.cc @@ -775,7 +775,7 @@ void BKE_main_library_weak_reference_add(ID *local_id, const char *library_id_name) { if (local_id->library_weak_reference == nullptr) { - local_id->library_weak_reference = MEM_cnew(__func__); + local_id->library_weak_reference = MEM_callocN(__func__); } STRNCPY(local_id->library_weak_reference->library_filepath, library_filepath); diff --git a/source/blender/blenkernel/intern/mask.cc b/source/blender/blenkernel/intern/mask.cc index 25a56803055..4044008da34 100644 --- a/source/blender/blenkernel/intern/mask.cc +++ b/source/blender/blenkernel/intern/mask.cc @@ -283,7 +283,7 @@ MaskSplinePoint *BKE_mask_spline_point_array_from_point(MaskSpline *spline, MaskLayer *BKE_mask_layer_new(Mask *mask, const char *name) { - MaskLayer *masklay = MEM_cnew(__func__); + MaskLayer *masklay = MEM_callocN(__func__); STRNCPY(masklay->name, name && name[0] ? name : DATA_("MaskLayer")); @@ -347,7 +347,7 @@ void BKE_mask_layer_rename(Mask *mask, MaskLayer *BKE_mask_layer_copy(const MaskLayer *masklay) { - MaskLayer *masklay_new = MEM_cnew("new mask layer"); + MaskLayer *masklay_new = MEM_callocN("new mask layer"); STRNCPY(masklay_new->name, masklay->name); @@ -378,7 +378,7 @@ MaskLayer *BKE_mask_layer_copy(const MaskLayer *masklay) /* correct animation */ if (masklay->splines_shapes.first) { LISTBASE_FOREACH (MaskLayerShape *, masklay_shape, &masklay->splines_shapes) { - MaskLayerShape *masklay_shape_new = MEM_cnew("new mask layer shape"); + MaskLayerShape *masklay_shape_new = MEM_callocN("new mask layer shape"); masklay_shape_new->data = static_cast(MEM_dupallocN(masklay_shape->data)); masklay_shape_new->tot_vert = masklay_shape->tot_vert; @@ -405,12 +405,12 @@ void BKE_mask_layer_copy_list(ListBase *masklayers_new, const ListBase *masklaye MaskSpline *BKE_mask_spline_add(MaskLayer *masklay) { - MaskSpline *spline = MEM_cnew("new mask spline"); + MaskSpline *spline = MEM_callocN("new mask spline"); BLI_addtail(&masklay->splines, spline); /* spline shall have one point at least */ - spline->points = MEM_cnew("new mask spline point"); + spline->points = MEM_callocN("new mask spline point"); spline->tot_point = 1; /* cyclic shapes are more usually used */ @@ -872,7 +872,7 @@ MaskSplinePointUW *BKE_mask_point_sort_uw(MaskSplinePoint *point, MaskSplinePoin void BKE_mask_point_add_uw(MaskSplinePoint *point, float u, float w) { if (!point->uw) { - point->uw = MEM_cnew("mask point uw"); + point->uw = MEM_callocN("mask point uw"); } else { point->uw = static_cast( @@ -1032,7 +1032,7 @@ static MaskSplinePoint *mask_spline_points_copy(const MaskSplinePoint *points, i MaskSpline *BKE_mask_spline_copy(const MaskSpline *spline) { - MaskSpline *nspline = MEM_cnew("new spline"); + MaskSpline *nspline = MEM_callocN("new spline"); *nspline = *spline; @@ -1051,10 +1051,10 @@ MaskLayerShape *BKE_mask_layer_shape_alloc(MaskLayer *masklay, const int frame) MaskLayerShape *masklay_shape; int tot_vert = BKE_mask_layer_shape_totvert(masklay); - masklay_shape = MEM_cnew(__func__); + masklay_shape = MEM_callocN(__func__); masklay_shape->frame = frame; masklay_shape->tot_vert = tot_vert; - masklay_shape->data = MEM_cnew_array(tot_vert * MASK_OBJECT_SHAPE_ELEM_SIZE, __func__); + masklay_shape->data = MEM_calloc_arrayN(tot_vert * MASK_OBJECT_SHAPE_ELEM_SIZE, __func__); return masklay_shape; } @@ -1474,7 +1474,7 @@ void BKE_mask_spline_ensure_deform(MaskSpline *spline) MEM_freeN(spline->points_deform); } - spline->points_deform = MEM_cnew_array(spline->tot_point, __func__); + spline->points_deform = MEM_calloc_arrayN(spline->tot_point, __func__); } else { // printf("alloc spline done\n"); @@ -1849,8 +1849,8 @@ void BKE_mask_layer_shape_changed_add(MaskLayer *masklay, float *data_resized; masklay_shape->tot_vert++; - data_resized = MEM_cnew_array(masklay_shape->tot_vert * MASK_OBJECT_SHAPE_ELEM_SIZE, - __func__); + data_resized = MEM_calloc_arrayN( + masklay_shape->tot_vert * MASK_OBJECT_SHAPE_ELEM_SIZE, __func__); if (index > 0) { memcpy(data_resized, masklay_shape->data, @@ -1909,8 +1909,8 @@ void BKE_mask_layer_shape_changed_remove(MaskLayer *masklay, int index, int coun float *data_resized; masklay_shape->tot_vert -= count; - data_resized = MEM_cnew_array(masklay_shape->tot_vert * MASK_OBJECT_SHAPE_ELEM_SIZE, - __func__); + data_resized = MEM_calloc_arrayN( + masklay_shape->tot_vert * MASK_OBJECT_SHAPE_ELEM_SIZE, __func__); if (index > 0) { memcpy(data_resized, masklay_shape->data, diff --git a/source/blender/blenkernel/intern/mask_evaluate.cc b/source/blender/blenkernel/intern/mask_evaluate.cc index 616cd1d6766..bd9337b7c92 100644 --- a/source/blender/blenkernel/intern/mask_evaluate.cc +++ b/source/blender/blenkernel/intern/mask_evaluate.cc @@ -133,7 +133,7 @@ float (*BKE_mask_spline_differentiate_with_resolution(MaskSpline *spline, /* len+1 because of 'forward_diff_bezier' function */ *r_tot_diff_point = tot; - diff_points = fp = MEM_cnew_array(tot + 1, "mask spline vets"); + diff_points = fp = MEM_calloc_arrayN(tot + 1, "mask spline vets"); a = spline->tot_point - 1; if (spline->flag & MASK_SPLINE_CYCLIC) { @@ -200,7 +200,7 @@ static void feather_bucket_add_edge(FeatherEdgesBucket *bucket, int start, int e if (bucket->tot_segment >= bucket->alloc_segment) { if (!bucket->segments) { - bucket->segments = MEM_cnew_array(alloc_delta, "feather bucket segments"); + bucket->segments = MEM_calloc_arrayN(alloc_delta, "feather bucket segments"); } else { bucket->segments = static_cast(MEM_reallocN( @@ -400,7 +400,7 @@ void BKE_mask_spline_feather_collapse_inner_loops(MaskSpline *spline, bucket_scale[1] = 1.0f / ((max[1] - min[1]) * bucket_size); /* fill in buckets' edges */ - buckets = MEM_cnew_array(tot_bucket, "feather buckets"); + buckets = MEM_calloc_arrayN(tot_bucket, "feather buckets"); for (int i = 0; i < tot_feather_point; i++) { int start = i, end = i + 1; @@ -501,7 +501,7 @@ static float ( int a; /* tot+1 because of 'forward_diff_bezier' function */ - feather = fp = MEM_cnew_array(tot + 1, "mask spline feather diff points"); + feather = fp = MEM_calloc_arrayN(tot + 1, "mask spline feather diff points"); a = spline->tot_point - 1; if (spline->flag & MASK_SPLINE_CYCLIC) { @@ -582,7 +582,7 @@ static float (*mask_spline_feather_differentiated_points_with_resolution__double /* len+1 because of 'forward_diff_bezier' function */ *r_tot_feather_point = tot; - feather = fp = MEM_cnew_array(tot + 1, "mask spline vets"); + feather = fp = MEM_calloc_arrayN(tot + 1, "mask spline vets"); a = spline->tot_point - 1; if (spline->flag & MASK_SPLINE_CYCLIC) { @@ -734,7 +734,7 @@ float (*BKE_mask_spline_feather_points(MaskSpline *spline, int *r_tot_feather_po } /* create data */ - feather = fp = MEM_cnew_array(tot, "mask spline feather points"); + feather = fp = MEM_calloc_arrayN(tot, "mask spline feather points"); for (i = 0; i < spline->tot_point; i++) { MaskSplinePoint *point = &points_array[i]; @@ -772,7 +772,7 @@ float *BKE_mask_point_segment_feather_diff( float *feather, *fp; uint resol = BKE_mask_spline_feather_resolution(spline, width, height); - feather = fp = MEM_cnew_array(2 * resol, "mask point spline feather diff points"); + feather = fp = MEM_calloc_arrayN(2 * resol, "mask point spline feather diff points"); for (uint i = 0; i < resol; i++, fp += 2) { float u = float(i % resol) / resol, weight; @@ -809,7 +809,7 @@ float *BKE_mask_point_segment_diff( /* resol+1 because of 'forward_diff_bezier' function */ *r_tot_diff_point = resol + 1; - diff_points = fp = MEM_cnew_array(2 * (resol + 1), "mask segment vets"); + diff_points = fp = MEM_calloc_arrayN(2 * (resol + 1), "mask segment vets"); for (j = 0; j < 2; j++) { BKE_curve_forward_diff_bezier(bezt->vec[1][j], diff --git a/source/blender/blenkernel/intern/mask_rasterize.cc b/source/blender/blenkernel/intern/mask_rasterize.cc index da9bfa1870d..aa5b685abd4 100644 --- a/source/blender/blenkernel/intern/mask_rasterize.cc +++ b/source/blender/blenkernel/intern/mask_rasterize.cc @@ -209,7 +209,7 @@ MaskRasterHandle *BKE_maskrasterize_handle_new() { MaskRasterHandle *mr_handle; - mr_handle = MEM_cnew("MaskRasterHandle"); + mr_handle = MEM_callocN("MaskRasterHandle"); return mr_handle; } @@ -428,8 +428,8 @@ static void layer_bucket_init(MaskRasterLayer *layer, const float pixel_size) float(*cos)[3] = layer->face_coords; const uint bucket_tot = layer->buckets_x * layer->buckets_y; - LinkNode **bucketstore = MEM_cnew_array(bucket_tot, __func__); - uint *bucketstore_tot = MEM_cnew_array(bucket_tot, __func__); + LinkNode **bucketstore = MEM_calloc_arrayN(bucket_tot, __func__); + uint *bucketstore_tot = MEM_calloc_arrayN(bucket_tot, __func__); uint face_index; @@ -527,12 +527,12 @@ static void layer_bucket_init(MaskRasterLayer *layer, const float pixel_size) if (true) { /* Now convert link-nodes into arrays for faster per pixel access. */ - uint **buckets_face = MEM_cnew_array(bucket_tot, __func__); + uint **buckets_face = MEM_calloc_arrayN(bucket_tot, __func__); uint bucket_index; for (bucket_index = 0; bucket_index < bucket_tot; bucket_index++) { if (bucketstore_tot[bucket_index]) { - uint *bucket = MEM_cnew_array((bucketstore_tot[bucket_index] + 1), __func__); + uint *bucket = MEM_calloc_arrayN((bucketstore_tot[bucket_index] + 1), __func__); LinkNode *bucket_node; buckets_face[bucket_index] = bucket; @@ -580,7 +580,7 @@ void BKE_maskrasterize_handle_init(MaskRasterHandle *mr_handle, MemArena *sf_arena; mr_handle->layers_tot = uint(BLI_listbase_count(&mask->masklayers)); - mr_handle->layers = MEM_cnew_array(mr_handle->layers_tot, "MaskRasterLayer"); + mr_handle->layers = MEM_calloc_arrayN(mr_handle->layers_tot, "MaskRasterLayer"); BLI_rctf_init_minmax(&mr_handle->bounds); sf_arena = BLI_memarena_new(BLI_SCANFILL_ARENA_SIZE, __func__); @@ -615,7 +615,7 @@ void BKE_maskrasterize_handle_init(MaskRasterHandle *mr_handle, } tot_splines = uint(BLI_listbase_count(&masklay->splines)); - open_spline_ranges = MEM_cnew_array(tot_splines, __func__); + open_spline_ranges = MEM_calloc_arrayN(tot_splines, __func__); BLI_scanfill_begin_arena(&sf_ctx, sf_arena); @@ -685,8 +685,8 @@ void BKE_maskrasterize_handle_init(MaskRasterHandle *mr_handle, if (do_mask_aa == true) { if (do_feather == false) { tot_diff_feather_points = tot_diff_point; - diff_feather_points = MEM_cnew_array(size_t(tot_diff_feather_points), - __func__); + diff_feather_points = MEM_calloc_arrayN(size_t(tot_diff_feather_points), + __func__); /* add single pixel feather */ maskrasterize_spline_differentiate_point_outset( diff_feather_points, diff_points, tot_diff_point, pixel_size, false); @@ -757,8 +757,8 @@ void BKE_maskrasterize_handle_init(MaskRasterHandle *mr_handle, if (diff_feather_points) { if (spline->flag & MASK_SPLINE_NOINTERSECT) { - diff_feather_points_flip = MEM_cnew_array(tot_diff_feather_points, - "diff_feather_points_flip"); + diff_feather_points_flip = MEM_calloc_arrayN(tot_diff_feather_points, + "diff_feather_points_flip"); float co_diff[2]; for (j = 0; j < tot_diff_point; j++) { @@ -912,7 +912,7 @@ void BKE_maskrasterize_handle_init(MaskRasterHandle *mr_handle, ListBase isect_remedgebase = {nullptr, nullptr}; /* now we have all the splines */ - face_coords = MEM_cnew_array(sf_vert_tot, "maskrast_face_coords"); + face_coords = MEM_calloc_arrayN(sf_vert_tot, "maskrast_face_coords"); /* init bounds */ BLI_rctf_init_minmax(&bounds); diff --git a/source/blender/blenkernel/intern/material.cc b/source/blender/blenkernel/intern/material.cc index 38e15d4f8da..bfc17b57ee0 100644 --- a/source/blender/blenkernel/intern/material.cc +++ b/source/blender/blenkernel/intern/material.cc @@ -590,7 +590,7 @@ void BKE_id_material_append(Main *bmain, ID *id, Material *ma) Material ***matar = BKE_id_material_array_p(id); if (matar) { short *totcol = BKE_id_material_len_p(id); - Material **mat = MEM_cnew_array((*totcol) + 1, "newmatar"); + Material **mat = MEM_calloc_arrayN((*totcol) + 1, "newmatar"); if (*totcol) { memcpy(mat, *matar, sizeof(void *) * (*totcol)); } @@ -980,8 +980,8 @@ void BKE_object_material_resize(Main *bmain, Object *ob, const short totcol, boo } } else if (ob->totcol < totcol) { - newmatar = MEM_cnew_array(totcol, "newmatar"); - newmatbits = MEM_cnew_array(totcol, "newmatbits"); + newmatar = MEM_calloc_arrayN(totcol, "newmatar"); + newmatbits = MEM_calloc_arrayN(totcol, "newmatbits"); if (ob->totcol) { memcpy(newmatar, ob->mat, sizeof(void *) * ob->totcol); memcpy(newmatbits, ob->matbits, sizeof(char) * ob->totcol); @@ -1070,7 +1070,7 @@ void BKE_id_material_assign(Main *bmain, ID *id, Material *ma, short act) } if (act > *totcolp) { - matar = MEM_cnew_array(act, "matarray1"); + matar = MEM_calloc_arrayN(act, "matarray1"); if (*totcolp) { memcpy(matar, *matarar, sizeof(void *) * (*totcolp)); @@ -1119,7 +1119,7 @@ static void object_material_assign( } if (act > *totcolp) { - matar = MEM_cnew_array(act, "matarray1"); + matar = MEM_calloc_arrayN(act, "matarray1"); if (*totcolp) { memcpy(matar, *matarar, sizeof(void *) * (*totcolp)); @@ -1306,7 +1306,7 @@ void BKE_object_material_from_eval_data(Main *bmain, Object *ob_orig, const ID * /* Create new material slots based on materials on evaluated geometry. */ *orig_totcol = *eval_totcol; - *orig_mat = *eval_totcol > 0 ? MEM_cnew_array(*eval_totcol, __func__) : nullptr; + *orig_mat = *eval_totcol > 0 ? MEM_calloc_arrayN(*eval_totcol, __func__) : nullptr; for (int i = 0; i < *eval_totcol; i++) { Material *material_eval = (*eval_mat)[i]; if (material_eval != nullptr) { diff --git a/source/blender/blenkernel/intern/mball.cc b/source/blender/blenkernel/intern/mball.cc index b7802fda56e..ef7d4803b25 100644 --- a/source/blender/blenkernel/intern/mball.cc +++ b/source/blender/blenkernel/intern/mball.cc @@ -183,7 +183,7 @@ MetaBall *BKE_mball_add(Main *bmain, const char *name) MetaElem *BKE_mball_element_add(MetaBall *mb, const int type) { - MetaElem *ml = MEM_cnew(__func__); + MetaElem *ml = MEM_callocN(__func__); unit_qt(ml->quat); diff --git a/source/blender/blenkernel/intern/mesh_calc_edges.cc b/source/blender/blenkernel/intern/mesh_calc_edges.cc index a411f56ff44..3189a21439d 100644 --- a/source/blender/blenkernel/intern/mesh_calc_edges.cc +++ b/source/blender/blenkernel/intern/mesh_calc_edges.cc @@ -199,7 +199,7 @@ void mesh_calc_edges(Mesh &mesh, bool keep_existing_edges, const bool select_new /* Create new edges. */ MutableAttributeAccessor attributes = mesh.attributes_for_write(); attributes.add(".corner_edge", AttrDomain::Corner, AttributeInitConstruct()); - MutableSpan new_edges(MEM_cnew_array(edge_offsets.total_size(), __func__), + MutableSpan new_edges(MEM_calloc_arrayN(edge_offsets.total_size(), __func__), edge_offsets.total_size()); calc_edges::serialize_and_initialize_deduplicated_edges(edge_maps, edge_offsets, new_edges); calc_edges::update_edge_indices_in_face_loops(mesh.faces(), diff --git a/source/blender/blenkernel/intern/mesh_convert.cc b/source/blender/blenkernel/intern/mesh_convert.cc index afe1ea9ffac..07acef71e9c 100644 --- a/source/blender/blenkernel/intern/mesh_convert.cc +++ b/source/blender/blenkernel/intern/mesh_convert.cc @@ -358,14 +358,14 @@ struct VertLink { static void prependPolyLineVert(ListBase *lb, uint index) { - VertLink *vl = MEM_cnew("VertLink"); + VertLink *vl = MEM_callocN("VertLink"); vl->index = index; BLI_addhead(lb, vl); } static void appendPolyLineVert(ListBase *lb, uint index) { - VertLink *vl = MEM_cnew("VertLink"); + VertLink *vl = MEM_callocN("VertLink"); vl->index = index; BLI_addtail(lb, vl); } @@ -393,7 +393,7 @@ void BKE_mesh_to_curve_nurblist(const Mesh *mesh, ListBase *nurblist, const int /* create edges from all faces (so as to find edges not in any faces) */ for (const int i : mesh_edges.index_range()) { if (edge_users[i] == edge_users_test) { - EdgeLink *edl = MEM_cnew("EdgeLink"); + EdgeLink *edl = MEM_callocN("EdgeLink"); edl->edge = &mesh_edges[i]; BLI_addtail(&edges, edl); @@ -1045,7 +1045,7 @@ static void move_shapekey_layers_to_keyblocks(const Mesh &mesh, if (kb->totelem != mesh.verts_num) { MEM_SAFE_FREE(kb->data); kb->totelem = mesh.verts_num; - kb->data = MEM_cnew_array(kb->totelem, __func__); + kb->data = MEM_calloc_arrayN(kb->totelem, __func__); CLOG_ERROR(&LOG, "Data for shape key '%s' on mesh missing from evaluated mesh ", kb->name); } } diff --git a/source/blender/blenkernel/intern/mesh_legacy_convert.cc b/source/blender/blenkernel/intern/mesh_legacy_convert.cc index f0de440c80d..b7cc7b76693 100644 --- a/source/blender/blenkernel/intern/mesh_legacy_convert.cc +++ b/source/blender/blenkernel/intern/mesh_legacy_convert.cc @@ -2124,7 +2124,7 @@ static bNodeTree *add_auto_smooth_node_tree(Main &bmain, Library *owner_library) bNodeTree *group = node_tree_add_in_lib( &bmain, owner_library, DATA_("Auto Smooth"), "GeometryNodeTree"); if (!group->geometry_node_asset_traits) { - group->geometry_node_asset_traits = MEM_cnew(__func__); + group->geometry_node_asset_traits = MEM_callocN(__func__); } group->geometry_node_asset_traits->flag |= GEO_NODE_ASSET_MODIFIER; diff --git a/source/blender/blenkernel/intern/mesh_legacy_derived_mesh.cc b/source/blender/blenkernel/intern/mesh_legacy_derived_mesh.cc index c5230efb9a6..5c6004c3097 100644 --- a/source/blender/blenkernel/intern/mesh_legacy_derived_mesh.cc +++ b/source/blender/blenkernel/intern/mesh_legacy_derived_mesh.cc @@ -73,7 +73,7 @@ static int *dm_getCornerEdgeArray(DerivedMesh *dm) static int *dm_getPolyArray(DerivedMesh *dm) { if (!dm->face_offsets) { - dm->face_offsets = MEM_cnew_array(dm->getNumPolys(dm) + 1, __func__); + dm->face_offsets = MEM_calloc_arrayN(dm->getNumPolys(dm) + 1, __func__); dm->copyPolyArray(dm, dm->face_offsets); } return dm->face_offsets; @@ -285,7 +285,7 @@ static void cdDM_release(DerivedMesh *dm) /**************** CDDM interface functions ****************/ static CDDerivedMesh *cdDM_create(const char *desc) { - CDDerivedMesh *cddm = MEM_cnew(desc); + CDDerivedMesh *cddm = MEM_callocN(desc); DerivedMesh *dm = &cddm->dm; dm->getNumVerts = cdDM_getNumVerts; diff --git a/source/blender/blenkernel/intern/mesh_mapping.cc b/source/blender/blenkernel/intern/mesh_mapping.cc index bf306a71857..4cff067265b 100644 --- a/source/blender/blenkernel/intern/mesh_mapping.cc +++ b/source/blender/blenkernel/intern/mesh_mapping.cc @@ -196,7 +196,7 @@ void BKE_mesh_vert_corner_tri_map_create(MeshElemMap **r_map, const int *corner_verts, const int /*corners_num*/) { - MeshElemMap *map = MEM_cnew_array(size_t(totvert), __func__); + MeshElemMap *map = MEM_calloc_arrayN(size_t(totvert), __func__); int *indices = static_cast(MEM_mallocN(sizeof(int) * size_t(tris_num) * 3, __func__)); int *index_step; int i; @@ -236,7 +236,7 @@ void BKE_mesh_origindex_map_create(MeshElemMap **r_map, const int *final_origindex, const int totfinal) { - MeshElemMap *map = MEM_cnew_array(size_t(totsource), __func__); + MeshElemMap *map = MEM_calloc_arrayN(size_t(totsource), __func__); int *indices = static_cast(MEM_mallocN(sizeof(int) * size_t(totfinal), __func__)); int *index_step; int i; @@ -277,7 +277,7 @@ void BKE_mesh_origindex_map_create_corner_tri(MeshElemMap **r_map, const int *corner_tri_faces, const int corner_tris_num) { - MeshElemMap *map = MEM_cnew_array(size_t(faces.size()), __func__); + MeshElemMap *map = MEM_calloc_arrayN(size_t(faces.size()), __func__); int *indices = static_cast(MEM_mallocN(sizeof(int) * size_t(corner_tris_num), __func__)); int *index_step; @@ -332,7 +332,7 @@ static Array reverse_indices_in_groups(const Span group_indices, * atomically by many threads in parallel. `calloc` can be measurably faster than a parallel fill * of zero. Alternatively the offsets could be copied and incremented directly, but the cost of * the copy is slightly higher than the cost of `calloc`. */ - int *counts = MEM_cnew_array(size_t(offsets.size()), __func__); + int *counts = MEM_calloc_arrayN(size_t(offsets.size()), __func__); BLI_SCOPED_DEFER([&]() { MEM_freeN(counts); }) Array results(group_indices.size()); threading::parallel_for(group_indices.index_range(), 1024, [&](const IndexRange range) { @@ -352,7 +352,7 @@ static void reverse_group_indices_in_groups(const OffsetIndices groups, const OffsetIndices offsets, MutableSpan results) { - int *counts = MEM_cnew_array(size_t(offsets.size()), __func__); + int *counts = MEM_calloc_arrayN(size_t(offsets.size()), __func__); BLI_SCOPED_DEFER([&]() { MEM_freeN(counts); }) threading::parallel_for(groups.index_range(), 1024, [&](const IndexRange range) { for (const int64_t face : range) { @@ -392,7 +392,7 @@ GroupedSpan build_vert_to_edge_map(const Span edges, r_indices.reinitialize(offsets.total_size()); /* Version of #reverse_indices_in_groups that accounts for storing two indices for each edge. */ - int *counts = MEM_cnew_array(size_t(offsets.size()), __func__); + int *counts = MEM_calloc_arrayN(size_t(offsets.size()), __func__); BLI_SCOPED_DEFER([&]() { MEM_freeN(counts); }) threading::parallel_for(edges.index_range(), 1024, [&](const IndexRange range) { for (const int64_t edge : range) { diff --git a/source/blender/blenkernel/intern/modifier.cc b/source/blender/blenkernel/intern/modifier.cc index 8bbce0122c0..8ffd27be89d 100644 --- a/source/blender/blenkernel/intern/modifier.cc +++ b/source/blender/blenkernel/intern/modifier.cc @@ -553,7 +553,7 @@ CDMaskLink *BKE_modifier_calc_data_masks(const Scene *scene, for (; md; md = md->next) { const ModifierTypeInfo *mti = BKE_modifier_get_info(ModifierType(md->type)); - curr = MEM_cnew(__func__); + curr = MEM_callocN(__func__); if (BKE_modifier_is_enabled(scene, md, required_mode)) { if (mti->type == ModifierTypeType::OnlyDeform) { diff --git a/source/blender/blenkernel/intern/node.cc b/source/blender/blenkernel/intern/node.cc index 056c8fe0b93..76dc01c2056 100644 --- a/source/blender/blenkernel/intern/node.cc +++ b/source/blender/blenkernel/intern/node.cc @@ -213,7 +213,7 @@ static void ntree_copy_data(Main * /*bmain*/, } if (ntree_src->geometry_node_asset_traits) { - ntree_dst->geometry_node_asset_traits = MEM_cnew( + ntree_dst->geometry_node_asset_traits = MEM_dupallocN( __func__, *ntree_src->geometry_node_asset_traits); } @@ -462,7 +462,7 @@ static bNodeSocket *make_socket(bNodeTree *ntree, return nullptr; } - bNodeSocket *sock = MEM_cnew(__func__); + bNodeSocket *sock = MEM_callocN(__func__); sock->runtime = MEM_new(__func__); StringRef(stype->idname).copy_utf8_truncated(sock->idname); sock->in_out = int(in_out); @@ -1946,7 +1946,7 @@ static bNodeSocket *make_socket(bNodeTree *ntree, BLI_uniquename_cb( unique_identifier_check, lb, "socket", '_', auto_identifier, sizeof(auto_identifier)); - bNodeSocket *sock = MEM_cnew(__func__); + bNodeSocket *sock = MEM_callocN(__func__); sock->runtime = MEM_new(__func__); sock->in_out = in_out; @@ -2661,7 +2661,7 @@ void node_unique_id(bNodeTree &ntree, bNode &node) bNode *node_add_node(const bContext *C, bNodeTree &ntree, const StringRef idname) { - bNode *node = MEM_cnew(__func__); + bNode *node = MEM_callocN(__func__); node->runtime = MEM_new(__func__); BLI_addtail(&ntree.nodes, node); node_unique_id(ntree, *node); @@ -2954,7 +2954,7 @@ bNodeLink &node_add_link( bNodeLink *link = nullptr; if (eNodeSocketInOut(fromsock.in_out) == SOCK_OUT && eNodeSocketInOut(tosock.in_out) == SOCK_IN) { - link = MEM_cnew(__func__); + link = MEM_callocN(__func__); BLI_addtail(&ntree.links, link); link->fromnode = &fromnode; link->fromsock = &fromsock; @@ -2965,7 +2965,7 @@ bNodeLink &node_add_link( eNodeSocketInOut(tosock.in_out) == SOCK_OUT) { /* OK but flip */ - link = MEM_cnew(__func__); + link = MEM_callocN(__func__); BLI_addtail(&ntree.links, link); link->fromnode = &tonode; link->fromsock = &tosock; diff --git a/source/blender/blenkernel/intern/node_tree_interface.cc b/source/blender/blenkernel/intern/node_tree_interface.cc index 544551e5526..abc6ede1f53 100644 --- a/source/blender/blenkernel/intern/node_tree_interface.cc +++ b/source/blender/blenkernel/intern/node_tree_interface.cc @@ -191,7 +191,7 @@ static void *make_socket_data(const StringRef socket_type) void *socket_data = nullptr; socket_data_to_static_type_tag(socket_type, [&socket_data](auto type_tag) { using SocketDataType = typename decltype(type_tag)::type; - SocketDataType *new_socket_data = MEM_cnew(__func__); + SocketDataType *new_socket_data = MEM_callocN(__func__); socket_data_init_impl(*new_socket_data); socket_data = new_socket_data; }); @@ -448,7 +448,7 @@ static void panel_init(bNodeTreeInterfacePanel &panel, UidGeneratorFn generate_uid) { panel.items_num = items_src.size(); - panel.items_array = MEM_cnew_array(panel.items_num, __func__); + panel.items_array = MEM_calloc_arrayN(panel.items_num, __func__); /* Copy buffers. */ for (const int i : items_src.index_range()) { @@ -887,7 +887,7 @@ void bNodeTreeInterfacePanel::insert_item(bNodeTreeInterfaceItem &item, int posi blender::MutableSpan old_items = this->items(); items_num++; - items_array = MEM_cnew_array(items_num, __func__); + items_array = MEM_calloc_arrayN(items_num, __func__); this->items().take_front(position).copy_from(old_items.take_front(position)); this->items().drop_front(position + 1).copy_from(old_items.drop_front(position)); this->items()[position] = &item; @@ -906,7 +906,7 @@ bool bNodeTreeInterfacePanel::remove_item(bNodeTreeInterfaceItem &item, const bo blender::MutableSpan old_items = this->items(); items_num--; - items_array = MEM_cnew_array(items_num, __func__); + items_array = MEM_calloc_arrayN(items_num, __func__); this->items().take_front(position).copy_from(old_items.take_front(position)); this->items().drop_front(position).copy_from(old_items.drop_front(position + 1)); @@ -1078,7 +1078,7 @@ static bNodeTreeInterfaceSocket *make_socket(const int uid, return nullptr; } - bNodeTreeInterfaceSocket *new_socket = MEM_cnew(__func__); + bNodeTreeInterfaceSocket *new_socket = MEM_callocN(__func__); BLI_assert(new_socket); /* Init common socket properties. */ @@ -1140,7 +1140,7 @@ static bNodeTreeInterfacePanel *make_panel(const int uid, { BLI_assert(!name.is_empty()); - bNodeTreeInterfacePanel *new_panel = MEM_cnew(__func__); + bNodeTreeInterfacePanel *new_panel = MEM_callocN(__func__); new_panel->item.item_type = NODE_INTERFACE_PANEL; new_panel->name = BLI_strdupn(name.data(), name.size()); new_panel->description = description.is_empty() ? diff --git a/source/blender/blenkernel/intern/object.cc b/source/blender/blenkernel/intern/object.cc index 7c4e2f931fd..2894150c8b3 100644 --- a/source/blender/blenkernel/intern/object.cc +++ b/source/blender/blenkernel/intern/object.cc @@ -3644,7 +3644,7 @@ void BKE_object_empty_draw_type_set(Object *ob, const int value) if (ob->type == OB_EMPTY && ob->empty_drawtype == OB_EMPTY_IMAGE) { if (!ob->iuser) { - ob->iuser = MEM_cnew("image user"); + ob->iuser = MEM_callocN("image user"); ob->iuser->flag |= IMA_ANIM_ALWAYS; ob->iuser->frames = 100; ob->iuser->sfra = 1; @@ -4246,7 +4246,7 @@ int BKE_object_insert_ptcache(Object *ob) } } - link = MEM_cnew("PCLink"); + link = MEM_callocN("PCLink"); link->data = POINTER_FROM_INT(i); BLI_addtail(&ob->pc_ids, link); diff --git a/source/blender/blenkernel/intern/object_dupli.cc b/source/blender/blenkernel/intern/object_dupli.cc index cc202481965..a94b6eab85e 100644 --- a/source/blender/blenkernel/intern/object_dupli.cc +++ b/source/blender/blenkernel/intern/object_dupli.cc @@ -258,7 +258,7 @@ static DupliObject *make_dupli(const DupliContext *ctx, /* Add a #DupliObject instance to the result container. */ if (ctx->duplilist) { - dob = MEM_cnew("dupli object"); + dob = MEM_callocN("dupli object"); BLI_addtail(ctx->duplilist, dob); } else { @@ -1786,7 +1786,7 @@ static const DupliGenerator *get_dupli_generator(const DupliContext *ctx) ListBase *object_duplilist(Depsgraph *depsgraph, Scene *sce, Object *ob) { - ListBase *duplilist = MEM_cnew("duplilist"); + ListBase *duplilist = MEM_callocN("duplilist"); DupliContext ctx; Vector instance_stack; Vector dupli_gen_type_stack({0}); @@ -1805,7 +1805,7 @@ ListBase *object_duplilist_preview(Depsgraph *depsgraph, Object *ob_eval, const ViewerPath *viewer_path) { - ListBase *duplilist = MEM_cnew("duplilist"); + ListBase *duplilist = MEM_callocN("duplilist"); DupliContext ctx; Vector instance_stack; Vector dupli_gen_type_stack({0}); diff --git a/source/blender/blenkernel/intern/paint.cc b/source/blender/blenkernel/intern/paint.cc index f24142dd550..fb8869c9d6b 100644 --- a/source/blender/blenkernel/intern/paint.cc +++ b/source/blender/blenkernel/intern/paint.cc @@ -1372,7 +1372,7 @@ Palette *BKE_palette_add(Main *bmain, const char *name) PaletteColor *BKE_palette_color_add(Palette *palette) { - PaletteColor *color = MEM_cnew(__func__); + PaletteColor *color = MEM_callocN(__func__); BLI_addtail(&palette->colors, color); return color; } @@ -1690,34 +1690,34 @@ bool BKE_paint_ensure(ToolSettings *ts, Paint **r_paint) } if (((VPaint **)r_paint == &ts->vpaint) || ((VPaint **)r_paint == &ts->wpaint)) { - VPaint *data = MEM_cnew(__func__); + VPaint *data = MEM_callocN(__func__); paint = &data->paint; } else if ((Sculpt **)r_paint == &ts->sculpt) { - Sculpt *data = MEM_cnew(__func__); + Sculpt *data = MEM_callocN(__func__); *data = *DNA_struct_default_get(Sculpt); paint = &data->paint; } else if ((GpPaint **)r_paint == &ts->gp_paint) { - GpPaint *data = MEM_cnew(__func__); + GpPaint *data = MEM_callocN(__func__); paint = &data->paint; } else if ((GpVertexPaint **)r_paint == &ts->gp_vertexpaint) { - GpVertexPaint *data = MEM_cnew(__func__); + GpVertexPaint *data = MEM_callocN(__func__); paint = &data->paint; } else if ((GpSculptPaint **)r_paint == &ts->gp_sculptpaint) { - GpSculptPaint *data = MEM_cnew(__func__); + GpSculptPaint *data = MEM_callocN(__func__); paint = &data->paint; } else if ((GpWeightPaint **)r_paint == &ts->gp_weightpaint) { - GpWeightPaint *data = MEM_cnew(__func__); + GpWeightPaint *data = MEM_callocN(__func__); paint = &data->paint; } else if ((CurvesSculpt **)r_paint == &ts->curves_sculpt) { - CurvesSculpt *data = MEM_cnew(__func__); + CurvesSculpt *data = MEM_callocN(__func__); paint = &data->paint; } else if (*r_paint == &ts->imapaint.paint) { diff --git a/source/blender/blenkernel/intern/scene.cc b/source/blender/blenkernel/intern/scene.cc index 5258bd3385c..4ff867139aa 100644 --- a/source/blender/blenkernel/intern/scene.cc +++ b/source/blender/blenkernel/intern/scene.cc @@ -352,7 +352,7 @@ static void scene_copy_data(Main *bmain, /* Copy sequencer, this is local data! */ if (scene_src->ed) { - scene_dst->ed = MEM_cnew(__func__); + scene_dst->ed = MEM_callocN(__func__); scene_dst->ed->seqbasep = &scene_dst->ed->seqbase; scene_dst->ed->cache_flag = scene_src->ed->cache_flag; scene_dst->ed->show_missing_media_flag = scene_src->ed->show_missing_media_flag; @@ -2648,7 +2648,7 @@ SceneRenderView *BKE_scene_add_render_view(Scene *sce, const char *name) name = DATA_("RenderView"); } - SceneRenderView *srv = MEM_cnew(__func__); + SceneRenderView *srv = MEM_callocN(__func__); STRNCPY(srv->name, name); BLI_uniquename(&sce->r.views, srv, @@ -3282,7 +3282,7 @@ static Depsgraph **scene_get_depsgraph_p(Scene *scene, } /* Depsgraph was not found in the ghash, but the key still needs allocating. */ - *key_ptr = MEM_cnew(__func__); + *key_ptr = MEM_callocN(__func__); **key_ptr = key; *depsgraph_ptr = nullptr; diff --git a/source/blender/blenkernel/intern/screen.cc b/source/blender/blenkernel/intern/screen.cc index 2bfd8693e0b..044bc55ff85 100644 --- a/source/blender/blenkernel/intern/screen.cc +++ b/source/blender/blenkernel/intern/screen.cc @@ -330,7 +330,7 @@ static void panel_list_copy(ListBase *newlb, const ListBase *lb) BLI_listbase_clear(&new_panel->layout_panel_states); LISTBASE_FOREACH (LayoutPanelState *, src_state, &old_panel->layout_panel_states) { - LayoutPanelState *new_state = MEM_cnew(__func__, *src_state); + LayoutPanelState *new_state = MEM_dupallocN(__func__, *src_state); new_state->idname = BLI_strdup(src_state->idname); BLI_addtail(&new_panel->layout_panel_states, new_state); } @@ -379,7 +379,7 @@ ARegion *BKE_area_region_copy(const SpaceType *st, const ARegion *region) ARegion *BKE_area_region_new() { - ARegion *region = MEM_cnew(__func__); + ARegion *region = MEM_callocN(__func__); region->runtime = MEM_new(__func__); return region; } @@ -519,7 +519,7 @@ LayoutPanelState *BKE_panel_layout_panel_state_ensure(Panel *panel, return state; } } - LayoutPanelState *state = MEM_cnew(__func__); + LayoutPanelState *state = MEM_callocN(__func__); state->idname = BLI_strdupn(idname.data(), idname.size()); SET_FLAG_FROM_TEST(state->flag, !default_closed, LAYOUT_PANEL_STATE_FLAG_OPEN); BLI_addtail(&panel->layout_panel_states, state); @@ -528,7 +528,7 @@ LayoutPanelState *BKE_panel_layout_panel_state_ensure(Panel *panel, Panel *BKE_panel_new(PanelType *panel_type) { - Panel *panel = MEM_cnew(__func__); + Panel *panel = MEM_callocN(__func__); panel->runtime = MEM_new(__func__); panel->type = panel_type; if (panel_type) { @@ -1237,7 +1237,7 @@ static void direct_link_region(BlendDataReader *reader, ARegion *region, int spa if (region->regiondata == nullptr) { /* To avoid crashing on some old files. */ - region->regiondata = MEM_cnew("region view3d"); + region->regiondata = MEM_callocN("region view3d"); } RegionView3D *rv3d = static_cast(region->regiondata); diff --git a/source/blender/blenkernel/intern/subdiv.cc b/source/blender/blenkernel/intern/subdiv.cc index f46b027228e..7952929cfc8 100644 --- a/source/blender/blenkernel/intern/subdiv.cc +++ b/source/blender/blenkernel/intern/subdiv.cc @@ -114,7 +114,7 @@ Subdiv *new_from_converter(const Settings *settings, OpenSubdiv_Converter *conve * The thing here is: OpenSubdiv can only deal with faces, but our * side of subdiv also deals with loose vertices and edges. */ } - Subdiv *subdiv = MEM_cnew(__func__); + Subdiv *subdiv = MEM_callocN(__func__); subdiv->settings = *settings; subdiv->topology_refiner = osd_topology_refiner; subdiv->evaluator = nullptr; diff --git a/source/blender/blenkernel/intern/subdiv_displacement_multires.cc b/source/blender/blenkernel/intern/subdiv_displacement_multires.cc index 68fb985cf65..fa0d46c2ba0 100644 --- a/source/blender/blenkernel/intern/subdiv_displacement_multires.cc +++ b/source/blender/blenkernel/intern/subdiv_displacement_multires.cc @@ -438,7 +438,7 @@ void displacement_attach_from_multires(Subdiv *subdiv, Mesh *mesh, const Multire return; } /* Allocate all required memory. */ - Displacement *displacement = MEM_cnew("multires displacement"); + Displacement *displacement = MEM_callocN("multires displacement"); displacement->user_data = MEM_new("multires displacement data"); displacement_init_data(displacement, subdiv, mesh, mmd); displacement_init_functions(displacement); diff --git a/source/blender/blenkernel/intern/subdiv_modifier.cc b/source/blender/blenkernel/intern/subdiv_modifier.cc index 146c85f6018..c74a6996af6 100644 --- a/source/blender/blenkernel/intern/subdiv_modifier.cc +++ b/source/blender/blenkernel/intern/subdiv_modifier.cc @@ -58,7 +58,7 @@ bool BKE_subsurf_modifier_runtime_init(SubsurfModifierData *smd, const bool use_ /* Allocate runtime data if it did not exist yet. */ if (runtime_data == nullptr) { - runtime_data = MEM_cnew(__func__); + runtime_data = MEM_callocN(__func__); smd->modifier.runtime = runtime_data; } runtime_data->settings = settings; diff --git a/source/blender/blenkernel/intern/subsurf_ccg.cc b/source/blender/blenkernel/intern/subsurf_ccg.cc index 2e265c62f89..e60131545db 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.cc +++ b/source/blender/blenkernel/intern/subsurf_ccg.cc @@ -1531,7 +1531,7 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss, int useSubsurfUv, DerivedMesh *dm) { - CCGDerivedMesh *ccgdm = MEM_cnew(__func__); + CCGDerivedMesh *ccgdm = MEM_callocN(__func__); DM_from_template(&ccgdm->dm, dm, DM_TYPE_CCGDM, diff --git a/source/blender/blenkernel/intern/texture.cc b/source/blender/blenkernel/intern/texture.cc index 8f9f6ca7854..c2ea010924b 100644 --- a/source/blender/blenkernel/intern/texture.cc +++ b/source/blender/blenkernel/intern/texture.cc @@ -229,7 +229,7 @@ void BKE_texture_mtex_foreach_id(LibraryForeachIDData *data, MTex *mtex) TexMapping *BKE_texture_mapping_add(int type) { - TexMapping *texmap = MEM_cnew("TexMapping"); + TexMapping *texmap = MEM_callocN("TexMapping"); BKE_texture_mapping_default(texmap, type); @@ -332,7 +332,7 @@ void BKE_texture_mapping_init(TexMapping *texmap) ColorMapping *BKE_texture_colormapping_add() { - ColorMapping *colormap = MEM_cnew("ColorMapping"); + ColorMapping *colormap = MEM_callocN("ColorMapping"); BKE_texture_colormapping_default(colormap); diff --git a/source/blender/blenkernel/intern/tracking.cc b/source/blender/blenkernel/intern/tracking.cc index 5016ce549b2..17432aff154 100644 --- a/source/blender/blenkernel/intern/tracking.cc +++ b/source/blender/blenkernel/intern/tracking.cc @@ -197,7 +197,7 @@ static void tracking_tracks_copy(TrackingCopyContext *ctx, BLI_listbase_clear(tracks_dst); LISTBASE_FOREACH (MovieTrackingTrack *, track_src, tracks_src) { - MovieTrackingTrack *track_dst = MEM_cnew(__func__, *track_src); + MovieTrackingTrack *track_dst = MEM_dupallocN(__func__, *track_src); if (track_src->markers) { track_dst->markers = static_cast(MEM_dupallocN(track_src->markers)); } @@ -221,12 +221,12 @@ static void tracking_plane_tracks_copy(TrackingCopyContext *ctx, BLI_listbase_clear(plane_tracks_list_dst); LISTBASE_FOREACH (MovieTrackingPlaneTrack *, plane_track_src, plane_tracks_list_src) { - MovieTrackingPlaneTrack *plane_track_dst = MEM_cnew(__func__, *plane_track_src); + MovieTrackingPlaneTrack *plane_track_dst = MEM_dupallocN(__func__, *plane_track_src); if (plane_track_src->markers) { plane_track_dst->markers = static_cast( MEM_dupallocN(plane_track_src->markers)); } - plane_track_dst->point_tracks = MEM_cnew_array( + plane_track_dst->point_tracks = MEM_calloc_arrayN( sizeof(*plane_track_dst->point_tracks) * plane_track_dst->point_tracksnr, __func__); for (int i = 0; i < plane_track_dst->point_tracksnr; i++) { plane_track_dst->point_tracks[i] = static_cast( @@ -300,7 +300,7 @@ static void tracking_objects_copy(ListBase *tracking_objects_dst, BLI_listbase_clear(tracking_objects_dst); LISTBASE_FOREACH (MovieTrackingObject *, tracking_object_src, tracking_objects_src) { - MovieTrackingObject *tracking_object_dst = MEM_cnew(__func__); + MovieTrackingObject *tracking_object_dst = MEM_callocN(__func__); tracking_object_copy(tracking_object_dst, tracking_object_src, flag); BLI_addtail(tracking_objects_dst, tracking_object_dst); } @@ -502,7 +502,7 @@ MovieTrackingTrack *BKE_tracking_track_add_empty(MovieTracking *tracking, ListBa { const MovieTrackingSettings *settings = &tracking->settings; - MovieTrackingTrack *track = MEM_cnew("add_marker_exec track"); + MovieTrackingTrack *track = MEM_callocN("add_marker_exec track"); STRNCPY(track->name, CTX_DATA_(BLT_I18NCONTEXT_ID_MOVIECLIP, "Track")); /* Fill track's settings from default settings. */ @@ -567,7 +567,7 @@ MovieTrackingTrack *BKE_tracking_track_duplicate(MovieTrackingTrack *track) { MovieTrackingTrack *new_track; - new_track = MEM_cnew("tracking_track_duplicate new_track"); + new_track = MEM_callocN("tracking_track_duplicate new_track"); *new_track = *track; new_track->next = new_track->prev = nullptr; @@ -656,7 +656,7 @@ MovieTrackingTrack **BKE_tracking_selected_tracks_in_active_object(MovieTracking return nullptr; } - MovieTrackingTrack **source_tracks = MEM_cnew_array( + MovieTrackingTrack **source_tracks = MEM_calloc_arrayN( num_selected_tracks, "selected tracks array"); int source_track_index = 0; LISTBASE_FOREACH (MovieTrackingTrack *, track, &tracking_object->tracks) { @@ -798,7 +798,7 @@ void BKE_tracking_tracks_join(MovieTracking *tracking, MovieTrackingMarker *markers; tot = dst_track->markersnr + src_track->markersnr; - markers = MEM_cnew_array(tot, "tmp tracking joined tracks"); + markers = MEM_calloc_arrayN(tot, "tmp tracking joined tracks"); while (a < src_track->markersnr || b < dst_track->markersnr) { if (b >= dst_track->markersnr) { @@ -894,7 +894,7 @@ void BKE_tracking_tracks_join(MovieTracking *tracking, MEM_freeN(dst_track->markers); - dst_track->markers = MEM_cnew_array(i, "tracking joined tracks"); + dst_track->markers = MEM_calloc_arrayN(i, "tracking joined tracks"); memcpy(dst_track->markers, markers, i * sizeof(MovieTrackingMarker)); dst_track->markersnr = i; @@ -955,9 +955,9 @@ static void tracking_average_markers(MovieTrackingTrack *dst_track, const int num_frames = last_frame - first_frame + 1; /* Allocate temporary array where averaging will happen into. */ - MovieTrackingMarker *accumulator = MEM_cnew_array( + MovieTrackingMarker *accumulator = MEM_calloc_arrayN( num_frames, "tracks average accumulator"); - int *counters = MEM_cnew_array(num_frames, "tracks accumulator counters"); + int *counters = MEM_calloc_arrayN(num_frames, "tracks accumulator counters"); for (int frame = first_frame; frame <= last_frame; ++frame) { const int frame_index = frame - first_frame; accumulator[frame_index].framenr = frame; @@ -1144,7 +1144,7 @@ float *tracking_track_get_mask_for_region(const int frame_width, if (layer != nullptr) { const int mask_width = region_max[0] - region_min[0]; const int mask_height = region_max[1] - region_min[1]; - mask = MEM_cnew_array(mask_width * mask_height, "track mask"); + mask = MEM_calloc_arrayN(mask_width * mask_height, "track mask"); track_mask_gpencil_layer_rasterize( frame_width, frame_height, region_min, layer, mask, mask_width, mask_height); } @@ -1264,7 +1264,7 @@ MovieTrackingMarker *BKE_tracking_marker_insert(MovieTrackingTrack *track, MEM_reallocN(track->markers, sizeof(MovieTrackingMarker) * track->markersnr)); } else { - track->markers = MEM_cnew("MovieTracking markers"); + track->markers = MEM_callocN("MovieTracking markers"); } /* shift array to "free" space for new marker */ @@ -1571,7 +1571,7 @@ MovieTrackingPlaneTrack *BKE_tracking_plane_track_add(MovieTracking *tracking, } /* Allocate new plane track. */ - plane_track = MEM_cnew("new plane track"); + plane_track = MEM_callocN("new plane track"); /* Use some default name. */ STRNCPY(plane_track->name, DATA_("Plane Track")); @@ -1579,8 +1579,8 @@ MovieTrackingPlaneTrack *BKE_tracking_plane_track_add(MovieTracking *tracking, plane_track->image_opacity = 1.0f; /* Use selected tracks from given list as a plane. */ - plane_track->point_tracks = MEM_cnew_array(num_selected_tracks, - "new plane tracks array"); + plane_track->point_tracks = MEM_calloc_arrayN(num_selected_tracks, + "new plane tracks array"); int track_index = 0; LISTBASE_FOREACH (MovieTrackingTrack *, track, tracks) { if (TRACK_SELECTED(track)) { @@ -1656,7 +1656,7 @@ bool BKE_tracking_plane_track_remove_point_track(MovieTrackingPlaneTrack *plane_ return false; } - MovieTrackingTrack **new_point_tracks = MEM_cnew_array( + MovieTrackingTrack **new_point_tracks = MEM_calloc_arrayN( plane_track->point_tracksnr - 1, "new point tracks array"); for (int i = 0, track_index = 0; i < plane_track->point_tracksnr; i++) { @@ -1896,7 +1896,7 @@ void BKE_tracking_plane_marker_get_subframe_corners(MovieTrackingPlaneTrack *pla MovieTrackingObject *BKE_tracking_object_add(MovieTracking *tracking, const char *name) { - MovieTrackingObject *tracking_object = MEM_cnew("tracking object"); + MovieTrackingObject *tracking_object = MEM_callocN("tracking object"); if (tracking->tot_object == 0) { /* first object is always camera */ @@ -2269,7 +2269,7 @@ MovieDistortion *BKE_tracking_distortion_new(MovieTracking *tracking, tracking_cameraIntrinscisOptionsFromTracking( tracking, calibration_width, calibration_height, &camera_intrinsics_options); - distortion = MEM_cnew("BKE_tracking_distortion_create"); + distortion = MEM_callocN("BKE_tracking_distortion_create"); distortion->intrinsics = libmv_cameraIntrinsicsNew(&camera_intrinsics_options); const MovieTrackingCamera *camera = &tracking->camera; @@ -2313,7 +2313,7 @@ MovieDistortion *BKE_tracking_distortion_copy(MovieDistortion *distortion) { MovieDistortion *new_distortion; - new_distortion = MEM_cnew("BKE_tracking_distortion_create"); + new_distortion = MEM_callocN("BKE_tracking_distortion_create"); *new_distortion = *distortion; new_distortion->intrinsics = libmv_cameraIntrinsicsCopy(distortion->intrinsics); @@ -3208,7 +3208,8 @@ static void tracking_dopesheet_channels_segments_calc(MovieTrackingDopesheetChan return; } - channel->segments = MEM_cnew_array(2 * channel->tot_segment, "tracking channel segments"); + channel->segments = MEM_calloc_arrayN(2 * channel->tot_segment, + "tracking channel segments"); /* create segments */ i = 0; @@ -3267,7 +3268,7 @@ static void tracking_dopesheet_channels_calc(MovieTracking *tracking) continue; } - MovieTrackingDopesheetChannel *channel = MEM_cnew( + MovieTrackingDopesheetChannel *channel = MEM_callocN( "tracking dopesheet channel"); channel->track = track; @@ -3374,7 +3375,7 @@ static void tracking_dopesheet_calc_coverage(MovieTracking *tracking) frames = end_frame - start_frame + 1; /* this is a per-frame counter of markers (how many markers belongs to the same frame) */ - per_frame_counter = MEM_cnew_array(frames, "per frame track counter"); + per_frame_counter = MEM_calloc_arrayN(frames, "per frame track counter"); /* find per-frame markers count */ LISTBASE_FOREACH (MovieTrackingTrack *, track, &tracking_object->tracks) { @@ -3413,7 +3414,7 @@ static void tracking_dopesheet_calc_coverage(MovieTracking *tracking) end_segment_frame++; } - coverage_segment = MEM_cnew( + coverage_segment = MEM_callocN( "tracking coverage segment"); coverage_segment->coverage = prev_coverage; coverage_segment->start_frame = last_segment_frame; diff --git a/source/blender/blenkernel/intern/tracking_auto.cc b/source/blender/blenkernel/intern/tracking_auto.cc index 26a7d535406..99f6e4ff054 100644 --- a/source/blender/blenkernel/intern/tracking_auto.cc +++ b/source/blender/blenkernel/intern/tracking_auto.cc @@ -411,8 +411,8 @@ static void autotrack_context_init_image_accessor(AutoTrackContext *context) clips[i] = context->autotrack_clips[i].clip; } - MovieTrackingTrack **tracks = MEM_cnew_array(context->num_all_tracks, - "image accessor init tracks"); + MovieTrackingTrack **tracks = MEM_calloc_arrayN( + context->num_all_tracks, "image accessor init tracks"); for (int i = 0; i < context->num_all_tracks; ++i) { tracks[i] = context->all_autotrack_tracks[i].track; } @@ -467,8 +467,8 @@ static void autotrack_context_init_autotrack(AutoTrackContext *context) } /* Allocate memory for all the markers. */ - libmv_Marker *libmv_markers = MEM_cnew_array(num_trackable_markers, - "libmv markers array"); + libmv_Marker *libmv_markers = MEM_calloc_arrayN(num_trackable_markers, + "libmv markers array"); /* Fill in markers array. */ int num_filled_libmv_markers = 0; @@ -508,8 +508,8 @@ static void autotrack_context_init_markers(AutoTrackContext *context) } /* Allocate required memory. */ - context->autotrack_markers = MEM_cnew_array(context->num_autotrack_markers, - "auto track options"); + context->autotrack_markers = MEM_calloc_arrayN(context->num_autotrack_markers, + "auto track options"); /* Fill in all the markers. */ int autotrack_marker_index = 0; @@ -542,7 +542,7 @@ AutoTrackContext *BKE_autotrack_context_new(MovieClip *clip, MovieClipUser *user, const bool is_backwards) { - AutoTrackContext *context = MEM_cnew("autotrack context"); + AutoTrackContext *context = MEM_callocN("autotrack context"); context->start_scene_frame = user->framenr; context->is_backwards = is_backwards; @@ -572,8 +572,8 @@ static void reference_keyframed_image_buffers(AutoTrackContext *context) /* NOTE: This is potentially over-allocating, but it simplifies memory manipulation. * In practice this is unlikely to be noticed in the profiler as the memory footprint of this * data is way less of what the tracking process will use. */ - context->referenced_image_buffers = MEM_cnew_array(context->num_autotrack_markers, - __func__); + context->referenced_image_buffers = MEM_calloc_arrayN(context->num_autotrack_markers, + __func__); context->num_referenced_image_buffers = 0; @@ -651,7 +651,7 @@ static void autotrack_context_step_cb(void *__restrict userdata, const int new_marker_frame = libmv_current_marker.frame + frame_delta; - AutoTrackTrackingResult *autotrack_result = MEM_cnew( + AutoTrackTrackingResult *autotrack_result = MEM_callocN( "autotrack result"); autotrack_result->libmv_marker = libmv_current_marker; autotrack_result->libmv_marker.frame = new_marker_frame; diff --git a/source/blender/blenkernel/intern/tracking_plane_tracker.cc b/source/blender/blenkernel/intern/tracking_plane_tracker.cc index 564883a89bc..e305a69df57 100644 --- a/source/blender/blenkernel/intern/tracking_plane_tracker.cc +++ b/source/blender/blenkernel/intern/tracking_plane_tracker.cc @@ -26,8 +26,8 @@ static int point_markers_correspondences_on_both_image( { Vec2 *x1, *x2; - *r_x1 = x1 = MEM_cnew_array(plane_track->point_tracksnr, "point correspondences x1"); - *r_x2 = x2 = MEM_cnew_array(plane_track->point_tracksnr, "point correspondences x2"); + *r_x1 = x1 = MEM_calloc_arrayN(plane_track->point_tracksnr, "point correspondences x1"); + *r_x2 = x2 = MEM_calloc_arrayN(plane_track->point_tracksnr, "point correspondences x2"); int correspondence_index = 0; for (int i = 0; i < plane_track->point_tracksnr; i++) { diff --git a/source/blender/blenkernel/intern/tracking_region_tracker.cc b/source/blender/blenkernel/intern/tracking_region_tracker.cc index cfb92744f79..21e0cda1c57 100644 --- a/source/blender/blenkernel/intern/tracking_region_tracker.cc +++ b/source/blender/blenkernel/intern/tracking_region_tracker.cc @@ -76,7 +76,7 @@ static float *track_get_search_floatbuf(ImBuf *ibuf, width = searchibuf->x; height = searchibuf->y; - gray_pixels = MEM_cnew_array(width * height, "tracking floatBuf"); + gray_pixels = MEM_calloc_arrayN(width * height, "tracking floatBuf"); if (searchibuf->float_buffer.data) { float_rgba_to_gray( diff --git a/source/blender/blenkernel/intern/tracking_solver.cc b/source/blender/blenkernel/intern/tracking_solver.cc index 9de2e0bb273..77ef63bfe56 100644 --- a/source/blender/blenkernel/intern/tracking_solver.cc +++ b/source/blender/blenkernel/intern/tracking_solver.cc @@ -162,7 +162,7 @@ static bool reconstruct_retrieve_libmv_tracks(MovieReconstructContext *context, reconstruction->camnr = 0; reconstruction->cameras = nullptr; - MovieReconstructedCamera *reconstructed_cameras = MEM_cnew_array( + MovieReconstructedCamera *reconstructed_cameras = MEM_calloc_arrayN( (efra - sfra + 1), "temp reconstructed camera"); for (int a = sfra; a <= efra; a++) { @@ -213,8 +213,8 @@ static bool reconstruct_retrieve_libmv_tracks(MovieReconstructContext *context, if (reconstruction->camnr) { const size_t size = reconstruction->camnr * sizeof(MovieReconstructedCamera); - reconstruction->cameras = MEM_cnew_array(reconstruction->camnr, - "reconstructed camera"); + reconstruction->cameras = MEM_calloc_arrayN(reconstruction->camnr, + "reconstructed camera"); memcpy(reconstruction->cameras, reconstructed_cameras, size); } @@ -324,7 +324,7 @@ MovieReconstructContext *BKE_tracking_reconstruction_context_new( int height) { MovieTracking *tracking = &clip->tracking; - MovieReconstructContext *context = MEM_cnew( + MovieReconstructContext *context = MEM_callocN( "MovieReconstructContext data"); const float aspy = 1.0f / tracking->camera.pixel_aspect; const int num_tracks = BLI_listbase_count(&tracking_object->tracks); diff --git a/source/blender/blenkernel/intern/tracking_stabilize.cc b/source/blender/blenkernel/intern/tracking_stabilize.cc index e0508f20a03..7d5e3d9736a 100644 --- a/source/blender/blenkernel/intern/tracking_stabilize.cc +++ b/source/blender/blenkernel/intern/tracking_stabilize.cc @@ -202,7 +202,7 @@ static void use_values_from_fcurves(StabContext *ctx, bool toggle) */ static StabContext *init_stabilization_working_context(MovieClip *clip) { - StabContext *ctx = MEM_cnew("2D stabilization animation runtime data"); + StabContext *ctx = MEM_callocN("2D stabilization animation runtime data"); ctx->clip = clip; ctx->tracking = &clip->tracking; ctx->stab = &clip->tracking.stabilization; @@ -869,7 +869,7 @@ static void init_all_tracks(StabContext *ctx, float aspect) LISTBASE_FOREACH (MovieTrackingTrack *, track, &tracking_camera_object->tracks) { TrackStabilizationBase *local_data = access_stabilization_baseline_data(ctx, track); if (!local_data) { - local_data = MEM_cnew("2D stabilization per track baseline data"); + local_data = MEM_callocN("2D stabilization per track baseline data"); attach_stabilization_baseline_data(ctx, track, local_data); } BLI_assert(local_data != nullptr); @@ -882,7 +882,7 @@ static void init_all_tracks(StabContext *ctx, float aspect) return; } - order = MEM_cnew_array(track_len, "stabilization track order"); + order = MEM_calloc_arrayN(track_len, "stabilization track order"); if (!order) { return; } diff --git a/source/blender/blenkernel/intern/tracking_util.cc b/source/blender/blenkernel/intern/tracking_util.cc index 6b6ce53224b..66cdb10ba25 100644 --- a/source/blender/blenkernel/intern/tracking_util.cc +++ b/source/blender/blenkernel/intern/tracking_util.cc @@ -50,13 +50,13 @@ TracksMap *tracks_map_new(const char *object_name, int num_tracks) { - TracksMap *map = MEM_cnew("TrackingsMap"); + TracksMap *map = MEM_callocN("TrackingsMap"); STRNCPY(map->object_name, object_name); map->num_tracks = num_tracks; - map->tracks = MEM_cnew_array(num_tracks, "TrackingsMap tracks"); + map->tracks = MEM_calloc_arrayN(num_tracks, "TrackingsMap tracks"); map->hash = BLI_ghash_ptr_new("TracksMap hash"); @@ -625,7 +625,7 @@ static ImBuf *make_grayscale_ibuf_copy(ImBuf *ibuf) */ const size_t num_pixels = size_t(grayscale->x) * size_t(grayscale->y); grayscale->channels = 1; - float *rect_float = MEM_cnew_array(num_pixels, "tracking grayscale image"); + float *rect_float = MEM_calloc_arrayN(num_pixels, "tracking grayscale image"); if (rect_float != nullptr) { IMB_assign_float_buffer(grayscale, rect_float, IB_TAKE_OWNERSHIP); @@ -653,7 +653,7 @@ static ImBuf *float_image_to_ibuf(libmv_FloatImage *float_image) ImBuf *ibuf = IMB_allocImBuf(float_image->width, float_image->height, 32, 0); size_t num_total_channels = size_t(ibuf->x) * size_t(ibuf->y) * float_image->channels; ibuf->channels = float_image->channels; - float *rect_float = MEM_cnew_array(num_total_channels, "tracking grayscale image"); + float *rect_float = MEM_calloc_arrayN(num_total_channels, "tracking grayscale image"); if (rect_float != nullptr) { IMB_assign_float_buffer(ibuf, rect_float, IB_TAKE_OWNERSHIP); @@ -885,14 +885,14 @@ TrackingImageAccessor *tracking_image_accessor_new(MovieClip *clips[MAX_ACCESSOR MovieTrackingTrack **tracks, int num_tracks) { - TrackingImageAccessor *accessor = MEM_cnew("tracking image accessor"); + TrackingImageAccessor *accessor = MEM_callocN("tracking image accessor"); BLI_assert(num_clips <= MAX_ACCESSOR_CLIP); memcpy(accessor->clips, clips, num_clips * sizeof(MovieClip *)); accessor->num_clips = num_clips; - accessor->tracks = MEM_cnew_array(num_tracks, "image accessor tracks"); + accessor->tracks = MEM_calloc_arrayN(num_tracks, "image accessor tracks"); memcpy(accessor->tracks, tracks, num_tracks * sizeof(MovieTrackingTrack *)); accessor->num_tracks = num_tracks; diff --git a/source/blender/blenkernel/intern/undo_system.cc b/source/blender/blenkernel/intern/undo_system.cc index 32c9db704a2..9343cd85092 100644 --- a/source/blender/blenkernel/intern/undo_system.cc +++ b/source/blender/blenkernel/intern/undo_system.cc @@ -269,7 +269,7 @@ static void undosys_stack_validate(UndoStack * /*ustack*/, bool /*expect_non_emp UndoStack *BKE_undosys_stack_create() { - UndoStack *ustack = MEM_cnew(__func__); + UndoStack *ustack = MEM_callocN(__func__); return ustack; } @@ -907,7 +907,7 @@ bool BKE_undosys_step_redo(UndoStack *ustack, bContext *C) UndoType *BKE_undosys_type_append(void (*undosys_fn)(UndoType *)) { - UndoType *ut = MEM_cnew(__func__); + UndoType *ut = MEM_callocN(__func__); undosys_fn(ut); diff --git a/source/blender/blenkernel/intern/viewer_path.cc b/source/blender/blenkernel/intern/viewer_path.cc index 8faa524ef86..3f10f31a10d 100644 --- a/source/blender/blenkernel/intern/viewer_path.cc +++ b/source/blender/blenkernel/intern/viewer_path.cc @@ -174,7 +174,7 @@ void BKE_viewer_path_id_remap(ViewerPath *viewer_path, template static T *make_elem(const ViewerPathElemType type) { - T *elem = MEM_cnew(__func__); + T *elem = MEM_callocN(__func__); elem->base.type = type; return elem; } diff --git a/source/blender/blenkernel/intern/workspace.cc b/source/blender/blenkernel/intern/workspace.cc index e51043c18e5..c09854fe4d6 100644 --- a/source/blender/blenkernel/intern/workspace.cc +++ b/source/blender/blenkernel/intern/workspace.cc @@ -239,7 +239,7 @@ static void workspace_relation_add(ListBase *relation_list, const int parentid, void *data) { - WorkSpaceDataRelation *relation = MEM_cnew(__func__); + WorkSpaceDataRelation *relation = MEM_callocN(__func__); relation->parent = parent; relation->parentid = parentid; relation->value = data; @@ -336,7 +336,7 @@ void BKE_workspace_remove(Main *bmain, WorkSpace *workspace) WorkSpaceInstanceHook *BKE_workspace_instance_hook_create(const Main *bmain, const int winid) { - WorkSpaceInstanceHook *hook = MEM_cnew(__func__); + WorkSpaceInstanceHook *hook = MEM_callocN(__func__); /* set an active screen-layout for each possible window/workspace combination */ for (WorkSpace *workspace = static_cast(bmain->workspaces.first); workspace; @@ -380,7 +380,7 @@ WorkSpaceLayout *BKE_workspace_layout_add(Main *bmain, bScreen *screen, const char *name) { - WorkSpaceLayout *layout = MEM_cnew(__func__); + WorkSpaceLayout *layout = MEM_callocN(__func__); BLI_assert(!workspaces_is_screen_used(bmain, screen)); #ifdef NDEBUG diff --git a/source/blender/blenlib/intern/BLI_args.cc b/source/blender/blenlib/intern/BLI_args.cc index 49c8dd6c2c7..4e75121b968 100644 --- a/source/blender/blenlib/intern/BLI_args.cc +++ b/source/blender/blenlib/intern/BLI_args.cc @@ -108,8 +108,8 @@ static void args_print_wrapper(void * /*user_data*/, const char *format, va_list bArgs *BLI_args_create(int argc, const char **argv) { - bArgs *ba = MEM_cnew("bArgs"); - ba->passes = MEM_cnew_array(argc, "bArgs passes"); + bArgs *ba = MEM_callocN("bArgs"); + ba->passes = MEM_calloc_arrayN(argc, "bArgs passes"); ba->items = BLI_ghash_new(keyhash, keycmp, "bArgs passes gh"); BLI_listbase_clear(&ba->docs); ba->argc = argc; @@ -166,7 +166,7 @@ static bArgDoc *internalDocs(bArgs *ba, { bArgDoc *d; - d = MEM_cnew("bArgDoc"); + d = MEM_callocN("bArgDoc"); if (doc == nullptr) { doc = NO_DOCS; @@ -202,8 +202,8 @@ static void internalAdd( a->key->case_str == 1 ? "not " : ""); } - a = MEM_cnew("bArgument"); - key = MEM_cnew("bAKey"); + a = MEM_callocN("bArgument"); + key = MEM_callocN("bAKey"); key->arg = arg; key->pass = pass; diff --git a/source/blender/blenlib/intern/BLI_dial_2d.cc b/source/blender/blenlib/intern/BLI_dial_2d.cc index 5e85cc5b8b8..dc20fd40e68 100644 --- a/source/blender/blenlib/intern/BLI_dial_2d.cc +++ b/source/blender/blenlib/intern/BLI_dial_2d.cc @@ -36,7 +36,7 @@ struct Dial { Dial *BLI_dial_init(const float start_position[2], float threshold) { - Dial *dial = MEM_cnew("dial"); + Dial *dial = MEM_callocN("dial"); copy_v2_v2(dial->center, start_position); dial->threshold_squared = threshold * threshold; diff --git a/source/blender/blenlib/intern/BLI_dynstr.cc b/source/blender/blenlib/intern/BLI_dynstr.cc index aaf60e3a1aa..b1a61fcfe64 100644 --- a/source/blender/blenlib/intern/BLI_dynstr.cc +++ b/source/blender/blenlib/intern/BLI_dynstr.cc @@ -35,12 +35,12 @@ struct DynStr { DynStr *BLI_dynstr_new() { - return MEM_cnew("DynStr"); + return MEM_callocN("DynStr"); } DynStr *BLI_dynstr_new_memarena() { - DynStr *ds = MEM_cnew("DynStr"); + DynStr *ds = MEM_callocN("DynStr"); ds->memarena = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, __func__); return ds; diff --git a/source/blender/blenlib/intern/BLI_ghash.cc b/source/blender/blenlib/intern/BLI_ghash.cc index 44f6284ffcf..2df955b571f 100644 --- a/source/blender/blenlib/intern/BLI_ghash.cc +++ b/source/blender/blenlib/intern/BLI_ghash.cc @@ -416,7 +416,7 @@ static GHash *ghash_new(GHashHashFP hashfp, const uint nentries_reserve, const uint flag) { - GHash *gh = MEM_cnew(info); + GHash *gh = MEM_callocN(info); gh->hashfp = hashfp; gh->cmpfp = cmpfp; @@ -887,7 +887,7 @@ void BLI_ghash_flag_clear(GHash *gh, uint flag) GHashIterator *BLI_ghashIterator_new(GHash *gh) { - GHashIterator *ghi = MEM_cnew("ghash iterator"); + GHashIterator *ghi = MEM_callocN("ghash iterator"); BLI_ghashIterator_init(ghi, gh); return ghi; } diff --git a/source/blender/blenlib/intern/BLI_heap.cc b/source/blender/blenlib/intern/BLI_heap.cc index 6ce8518c965..25142665d06 100644 --- a/source/blender/blenlib/intern/BLI_heap.cc +++ b/source/blender/blenlib/intern/BLI_heap.cc @@ -170,11 +170,11 @@ static void heap_node_free(Heap *heap, HeapNode *node) Heap *BLI_heap_new_ex(uint reserve_num) { - Heap *heap = MEM_cnew(__func__); + Heap *heap = MEM_callocN(__func__); /* ensure we have at least one so we can keep doubling it */ heap->size = 0; heap->bufsize = std::max(1u, reserve_num); - heap->tree = MEM_cnew_array(heap->bufsize, "BLIHeapTree"); + heap->tree = MEM_calloc_arrayN(heap->bufsize, "BLIHeapTree"); heap->nodes.chunk = heap_node_alloc_chunk( (reserve_num > 1) ? reserve_num : HEAP_CHUNK_DEFAULT_NUM, nullptr); diff --git a/source/blender/blenlib/intern/BLI_heap_simple.cc b/source/blender/blenlib/intern/BLI_heap_simple.cc index f555e937c84..3a5c4ed6a01 100644 --- a/source/blender/blenlib/intern/BLI_heap_simple.cc +++ b/source/blender/blenlib/intern/BLI_heap_simple.cc @@ -138,11 +138,11 @@ static void heapsimple_up(HeapSimple *heap, uint i, float active_val, void *acti HeapSimple *BLI_heapsimple_new_ex(uint reserve_num) { - HeapSimple *heap = MEM_cnew(__func__); + HeapSimple *heap = MEM_callocN(__func__); /* ensure we have at least one so we can keep doubling it */ heap->size = 0; heap->bufsize = std::max(1u, reserve_num); - heap->tree = MEM_cnew_array(heap->bufsize, "BLIHeapSimpleTree"); + heap->tree = MEM_calloc_arrayN(heap->bufsize, "BLIHeapSimpleTree"); return heap; } diff --git a/source/blender/blenlib/intern/BLI_kdopbvh.cc b/source/blender/blenlib/intern/BLI_kdopbvh.cc index c94acf6b86c..ddbee96847d 100644 --- a/source/blender/blenlib/intern/BLI_kdopbvh.cc +++ b/source/blender/blenlib/intern/BLI_kdopbvh.cc @@ -856,7 +856,7 @@ BVHTree *BLI_bvhtree_new(int maxsize, float epsilon, char tree_type, char axis) BLI_assert(tree_type >= 2 && tree_type <= MAX_TREETYPE); - BVHTree *tree = MEM_cnew(__func__); + BVHTree *tree = MEM_callocN(__func__); /* tree epsilon must be >= FLT_EPSILON * so that tangent rays can still hit a bounding volume.. @@ -899,10 +899,10 @@ BVHTree *BLI_bvhtree_new(int maxsize, float epsilon, char tree_type, char axis) /* Allocate arrays */ numnodes = maxsize + implicit_needed_branches(tree_type, maxsize) + tree_type; - tree->nodes = MEM_cnew_array(size_t(numnodes), "BVHNodes"); - tree->nodebv = MEM_cnew_array(axis * size_t(numnodes), "BVHNodeBV"); - tree->nodechild = MEM_cnew_array(tree_type * size_t(numnodes), "BVHNodeBV"); - tree->nodearray = MEM_cnew_array(size_t(numnodes), "BVHNodeArray"); + tree->nodes = MEM_calloc_arrayN(size_t(numnodes), "BVHNodes"); + tree->nodebv = MEM_calloc_arrayN(axis * size_t(numnodes), "BVHNodeBV"); + tree->nodechild = MEM_calloc_arrayN(tree_type * size_t(numnodes), "BVHNodeBV"); + tree->nodearray = MEM_calloc_arrayN(size_t(numnodes), "BVHNodeArray"); if (UNLIKELY((!tree->nodes) || (!tree->nodebv) || (!tree->nodechild) || (!tree->nodearray))) { goto fail; diff --git a/source/blender/blenlib/intern/BLI_linklist.cc b/source/blender/blenlib/intern/BLI_linklist.cc index 0ead5dee134..175b601e57a 100644 --- a/source/blender/blenlib/intern/BLI_linklist.cc +++ b/source/blender/blenlib/intern/BLI_linklist.cc @@ -237,7 +237,7 @@ void *BLI_linklist_pop_pool(LinkNode **listp, BLI_mempool *mempool) void BLI_linklist_insert_after(LinkNode **listp, void *ptr) { - LinkNode *nlink = MEM_cnew(__func__); + LinkNode *nlink = MEM_callocN(__func__); LinkNode *node = *listp; nlink->link = ptr; diff --git a/source/blender/blenlib/intern/BLI_memarena.cc b/source/blender/blenlib/intern/BLI_memarena.cc index e46a96b09d8..d043ec67939 100644 --- a/source/blender/blenlib/intern/BLI_memarena.cc +++ b/source/blender/blenlib/intern/BLI_memarena.cc @@ -65,7 +65,7 @@ static void memarena_buf_free_all(MemBuf *mb) MemArena *BLI_memarena_new(const size_t bufsize, const char *name) { - MemArena *ma = MEM_cnew("memarena"); + MemArena *ma = MEM_callocN("memarena"); ma->bufsize = bufsize; ma->align = 8; ma->name = name; @@ -130,8 +130,13 @@ void *BLI_memarena_alloc(MemArena *ma, size_t size) ma->cursize = ma->bufsize; } - MemBuf *mb = static_cast( - (ma->use_calloc ? MEM_callocN : MEM_mallocN)(sizeof(*mb) + ma->cursize, ma->name)); + MemBuf *mb; + if (ma->use_calloc) { + mb = static_cast(MEM_callocN(sizeof(*mb) + ma->cursize, ma->name)); + } + else { + mb = static_cast(MEM_mallocN(sizeof(*mb) + ma->cursize, ma->name)); + } ma->curbuf = mb->data; mb->next = ma->bufs; ma->bufs = mb; diff --git a/source/blender/blenlib/intern/BLI_memblock.cc b/source/blender/blenlib/intern/BLI_memblock.cc index f391337d506..fa05d6621c5 100644 --- a/source/blender/blenlib/intern/BLI_memblock.cc +++ b/source/blender/blenlib/intern/BLI_memblock.cc @@ -47,13 +47,13 @@ BLI_memblock *BLI_memblock_create_ex(uint elem_size, uint chunk_size) { BLI_assert(elem_size < chunk_size); - BLI_memblock *mblk = MEM_cnew("BLI_memblock"); + BLI_memblock *mblk = MEM_callocN("BLI_memblock"); mblk->elem_size = int(elem_size); mblk->elem_next = 0; mblk->elem_last = -1; mblk->chunk_size = int(chunk_size); mblk->chunk_len = CHUNK_LIST_SIZE; - mblk->chunk_list = MEM_cnew_array(size_t(mblk->chunk_len), "chunk list"); + mblk->chunk_list = MEM_calloc_arrayN(size_t(mblk->chunk_len), "chunk list"); mblk->chunk_list[0] = MEM_mallocN_aligned(size_t(mblk->chunk_size), 32, "BLI_memblock chunk"); memset(mblk->chunk_list[0], 0x0, uint(mblk->chunk_size)); mblk->chunk_max_ofs = (mblk->chunk_size / mblk->elem_size) * mblk->elem_size; diff --git a/source/blender/blenlib/intern/BLI_memiter.cc b/source/blender/blenlib/intern/BLI_memiter.cc index f754370923e..5a482d7a921 100644 --- a/source/blender/blenlib/intern/BLI_memiter.cc +++ b/source/blender/blenlib/intern/BLI_memiter.cc @@ -115,7 +115,7 @@ static void memiter_init(BLI_memiter *mi) BLI_memiter *BLI_memiter_create(uint chunk_size_min) { - BLI_memiter *mi = MEM_cnew("BLI_memiter"); + BLI_memiter *mi = MEM_callocN("BLI_memiter"); memiter_init(mi); /* Small values are used for tests to check for correctness, diff --git a/source/blender/blenlib/intern/BLI_mempool.cc b/source/blender/blenlib/intern/BLI_mempool.cc index 76a9b83e7b2..94f0f6e8838 100644 --- a/source/blender/blenlib/intern/BLI_mempool.cc +++ b/source/blender/blenlib/intern/BLI_mempool.cc @@ -340,7 +340,7 @@ BLI_mempool *BLI_mempool_create(uint esize, uint elem_num, uint pchunk, uint fla uint i, maxchunks; /* allocate the pool structure */ - pool = MEM_cnew("memory pool"); + pool = MEM_callocN("memory pool"); #ifdef WITH_ASAN BLI_mutex_init(&pool->mutex); @@ -618,8 +618,9 @@ ParallelMempoolTaskData *mempool_iter_threadsafe_create(BLI_mempool *pool, const { BLI_assert(pool->flag & BLI_MEMPOOL_ALLOW_ITER); - ParallelMempoolTaskData *iter_arr = MEM_cnew_array(iter_num, __func__); - BLI_mempool_chunk **curchunk_threaded_shared = MEM_cnew(__func__); + ParallelMempoolTaskData *iter_arr = MEM_calloc_arrayN(iter_num, + __func__); + BLI_mempool_chunk **curchunk_threaded_shared = MEM_callocN(__func__); mempool_threadsafe_iternew(pool, &iter_arr->ts_iter); diff --git a/source/blender/blenlib/intern/BLI_mmap.cc b/source/blender/blenlib/intern/BLI_mmap.cc index af640308a0e..5317e7935ba 100644 --- a/source/blender/blenlib/intern/BLI_mmap.cc +++ b/source/blender/blenlib/intern/BLI_mmap.cc @@ -167,7 +167,7 @@ BLI_mmap_file *BLI_mmap_open(int fd) #endif /* Now that the mapping was successful, allocate memory and set up the BLI_mmap_file. */ - BLI_mmap_file *file = MEM_cnew(__func__); + BLI_mmap_file *file = MEM_callocN(__func__); file->memory = static_cast(memory); file->handle = handle; file->length = length; diff --git a/source/blender/blenlib/intern/BLI_timer.cc b/source/blender/blenlib/intern/BLI_timer.cc index a72b2280287..e4f0b385324 100644 --- a/source/blender/blenlib/intern/BLI_timer.cc +++ b/source/blender/blenlib/intern/BLI_timer.cc @@ -38,7 +38,7 @@ void BLI_timer_register(uintptr_t uuid, double first_interval, bool persistent) { - TimedFunction *timed_func = MEM_cnew(__func__); + TimedFunction *timed_func = MEM_callocN(__func__); timed_func->func = func; timed_func->user_data_free = user_data_free; timed_func->user_data = user_data; diff --git a/source/blender/blenlib/intern/array_store.cc b/source/blender/blenlib/intern/array_store.cc index 3e8ee443fc2..17f314b2574 100644 --- a/source/blender/blenlib/intern/array_store.cc +++ b/source/blender/blenlib/intern/array_store.cc @@ -1497,7 +1497,7 @@ BArrayStore *BLI_array_store_create(uint stride, uint chunk_count) { BLI_assert(stride > 0 && chunk_count > 0); - BArrayStore *bs = MEM_cnew(__func__); + BArrayStore *bs = MEM_callocN(__func__); bs->info.chunk_stride = stride; // bs->info.chunk_count = chunk_count; @@ -1656,7 +1656,7 @@ BArrayState *BLI_array_store_state_add(BArrayStore *bs, chunk_list->users += 1; - BArrayState *state = MEM_cnew(__func__); + BArrayState *state = MEM_callocN(__func__); state->chunk_list = chunk_list; BLI_addtail(&bs->states, state); diff --git a/source/blender/blenlib/intern/boxpack_2d.cc b/source/blender/blenlib/intern/boxpack_2d.cc index 623393832eb..9cb05a2fb67 100644 --- a/source/blender/blenlib/intern/boxpack_2d.cc +++ b/source/blender/blenlib/intern/boxpack_2d.cc @@ -655,7 +655,7 @@ void BLI_box_pack_2d( void BLI_box_pack_2d_fixedarea(ListBase *boxes, int width, int height, ListBase *packed) { ListBase spaces = {nullptr}; - FixedSizeBoxPack *full_rect = MEM_cnew(__func__); + FixedSizeBoxPack *full_rect = MEM_callocN(__func__); full_rect->w = width; full_rect->h = height; @@ -717,7 +717,7 @@ void BLI_box_pack_2d_fixedarea(ListBase *boxes, int width, int height, ListBase /* Perform split. This space becomes the larger space, * while the new smaller space is inserted _before_ it. */ - FixedSizeBoxPack *new_space = MEM_cnew(__func__); + FixedSizeBoxPack *new_space = MEM_callocN(__func__); if (area_hsplit_large > area_vsplit_large) { new_space->x = space->x + box->w; new_space->y = space->y; diff --git a/source/blender/blenlib/intern/fileops_c.cc b/source/blender/blenlib/intern/fileops_c.cc index f17435308c2..25b4effa323 100644 --- a/source/blender/blenlib/intern/fileops_c.cc +++ b/source/blender/blenlib/intern/fileops_c.cc @@ -403,7 +403,7 @@ bool BLI_dir_create_recursive(const char *dirname) size_t len = strlen(dirname); if (len >= sizeof(dirname_static_buf)) { - dirname_mut = MEM_cnew_array(len + 1, __func__); + dirname_mut = MEM_calloc_arrayN(len + 1, __func__); } memcpy(dirname_mut, dirname, len + 1); @@ -786,7 +786,7 @@ static const char *path_destination_ensure_filename(const char *path_src, size_t buf_size_needed = path_dst_len + strlen(filename_src) + 1; char *path_dst_with_filename = (buf_size_needed <= buf_size) ? buf : - MEM_cnew_array(buf_size_needed, __func__); + MEM_calloc_arrayN(buf_size_needed, __func__); BLI_string_join(path_dst_with_filename, buf_size_needed, path_dst, filename_src); return path_dst_with_filename; } @@ -1389,7 +1389,7 @@ static int copy_single_file(const char *from, const char *to) need_free = 0; } else { - link_buffer = MEM_cnew_array(st.st_size + 2, "copy_single_file link_buffer"); + link_buffer = MEM_calloc_arrayN(st.st_size + 2, "copy_single_file link_buffer"); need_free = 1; } @@ -1512,7 +1512,7 @@ static const char *path_destination_ensure_filename(const char *path_src, const size_t buf_size_needed = strlen(path_dst) + 1 + strlen(filename_src) + 1; char *path_dst_with_filename = (buf_size_needed <= buf_size) ? buf : - MEM_cnew_array(buf_size_needed, __func__); + MEM_calloc_arrayN(buf_size_needed, __func__); BLI_path_join(path_dst_with_filename, buf_size_needed, path_dst, filename_src); path_dst = path_dst_with_filename; } diff --git a/source/blender/blenlib/intern/filereader_file.cc b/source/blender/blenlib/intern/filereader_file.cc index 9421059c779..3517310fcd1 100644 --- a/source/blender/blenlib/intern/filereader_file.cc +++ b/source/blender/blenlib/intern/filereader_file.cc @@ -53,7 +53,7 @@ static void file_close(FileReader *reader) FileReader *BLI_filereader_new_file(int filedes) { - RawFileReader *rawfile = MEM_cnew(__func__); + RawFileReader *rawfile = MEM_callocN(__func__); rawfile->filedes = filedes; diff --git a/source/blender/blenlib/intern/filereader_gzip.cc b/source/blender/blenlib/intern/filereader_gzip.cc index f4a4f37d0e6..a62d668674b 100644 --- a/source/blender/blenlib/intern/filereader_gzip.cc +++ b/source/blender/blenlib/intern/filereader_gzip.cc @@ -74,7 +74,7 @@ static void gzip_close(FileReader *reader) FileReader *BLI_filereader_new_gzip(FileReader *base) { - GzipReader *gzip = MEM_cnew(__func__); + GzipReader *gzip = MEM_callocN(__func__); gzip->base = base; if (inflateInit2(&gzip->strm, 16 + MAX_WBITS) != Z_OK) { diff --git a/source/blender/blenlib/intern/filereader_memory.cc b/source/blender/blenlib/intern/filereader_memory.cc index 73854fcf7df..1d795cf2ac9 100644 --- a/source/blender/blenlib/intern/filereader_memory.cc +++ b/source/blender/blenlib/intern/filereader_memory.cc @@ -70,7 +70,7 @@ static void memory_close_raw(FileReader *reader) FileReader *BLI_filereader_new_memory(const void *data, size_t len) { - MemoryReader *mem = MEM_cnew(__func__); + MemoryReader *mem = MEM_callocN(__func__); mem->data = (const char *)data; mem->length = len; @@ -118,7 +118,7 @@ FileReader *BLI_filereader_new_mmap(int filedes) return nullptr; } - MemoryReader *mem = MEM_cnew(__func__); + MemoryReader *mem = MEM_callocN(__func__); mem->mmap = mmap; mem->length = BLI_mmap_get_length(mmap); diff --git a/source/blender/blenlib/intern/filereader_zstd.cc b/source/blender/blenlib/intern/filereader_zstd.cc index a8e8f79f944..0de92aa6dca 100644 --- a/source/blender/blenlib/intern/filereader_zstd.cc +++ b/source/blender/blenlib/intern/filereader_zstd.cc @@ -303,7 +303,7 @@ static void zstd_close(FileReader *reader) FileReader *BLI_filereader_new_zstd(FileReader *base) { - ZstdReader *zstd = MEM_cnew(__func__); + ZstdReader *zstd = MEM_callocN(__func__); zstd->ctx = ZSTD_createDCtx(); zstd->base = base; diff --git a/source/blender/blenlib/intern/gsqueue.cc b/source/blender/blenlib/intern/gsqueue.cc index 67b0824054f..09d4e6bacc7 100644 --- a/source/blender/blenlib/intern/gsqueue.cc +++ b/source/blender/blenlib/intern/gsqueue.cc @@ -71,7 +71,7 @@ static size_t queue_chunk_elem_max_calc(const size_t elem_size, size_t chunk_siz GSQueue *BLI_gsqueue_new(const size_t elem_size) { - GSQueue *queue = MEM_cnew("BLI_gsqueue_new"); + GSQueue *queue = MEM_callocN("BLI_gsqueue_new"); queue->chunk_elem_max = queue_chunk_elem_max_calc(elem_size, CHUNK_SIZE_DEFAULT); queue->elem_size = elem_size; diff --git a/source/blender/blenlib/intern/kdtree_impl.h b/source/blender/blenlib/intern/kdtree_impl.h index d1121dcff16..bd7ca4a350a 100644 --- a/source/blender/blenlib/intern/kdtree_impl.h +++ b/source/blender/blenlib/intern/kdtree_impl.h @@ -94,7 +94,7 @@ KDTree *BLI_kdtree_nd_(new)(uint nodes_len_capacity) { KDTree *tree; - tree = MEM_cnew("KDTree"); + tree = MEM_callocN("KDTree"); tree->nodes = static_cast( MEM_mallocN(sizeof(KDTreeNode) * nodes_len_capacity, "KDTreeNode")); tree->nodes_len = 0; diff --git a/source/blender/blenlib/intern/listbase.cc b/source/blender/blenlib/intern/listbase.cc index 99065d2613c..7488a4d285b 100644 --- a/source/blender/blenlib/intern/listbase.cc +++ b/source/blender/blenlib/intern/listbase.cc @@ -916,7 +916,7 @@ LinkData *BLI_genericNodeN(void *data) } /* create new link, and make it hold the given data */ - ld = MEM_cnew(__func__); + ld = MEM_callocN(__func__); ld->data = data; return ld; diff --git a/source/blender/blenlib/intern/path_utils.cc b/source/blender/blenlib/intern/path_utils.cc index e3683d0d6ee..1e11c02325a 100644 --- a/source/blender/blenlib/intern/path_utils.cc +++ b/source/blender/blenlib/intern/path_utils.cc @@ -1988,9 +1988,9 @@ int BLI_path_cmp_normalized(const char *p1, const char *p2) const size_t p2_size = strlen(p2) + 1; char *norm_p1 = (p1_size <= sizeof(norm_p1_buf)) ? norm_p1_buf : - MEM_cnew_array(p1_size, __func__); + MEM_calloc_arrayN(p1_size, __func__); char *norm_p2 = (p2_size <= sizeof(norm_p2_buf)) ? norm_p2_buf : - MEM_cnew_array(p2_size, __func__); + MEM_calloc_arrayN(p2_size, __func__); memcpy(norm_p1, p1, p1_size); memcpy(norm_p2, p2, p2_size); diff --git a/source/blender/blenlib/intern/scanfill.cc b/source/blender/blenlib/intern/scanfill.cc index 05e3134070d..71e22ccda32 100644 --- a/source/blender/blenlib/intern/scanfill.cc +++ b/source/blender/blenlib/intern/scanfill.cc @@ -1067,7 +1067,7 @@ uint BLI_scanfill_calc_ex(ScanFillContext *sf_ctx, const int flag, const float n } #endif - uint *target_map = MEM_cnew_array(poly, "polycache"); + uint *target_map = MEM_calloc_arrayN(poly, "polycache"); range_vn_u(target_map, poly, 0); for (a = 0; a < poly; a++) { diff --git a/source/blender/blenlib/intern/scanfill_utils.cc b/source/blender/blenlib/intern/scanfill_utils.cc index ceeb44e6188..cf023f18563 100644 --- a/source/blender/blenlib/intern/scanfill_utils.cc +++ b/source/blender/blenlib/intern/scanfill_utils.cc @@ -93,7 +93,7 @@ static ListBase *edge_isect_ls_ensure(GHash *isect_hash, ScanFillEdge *eed) void **val_p; if (!BLI_ghash_ensure_p(isect_hash, eed, &val_p)) { - *val_p = MEM_cnew(__func__); + *val_p = MEM_callocN(__func__); } return static_cast(*val_p); @@ -104,7 +104,7 @@ static ListBase *edge_isect_ls_add(GHash *isect_hash, ScanFillEdge *eed, ScanFil ListBase *e_ls; LinkData *isect_link; e_ls = edge_isect_ls_ensure(isect_hash, eed); - isect_link = MEM_cnew(__func__); + isect_link = MEM_callocN(__func__); isect_link->data = isect; EFLAG_SET(eed, E_ISISECT); BLI_addtail(e_ls, isect_link); @@ -367,7 +367,7 @@ bool BLI_scanfill_calc_self_isect(ScanFillContext *sf_ctx, return false; } - PolyInfo *poly_info = MEM_cnew_array(poly_num, __func__); + PolyInfo *poly_info = MEM_calloc_arrayN(poly_num, __func__); /* get the polygon span */ if (sf_ctx->poly_nr == 0) { diff --git a/source/blender/blenlib/intern/stack.cc b/source/blender/blenlib/intern/stack.cc index 2e9d59da8ff..15f24e805c9 100644 --- a/source/blender/blenlib/intern/stack.cc +++ b/source/blender/blenlib/intern/stack.cc @@ -69,7 +69,7 @@ BLI_Stack *BLI_stack_new_ex(const size_t elem_size, const char *description, const size_t chunk_size) { - BLI_Stack *stack = MEM_cnew(description); + BLI_Stack *stack = MEM_callocN(description); stack->chunk_elem_max = stack_chunk_elem_max_calc(elem_size, chunk_size); stack->elem_size = elem_size; diff --git a/source/blender/blenlib/intern/storage.cc b/source/blender/blenlib/intern/storage.cc index f65352e016b..4aea5859874 100644 --- a/source/blender/blenlib/intern/storage.cc +++ b/source/blender/blenlib/intern/storage.cc @@ -594,7 +594,7 @@ LinkNode *BLI_file_read_as_lines(const char *filepath) return nullptr; } - buf = MEM_cnew_array(size, "file_as_lines"); + buf = MEM_calloc_arrayN(size, "file_as_lines"); if (buf) { size_t i, last = 0; diff --git a/source/blender/blenlib/intern/string.cc b/source/blender/blenlib/intern/string.cc index 31a1deec514..3d705ba7481 100644 --- a/source/blender/blenlib/intern/string.cc +++ b/source/blender/blenlib/intern/string.cc @@ -55,7 +55,7 @@ char *BLI_strdupcat(const char *__restrict str1, const char *__restrict str2) const size_t str2_len = strlen(str2) + 1; char *str, *s; - str = MEM_cnew_array(str1_len + str2_len, "strdupcat"); + str = MEM_calloc_arrayN(str1_len + str2_len, "strdupcat"); s = str; memcpy(s, str1, str1_len); /* NOLINT: bugprone-not-null-terminated-result */ @@ -244,7 +244,7 @@ char *BLI_sprintfN_with_buffer( /* Return an empty string as there was an error there is no valid output. */ *result_len = 0; if (UNLIKELY(fixed_buf_size == 0)) { - return MEM_cnew_array(1, __func__); + return MEM_calloc_arrayN(1, __func__); } *fixed_buf = '\0'; return fixed_buf; @@ -279,7 +279,7 @@ char *BLI_vsprintfN_with_buffer(char *fixed_buf, /* Return an empty string as there was an error there is no valid output. */ *result_len = 0; if (UNLIKELY(fixed_buf_size == 0)) { - return MEM_cnew_array(1, __func__); + return MEM_calloc_arrayN(1, __func__); } *fixed_buf = '\0'; return fixed_buf; @@ -326,7 +326,7 @@ char *BLI_vsprintfN(const char *__restrict format, va_list args) return result; } size_t size = result_len + 1; - result = MEM_cnew_array(size, __func__); + result = MEM_calloc_arrayN(size, __func__); memcpy(result, fixed_buf, size); return result; } diff --git a/source/blender/blenlib/intern/string_utils.cc b/source/blender/blenlib/intern/string_utils.cc index 18ea6f21c48..c5484d80aee 100644 --- a/source/blender/blenlib/intern/string_utils.cc +++ b/source/blender/blenlib/intern/string_utils.cc @@ -607,7 +607,7 @@ size_t BLI_string_join_array_by_sep_char( char *BLI_string_join_arrayN(const char *strings[], uint strings_num) { const size_t result_size = BLI_string_len_array(strings, strings_num) + 1; - char *result = MEM_cnew_array(result_size, __func__); + char *result = MEM_calloc_arrayN(result_size, __func__); char *c = result; for (uint i = 0; i < strings_num; i++) { const size_t string_len = strlen(strings[i]); @@ -624,7 +624,7 @@ char *BLI_string_join_array_by_sep_charN(char sep, const char *strings[], uint s { const size_t result_size = BLI_string_len_array(strings, strings_num) + (strings_num ? strings_num - 1 : 0) + 1; - char *result = MEM_cnew_array(result_size, __func__); + char *result = MEM_calloc_arrayN(result_size, __func__); char *c = result; if (strings_num != 0) { for (uint i = 0; i < strings_num; i++) { @@ -654,7 +654,7 @@ char *BLI_string_join_array_by_sep_char_with_tableN(char sep, result_size = 1; } - char *result = MEM_cnew_array(result_size, __func__); + char *result = MEM_calloc_arrayN(result_size, __func__); char *c = result; if (strings_num != 0) { for (uint i = 0; i < strings_num; i++) { diff --git a/source/blender/blenlib/tests/BLI_array_state_test.cc b/source/blender/blenlib/tests/BLI_array_state_test.cc index d04a8fc683f..3cc14670ee1 100644 --- a/source/blender/blenlib/tests/BLI_array_state_test.cc +++ b/source/blender/blenlib/tests/BLI_array_state_test.cc @@ -27,7 +27,7 @@ TEST(array_state, NoSharing) TEST(array_state, WithSharing) { - int *data = MEM_cnew_array(3, __func__); + int *data = MEM_calloc_arrayN(3, __func__); data[0] = 0; data[1] = 10; data[2] = 20; @@ -42,13 +42,13 @@ TEST(array_state, WithSharing) TEST(array_state, DifferentSharingInfoButSameData) { - int *data1 = MEM_cnew_array(3, __func__); + int *data1 = MEM_calloc_arrayN(3, __func__); data1[0] = 0; data1[1] = 10; data1[2] = 20; ImplicitSharingPtr sharing_info1{implicit_sharing::info_for_mem_free(data1)}; - int *data2 = MEM_cnew_array(3, __func__); + int *data2 = MEM_calloc_arrayN(3, __func__); data2[0] = 0; data2[1] = 10; data2[2] = 20; diff --git a/source/blender/blenlib/tests/BLI_task_test.cc b/source/blender/blenlib/tests/BLI_task_test.cc index 82aa3a7e3c6..303fc3d2edc 100644 --- a/source/blender/blenlib/tests/BLI_task_test.cc +++ b/source/blender/blenlib/tests/BLI_task_test.cc @@ -156,7 +156,7 @@ static void task_mempool_iter_tls_func(void * /*userdata*/, EXPECT_TRUE(data != nullptr); if (task_data->accumulate_items == nullptr) { - task_data->accumulate_items = MEM_cnew(__func__); + task_data->accumulate_items = MEM_callocN(__func__); } /* Flip to prove this has been touched. */ @@ -174,7 +174,7 @@ static void task_mempool_iter_tls_reduce(const void *__restrict /*userdata*/, if (data_chunk->accumulate_items != nullptr) { if (join_chunk->accumulate_items == nullptr) { - join_chunk->accumulate_items = MEM_cnew(__func__); + join_chunk->accumulate_items = MEM_callocN(__func__); } BLI_movelisttolist(join_chunk->accumulate_items, data_chunk->accumulate_items); } diff --git a/source/blender/blenlib/tests/BLI_vector_test.cc b/source/blender/blenlib/tests/BLI_vector_test.cc index a39f2930ee1..7a13fc6126c 100644 --- a/source/blender/blenlib/tests/BLI_vector_test.cc +++ b/source/blender/blenlib/tests/BLI_vector_test.cc @@ -944,7 +944,7 @@ TEST(vector, RecursiveStructure) TEST(vector, FromRaw) { VectorData data; - data.data = MEM_cnew_array(30, __func__); + data.data = MEM_calloc_arrayN(30, __func__); data.size = 10; data.capacity = 30; diff --git a/source/blender/blenloader/intern/readfile.cc b/source/blender/blenloader/intern/readfile.cc index 02dc34def83..832c1441b27 100644 --- a/source/blender/blenloader/intern/readfile.cc +++ b/source/blender/blenloader/intern/readfile.cc @@ -2142,7 +2142,7 @@ static void readfile_id_runtime_data_ensure(ID &id) if (id.runtime.readfile_data) { return; } - id.runtime.readfile_data = MEM_cnew(__func__); + id.runtime.readfile_data = MEM_callocN(__func__); } ID_Readfile_Data::Tags BLO_readfile_id_runtime_tags(ID &id) diff --git a/source/blender/blenloader/intern/versioning_260.cc b/source/blender/blenloader/intern/versioning_260.cc index f8d6953a35c..9cb209306ab 100644 --- a/source/blender/blenloader/intern/versioning_260.cc +++ b/source/blender/blenloader/intern/versioning_260.cc @@ -254,7 +254,7 @@ static void do_versions_nodetree_multi_file_output_format_2_62_1(Scene *sce, bNo if (node->type_legacy == CMP_NODE_OUTPUT_FILE) { /* previous CMP_NODE_OUTPUT_FILE nodes get converted to multi-file outputs */ NodeImageFile *old_data = static_cast(node->storage); - NodeImageMultiFile *nimf = MEM_cnew("node image multi file"); + NodeImageMultiFile *nimf = MEM_callocN("node image multi file"); bNodeSocket *old_image = static_cast(BLI_findlink(&node->inputs, 0)); bNodeSocket *old_z = static_cast(BLI_findlink(&node->inputs, 1)); @@ -400,7 +400,7 @@ static void do_versions_nodetree_image_layer_2_64_5(bNodeTree *ntree) LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { if (node->type_legacy == CMP_NODE_IMAGE) { LISTBASE_FOREACH (bNodeSocket *, sock, &node->outputs) { - NodeImageLayer *output = MEM_cnew("node image layer"); + NodeImageLayer *output = MEM_callocN("node image layer"); /* Take pass index both from current storage pointer (actually an int). */ output->pass_index = POINTER_AS_INT(sock->storage); @@ -418,7 +418,7 @@ static void do_versions_nodetree_frame_2_64_6(bNodeTree *ntree) if (node->type_legacy == NODE_FRAME) { /* initialize frame node storage data */ if (node->storage == nullptr) { - NodeFrame *data = MEM_cnew("frame node storage"); + NodeFrame *data = MEM_callocN("frame node storage"); node->storage = data; /* copy current flags */ @@ -1052,7 +1052,7 @@ static bNodeSocket *version_make_socket_stub(const char *idname, const void *default_value, const IDProperty *prop) { - bNodeSocket *socket = MEM_cnew(__func__); + bNodeSocket *socket = MEM_callocN(__func__); socket->runtime = MEM_new(__func__); STRNCPY(socket->idname, idname); socket->type = int(type); @@ -1081,7 +1081,7 @@ static bNode *version_add_group_in_out_node(bNodeTree *ntree, const int type) ListBase *node_socket_list = nullptr; eNodeSocketInOut socket_in_out = SOCK_IN; - bNode *node = MEM_cnew("new node"); + bNode *node = MEM_callocN("new node"); switch (type) { case NODE_GROUP_INPUT: STRNCPY(node->idname, "NodeGroupInput"); @@ -1789,7 +1789,7 @@ void blo_do_versions_260(FileData *fd, Library * /*lib*/, Main *bmain) LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { if (node->type_legacy == CMP_NODE_DILATEERODE) { if (node->storage == nullptr) { - NodeDilateErode *data = MEM_cnew(__func__); + NodeDilateErode *data = MEM_callocN(__func__); data->falloff = PROP_SMOOTH; node->storage = data; } @@ -1832,7 +1832,7 @@ void blo_do_versions_260(FileData *fd, Library * /*lib*/, Main *bmain) LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { if (node->type_legacy == CMP_NODE_MASK) { if (node->storage == nullptr) { - NodeMask *data = MEM_cnew(__func__); + NodeMask *data = MEM_callocN(__func__); /* move settings into own struct */ data->size_x = int(node->custom3); data->size_y = int(node->custom4); @@ -2196,7 +2196,7 @@ void blo_do_versions_260(FileData *fd, Library * /*lib*/, Main *bmain) if (ntree->type == NTREE_COMPOSIT) { LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { if (node->type_legacy == CMP_NODE_TRANSLATE && node->storage == nullptr) { - node->storage = MEM_cnew("node translate data"); + node->storage = MEM_callocN("node translate data"); } } } diff --git a/source/blender/blenloader/intern/versioning_290.cc b/source/blender/blenloader/intern/versioning_290.cc index 29ba87d1271..c85e7f02059 100644 --- a/source/blender/blenloader/intern/versioning_290.cc +++ b/source/blender/blenloader/intern/versioning_290.cc @@ -152,10 +152,10 @@ static void strip_convert_transform_crop(const Scene *scene, const eSpaceSeq_Proxy_RenderSize render_size) { if (strip->data->transform == nullptr) { - strip->data->transform = MEM_cnew(__func__); + strip->data->transform = MEM_callocN(__func__); } if (strip->data->crop == nullptr) { - strip->data->crop = MEM_cnew(__func__); + strip->data->crop = MEM_callocN(__func__); } StripCrop *c = strip->data->crop; @@ -1635,7 +1635,7 @@ void blo_do_versions_290(FileData *fd, Library * /*lib*/, Main *bmain) if (node->type_legacy != CMP_NODE_SETALPHA) { continue; } - NodeSetAlpha *storage = MEM_cnew("NodeSetAlpha"); + NodeSetAlpha *storage = MEM_callocN("NodeSetAlpha"); storage->mode = CMP_NODE_SETALPHA_MODE_REPLACE_ALPHA; node->storage = storage; } diff --git a/source/blender/blenloader/intern/versioning_300.cc b/source/blender/blenloader/intern/versioning_300.cc index 145d666b781..5a8cd6d5e48 100644 --- a/source/blender/blenloader/intern/versioning_300.cc +++ b/source/blender/blenloader/intern/versioning_300.cc @@ -872,7 +872,7 @@ static void version_geometry_nodes_primitive_uv_maps(bNodeTree &ntree) store_attribute_node->parent = node->parent; store_attribute_node->locx_legacy = node->locx_legacy + 25; store_attribute_node->locy_legacy = node->locy_legacy; - auto &storage = *MEM_cnew(__func__); + auto &storage = *MEM_callocN(__func__); store_attribute_node->storage = &storage; storage.domain = int8_t(blender::bke::AttrDomain::Corner); /* Intentionally use 3D instead of 2D vectors, because 2D vectors did not exist in older @@ -1002,7 +1002,7 @@ static void version_geometry_nodes_extrude_smooth_propagation(bNodeTree &ntree) capture_node.locx_legacy = node->locx_legacy - 25; capture_node.locy_legacy = node->locy_legacy; new_nodes.append(&capture_node); - auto *capture_node_storage = MEM_cnew(__func__); + auto *capture_node_storage = MEM_callocN(__func__); capture_node.storage = capture_node_storage; capture_node_storage->data_type_legacy = CD_PROP_BOOL; capture_node_storage->domain = int8_t(bke::AttrDomain::Face); @@ -3375,7 +3375,7 @@ void blo_do_versions_300(FileData *fd, Library * /*lib*/, Main *bmain) LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { if (node->type_legacy == SH_NODE_MAP_RANGE) { if (node->storage == nullptr) { - NodeMapRange *data = MEM_cnew(__func__); + NodeMapRange *data = MEM_callocN(__func__); data->clamp = node->custom1; data->data_type = CD_PROP_FLOAT; data->interpolation_type = node->custom2; @@ -3618,7 +3618,7 @@ void blo_do_versions_300(FileData *fd, Library * /*lib*/, Main *bmain) if (brush->curves_sculpt_settings != nullptr) { continue; } - brush->curves_sculpt_settings = MEM_cnew(__func__); + brush->curves_sculpt_settings = MEM_callocN(__func__); brush->curves_sculpt_settings->add_amount = 1; } @@ -3791,7 +3791,8 @@ void blo_do_versions_300(FileData *fd, Library * /*lib*/, Main *bmain) LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { if (node->type_legacy == GEO_NODE_MERGE_BY_DISTANCE) { if (node->storage == nullptr) { - NodeGeometryMergeByDistance *data = MEM_cnew(__func__); + NodeGeometryMergeByDistance *data = MEM_callocN( + __func__); data->mode = GEO_NODE_MERGE_BY_DISTANCE_MODE_ALL; node->storage = data; } diff --git a/source/blender/blenloader/intern/versioning_400.cc b/source/blender/blenloader/intern/versioning_400.cc index bda49f02565..8012ef1326d 100644 --- a/source/blender/blenloader/intern/versioning_400.cc +++ b/source/blender/blenloader/intern/versioning_400.cc @@ -2020,7 +2020,7 @@ static void versioning_replace_musgrave_texture_node(bNodeTree *ntree) STRNCPY(node->idname, "ShaderNodeTexNoise"); node->type_legacy = SH_NODE_TEX_NOISE; - NodeTexNoise *data = MEM_cnew(__func__); + NodeTexNoise *data = MEM_callocN(__func__); data->base = (static_cast(node->storage))->base; data->dimensions = (static_cast(node->storage))->dimensions; data->normalize = false; @@ -2554,7 +2554,7 @@ static void version_replace_principled_hair_model(bNodeTree *ntree) if (node->type_legacy != SH_NODE_BSDF_HAIR_PRINCIPLED) { continue; } - NodeShaderHairPrincipled *data = MEM_cnew(__func__); + NodeShaderHairPrincipled *data = MEM_callocN(__func__); data->model = SHD_PRINCIPLED_HAIR_CHIANG; data->parametrization = node->custom1; @@ -2572,7 +2572,7 @@ static void change_input_socket_to_rotation_type(bNodeTree &ntree, socket.type = SOCK_ROTATION; STRNCPY(socket.idname, "NodeSocketRotation"); auto *old_value = static_cast(socket.default_value); - auto *new_value = MEM_cnew(__func__); + auto *new_value = MEM_callocN(__func__); copy_v3_v3(new_value->value_euler, old_value->value); socket.default_value = new_value; MEM_freeN(old_value); @@ -2691,7 +2691,7 @@ static blender::StringRef legacy_socket_idname_to_socket_type(blender::StringRef static bNodeTreeInterfaceItem *legacy_socket_move_to_interface(bNodeSocket &legacy_socket, const eNodeSocketInOut in_out) { - bNodeTreeInterfaceSocket *new_socket = MEM_cnew(__func__); + bNodeTreeInterfaceSocket *new_socket = MEM_callocN(__func__); new_socket->item.item_type = NODE_INTERFACE_SOCKET; /* Move reusable data. */ @@ -2852,7 +2852,7 @@ static void remove_triangulate_node_min_size_input(bNodeTree *tree) } bNode &greater_or_equal = version_node_add_empty(*tree, "FunctionNodeCompare"); - auto *compare_storage = MEM_cnew(__func__); + auto *compare_storage = MEM_callocN(__func__); compare_storage->operation = NODE_COMPARE_GREATER_EQUAL; compare_storage->data_type = SOCK_INT; greater_or_equal.storage = compare_storage; @@ -3107,7 +3107,7 @@ static void version_nodes_insert_item(bNodeTreeInterfacePanel &parent, blender::MutableSpan old_items = {parent.items_array, parent.items_num}; parent.items_num++; - parent.items_array = MEM_cnew_array(parent.items_num, __func__); + parent.items_array = MEM_calloc_arrayN(parent.items_num, __func__); parent.items().take_front(position).copy_from(old_items.take_front(position)); parent.items().drop_front(position + 1).copy_from(old_items.drop_front(position)); parent.items()[position] = &socket.item; @@ -3197,7 +3197,7 @@ static void enable_geometry_nodes_is_modifier(Main &bmain) return true; } if (!group->geometry_node_asset_traits) { - group->geometry_node_asset_traits = MEM_cnew(__func__); + group->geometry_node_asset_traits = MEM_callocN(__func__); } group->geometry_node_asset_traits->flag |= GEO_NODE_ASSET_MODIFIER; return false; @@ -3497,7 +3497,7 @@ static void add_image_editor_asset_shelf(Main &bmain) if (ARegion *new_shelf_region = do_versions_add_region_if_not_found( regionbase, RGN_TYPE_ASSET_SHELF, __func__, RGN_TYPE_TOOL_HEADER)) { - new_shelf_region->regiondata = MEM_cnew(__func__); + new_shelf_region->regiondata = MEM_callocN(__func__); new_shelf_region->alignment = RGN_ALIGN_BOTTOM; new_shelf_region->flag |= RGN_FLAG_HIDDEN; } @@ -3529,7 +3529,7 @@ static void node_reroute_add_storage(bNodeTree &tree) STRNCPY(input.identifier, "Input"); STRNCPY(output.identifier, "Output"); - NodeReroute *data = MEM_cnew(__func__); + NodeReroute *data = MEM_callocN(__func__); STRNCPY(data->type_idname, input.idname); node->storage = data; } @@ -3611,7 +3611,7 @@ static void hide_simulation_node_skip_socket_value(Main &bmain) input_node.locx_legacy = node->locx_legacy - 25; input_node.locy_legacy = node->locy_legacy; - NodeInputBool *input_node_storage = MEM_cnew(__func__); + NodeInputBool *input_node_storage = MEM_callocN(__func__); input_node.storage = input_node_storage; input_node_storage->boolean = true; @@ -4002,7 +4002,7 @@ void blo_do_versions_400(FileData *fd, Library * /*lib*/, Main *bmain) LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { if (node->type_legacy == SH_NODE_TEX_NOISE) { if (!node->storage) { - NodeTexNoise *tex = MEM_cnew(__func__); + NodeTexNoise *tex = MEM_callocN(__func__); BKE_texture_mapping_default(&tex->base.tex_mapping, TEXMAP_TYPE_POINT); BKE_texture_colormapping_default(&tex->base.color_mapping); tex->dimensions = 3; @@ -5256,7 +5256,7 @@ void blo_do_versions_400(FileData *fd, Library * /*lib*/, Main *bmain) continue; } storage->capture_items_num = 1; - storage->capture_items = MEM_cnew_array( + storage->capture_items = MEM_calloc_arrayN( storage->capture_items_num, __func__); NodeGeometryAttributeCaptureItem &item = storage->capture_items[0]; item.data_type = storage->data_type_legacy; diff --git a/source/blender/blenloader/intern/versioning_common.cc b/source/blender/blenloader/intern/versioning_common.cc index bfa700c3300..acf1bd0c9de 100644 --- a/source/blender/blenloader/intern/versioning_common.cc +++ b/source/blender/blenloader/intern/versioning_common.cc @@ -208,7 +208,7 @@ bNode &version_node_add_empty(bNodeTree &ntree, const char *idname) { blender::bke::bNodeType *ntype = blender::bke::node_type_find(idname); - bNode *node = MEM_cnew(__func__); + bNode *node = MEM_callocN(__func__); node->runtime = MEM_new(__func__); BLI_addtail(&ntree.nodes, node); blender::bke::node_unique_id(ntree, *node); @@ -236,7 +236,7 @@ bNodeSocket &version_node_add_socket(bNodeTree &ntree, { blender::bke::bNodeSocketType *stype = blender::bke::node_socket_type_find(idname); - bNodeSocket *socket = MEM_cnew(__func__); + bNodeSocket *socket = MEM_callocN(__func__); socket->runtime = MEM_new(__func__); socket->in_out = in_out; socket->limit = (in_out == SOCK_IN ? 1 : 0xFFF); @@ -272,7 +272,7 @@ bNodeLink &version_node_add_link( bNode &node_to = node_b; bNodeSocket &socket_to = socket_b; - bNodeLink *link = MEM_cnew(__func__); + bNodeLink *link = MEM_callocN(__func__); link->fromnode = &node_from; link->fromsock = &socket_from; link->tonode = &node_to; diff --git a/source/blender/blentranslation/msgfmt/msgfmt.cc b/source/blender/blentranslation/msgfmt/msgfmt.cc index b9e0c2574cb..7d9ac4c9255 100644 --- a/source/blender/blentranslation/msgfmt/msgfmt.cc +++ b/source/blender/blentranslation/msgfmt/msgfmt.cc @@ -141,7 +141,7 @@ static char *generate(blender::Map &messages, size_t * return a.key < b.key; }); - Offset *offsets = MEM_cnew_array(num_keys, __func__); + Offset *offsets = MEM_calloc_arrayN(num_keys, __func__); uint32_t tot_keys_len = 0; uint32_t tot_vals_len = 0; @@ -170,7 +170,7 @@ static char *generate(blender::Map &messages, size_t * /* Final buffer representing the binary MO file. */ *r_output_size = valstart + tot_vals_len; - char *output = MEM_cnew_array(*r_output_size, __func__); + char *output = MEM_calloc_arrayN(*r_output_size, __func__); char *h = output; char *ik = output + idx_keystart; char *iv = output + idx_valstart; diff --git a/source/blender/bmesh/intern/bmesh_mesh_normals.cc b/source/blender/bmesh/intern/bmesh_mesh_normals.cc index 446fe83b0ea..484d6a217aa 100644 --- a/source/blender/bmesh/intern/bmesh_mesh_normals.cc +++ b/source/blender/bmesh/intern/bmesh_mesh_normals.cc @@ -1881,7 +1881,7 @@ void BM_lnorspace_rebuild(BMesh *bm, bool preserve_clnor) void BM_lnorspace_update(BMesh *bm) { if (bm->lnor_spacearr == nullptr) { - bm->lnor_spacearr = MEM_cnew(__func__); + bm->lnor_spacearr = MEM_callocN(__func__); } if (bm->lnor_spacearr->lspacearr == nullptr) { Array lnors(bm->totloop, float3(0)); @@ -1911,7 +1911,7 @@ void BM_lnorspace_err(BMesh *bm) bm->spacearr_dirty |= BM_SPACEARR_DIRTY_ALL; bool clear = true; - MLoopNorSpaceArray *temp = MEM_cnew(__func__); + MLoopNorSpaceArray *temp = MEM_callocN(__func__); temp->lspacearr = nullptr; BKE_lnor_spacearr_init(temp, bm->totloop, MLNOR_SPACEARR_BMLOOP_PTR); @@ -2137,8 +2137,9 @@ BMLoopNorEditDataArray *BM_loop_normal_editdata_array_init(BMesh *bm, BLI_assert(bm->spacearr_dirty == 0); - BMLoopNorEditDataArray *lnors_ed_arr = MEM_cnew(__func__); - lnors_ed_arr->lidx_to_lnor_editdata = MEM_cnew_array(bm->totloop, __func__); + BMLoopNorEditDataArray *lnors_ed_arr = MEM_callocN(__func__); + lnors_ed_arr->lidx_to_lnor_editdata = MEM_calloc_arrayN(bm->totloop, + __func__); BM_data_layer_ensure_named(bm, &bm->ldata, CD_PROP_INT16_2D, "custom_normal"); const int cd_custom_normal_offset = CustomData_get_offset_named( @@ -2237,7 +2238,7 @@ void BM_custom_loop_normals_from_vector_layer(BMesh *bm, bool add_sharp_edges) } if (bm->lnor_spacearr == nullptr) { - bm->lnor_spacearr = MEM_cnew(__func__); + bm->lnor_spacearr = MEM_callocN(__func__); } bm_mesh_loops_custom_normals_set(bm, diff --git a/source/blender/compositor/intern/render_context.cc b/source/blender/compositor/intern/render_context.cc index 0080ad09fda..dbc3d9e36b1 100644 --- a/source/blender/compositor/intern/render_context.cc +++ b/source/blender/compositor/intern/render_context.cc @@ -40,7 +40,7 @@ FileOutput::FileOutput(const std::string &path, bool save_as_render) : path_(path), format_(format), save_as_render_(save_as_render) { - render_result_ = MEM_cnew("Temporary Render Result For File Output"); + render_result_ = MEM_callocN("Temporary Render Result For File Output"); render_result_->rectx = size.x; render_result_->recty = size.y; @@ -50,7 +50,7 @@ FileOutput::FileOutput(const std::string &path, * by the EXR writer as a special case where the channel names take the form: * .. * Otherwise, the layer name would have preceded in the pass name in yet another section. */ - RenderLayer *render_layer = MEM_cnew("Render Layer For File Output."); + RenderLayer *render_layer = MEM_callocN("Render Layer For File Output."); BLI_addtail(&render_result_->layers, render_layer); render_layer->name[0] = '\0'; @@ -68,14 +68,14 @@ void FileOutput::add_view(const char *view_name) /* Empty views can only be added for EXR images. */ BLI_assert(ELEM(format_.imtype, R_IMF_IMTYPE_OPENEXR, R_IMF_IMTYPE_MULTILAYER)); - RenderView *render_view = MEM_cnew("Render View For File Output."); + RenderView *render_view = MEM_callocN("Render View For File Output."); BLI_addtail(&render_result_->views, render_view); STRNCPY(render_view->name, view_name); } void FileOutput::add_view(const char *view_name, int channels, float *buffer) { - RenderView *render_view = MEM_cnew("Render View For File Output."); + RenderView *render_view = MEM_callocN("Render View For File Output."); BLI_addtail(&render_result_->views, render_view); STRNCPY(render_view->name, view_name); @@ -94,7 +94,7 @@ void FileOutput::add_pass(const char *pass_name, BLI_assert(ELEM(format_.imtype, R_IMF_IMTYPE_OPENEXR, R_IMF_IMTYPE_MULTILAYER)); RenderLayer *render_layer = static_cast(render_result_->layers.first); - RenderPass *render_pass = MEM_cnew("Render Pass For File Output."); + RenderPass *render_pass = MEM_callocN("Render Pass For File Output."); BLI_addtail(&render_layer->passes, render_pass); STRNCPY(render_pass->name, pass_name); STRNCPY(render_pass->view, view_name); diff --git a/source/blender/depsgraph/intern/depsgraph_light_linking.cc b/source/blender/depsgraph/intern/depsgraph_light_linking.cc index b1a5d57e8da..f5b1433f496 100644 --- a/source/blender/depsgraph/intern/depsgraph_light_linking.cc +++ b/source/blender/depsgraph/intern/depsgraph_light_linking.cc @@ -490,7 +490,7 @@ void Cache::eval_runtime_data(Object &object_eval) const } } else if (need_runtime) { - object_eval.light_linking = MEM_cnew(__func__); + object_eval.light_linking = MEM_callocN(__func__); object_eval.light_linking->runtime = runtime; } } diff --git a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_object.cc b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_object.cc index db398a708da..6784e3be6f9 100644 --- a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_object.cc +++ b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_object.cc @@ -132,7 +132,7 @@ void ObjectRuntimeBackup::restore_to_object(Object *object) /* Lazily allocate light linking on the evaluated object for the cases when the object is only * a receiver or a blocker and does not need its own LightLinking on the original object. */ if (!object->light_linking) { - object->light_linking = MEM_cnew(__func__); + object->light_linking = MEM_callocN(__func__); } object->light_linking->runtime = *light_linking_runtime; } diff --git a/source/blender/draw/intern/draw_cache_impl_volume.cc b/source/blender/draw/intern/draw_cache_impl_volume.cc index dbd3ef6ac73..a8780cc8c33 100644 --- a/source/blender/draw/intern/draw_cache_impl_volume.cc +++ b/source/blender/draw/intern/draw_cache_impl_volume.cc @@ -72,7 +72,7 @@ static void volume_batch_cache_init(Volume *volume) VolumeBatchCache *cache = static_cast(volume->batch_cache); if (!cache) { - volume->batch_cache = cache = MEM_cnew(__func__); + volume->batch_cache = cache = MEM_callocN(__func__); } else { memset(cache, 0, sizeof(*cache)); @@ -296,7 +296,7 @@ static DRWVolumeGrid *volume_grid_cache_get(const Volume *volume, } /* Allocate new grid. */ - DRWVolumeGrid *cache_grid = MEM_cnew(__func__); + DRWVolumeGrid *cache_grid = MEM_callocN(__func__); cache_grid->name = BLI_strdup(name.c_str()); BLI_addtail(&cache->grids, cache_grid); diff --git a/source/blender/draw/intern/draw_manager_text.cc b/source/blender/draw/intern/draw_manager_text.cc index ded75c3b8ab..03de2f225eb 100644 --- a/source/blender/draw/intern/draw_manager_text.cc +++ b/source/blender/draw/intern/draw_manager_text.cc @@ -74,7 +74,7 @@ struct DRWTextStore { DRWTextStore *DRW_text_cache_create() { - DRWTextStore *dt = MEM_cnew(__func__); + DRWTextStore *dt = MEM_callocN(__func__); dt->cache_strings = BLI_memiter_create(1 << 14); /* 16kb */ return dt; } diff --git a/source/blender/editors/animation/anim_filter.cc b/source/blender/editors/animation/anim_filter.cc index 3d4833b276e..67abfb0a5a8 100644 --- a/source/blender/editors/animation/anim_filter.cc +++ b/source/blender/editors/animation/anim_filter.cc @@ -3612,7 +3612,7 @@ static Base **animdata_filter_ds_sorted_bases(bAnimContext *ac, size_t tot_bases = BLI_listbase_count(object_bases); size_t num_bases = 0; - Base **sorted_bases = MEM_cnew_array(tot_bases, "Dopesheet Usable Sorted Bases"); + Base **sorted_bases = MEM_calloc_arrayN(tot_bases, "Dopesheet Usable Sorted Bases"); LISTBASE_FOREACH (Base *, base, object_bases) { if (animdata_filter_base_is_ok(ac, base, OB_MODE_OBJECT, filter_mode)) { sorted_bases[num_bases++] = base; diff --git a/source/blender/editors/armature/armature_utils.cc b/source/blender/editors/armature/armature_utils.cc index 92d373be180..cce83a32b56 100644 --- a/source/blender/editors/armature/armature_utils.cc +++ b/source/blender/editors/armature/armature_utils.cc @@ -731,7 +731,7 @@ void ED_armature_from_edit(Main *bmain, bArmature *arm) newBone->color = eBone->color; LISTBASE_FOREACH (BoneCollectionReference *, ref, &eBone->bone_collections) { - BoneCollectionReference *newBoneRef = MEM_cnew( + BoneCollectionReference *newBoneRef = MEM_dupallocN( "ED_armature_from_edit", *ref); BLI_addtail(&newBone->runtime.collections, newBoneRef); } diff --git a/source/blender/editors/asset/intern/asset_shelf.cc b/source/blender/editors/asset/intern/asset_shelf.cc index c22206d3106..6151f9a6cb2 100644 --- a/source/blender/editors/asset/intern/asset_shelf.cc +++ b/source/blender/editors/asset/intern/asset_shelf.cc @@ -863,7 +863,7 @@ static void asset_shelf_header_draw(const bContext *C, Header *header) static void header_regiontype_register(ARegionType *region_type, const int space_type) { - HeaderType *ht = MEM_cnew(__func__); + HeaderType *ht = MEM_callocN(__func__); STRNCPY(ht->idname, "ASSETSHELF_HT_settings"); ht->space_type = space_type; ht->region_type = RGN_TYPE_ASSET_SHELF_HEADER; diff --git a/source/blender/editors/asset/intern/asset_shelf_catalog_selector.cc b/source/blender/editors/asset/intern/asset_shelf_catalog_selector.cc index f387d9b1344..252c24c26e4 100644 --- a/source/blender/editors/asset/intern/asset_shelf_catalog_selector.cc +++ b/source/blender/editors/asset/intern/asset_shelf_catalog_selector.cc @@ -229,7 +229,7 @@ void catalog_selector_panel_register(ARegionType *region_type) return; } - PanelType *pt = MEM_cnew(__func__); + PanelType *pt = MEM_callocN(__func__); STRNCPY(pt->idname, "ASSETSHELF_PT_catalog_selector"); STRNCPY(pt->label, N_("Catalog Selector")); STRNCPY(pt->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA); diff --git a/source/blender/editors/asset/intern/asset_shelf_popover.cc b/source/blender/editors/asset/intern/asset_shelf_popover.cc index df4ec12ad4e..388ac2875e3 100644 --- a/source/blender/editors/asset/intern/asset_shelf_popover.cc +++ b/source/blender/editors/asset/intern/asset_shelf_popover.cc @@ -285,7 +285,7 @@ void popover_panel_register(ARegionType *region_type) return; } - PanelType *pt = MEM_cnew(__func__); + PanelType *pt = MEM_callocN(__func__); STRNCPY(pt->idname, "ASSETSHELF_PT_popover_panel"); STRNCPY(pt->label, N_("Asset Shelf Panel")); STRNCPY(pt->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA); diff --git a/source/blender/editors/asset/intern/asset_shelf_regiondata.cc b/source/blender/editors/asset/intern/asset_shelf_regiondata.cc index b91c01d2288..c260f647e03 100644 --- a/source/blender/editors/asset/intern/asset_shelf_regiondata.cc +++ b/source/blender/editors/asset/intern/asset_shelf_regiondata.cc @@ -33,7 +33,7 @@ RegionAssetShelf *RegionAssetShelf::ensure_from_asset_shelf_region(ARegion ®i return nullptr; } if (!region.regiondata) { - region.regiondata = MEM_cnew("RegionAssetShelf"); + region.regiondata = MEM_callocN("RegionAssetShelf"); } return static_cast(region.regiondata); } @@ -44,7 +44,7 @@ RegionAssetShelf *regiondata_duplicate(const RegionAssetShelf *shelf_regiondata) { static_assert(std::is_trivial_v, "RegionAssetShelf needs to be trivial to allow freeing with MEM_freeN()"); - RegionAssetShelf *new_shelf_regiondata = MEM_cnew(__func__); + RegionAssetShelf *new_shelf_regiondata = MEM_callocN(__func__); *new_shelf_regiondata = *shelf_regiondata; BLI_listbase_clear(&new_shelf_regiondata->shelves); diff --git a/source/blender/editors/curves/intern/curves_add.cc b/source/blender/editors/curves/intern/curves_add.cc index 74e44f9ddf6..642323fa34a 100644 --- a/source/blender/editors/curves/intern/curves_add.cc +++ b/source/blender/editors/curves/intern/curves_add.cc @@ -76,7 +76,7 @@ void ensure_surface_deformation_node_exists(bContext &C, Object &curves_ob) nmd.node_group = bke::node_tree_add_tree(bmain, DATA_("Surface Deform"), "GeometryNodeTree"); if (!nmd.node_group->geometry_node_asset_traits) { - nmd.node_group->geometry_node_asset_traits = MEM_cnew(__func__); + nmd.node_group->geometry_node_asset_traits = MEM_callocN(__func__); } nmd.node_group->geometry_node_asset_traits->flag |= GEO_NODE_ASSET_MODIFIER; diff --git a/source/blender/editors/gpencil_legacy/gpencil_undo.cc b/source/blender/editors/gpencil_legacy/gpencil_undo.cc index 8cfc6e973cb..1053e3fe78d 100644 --- a/source/blender/editors/gpencil_legacy/gpencil_undo.cc +++ b/source/blender/editors/gpencil_legacy/gpencil_undo.cc @@ -153,7 +153,7 @@ void gpencil_undo_push(bGPdata *gpd) } /* create new undo node */ - undo_node = MEM_cnew("gpencil undo node"); + undo_node = MEM_callocN("gpencil undo node"); undo_node->gpd = BKE_gpencil_data_duplicate(nullptr, gpd, true); cur_node = undo_node; diff --git a/source/blender/editors/grease_pencil/intern/grease_pencil_frames.cc b/source/blender/editors/grease_pencil/intern/grease_pencil_frames.cc index ba1fdf8face..b02a2157ee2 100644 --- a/source/blender/editors/grease_pencil/intern/grease_pencil_frames.cc +++ b/source/blender/editors/grease_pencil/intern/grease_pencil_frames.cc @@ -321,7 +321,7 @@ static void append_frame_to_key_edit_data(KeyframeEditData *ked, const int frame_number, const GreasePencilFrame &frame) { - CfraElem *ce = MEM_cnew(__func__); + CfraElem *ce = MEM_callocN(__func__); ce->cfra = float(frame_number); ce->sel = frame.is_selected(); BLI_addtail(&ked->list, ce); diff --git a/source/blender/editors/grease_pencil/intern/grease_pencil_weight_paint.cc b/source/blender/editors/grease_pencil/intern/grease_pencil_weight_paint.cc index 88418d1f086..010481cbfc6 100644 --- a/source/blender/editors/grease_pencil/intern/grease_pencil_weight_paint.cc +++ b/source/blender/editors/grease_pencil/intern/grease_pencil_weight_paint.cc @@ -300,7 +300,7 @@ static int lookup_or_add_deform_group_index(CurvesGeometry &curves, const String /* Lazily add the vertex group. */ if (def_nr == -1) { - bDeformGroup *defgroup = MEM_cnew(__func__); + bDeformGroup *defgroup = MEM_callocN(__func__); name.copy_utf8_truncated(defgroup->name); BLI_addtail(&curves.vertex_group_names, defgroup); def_nr = BLI_listbase_count(&curves.vertex_group_names) - 1; diff --git a/source/blender/editors/interface/interface.cc b/source/blender/editors/interface/interface.cc index 24eb0d35058..38f8d04eff8 100644 --- a/source/blender/editors/interface/interface.cc +++ b/source/blender/editors/interface/interface.cc @@ -1744,10 +1744,10 @@ static PointerRNA *ui_but_extra_operator_icon_add_ptr(uiBut *but, wmOperatorCallContext opcontext, int icon) { - uiButExtraOpIcon *extra_op_icon = MEM_cnew(__func__); + uiButExtraOpIcon *extra_op_icon = MEM_callocN(__func__); extra_op_icon->icon = icon; - extra_op_icon->optype_params = MEM_cnew(__func__); + extra_op_icon->optype_params = MEM_callocN(__func__); extra_op_icon->optype_params->optype = optype; extra_op_icon->optype_params->opptr = MEM_new(__func__); WM_operator_properties_create_ptr(extra_op_icon->optype_params->opptr, @@ -3835,7 +3835,7 @@ uiBlock *UI_block_begin(const bContext *C, STRNCPY(block->display_device, scene->display_settings.display_device); /* Copy to avoid crash when scene gets deleted with UI still open. */ - UnitSettings *unit = MEM_cnew(__func__); + UnitSettings *unit = MEM_callocN(__func__); memcpy(unit, &scene->unit, sizeof(scene->unit)); block->unit = unit; } @@ -5122,7 +5122,7 @@ AutoComplete *UI_autocomplete_begin(const char *startname, size_t maxncpy) { AutoComplete *autocpl; - autocpl = MEM_cnew(__func__); + autocpl = MEM_callocN(__func__); autocpl->maxncpy = maxncpy; autocpl->matches = 0; autocpl->truncate = static_cast(MEM_callocN(sizeof(char) * maxncpy, __func__)); diff --git a/source/blender/editors/interface/interface_handlers.cc b/source/blender/editors/interface/interface_handlers.cc index 649899982e1..cb9fffb33cb 100644 --- a/source/blender/editors/interface/interface_handlers.cc +++ b/source/blender/editors/interface/interface_handlers.cc @@ -2143,7 +2143,7 @@ static bool ui_but_drag_init(bContext *C, data->cancel = true; #ifdef USE_DRAG_TOGGLE if (ui_drag_toggle_but_is_supported(but)) { - uiDragToggleHandle *drag_info = MEM_cnew(__func__); + uiDragToggleHandle *drag_info = MEM_callocN(__func__); ARegion *region_prev; /* call here because regular mouse-up event won't run, @@ -2198,7 +2198,7 @@ static bool ui_but_drag_init(bContext *C, if (but->type == UI_BTYPE_COLOR) { bool valid = false; - uiDragColorHandle *drag_info = MEM_cnew(__func__); + uiDragColorHandle *drag_info = MEM_callocN(__func__); drag_info->has_alpha = ui_but_color_has_alpha(but); @@ -2723,7 +2723,7 @@ static void ui_but_paste_colorband(bContext *C, uiBut *but, uiHandleButtonData * { if (but_copypaste_coba.tot != 0) { if (!but->poin) { - but->poin = reinterpret_cast(MEM_cnew(__func__)); + but->poin = reinterpret_cast(MEM_callocN(__func__)); } button_activate_state(C, but, BUTTON_STATE_NUM_EDITING); @@ -2745,7 +2745,7 @@ static void ui_but_paste_curvemapping(bContext *C, uiBut *but) { if (but_copypaste_curve_alive) { if (!but->poin) { - but->poin = reinterpret_cast(MEM_cnew(__func__)); + but->poin = reinterpret_cast(MEM_callocN(__func__)); } button_activate_state(C, but, BUTTON_STATE_NUM_EDITING); @@ -2768,7 +2768,7 @@ static void ui_but_paste_CurveProfile(bContext *C, uiBut *but) { if (but_copypaste_profile_alive) { if (!but->poin) { - but->poin = reinterpret_cast(MEM_cnew(__func__)); + but->poin = reinterpret_cast(MEM_callocN(__func__)); } button_activate_state(C, but, BUTTON_STATE_NUM_EDITING); @@ -12423,7 +12423,7 @@ static uiBlockInteraction_Handle *ui_block_interaction_begin(bContext *C, const bool is_click) { BLI_assert(block->custom_interaction_callbacks.begin_fn != nullptr); - uiBlockInteraction_Handle *interaction = MEM_cnew(__func__); + uiBlockInteraction_Handle *interaction = MEM_callocN(__func__); int unique_retval_ids_len = 0; for (const std::unique_ptr &but : block->buttons) { diff --git a/source/blender/editors/interface/interface_icons.cc b/source/blender/editors/interface/interface_icons.cc index b3e08a4b35a..59e99c5a03e 100644 --- a/source/blender/editors/interface/interface_icons.cc +++ b/source/blender/editors/interface/interface_icons.cc @@ -130,19 +130,19 @@ static const IconType icontypes[] = { static DrawInfo *def_internal_icon( ImBuf *bbuf, int icon_id, int xofs, int yofs, int size, int type, int theme_color) { - Icon *new_icon = MEM_cnew(__func__); + Icon *new_icon = MEM_callocN(__func__); new_icon->obj = nullptr; /* icon is not for library object */ new_icon->id_type = 0; - DrawInfo *di = MEM_cnew(__func__); + DrawInfo *di = MEM_callocN(__func__); di->type = type; if (type == ICON_TYPE_SVG_MONO) { di->data.texture.theme_color = theme_color; } else if (type == ICON_TYPE_BUFFER) { - IconImage *iimg = MEM_cnew(__func__); + IconImage *iimg = MEM_callocN(__func__); iimg->w = size; iimg->h = size; @@ -179,12 +179,12 @@ static DrawInfo *def_internal_icon( static void def_internal_vicon(int icon_id, VectorDrawFunc drawFunc) { - Icon *new_icon = MEM_cnew("texicon"); + Icon *new_icon = MEM_callocN("texicon"); new_icon->obj = nullptr; /* icon is not for library object */ new_icon->id_type = 0; - DrawInfo *di = MEM_cnew("drawinfo"); + DrawInfo *di = MEM_callocN("drawinfo"); di->type = ICON_TYPE_VECTOR; di->data.vector.func = drawFunc; @@ -928,7 +928,7 @@ static DrawInfo *icon_create_drawinfo(Icon *icon) { const int icon_data_type = icon->obj_type; - DrawInfo *di = MEM_cnew("di_icon"); + DrawInfo *di = MEM_callocN("di_icon"); if (ELEM(icon_data_type, ICON_DATA_ID, ICON_DATA_PREVIEW)) { di->type = ICON_TYPE_PREVIEW; @@ -1107,7 +1107,7 @@ void ui_icon_ensure_deferred(const bContext *C, const int icon_id, const bool bi wmWindowManager *wm = CTX_wm_manager(C); StudioLight *sl = static_cast(icon->obj); BKE_studiolight_set_free_function(sl, &ui_studiolight_free_function, wm); - IconImage *img = MEM_cnew(__func__); + IconImage *img = MEM_callocN(__func__); img->w = STUDIOLIGHT_ICON_SIZE; img->h = STUDIOLIGHT_ICON_SIZE; @@ -1122,7 +1122,7 @@ void ui_icon_ensure_deferred(const bContext *C, const int icon_id, const bool bi "StudioLight Icon", eWM_JobFlag(0), WM_JOB_TYPE_STUDIOLIGHT); - Icon **tmp = MEM_cnew(__func__); + Icon **tmp = MEM_callocN(__func__); *tmp = icon; WM_jobs_customdata_set(wm_job, tmp, MEM_freeN); WM_jobs_timer(wm_job, 0.01, 0, NC_WINDOW); diff --git a/source/blender/editors/interface/interface_layout.cc b/source/blender/editors/interface/interface_layout.cc index 961bcb31e44..ed376a3a6db 100644 --- a/source/blender/editors/interface/interface_layout.cc +++ b/source/blender/editors/interface/interface_layout.cc @@ -5881,7 +5881,7 @@ uiLayout *UI_block_layout(uiBlock *block, int padding, const uiStyle *style) { - uiLayoutRoot *root = MEM_cnew(__func__); + uiLayoutRoot *root = MEM_callocN(__func__); root->type = type; root->style = style; root->block = block; diff --git a/source/blender/editors/interface/interface_ops.cc b/source/blender/editors/interface/interface_ops.cc index 26b6e6017e5..00954417804 100644 --- a/source/blender/editors/interface/interface_ops.cc +++ b/source/blender/editors/interface/interface_ops.cc @@ -1007,7 +1007,7 @@ static void override_idtemplate_menu() { MenuType *mt; - mt = MEM_cnew(__func__); + mt = MEM_callocN(__func__); STRNCPY(mt->idname, "UI_MT_idtemplate_liboverride"); STRNCPY(mt->label, N_("Library Override")); mt->poll = override_idtemplate_menu_poll; @@ -2065,7 +2065,7 @@ extern void PyC_FileAndNum_Safe(const char **r_filename, int *r_lineno); void UI_editsource_active_but_test(uiBut *but) { - uiEditSourceButStore *but_store = MEM_cnew(__func__); + uiEditSourceButStore *but_store = MEM_callocN(__func__); const char *fn; int line_number = -1; diff --git a/source/blender/editors/interface/interface_panel.cc b/source/blender/editors/interface/interface_panel.cc index b0226da21f4..933ff831b3e 100644 --- a/source/blender/editors/interface/interface_panel.cc +++ b/source/blender/editors/interface/interface_panel.cc @@ -2154,7 +2154,7 @@ void ui_panel_drag_collapse_handler_add(const bContext *C, const bool was_open) { wmWindow *win = CTX_wm_window(C); const wmEvent *event = win->eventstate; - uiPanelDragCollapseHandle *dragcol_data = MEM_cnew(__func__); + uiPanelDragCollapseHandle *dragcol_data = MEM_callocN(__func__); dragcol_data->was_first_open = was_open; copy_v2_v2_int(dragcol_data->xy_init, event->xy); @@ -2333,7 +2333,7 @@ static void ui_panel_category_active_set(ARegion *region, const char *idname, bo BLI_remlink(lb, pc_act); } else { - pc_act = MEM_cnew(__func__); + pc_act = MEM_callocN(__func__); STRNCPY(pc_act->idname, idname); } @@ -2420,7 +2420,7 @@ static PanelCategoryDyn *panel_categories_find_mouse_over(ARegion *region, const void UI_panel_category_add(ARegion *region, const char *name) { - PanelCategoryDyn *pc_dyn = MEM_cnew(__func__); + PanelCategoryDyn *pc_dyn = MEM_callocN(__func__); BLI_addtail(®ion->runtime->panels_category, pc_dyn); STRNCPY(pc_dyn->idname, name); diff --git a/source/blender/editors/interface/interface_style.cc b/source/blender/editors/interface/interface_style.cc index 41c5f614926..28e9ceb339e 100644 --- a/source/blender/editors/interface/interface_style.cc +++ b/source/blender/editors/interface/interface_style.cc @@ -57,7 +57,7 @@ static void fontstyle_set_ex(const uiFontStyle *fs, const float dpi_fac); static uiStyle *ui_style_new(ListBase *styles, const char *name, short uifont_id) { - uiStyle *style = MEM_cnew(__func__); + uiStyle *style = MEM_callocN(__func__); BLI_addtail(styles, style); STRNCPY(style->name, name); @@ -383,7 +383,7 @@ void uiStyleInit() /* default builtin */ if (font_first == nullptr) { - font_first = MEM_cnew(__func__); + font_first = MEM_callocN(__func__); BLI_addtail(&U.uifonts, font_first); } diff --git a/source/blender/editors/interface/interface_undo.cc b/source/blender/editors/interface/interface_undo.cc index d4c1b3a336b..a7e546f32fc 100644 --- a/source/blender/editors/interface/interface_undo.cc +++ b/source/blender/editors/interface/interface_undo.cc @@ -98,7 +98,7 @@ void ui_textedit_undo_push(uiUndoStack_Text *stack, const char *text, int cursor uiUndoStack_Text *ui_textedit_undo_stack_create() { - uiUndoStack_Text *stack = MEM_cnew(__func__); + uiUndoStack_Text *stack = MEM_callocN(__func__); stack->current = nullptr; BLI_listbase_clear(&stack->states); diff --git a/source/blender/editors/interface/interface_utils.cc b/source/blender/editors/interface/interface_utils.cc index 52b099512fc..ae3cf35c448 100644 --- a/source/blender/editors/interface/interface_utils.cc +++ b/source/blender/editors/interface/interface_utils.cc @@ -901,7 +901,7 @@ struct uiButStoreElem { uiButStore *UI_butstore_create(uiBlock *block) { - uiButStore *bs_handle = MEM_cnew(__func__); + uiButStore *bs_handle = MEM_callocN(__func__); bs_handle->block = block; BLI_addtail(&block->butstore, bs_handle); @@ -950,7 +950,7 @@ bool UI_butstore_is_registered(uiBlock *block, uiBut *but) void UI_butstore_register(uiButStore *bs_handle, uiBut **but_p) { - uiButStoreElem *bs_elem = MEM_cnew(__func__); + uiButStoreElem *bs_elem = MEM_callocN(__func__); BLI_assert(*but_p); bs_elem->but_p = but_p; diff --git a/source/blender/editors/interface/regions/interface_region_color_picker.cc b/source/blender/editors/interface/regions/interface_region_color_picker.cc index 8fe5e69d015..8808893426a 100644 --- a/source/blender/editors/interface/regions/interface_region_color_picker.cc +++ b/source/blender/editors/interface/regions/interface_region_color_picker.cc @@ -917,7 +917,7 @@ uiBlock *ui_block_func_COLOR(bContext *C, uiPopupBlockHandle *handle, void *arg_ ColorPicker *ui_block_colorpicker_create(uiBlock *block) { - ColorPicker *cpicker = MEM_cnew(__func__); + ColorPicker *cpicker = MEM_callocN(__func__); BLI_addhead(&block->color_pickers.list, cpicker); return cpicker; diff --git a/source/blender/editors/interface/regions/interface_region_hud.cc b/source/blender/editors/interface/regions/interface_region_hud.cc index f5deead52f5..2c08e94483b 100644 --- a/source/blender/editors/interface/regions/interface_region_hud.cc +++ b/source/blender/editors/interface/regions/interface_region_hud.cc @@ -180,7 +180,7 @@ static void hud_panel_operator_redo_draw(const bContext *C, Panel *panel) static void hud_panels_register(ARegionType *art, int space_type, int region_type) { - PanelType *pt = MEM_cnew(__func__); + PanelType *pt = MEM_callocN(__func__); STRNCPY(pt->idname, "OPERATOR_PT_redo"); STRNCPY(pt->label, N_("Redo")); STRNCPY(pt->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA); @@ -293,7 +293,7 @@ static void hud_region_listener(const wmRegionListenerParams *params) ARegionType *ED_area_type_hud(int space_type) { - ARegionType *art = MEM_cnew(__func__); + ARegionType *art = MEM_callocN(__func__); art->regionid = RGN_TYPE_HUD; art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D; art->listener = hud_region_listener; @@ -404,7 +404,7 @@ void ED_area_type_hud_ensure(bContext *C, ScrArea *area) { HudRegionData *hrd = static_cast(region->regiondata); if (hrd == nullptr) { - hrd = MEM_cnew(__func__); + hrd = MEM_callocN(__func__); region->regiondata = hrd; } if (region_op) { diff --git a/source/blender/editors/interface/regions/interface_region_menu_pie.cc b/source/blender/editors/interface/regions/interface_region_menu_pie.cc index 73ae5f88d55..0c5be368dca 100644 --- a/source/blender/editors/interface/regions/interface_region_menu_pie.cc +++ b/source/blender/editors/interface/regions/interface_region_menu_pie.cc @@ -96,7 +96,7 @@ uiPieMenu *UI_pie_menu_begin(bContext *C, const char *title, int icon, const wmE wmWindow *win = CTX_wm_window(C); - uiPieMenu *pie = MEM_cnew(__func__); + uiPieMenu *pie = MEM_callocN(__func__); pie->pie_block = UI_block_begin(C, nullptr, __func__, UI_EMBOSS); /* may be useful later to allow spawning pies diff --git a/source/blender/editors/interface/regions/interface_region_popup.cc b/source/blender/editors/interface/regions/interface_region_popup.cc index 9f6e2c49f4d..beab802b089 100644 --- a/source/blender/editors/interface/regions/interface_region_popup.cc +++ b/source/blender/editors/interface/regions/interface_region_popup.cc @@ -394,7 +394,7 @@ static void ui_popup_block_position(wmWindow *window, } /* Keep a list of these, needed for pull-down menus. */ - uiSafetyRct *saferct = MEM_cnew(__func__); + uiSafetyRct *saferct = MEM_callocN(__func__); saferct->parent = butrct; saferct->safety = block->safety; BLI_freelistN(&block->saferct); @@ -722,7 +722,7 @@ uiBlock *ui_popup_block_refresh(bContext *C, } else { /* Keep a list of these, needed for pull-down menus. */ - uiSafetyRct *saferct = MEM_cnew(__func__); + uiSafetyRct *saferct = MEM_callocN(__func__); saferct->safety = block->safety; BLI_addhead(&block->saferct, saferct); } diff --git a/source/blender/editors/interface/regions/interface_region_search.cc b/source/blender/editors/interface/regions/interface_region_search.cc index f43862aa0eb..ba8f2f6b667 100644 --- a/source/blender/editors/interface/regions/interface_region_search.cc +++ b/source/blender/editors/interface/regions/interface_region_search.cc @@ -871,7 +871,7 @@ static ARegion *ui_searchbox_create_generic_ex(bContext *C, region->runtime->type = &type; /* Create search-box data. */ - uiSearchboxData *data = MEM_cnew(__func__); + uiSearchboxData *data = MEM_callocN(__func__); data->search_arg = but->arg; data->search_but = but; data->butregion = butregion; @@ -1088,7 +1088,7 @@ void ui_but_search_refresh(uiButSearch *but) return; } - uiSearchItems *items = MEM_cnew(__func__); + uiSearchItems *items = MEM_callocN(__func__); /* setup search struct */ items->maxitem = 10; diff --git a/source/blender/editors/interface/resources.cc b/source/blender/editors/interface/resources.cc index 65f9e228248..5b4e16556bd 100644 --- a/source/blender/editors/interface/resources.cc +++ b/source/blender/editors/interface/resources.cc @@ -1098,7 +1098,7 @@ void UI_theme_init_default() bTheme *btheme = static_cast( BLI_findstring(&U.themes, U_theme_default.name, offsetof(bTheme, name))); if (btheme == nullptr) { - btheme = MEM_cnew(__func__); + btheme = MEM_callocN(__func__); STRNCPY(btheme->name, U_theme_default.name); BLI_addhead(&U.themes, btheme); } diff --git a/source/blender/editors/interface/templates/interface_template_bone_collection_tree.cc b/source/blender/editors/interface/templates/interface_template_bone_collection_tree.cc index 92a534633ef..3810171c22c 100644 --- a/source/blender/editors/interface/templates/interface_template_bone_collection_tree.cc +++ b/source/blender/editors/interface/templates/interface_template_bone_collection_tree.cc @@ -446,7 +446,7 @@ eWM_DragDataType BoneCollectionDragController::get_drag_type() const void *BoneCollectionDragController::create_drag_data() const { - ArmatureBoneCollection *drag_data = MEM_cnew(__func__); + ArmatureBoneCollection *drag_data = MEM_callocN(__func__); *drag_data = drag_arm_bcoll_; return drag_data; } diff --git a/source/blender/editors/interface/templates/interface_template_grease_pencil_layer_tree.cc b/source/blender/editors/interface/templates/interface_template_grease_pencil_layer_tree.cc index 96519a34ab9..b2be3355acc 100644 --- a/source/blender/editors/interface/templates/interface_template_grease_pencil_layer_tree.cc +++ b/source/blender/editors/interface/templates/interface_template_grease_pencil_layer_tree.cc @@ -189,7 +189,7 @@ class LayerViewItemDragController : public AbstractViewItemDragController { void *create_drag_data() const override { - wmDragGreasePencilLayer *drag_data = MEM_cnew(__func__); + wmDragGreasePencilLayer *drag_data = MEM_callocN(__func__); drag_data->node = &dragged_node_; drag_data->grease_pencil = &grease_pencil_; return drag_data; diff --git a/source/blender/editors/interface/templates/interface_template_node_tree_interface.cc b/source/blender/editors/interface/templates/interface_template_node_tree_interface.cc index e6a2ac65a6e..8d1eaad48f4 100644 --- a/source/blender/editors/interface/templates/interface_template_node_tree_interface.cc +++ b/source/blender/editors/interface/templates/interface_template_node_tree_interface.cc @@ -337,7 +337,7 @@ eWM_DragDataType NodeTreeInterfaceDragController::get_drag_type() const void *NodeTreeInterfaceDragController::create_drag_data() const { - wmDragNodeTreeInterface *drag_data = MEM_cnew(__func__); + wmDragNodeTreeInterface *drag_data = MEM_callocN(__func__); drag_data->item = &item_; return drag_data; } diff --git a/source/blender/editors/interface/templates/interface_template_operator_property.cc b/source/blender/editors/interface/templates/interface_template_operator_property.cc index 2989a1c3860..ba4b35646bf 100644 --- a/source/blender/editors/interface/templates/interface_template_operator_property.cc +++ b/source/blender/editors/interface/templates/interface_template_operator_property.cc @@ -333,7 +333,7 @@ static wmOperator *minimal_operator_create(wmOperatorType *ot, PointerRNA *prope { /* Copied from #wm_operator_create. * Create a slimmed down operator suitable only for UI drawing. */ - wmOperator *op = MEM_cnew(ot->rna_ext.srna ? __func__ : ot->idname); + wmOperator *op = MEM_callocN(ot->rna_ext.srna ? __func__ : ot->idname); STRNCPY(op->idname, ot->idname); op->type = ot; @@ -408,7 +408,7 @@ void uiTemplateCollectionExporters(uiLayout *layout, bContext *C) /* Register the exporter list type on first use. */ static const uiListType *exporter_item_list = []() { - uiListType *lt = MEM_cnew(__func__); + uiListType *lt = MEM_callocN(__func__); STRNCPY(lt->idname, "COLLECTION_UL_exporter_list"); lt->draw_item = draw_exporter_item; WM_uilisttype_add(lt); diff --git a/source/blender/editors/interface/templates/interface_template_preview.cc b/source/blender/editors/interface/templates/interface_template_preview.cc index 42617e6c021..3c3318f3a81 100644 --- a/source/blender/editors/interface/templates/interface_template_preview.cc +++ b/source/blender/editors/interface/templates/interface_template_preview.cc @@ -98,7 +98,7 @@ void uiTemplatePreview(uiLayout *layout, BLI_findstring(®ion->ui_previews, preview_id, offsetof(uiPreview, preview_id))); if (!ui_preview) { - ui_preview = MEM_cnew(__func__); + ui_preview = MEM_callocN(__func__); STRNCPY(ui_preview->preview_id, preview_id); ui_preview->height = short(UI_UNIT_Y * 7.6f); ui_preview->id_session_uid = pid->session_uid; diff --git a/source/blender/editors/interface/view2d/view2d_gizmo_navigate.cc b/source/blender/editors/interface/view2d/view2d_gizmo_navigate.cc index 0845a4b0ae0..2be4e27209a 100644 --- a/source/blender/editors/interface/view2d/view2d_gizmo_navigate.cc +++ b/source/blender/editors/interface/view2d/view2d_gizmo_navigate.cc @@ -149,7 +149,7 @@ static bool WIDGETGROUP_navigate_poll(const bContext *C, wmGizmoGroupType * /*gz static void WIDGETGROUP_navigate_setup(const bContext * /*C*/, wmGizmoGroup *gzgroup) { - NavigateWidgetGroup *navgroup = MEM_cnew(__func__); + NavigateWidgetGroup *navgroup = MEM_callocN(__func__); const NavigateGizmoInfo *navigate_params = navigate_params_from_space_type( gzgroup->type->gzmap_params.spaceid); diff --git a/source/blender/editors/interface/view2d/view2d_ops.cc b/source/blender/editors/interface/view2d/view2d_ops.cc index 5be2303240c..d1f0fba09a6 100644 --- a/source/blender/editors/interface/view2d/view2d_ops.cc +++ b/source/blender/editors/interface/view2d/view2d_ops.cc @@ -140,7 +140,7 @@ static void view_pan_init(bContext *C, wmOperator *op) BLI_assert(view_pan_poll(C)); /* set custom-data for operator */ - v2dViewPanData *vpd = MEM_cnew(__func__); + v2dViewPanData *vpd = MEM_callocN(__func__); op->customdata = vpd; /* set pointers to owners */ @@ -724,7 +724,7 @@ static void view_zoomdrag_init(bContext *C, wmOperator *op) BLI_assert(view_zoom_poll(C)); /* set custom-data for operator */ - v2dViewZoomData *vzd = MEM_cnew(__func__); + v2dViewZoomData *vzd = MEM_callocN(__func__); op->customdata = vzd; /* set pointers to owners */ @@ -1896,7 +1896,7 @@ static void scroller_activate_init(bContext *C, View2D *v2d = ®ion->v2d; /* set custom-data for operator */ - v2dScrollerMove *vsm = MEM_cnew(__func__); + v2dScrollerMove *vsm = MEM_callocN(__func__); op->customdata = vsm; /* set general data */ diff --git a/source/blender/editors/interface/views/interface_view.cc b/source/blender/editors/interface/views/interface_view.cc index 386c583e163..2cb22108ca2 100644 --- a/source/blender/editors/interface/views/interface_view.cc +++ b/source/blender/editors/interface/views/interface_view.cc @@ -160,7 +160,7 @@ static uiViewStateLink *ensure_view_state(ARegion ®ion, const ViewLink &link) } } - uiViewStateLink *new_state = MEM_cnew(__func__); + uiViewStateLink *new_state = MEM_callocN(__func__); link.idname.copy(new_state->idname, sizeof(new_state->idname)); BLI_addhead(®ion.view_states, new_state); return new_state; diff --git a/source/blender/editors/io/io_usd.cc b/source/blender/editors/io/io_usd.cc index fed3347f1dd..d3378e27cea 100644 --- a/source/blender/editors/io/io_usd.cc +++ b/source/blender/editors/io/io_usd.cc @@ -246,7 +246,7 @@ static void process_prim_path(char *prim_path) static int wm_usd_export_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/) { - eUSDOperatorOptions *options = MEM_cnew("eUSDOperatorOptions"); + eUSDOperatorOptions *options = MEM_callocN("eUSDOperatorOptions"); options->as_background_job = true; op->customdata = options; @@ -913,7 +913,7 @@ void WM_OT_usd_export(wmOperatorType *ot) static int wm_usd_import_invoke(bContext *C, wmOperator *op, const wmEvent *event) { - eUSDOperatorOptions *options = MEM_cnew("eUSDOperatorOptions"); + eUSDOperatorOptions *options = MEM_callocN("eUSDOperatorOptions"); options->as_background_job = true; op->customdata = options; diff --git a/source/blender/editors/mask/mask_add.cc b/source/blender/editors/mask/mask_add.cc index 5155052272f..a6525c2837c 100644 --- a/source/blender/editors/mask/mask_add.cc +++ b/source/blender/editors/mask/mask_add.cc @@ -226,7 +226,8 @@ static void mask_spline_add_point_at_index(MaskSpline *spline, int point_index) { MaskSplinePoint *new_point_array; - new_point_array = MEM_cnew_array(spline->tot_point + 1, "add mask vert points"); + new_point_array = MEM_calloc_arrayN(spline->tot_point + 1, + "add mask vert points"); memcpy(new_point_array, spline->points, sizeof(MaskSplinePoint) * (point_index + 1)); memcpy(new_point_array + point_index + 2, @@ -716,7 +717,7 @@ static BezTriple *points_to_bezier(const float (*points)[2], const float scale, const float location[2]) { - BezTriple *bezier_points = MEM_cnew_array(num_points, __func__); + BezTriple *bezier_points = MEM_calloc_arrayN(num_points, __func__); for (int i = 0; i < num_points; i++) { copy_v2_v2(bezier_points[i].vec[1], points[i]); mul_v2_fl(bezier_points[i].vec[1], scale); diff --git a/source/blender/editors/mask/mask_draw.cc b/source/blender/editors/mask/mask_draw.cc index 321e65c5715..02b0e005f50 100644 --- a/source/blender/editors/mask/mask_draw.cc +++ b/source/blender/editors/mask/mask_draw.cc @@ -392,7 +392,7 @@ static void mask_draw_curve_type(const bContext *C, const bool undistort = sc->clip && (sc->user.render_flag & MCLIP_PROXY_RENDER_UNDISTORT); if (undistort) { - points = MEM_cnew_array(tot_point, "undistorthed mask curve"); + points = MEM_calloc_arrayN(tot_point, "undistorthed mask curve"); for (int i = 0; i < tot_point; i++) { mask_point_undistort_pos(sc, points[i], orig_points[i]); @@ -624,7 +624,7 @@ static void draw_mask_layers( static float *mask_rasterize(Mask *mask, const int width, const int height) { MaskRasterHandle *handle; - float *buffer = MEM_cnew_array(height * width, "rasterized mask buffer"); + float *buffer = MEM_calloc_arrayN(height * width, "rasterized mask buffer"); /* Initialize rasterization handle. */ handle = BKE_maskrasterize_handle_new(); diff --git a/source/blender/editors/mask/mask_editaction.cc b/source/blender/editors/mask/mask_editaction.cc index 58d8a56f78d..bde4ed6d7c7 100644 --- a/source/blender/editors/mask/mask_editaction.cc +++ b/source/blender/editors/mask/mask_editaction.cc @@ -69,7 +69,7 @@ void ED_masklayer_make_cfra_list(MaskLayer *mask_layer, ListBase *elems, bool on /* loop through mask-frames, adding */ LISTBASE_FOREACH (MaskLayerShape *, mask_layer_shape, &mask_layer->splines_shapes) { if ((onlysel == false) || (mask_layer_shape->flag & MASK_SHAPE_SELECT)) { - CfraElem *ce = MEM_cnew("CfraElem"); + CfraElem *ce = MEM_callocN("CfraElem"); ce->cfra = float(mask_layer_shape->frame); ce->sel = (mask_layer_shape->flag & MASK_SHAPE_SELECT) ? 1 : 0; diff --git a/source/blender/editors/mask/mask_ops.cc b/source/blender/editors/mask/mask_ops.cc index d5a107d0658..994a4f58bbb 100644 --- a/source/blender/editors/mask/mask_ops.cc +++ b/source/blender/editors/mask/mask_ops.cc @@ -488,7 +488,7 @@ static SlidePointData *slide_point_customdata(bContext *C, wmOperator *op, const } if (action != SLIDE_ACTION_NONE) { - customdata = MEM_cnew("mask slide point data"); + customdata = MEM_callocN("mask slide point data"); customdata->event_invoke_type = event->type; customdata->mask = mask; customdata->mask_layer = mask_layer; @@ -1032,7 +1032,7 @@ static SlideSplineCurvatureData *slide_spline_curvature_customdata(bContext *C, return nullptr; } - slide_data = MEM_cnew("slide curvature slide"); + slide_data = MEM_callocN("slide curvature slide"); slide_data->event_invoke_type = event->type; slide_data->mask = mask; slide_data->mask_layer = mask_layer; @@ -1386,7 +1386,7 @@ static void delete_feather_points(MaskSplinePoint *point) MaskSplinePointUW *new_uw; int j = 0; - new_uw = MEM_cnew_array(count, "new mask uw points"); + new_uw = MEM_calloc_arrayN(count, "new mask uw points"); for (int i = 0; i < point->tot_uw; i++) { if ((point->uw[i].flag & SELECT) == 0) { @@ -1451,7 +1451,7 @@ static int delete_exec(bContext *C, wmOperator * /*op*/) else { MaskSplinePoint *new_points; - new_points = MEM_cnew_array(count, "deleteMaskPoints"); + new_points = MEM_calloc_arrayN(count, "deleteMaskPoints"); for (int i = 0, j = 0; i < tot_point_orig; i++) { MaskSplinePoint *point = &spline->points[i]; @@ -2027,8 +2027,8 @@ static int mask_duplicate_exec(bContext *C, wmOperator * /*op*/) /* Allocate new points and copy them from old spline. */ new_spline->tot_point = end - start + 1; - new_spline->points = MEM_cnew_array(new_spline->tot_point, - "duplicated mask points"); + new_spline->points = MEM_calloc_arrayN(new_spline->tot_point, + "duplicated mask points"); memcpy(new_spline->points, spline->points + start, diff --git a/source/blender/editors/mesh/editmesh_tools.cc b/source/blender/editors/mesh/editmesh_tools.cc index b62a0dbcd60..05bd31b82d9 100644 --- a/source/blender/editors/mesh/editmesh_tools.cc +++ b/source/blender/editors/mesh/editmesh_tools.cc @@ -4783,7 +4783,7 @@ struct FillGridSplitJoin { */ static FillGridSplitJoin *edbm_fill_grid_split_join_init(BMEditMesh *em) { - FillGridSplitJoin *split_join = MEM_cnew(__func__); + FillGridSplitJoin *split_join = MEM_callocN(__func__); /* Split the selection into an island. */ BMOperator split_op; diff --git a/source/blender/editors/object/add_modifier_assets.cc b/source/blender/editors/object/add_modifier_assets.cc index 0933e8ed34c..ac71bc6ca3e 100644 --- a/source/blender/editors/object/add_modifier_assets.cc +++ b/source/blender/editors/object/add_modifier_assets.cc @@ -397,9 +397,9 @@ static MenuType modifier_add_root_catalogs_menu_type() void object_modifier_add_asset_register() { - WM_menutype_add(MEM_cnew(__func__, modifier_add_catalog_assets_menu_type())); - WM_menutype_add(MEM_cnew(__func__, modifier_add_unassigned_assets_menu_type())); - WM_menutype_add(MEM_cnew(__func__, modifier_add_root_catalogs_menu_type())); + WM_menutype_add(MEM_dupallocN(__func__, modifier_add_catalog_assets_menu_type())); + WM_menutype_add(MEM_dupallocN(__func__, modifier_add_unassigned_assets_menu_type())); + WM_menutype_add(MEM_dupallocN(__func__, modifier_add_root_catalogs_menu_type())); WM_operatortype_append(OBJECT_OT_modifier_add_node_group); } diff --git a/source/blender/editors/object/object_bake.cc b/source/blender/editors/object/object_bake.cc index fdc32a1bcd5..b5f70feb124 100644 --- a/source/blender/editors/object/object_bake.cc +++ b/source/blender/editors/object/object_bake.cc @@ -444,7 +444,7 @@ static void init_multiresbake_job(bContext *C, MultiresBakeJob *bkj) multires_flush_sculpt_updates(ob); - MultiresBakerJobData *data = MEM_cnew(__func__); + MultiresBakerJobData *data = MEM_callocN(__func__); data->ob_image.array = bake_object_image_get_array(ob); data->ob_image.len = ob->totcol; @@ -557,7 +557,7 @@ static int multiresbake_image_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - MultiresBakeJob *bkr = MEM_cnew(__func__); + MultiresBakeJob *bkr = MEM_callocN(__func__); init_multiresbake_job(C, bkr); if (!bkr->data.first) { diff --git a/source/blender/editors/object/object_bake_api.cc b/source/blender/editors/object/object_bake_api.cc index dcf8cda9551..a460ff91c71 100644 --- a/source/blender/editors/object/object_bake_api.cc +++ b/source/blender/editors/object/object_bake_api.cc @@ -1009,7 +1009,7 @@ static bool bake_targets_init_vertex_colors(Main *bmain, /* Ensure mesh and editmesh topology are in sync. */ editmode_load(bmain, ob); - targets->images = MEM_cnew(__func__); + targets->images = MEM_callocN(__func__); targets->images_num = 1; targets->material_to_image = static_cast( diff --git a/source/blender/editors/object/object_bake_simulation.cc b/source/blender/editors/object/object_bake_simulation.cc index 63169066ef4..73cd58ffb8e 100644 --- a/source/blender/editors/object/object_bake_simulation.cc +++ b/source/blender/editors/object/object_bake_simulation.cc @@ -371,15 +371,15 @@ static void bake_geometry_nodes_startjob(void *customdata, wmJobWorkerStatus *wo continue; } - NodesModifierPackedBake *packed_bake = MEM_cnew(__func__); + NodesModifierPackedBake *packed_bake = MEM_callocN(__func__); packed_bake->meta_files_num = packed_data->meta_files.size(); packed_bake->blob_files_num = packed_data->blob_files.size(); - packed_bake->meta_files = MEM_cnew_array(packed_bake->meta_files_num, - __func__); - packed_bake->blob_files = MEM_cnew_array(packed_bake->blob_files_num, - __func__); + packed_bake->meta_files = MEM_calloc_arrayN(packed_bake->meta_files_num, + __func__); + packed_bake->blob_files = MEM_calloc_arrayN(packed_bake->blob_files_num, + __func__); auto transfer_to_bake = [&](NodesModifierBakeFile *bake_files, MemoryBakeFile *memory_bake_files, const int num) { diff --git a/source/blender/editors/object/object_collection.cc b/source/blender/editors/object/object_collection.cc index c5950f7b558..5931716b27c 100644 --- a/source/blender/editors/object/object_collection.cc +++ b/source/blender/editors/object/object_collection.cc @@ -496,7 +496,7 @@ static int collection_exporter_add_exec(bContext *C, wmOperator *op) /* Add a new #CollectionExport item to our handler list and fill it with #FileHandlerType * information. Also load in the operator's properties now as well. */ - CollectionExport *data = MEM_cnew("CollectionExport"); + CollectionExport *data = MEM_callocN("CollectionExport"); STRNCPY(data->fh_idname, fh->idname); BKE_collection_exporter_name_set(exporters, data, fh->label); @@ -842,7 +842,7 @@ static void collection_exporter_menu_draw(const bContext * /*C*/, Menu *menu) void collection_exporter_register() { - MenuType *mt = MEM_cnew(__func__); + MenuType *mt = MEM_callocN(__func__); STRNCPY(mt->idname, "COLLECTION_MT_exporter_add"); STRNCPY(mt->label, N_("Add Exporter")); mt->draw = collection_exporter_menu_draw; diff --git a/source/blender/editors/object/object_modifier.cc b/source/blender/editors/object/object_modifier.cc index e318f07823c..5bc1b8db998 100644 --- a/source/blender/editors/object/object_modifier.cc +++ b/source/blender/editors/object/object_modifier.cc @@ -3017,7 +3017,7 @@ static Object *modifier_skin_armature_create(Depsgraph *depsgraph, Main *bmain, ANIM_armature_bonecoll_show_all(arm); arm_ob->dtx |= OB_DRAW_IN_FRONT; arm->drawtype = ARM_LINE; - arm->edbo = MEM_cnew("edbo armature"); + arm->edbo = MEM_callocN("edbo armature"); MVertSkin *mvert_skin = static_cast( CustomData_get_layer_for_write(&mesh->vert_data, CD_MVERT_SKIN, mesh->verts_num)); @@ -3489,7 +3489,7 @@ static int ocean_bake_exec(bContext *C, wmOperator *op) "Ocean Simulation", WM_JOB_PROGRESS, WM_JOB_TYPE_OBJECT_SIM_OCEAN); - OceanBakeJob *oj = MEM_cnew("ocean bake job"); + OceanBakeJob *oj = MEM_callocN("ocean bake job"); oj->owner = ob; oj->ocean = ocean; oj->och = och; diff --git a/source/blender/editors/object/object_remesh.cc b/source/blender/editors/object/object_remesh.cc index 65a937080b2..412717baa7f 100644 --- a/source/blender/editors/object/object_remesh.cc +++ b/source/blender/editors/object/object_remesh.cc @@ -438,7 +438,7 @@ static int voxel_size_edit_invoke(bContext *C, wmOperator *op, const wmEvent *ev Object *active_object = CTX_data_active_object(C); Mesh *mesh = (Mesh *)active_object->data; - VoxelSizeEditCustomData *cd = MEM_cnew( + VoxelSizeEditCustomData *cd = MEM_callocN( "Voxel Size Edit OP Custom Data"); /* Initial operator Custom Data setup. */ diff --git a/source/blender/editors/object/object_visual_geometry_to_objects.cc b/source/blender/editors/object/object_visual_geometry_to_objects.cc index b261b5e7d1d..cabda722787 100644 --- a/source/blender/editors/object/object_visual_geometry_to_objects.cc +++ b/source/blender/editors/object/object_visual_geometry_to_objects.cc @@ -97,10 +97,10 @@ static void copy_materials_to_new_geometry_object(const Object &src_ob_eval, *BKE_id_material_len_p(&dst_data_orig) = materials_num; dst_ob_orig.totcol = materials_num; - dst_ob_orig.matbits = MEM_cnew_array(materials_num, __func__); - dst_ob_orig.mat = MEM_cnew_array(materials_num, __func__); + dst_ob_orig.matbits = MEM_calloc_arrayN(materials_num, __func__); + dst_ob_orig.mat = MEM_calloc_arrayN(materials_num, __func__); Material ***dst_materials = BKE_id_material_array_p(&dst_data_orig); - *dst_materials = MEM_cnew_array(materials_num, __func__); + *dst_materials = MEM_calloc_arrayN(materials_num, __func__); for (int i = 0; i < materials_num; i++) { const Material *material_eval = BKE_object_material_get_eval( diff --git a/source/blender/editors/render/render_opengl.cc b/source/blender/editors/render/render_opengl.cc index bc02ecfa906..a2a5976d7ca 100644 --- a/source/blender/editors/render/render_opengl.cc +++ b/source/blender/editors/render/render_opengl.cc @@ -181,7 +181,7 @@ static void screen_opengl_views_setup(OGLRender *oglrender) rv = static_cast(rr->views.first); if (rv == nullptr) { - rv = MEM_cnew("new opengl render view"); + rv = MEM_callocN("new opengl render view"); BLI_addtail(&rr->views, rv); } @@ -229,7 +229,7 @@ static void screen_opengl_views_setup(OGLRender *oglrender) BLI_findstring(&rr->views, srv->name, offsetof(SceneRenderView, name))); if (rv == nullptr) { - rv = MEM_cnew("new opengl render view"); + rv = MEM_callocN("new opengl render view"); STRNCPY(rv->name, srv->name); BLI_addtail(&rr->views, rv); } @@ -1090,7 +1090,7 @@ static bool schedule_write_result(OGLRender *oglrender, RenderResult *rr) return false; } Scene *scene = oglrender->scene; - WriteTaskData *task_data = MEM_cnew("write task data"); + WriteTaskData *task_data = MEM_callocN("write task data"); task_data->rr = rr; memcpy(&task_data->tmp_scene, scene, sizeof(task_data->tmp_scene)); { diff --git a/source/blender/editors/render/render_preview.cc b/source/blender/editors/render/render_preview.cc index fab0594f46f..fd1b9722aa8 100644 --- a/source/blender/editors/render/render_preview.cc +++ b/source/blender/editors/render/render_preview.cc @@ -1518,7 +1518,7 @@ static void other_id_types_preview_render(IconPreview *ip, const ePreviewRenderMethod pr_method, wmJobWorkerStatus *worker_status) { - ShaderPreview *sp = MEM_cnew("Icon ShaderPreview"); + ShaderPreview *sp = MEM_callocN("Icon ShaderPreview"); /* These types don't use the ShaderPreview mess, they have their own types and functions. */ BLI_assert(!ip->id || !ELEM(GS(ip->id->name), ID_OB)); @@ -1661,7 +1661,7 @@ static void icon_preview_add_size(IconPreview *ip, uint *rect, int sizex, int si cur_size = cur_size->next; } - IconPreviewSize *new_size = MEM_cnew("IconPreviewSize"); + IconPreviewSize *new_size = MEM_callocN("IconPreviewSize"); new_size->sizex = sizex; new_size->sizey = sizey; new_size->rect = rect; @@ -2046,7 +2046,7 @@ void ED_preview_icon_job( WM_JOB_EXCL_RENDER, WM_JOB_TYPE_RENDER_PREVIEW); - ip = MEM_cnew("icon preview"); + ip = MEM_callocN("icon preview"); /* render all resolutions from suspended job too */ old_ip = static_cast(WM_jobs_customdata_get(wm_job)); @@ -2113,7 +2113,7 @@ void ED_preview_shader_job(const bContext *C, "Shader Preview", WM_JOB_EXCL_RENDER, WM_JOB_TYPE_RENDER_PREVIEW); - sp = MEM_cnew("shader preview"); + sp = MEM_callocN("shader preview"); /* customdata for preview thread */ sp->scene = scene; @@ -2184,7 +2184,7 @@ void ED_preview_restart_queue_free() void ED_preview_restart_queue_add(ID *id, enum eIconSizes size) { - PreviewRestartQueueEntry *queue_entry = MEM_cnew(__func__); + PreviewRestartQueueEntry *queue_entry = MEM_callocN(__func__); queue_entry->size = size; queue_entry->id = id; BLI_addtail(&G_restart_previews_queue, queue_entry); diff --git a/source/blender/editors/sculpt_paint/paint_hide.cc b/source/blender/editors/sculpt_paint/paint_hide.cc index 6df0b4bcfd8..f631a5e30ba 100644 --- a/source/blender/editors/sculpt_paint/paint_hide.cc +++ b/source/blender/editors/sculpt_paint/paint_hide.cc @@ -1319,7 +1319,7 @@ static void hide_show_init_properties(bContext & /*C*/, wmOperator &op) { gesture_data.operation = reinterpret_cast( - MEM_cnew(__func__)); + MEM_callocN(__func__)); HideShowOperation *operation = reinterpret_cast(gesture_data.operation); diff --git a/source/blender/editors/sculpt_paint/paint_image.cc b/source/blender/editors/sculpt_paint/paint_image.cc index 32a4e306759..95006b810b9 100644 --- a/source/blender/editors/sculpt_paint/paint_image.cc +++ b/source/blender/editors/sculpt_paint/paint_image.cc @@ -543,7 +543,7 @@ static int grab_clone_invoke(bContext *C, wmOperator *op, const wmEvent *event) const ImagePaintSettings &image_paint_settings = settings->imapaint; GrabClone *cmv; - cmv = MEM_cnew("GrabClone"); + cmv = MEM_callocN("GrabClone"); copy_v2_v2(cmv->startoffset, image_paint_settings.clone_offset); cmv->startx = event->xy[0]; cmv->starty = event->xy[1]; diff --git a/source/blender/editors/sculpt_paint/paint_image_2d.cc b/source/blender/editors/sculpt_paint/paint_image_2d.cc index 1c371647fcf..fff8378bf87 100644 --- a/source/blender/editors/sculpt_paint/paint_image_2d.cc +++ b/source/blender/editors/sculpt_paint/paint_image_2d.cc @@ -140,7 +140,7 @@ static BrushPainter *brush_painter_2d_new(Scene *scene, Brush *brush, bool invert) { - BrushPainter *painter = MEM_cnew(__func__); + BrushPainter *painter = MEM_callocN(__func__); painter->brush = brush; painter->scene = scene; @@ -1585,7 +1585,7 @@ void *paint_2d_new_stroke(bContext *C, wmOperator *op, int mode) const Paint *paint = BKE_paint_get_active_from_context(C); Brush *brush = BKE_paint_brush(&settings->imapaint.paint); - ImagePaintState *s = MEM_cnew(__func__); + ImagePaintState *s = MEM_callocN(__func__); s->sima = CTX_wm_space_image(C); s->v2d = &CTX_wm_region(C)->v2d; @@ -1609,7 +1609,7 @@ void *paint_2d_new_stroke(bContext *C, wmOperator *op, int mode) } s->num_tiles = BLI_listbase_count(&s->image->tiles); - s->tiles = MEM_cnew_array(s->num_tiles, __func__); + s->tiles = MEM_calloc_arrayN(s->num_tiles, __func__); for (int i = 0; i < s->num_tiles; i++) { s->tiles[i].iuser = sima->iuser; } diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.cc b/source/blender/editors/sculpt_paint/paint_image_proj.cc index e7397701ddb..40528f6897f 100644 --- a/source/blender/editors/sculpt_paint/paint_image_proj.cc +++ b/source/blender/editors/sculpt_paint/paint_image_proj.cc @@ -3892,7 +3892,7 @@ static void proj_paint_state_cavity_init(ProjPaintState *ps) int a; if (ps->do_mask_cavity) { - int *counter = MEM_cnew_array(ps->totvert_eval, "counter"); + int *counter = MEM_calloc_arrayN(ps->totvert_eval, "counter"); float(*edges)[3] = static_cast( MEM_callocN(sizeof(float[3]) * ps->totvert_eval, "edges")); ps->cavities = static_cast( @@ -3929,12 +3929,12 @@ static void proj_paint_state_cavity_init(ProjPaintState *ps) static void proj_paint_state_seam_bleed_init(ProjPaintState *ps) { if (ps->seam_bleed_px > 0.0f) { - ps->vertFaces = MEM_cnew_array(ps->totvert_eval, "paint-vertFaces"); - ps->faceSeamFlags = MEM_cnew_array(ps->corner_tris_eval.size(), __func__); - ps->faceWindingFlags = MEM_cnew_array(ps->corner_tris_eval.size(), __func__); + ps->vertFaces = MEM_calloc_arrayN(ps->totvert_eval, "paint-vertFaces"); + ps->faceSeamFlags = MEM_calloc_arrayN(ps->corner_tris_eval.size(), __func__); + ps->faceWindingFlags = MEM_calloc_arrayN(ps->corner_tris_eval.size(), __func__); ps->loopSeamData = static_cast( MEM_mallocN(sizeof(LoopSeamData) * ps->totloop_eval, "paint-loopSeamUVs")); - ps->vertSeams = MEM_cnew_array(ps->totvert_eval, "paint-vertSeams"); + ps->vertSeams = MEM_calloc_arrayN(ps->totvert_eval, "paint-vertSeams"); } } #endif @@ -3977,7 +3977,7 @@ static void proj_paint_state_vert_flags_init(ProjPaintState *ps) float no[3]; int a; - ps->vertFlags = MEM_cnew_array(ps->totvert_eval, "paint-vertFlags"); + ps->vertFlags = MEM_calloc_arrayN(ps->totvert_eval, "paint-vertFlags"); for (a = 0; a < ps->totvert_eval; a++) { copy_v3_v3(no, ps->vert_normals[a]); @@ -4456,7 +4456,7 @@ static void project_paint_prepare_all_faces(ProjPaintState *ps, iuser.tile = tile; iuser.framenr = tpage->lastframe; if (BKE_image_has_ibuf(tpage, &iuser)) { - PrepareImageEntry *e = MEM_cnew("PrepareImageEntry"); + PrepareImageEntry *e = MEM_callocN("PrepareImageEntry"); e->ima = tpage; e->iuser = iuser; BLI_addtail(&used_images, e); @@ -4575,10 +4575,12 @@ static void project_paint_begin(const bContext *C, CLAMP(ps->buckets_x, PROJ_BUCKET_RECT_MIN, PROJ_BUCKET_RECT_MAX); CLAMP(ps->buckets_y, PROJ_BUCKET_RECT_MIN, PROJ_BUCKET_RECT_MAX); - ps->bucketRect = MEM_cnew_array(ps->buckets_x * ps->buckets_y, "paint-bucketRect"); - ps->bucketFaces = MEM_cnew_array(ps->buckets_x * ps->buckets_y, "paint-bucketFaces"); + ps->bucketRect = MEM_calloc_arrayN(ps->buckets_x * ps->buckets_y, + "paint-bucketRect"); + ps->bucketFaces = MEM_calloc_arrayN(ps->buckets_x * ps->buckets_y, + "paint-bucketFaces"); - ps->bucketFlags = MEM_cnew_array(ps->buckets_x * ps->buckets_y, "paint-bucketFaces"); + ps->bucketFlags = MEM_calloc_arrayN(ps->buckets_x * ps->buckets_y, "paint-bucketFaces"); #ifndef PROJ_DEBUG_NOSEAMBLEED if (ps->is_shared_user == false) { proj_paint_state_seam_bleed_init(ps); @@ -5955,7 +5957,7 @@ void *paint_proj_new_stroke(bContext *C, Object *ob, const float mouse[2], int m ToolSettings *settings = scene->toolsettings; char symmetry_flag_views[BOUNDED_ARRAY_TYPE_SIZEps_views)>()] = {0}; - ps_handle = MEM_cnew("ProjStrokeHandle"); + ps_handle = MEM_callocN("ProjStrokeHandle"); ps_handle->scene = scene; ps_handle->brush = BKE_paint_brush(&settings->imapaint.paint); diff --git a/source/blender/editors/sculpt_paint/paint_mask.cc b/source/blender/editors/sculpt_paint/paint_mask.cc index 9d468eebd71..d4601f4dd77 100644 --- a/source/blender/editors/sculpt_paint/paint_mask.cc +++ b/source/blender/editors/sculpt_paint/paint_mask.cc @@ -851,7 +851,7 @@ static void gesture_end(bContext &C, gesture::GestureData &gesture_data) static void init_operation(bContext &C, gesture::GestureData &gesture_data, wmOperator &op) { gesture_data.operation = reinterpret_cast( - MEM_cnew(__func__)); + MEM_callocN(__func__)); MaskOperation *mask_operation = (MaskOperation *)gesture_data.operation; diff --git a/source/blender/editors/sculpt_paint/paint_ops.cc b/source/blender/editors/sculpt_paint/paint_ops.cc index 25ff090e0a8..ba2917b8196 100644 --- a/source/blender/editors/sculpt_paint/paint_ops.cc +++ b/source/blender/editors/sculpt_paint/paint_ops.cc @@ -340,7 +340,7 @@ static int palette_sort_exec(bContext *C, wmOperator *op) const int totcol = BLI_listbase_count(&palette->colors); if (totcol > 0) { - color_array = MEM_cnew_array(totcol, __func__); + color_array = MEM_calloc_arrayN(totcol, __func__); /* Put all colors in an array. */ int t = 0; LISTBASE_FOREACH (PaletteColor *, color, &palette->colors) { diff --git a/source/blender/editors/sculpt_paint/sculpt_detail.cc b/source/blender/editors/sculpt_paint/sculpt_detail.cc index d3977ba3a09..361a8799fe7 100644 --- a/source/blender/editors/sculpt_paint/sculpt_detail.cc +++ b/source/blender/editors/sculpt_paint/sculpt_detail.cc @@ -809,7 +809,7 @@ static int dyntopo_detail_size_edit_invoke(bContext *C, wmOperator *op, const wm Object &active_object = *CTX_data_active_object(C); Brush *brush = BKE_paint_brush(&sd->paint); - DyntopoDetailSizeEditCustomData *cd = MEM_cnew(__func__); + DyntopoDetailSizeEditCustomData *cd = MEM_callocN(__func__); /* Initial operator Custom Data setup. */ cd->draw_handle = ED_region_draw_cb_activate( diff --git a/source/blender/editors/sculpt_paint/sculpt_face_set.cc b/source/blender/editors/sculpt_paint/sculpt_face_set.cc index 0f228f41b28..526abe0c9c7 100644 --- a/source/blender/editors/sculpt_paint/sculpt_face_set.cc +++ b/source/blender/editors/sculpt_paint/sculpt_face_set.cc @@ -1799,7 +1799,7 @@ static void init_operation(gesture::GestureData &gesture_data, wmOperator & /*op { Object &object = *gesture_data.vc.obact; gesture_data.operation = reinterpret_cast( - MEM_cnew(__func__)); + MEM_callocN(__func__)); FaceSetOperation *face_set_operation = (FaceSetOperation *)gesture_data.operation; diff --git a/source/blender/editors/sculpt_paint/sculpt_project.cc b/source/blender/editors/sculpt_paint/sculpt_project.cc index f1ea6820c29..ea95d08cc6f 100644 --- a/source/blender/editors/sculpt_paint/sculpt_project.cc +++ b/source/blender/editors/sculpt_paint/sculpt_project.cc @@ -213,7 +213,7 @@ static void gesture_end(bContext &C, gesture::GestureData &gesture_data) static void init_operation(gesture::GestureData &gesture_data, wmOperator & /*op*/) { gesture_data.operation = reinterpret_cast( - MEM_cnew(__func__)); + MEM_callocN(__func__)); ProjectOperation *project_operation = (ProjectOperation *)gesture_data.operation; diff --git a/source/blender/editors/sculpt_paint/sculpt_trim.cc b/source/blender/editors/sculpt_paint/sculpt_trim.cc index f01906207e1..46b21b32931 100644 --- a/source/blender/editors/sculpt_paint/sculpt_trim.cc +++ b/source/blender/editors/sculpt_paint/sculpt_trim.cc @@ -809,7 +809,7 @@ static int gesture_box_exec(bContext *C, wmOperator *op) } gesture_data->operation = reinterpret_cast( - MEM_cnew(__func__)); + MEM_callocN(__func__)); initialize_cursor_info(*C, *op, *gesture_data); init_operation(*gesture_data, *op); @@ -840,7 +840,7 @@ static int gesture_lasso_exec(bContext *C, wmOperator *op) } gesture_data->operation = reinterpret_cast( - MEM_cnew(__func__)); + MEM_callocN(__func__)); initialize_cursor_info(*C, *op, *gesture_data); init_operation(*gesture_data, *op); @@ -871,7 +871,7 @@ static int gesture_line_exec(bContext *C, wmOperator *op) } gesture_data->operation = reinterpret_cast( - MEM_cnew(__func__)); + MEM_callocN(__func__)); initialize_cursor_info(*C, *op, *gesture_data); init_operation(*gesture_data, *op); @@ -902,7 +902,7 @@ static int gesture_polyline_exec(bContext *C, wmOperator *op) } gesture_data->operation = reinterpret_cast( - MEM_cnew(__func__)); + MEM_callocN(__func__)); initialize_cursor_info(*C, *op, *gesture_data); init_operation(*gesture_data, *op); diff --git a/source/blender/editors/sculpt_paint/sculpt_uv.cc b/source/blender/editors/sculpt_paint/sculpt_uv.cc index 09daf9c2b2f..218460c2051 100644 --- a/source/blender/editors/sculpt_paint/sculpt_uv.cc +++ b/source/blender/editors/sculpt_paint/sculpt_uv.cc @@ -651,7 +651,7 @@ static UvSculptData *uv_sculpt_stroke_init(bContext *C, wmOperator *op, const wm Scene *scene = CTX_data_scene(C); Object *obedit = CTX_data_edit_object(C); ToolSettings *ts = scene->toolsettings; - UvSculptData *data = MEM_cnew(__func__); + UvSculptData *data = MEM_callocN(__func__); BMEditMesh *em = BKE_editmesh_from_object(obedit); BMesh *bm = em->bm; @@ -721,13 +721,13 @@ static UvSculptData *uv_sculpt_stroke_init(bContext *C, wmOperator *op, const wm } /* Allocate the unique uv buffers */ - data->uv = MEM_cnew_array(unique_uvs, __func__); + data->uv = MEM_calloc_arrayN(unique_uvs, __func__); /* Holds, for each UvElement in elementMap, an index of its unique UV. */ int *uniqueUv = static_cast( MEM_mallocN(sizeof(*uniqueUv) * data->elementMap->total_uvs, __func__)); GHash *edgeHash = BLI_ghash_new(uv_edge_hash, uv_edge_compare, "uv_brush_edge_hash"); /* we have at most totalUVs edges */ - UvEdge *edges = MEM_cnew_array(data->elementMap->total_uvs, __func__); + UvEdge *edges = MEM_calloc_arrayN(data->elementMap->total_uvs, __func__); if (!data->uv || !uniqueUv || !edgeHash || !edges) { MEM_SAFE_FREE(edges); MEM_SAFE_FREE(uniqueUv); @@ -815,7 +815,7 @@ static UvSculptData *uv_sculpt_stroke_init(bContext *C, wmOperator *op, const wm MEM_SAFE_FREE(uniqueUv); /* Allocate connectivity data, we allocate edges once */ - data->uvedges = MEM_cnew_array(BLI_ghash_len(edgeHash), __func__); + data->uvedges = MEM_calloc_arrayN(BLI_ghash_len(edgeHash), __func__); if (!data->uvedges) { BLI_ghash_free(edgeHash, nullptr, nullptr); MEM_SAFE_FREE(edges); diff --git a/source/blender/editors/space_action/action_buttons.cc b/source/blender/editors/space_action/action_buttons.cc index b5a404c163e..41bddd2b3b3 100644 --- a/source/blender/editors/space_action/action_buttons.cc +++ b/source/blender/editors/space_action/action_buttons.cc @@ -24,7 +24,7 @@ void action_buttons_register(ARegionType * /*art*/) /* TODO: AnimData / Actions List */ - pt = MEM_cnew("spacetype action panel properties"); + pt = MEM_callocN("spacetype action panel properties"); STRNCPY(pt->idname, "ACTION_PT_properties"); STRNCPY(pt->label, N_("Active F-Curve")); STRNCPY(pt->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA); @@ -32,7 +32,7 @@ void action_buttons_register(ARegionType * /*art*/) pt->poll = action_anim_panel_poll; BLI_addtail(&art->paneltypes, pt); - pt = MEM_cnew("spacetype action panel properties"); + pt = MEM_callocN("spacetype action panel properties"); STRNCPY(pt->idname, "ACTION_PT_key_properties"); STRNCPY(pt->label, N_("Active Keyframe")); STRNCPY(pt->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA); diff --git a/source/blender/editors/space_action/action_select.cc b/source/blender/editors/space_action/action_select.cc index f26448ca686..2ed89fdada1 100644 --- a/source/blender/editors/space_action/action_select.cc +++ b/source/blender/editors/space_action/action_select.cc @@ -1195,7 +1195,7 @@ static void columnselect_action_keys(bAnimContext *ac, short mode) case ACTKEYS_COLUMNSEL_CFRA: /* current frame */ /* make a single CfraElem for storing this */ - ce = MEM_cnew("cfraElem"); + ce = MEM_callocN("cfraElem"); BLI_addtail(&ked.list, ce); ce->cfra = float(scene->r.cfra); diff --git a/source/blender/editors/space_action/space_action.cc b/source/blender/editors/space_action/space_action.cc index 1cacc5c1a10..6dc9553c3e1 100644 --- a/source/blender/editors/space_action/space_action.cc +++ b/source/blender/editors/space_action/space_action.cc @@ -58,7 +58,7 @@ static SpaceLink *action_create(const ScrArea *area, const Scene *scene) SpaceAction *saction; ARegion *region; - saction = MEM_cnew("initaction"); + saction = MEM_callocN("initaction"); saction->spacetype = SPACE_ACTION; saction->mode = SACTCONT_DOPESHEET; @@ -948,7 +948,7 @@ void ED_spacetype_action() st->blend_write = action_space_blend_write; /* regions: main window */ - art = MEM_cnew("spacetype action region"); + art = MEM_callocN("spacetype action region"); art->regionid = RGN_TYPE_WINDOW; art->init = action_main_region_init; art->draw = action_main_region_draw; @@ -960,7 +960,7 @@ void ED_spacetype_action() BLI_addhead(&st->regiontypes, art); /* regions: header */ - art = MEM_cnew("spacetype action region"); + art = MEM_callocN("spacetype action region"); art->regionid = RGN_TYPE_HEADER; art->prefsizey = HEADERY; art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_HEADER; @@ -972,7 +972,7 @@ void ED_spacetype_action() BLI_addhead(&st->regiontypes, art); /* regions: channels */ - art = MEM_cnew("spacetype action region"); + art = MEM_callocN("spacetype action region"); art->regionid = RGN_TYPE_CHANNELS; art->prefsizex = 200; art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES; @@ -985,7 +985,7 @@ void ED_spacetype_action() BLI_addhead(&st->regiontypes, art); /* regions: UI buttons */ - art = MEM_cnew("spacetype action region"); + art = MEM_callocN("spacetype action region"); art->regionid = RGN_TYPE_UI; art->prefsizex = UI_SIDEBAR_PANEL_WIDTH; art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_FRAMES; diff --git a/source/blender/editors/space_api/spacetypes.cc b/source/blender/editors/space_api/spacetypes.cc index 5f768cb4114..f59863238ae 100644 --- a/source/blender/editors/space_api/spacetypes.cc +++ b/source/blender/editors/space_api/spacetypes.cc @@ -236,7 +236,7 @@ void *ED_region_draw_cb_activate(ARegionType *art, void *customdata, int type) { - RegionDrawCB *rdc = MEM_cnew(__func__); + RegionDrawCB *rdc = MEM_callocN(__func__); BLI_addtail(&art->drawcalls, rdc); rdc->draw = draw; diff --git a/source/blender/editors/space_buttons/buttons_texture.cc b/source/blender/editors/space_buttons/buttons_texture.cc index a67bf8158e7..7ed82fb0131 100644 --- a/source/blender/editors/space_buttons/buttons_texture.cc +++ b/source/blender/editors/space_buttons/buttons_texture.cc @@ -359,7 +359,7 @@ void buttons_texture_context_compute(const bContext *C, SpaceProperties *sbuts) ID *pinid = sbuts->pinid; if (!ct) { - ct = MEM_cnew("ButsContextTexture"); + ct = MEM_callocN("ButsContextTexture"); sbuts->texuser = ct; } else { diff --git a/source/blender/editors/space_clip/clip_buttons.cc b/source/blender/editors/space_clip/clip_buttons.cc index ccf43667c83..e5889993aa9 100644 --- a/source/blender/editors/space_clip/clip_buttons.cc +++ b/source/blender/editors/space_clip/clip_buttons.cc @@ -76,7 +76,7 @@ void ED_clip_buttons_register(ARegionType *art) { PanelType *pt; - pt = MEM_cnew("spacetype clip panel metadata"); + pt = MEM_callocN("spacetype clip panel metadata"); STRNCPY(pt->idname, "CLIP_PT_metadata"); STRNCPY(pt->label, N_("Metadata")); STRNCPY(pt->category, "Footage"); @@ -409,7 +409,7 @@ void uiTemplateMarker(uiLayout *layout, int clip_framenr = BKE_movieclip_remap_scene_to_clip_frame(clip, user->framenr); MovieTrackingMarker *marker = BKE_tracking_marker_get(track, clip_framenr); - MarkerUpdateCb *cb = MEM_cnew("uiTemplateMarker update_cb"); + MarkerUpdateCb *cb = MEM_callocN("uiTemplateMarker update_cb"); cb->compact = compact; cb->clip = clip; cb->user = user; diff --git a/source/blender/editors/space_clip/clip_draw.cc b/source/blender/editors/space_clip/clip_draw.cc index f48da78462f..470c466245e 100644 --- a/source/blender/editors/space_clip/clip_draw.cc +++ b/source/blender/editors/space_clip/clip_draw.cc @@ -508,7 +508,7 @@ static void draw_track_path(SpaceClip *sc, MovieClip * /*clip*/, MovieTrackingTr * for really long paths. */ path = (count < MAX_STATIC_PATH) ? path_static : - MEM_cnew_array(sizeof(*path) * (count + 1) * 2, "path"); + MEM_calloc_arrayN(sizeof(*path) * (count + 1) * 2, "path"); /* Collect path information. */ const int num_points_before = track_to_path_segment(sc, track, -1, path); const int num_points_after = track_to_path_segment(sc, track, 1, path); @@ -1496,7 +1496,7 @@ static void draw_tracking_tracks(SpaceClip *sc, /* undistort */ if (count) { - marker_pos = MEM_cnew_array(2 * count, "draw_tracking_tracks marker_pos"); + marker_pos = MEM_calloc_arrayN(2 * count, "draw_tracking_tracks marker_pos"); fp = marker_pos; LISTBASE_FOREACH (MovieTrackingTrack *, track, &tracking_object->tracks) { diff --git a/source/blender/editors/space_clip/clip_editor.cc b/source/blender/editors/space_clip/clip_editor.cc index a62392adf26..06db2f2150c 100644 --- a/source/blender/editors/space_clip/clip_editor.cc +++ b/source/blender/editors/space_clip/clip_editor.cc @@ -717,7 +717,7 @@ static uchar *prefetch_read_file_to_memory( return nullptr; } - uchar *mem = MEM_cnew_array(size, "movieclip prefetch memory file"); + uchar *mem = MEM_calloc_arrayN(size, "movieclip prefetch memory file"); if (mem == nullptr) { close(file); return nullptr; @@ -1126,7 +1126,7 @@ void clip_start_prefetch_job(const bContext *C) WM_JOB_TYPE_CLIP_PREFETCH); /* create new job */ - pj = MEM_cnew("prefetch job"); + pj = MEM_callocN("prefetch job"); pj->clip = ED_space_clip_get_clip(sc); pj->start_frame = prefetch_get_start_frame(C); pj->current_frame = sc->user.framenr; diff --git a/source/blender/editors/space_clip/clip_ops.cc b/source/blender/editors/space_clip/clip_ops.cc index 7a202201703..bf364dec959 100644 --- a/source/blender/editors/space_clip/clip_ops.cc +++ b/source/blender/editors/space_clip/clip_ops.cc @@ -377,7 +377,7 @@ static void view_pan_init(bContext *C, wmOperator *op, const wmEvent *event) SpaceClip *sc = CTX_wm_space_clip(C); ViewPanData *vpd; - op->customdata = vpd = MEM_cnew("ClipViewPanData"); + op->customdata = vpd = MEM_callocN("ClipViewPanData"); /* Grab will be set when running from gizmo. */ vpd->own_cursor = (win->grabcursor == 0); @@ -553,7 +553,7 @@ static void view_zoom_init(bContext *C, wmOperator *op, const wmEvent *event) ARegion *region = CTX_wm_region(C); ViewZoomData *vpd; - op->customdata = vpd = MEM_cnew("ClipViewZoomData"); + op->customdata = vpd = MEM_callocN("ClipViewZoomData"); /* Grab will be set when running from gizmo. */ vpd->own_cursor = (win->grabcursor == 0); @@ -1334,7 +1334,7 @@ static uchar *proxy_thread_next_frame(ProxyQueue *queue, return nullptr; } - mem = MEM_cnew_array(size, "movieclip proxy memory file"); + mem = MEM_calloc_arrayN(size, "movieclip proxy memory file"); if (BLI_read(file, mem, size) != size) { close(file); @@ -1425,7 +1425,7 @@ static void do_sequence_proxy(void *pjv, queue.progress = progress; TaskPool *task_pool = BLI_task_pool_create(&queue, TASK_PRIORITY_LOW); - handles = MEM_cnew_array(tot_thread, "proxy threaded handles"); + handles = MEM_calloc_arrayN(tot_thread, "proxy threaded handles"); for (int i = 0; i < tot_thread; i++) { ProxyThread *handle = &handles[i]; @@ -1538,7 +1538,7 @@ static int clip_rebuild_proxy_exec(bContext *C, wmOperator * /*op*/) WM_JOB_PROGRESS, WM_JOB_TYPE_CLIP_BUILD_PROXY); - pj = MEM_cnew("proxy rebuild job"); + pj = MEM_callocN("proxy rebuild job"); pj->scene = scene; pj->main = CTX_data_main(C); pj->clip = clip; diff --git a/source/blender/editors/space_clip/space_clip.cc b/source/blender/editors/space_clip/space_clip.cc index 8fb72586850..64f27054e0c 100644 --- a/source/blender/editors/space_clip/space_clip.cc +++ b/source/blender/editors/space_clip/space_clip.cc @@ -235,7 +235,7 @@ static void clip_init(wmWindowManager * /*wm*/, ScrArea *area) static SpaceLink *clip_duplicate(SpaceLink *sl) { - SpaceClip *scn = MEM_cnew("clip_duplicate", *reinterpret_cast(sl)); + SpaceClip *scn = MEM_dupallocN("clip_duplicate", *reinterpret_cast(sl)); /* clear or remove stuff from old */ scn->scopes.track_search = nullptr; @@ -1241,7 +1241,7 @@ void ED_spacetype_clip() st->blend_write = clip_space_blend_write; /* regions: main window */ - art = MEM_cnew("spacetype clip region"); + art = MEM_callocN("spacetype clip region"); art->regionid = RGN_TYPE_WINDOW; art->poll = clip_main_region_poll; art->init = clip_main_region_init; @@ -1252,7 +1252,7 @@ void ED_spacetype_clip() BLI_addhead(&st->regiontypes, art); /* preview */ - art = MEM_cnew("spacetype clip region preview"); + art = MEM_callocN("spacetype clip region preview"); art->regionid = RGN_TYPE_PREVIEW; art->prefsizey = 240; art->poll = clip_preview_region_poll; @@ -1264,7 +1264,7 @@ void ED_spacetype_clip() BLI_addhead(&st->regiontypes, art); /* regions: properties */ - art = MEM_cnew("spacetype clip region properties"); + art = MEM_callocN("spacetype clip region properties"); art->regionid = RGN_TYPE_UI; art->prefsizex = UI_SIDEBAR_PANEL_WIDTH; art->keymapflag = ED_KEYMAP_FRAMES | ED_KEYMAP_UI; @@ -1276,7 +1276,7 @@ void ED_spacetype_clip() ED_clip_buttons_register(art); /* regions: tools */ - art = MEM_cnew("spacetype clip region tools"); + art = MEM_callocN("spacetype clip region tools"); art->regionid = RGN_TYPE_TOOLS; art->prefsizex = UI_SIDEBAR_PANEL_WIDTH; art->keymapflag = ED_KEYMAP_FRAMES | ED_KEYMAP_UI; @@ -1288,7 +1288,7 @@ void ED_spacetype_clip() BLI_addhead(&st->regiontypes, art); /* regions: header */ - art = MEM_cnew("spacetype clip region"); + art = MEM_callocN("spacetype clip region"); art->regionid = RGN_TYPE_HEADER; art->prefsizey = HEADERY; art->keymapflag = ED_KEYMAP_FRAMES | ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_HEADER; @@ -1300,7 +1300,7 @@ void ED_spacetype_clip() BLI_addhead(&st->regiontypes, art); /* channels */ - art = MEM_cnew("spacetype clip channels region"); + art = MEM_callocN("spacetype clip channels region"); art->regionid = RGN_TYPE_CHANNELS; art->prefsizex = UI_COMPACT_PANEL_WIDTH; art->keymapflag = ED_KEYMAP_FRAMES | ED_KEYMAP_UI; diff --git a/source/blender/editors/space_clip/tracking_ops.cc b/source/blender/editors/space_clip/tracking_ops.cc index f798e3d2294..7a20559770c 100644 --- a/source/blender/editors/space_clip/tracking_ops.cc +++ b/source/blender/editors/space_clip/tracking_ops.cc @@ -408,7 +408,7 @@ static SlideMarkerData *create_slide_marker_data(SpaceClip *sc, int width, int height) { - SlideMarkerData *data = MEM_cnew("slide marker data"); + SlideMarkerData *data = MEM_callocN("slide marker data"); int framenr = ED_space_clip_get_clip_frame_number(sc); marker = BKE_tracking_marker_ensure(track, framenr); @@ -1584,7 +1584,7 @@ static bool is_track_clean(MovieTrackingTrack *track, int frames, int del) int markersnr = track->markersnr; if (del) { - new_markers = MEM_cnew_array(markersnr, "track cleaned markers"); + new_markers = MEM_calloc_arrayN(markersnr, "track cleaned markers"); } for (int a = 0; a < markersnr; a++) { diff --git a/source/blender/editors/space_clip/tracking_ops_plane.cc b/source/blender/editors/space_clip/tracking_ops_plane.cc index 24abc2b0174..3f4892fcf31 100644 --- a/source/blender/editors/space_clip/tracking_ops_plane.cc +++ b/source/blender/editors/space_clip/tracking_ops_plane.cc @@ -146,7 +146,7 @@ static SlidePlaneMarkerData *slide_plane_marker_customdata(bContext *C, const wm if (plane_track) { MovieTrackingPlaneMarker *plane_marker; - customdata = MEM_cnew("slide plane marker data"); + customdata = MEM_callocN("slide plane marker data"); customdata->launch_event = WM_userdef_event_type_from_keymap_type(event->type); diff --git a/source/blender/editors/space_clip/tracking_ops_solve.cc b/source/blender/editors/space_clip/tracking_ops_solve.cc index f37d2ed8066..82959d9ac92 100644 --- a/source/blender/editors/space_clip/tracking_ops_solve.cc +++ b/source/blender/editors/space_clip/tracking_ops_solve.cc @@ -77,7 +77,7 @@ static bool solve_camera_initjob( width, height); - tracking->stats = MEM_cnew("solve camera stats"); + tracking->stats = MEM_callocN("solve camera stats"); WM_set_locked_interface(scj->wm, true); @@ -180,7 +180,7 @@ static int solve_camera_exec(bContext *C, wmOperator *op) { SolveCameraJob *scj; char error_msg[256] = "\0"; - scj = MEM_cnew("SolveCameraJob data"); + scj = MEM_callocN("SolveCameraJob data"); if (!solve_camera_initjob(C, scj, op, error_msg, sizeof(error_msg))) { if (error_msg[0]) { BKE_report(op->reports, RPT_ERROR, error_msg); @@ -210,7 +210,7 @@ static int solve_camera_invoke(bContext *C, wmOperator *op, const wmEvent * /*ev return OPERATOR_CANCELLED; } - scj = MEM_cnew("SolveCameraJob data"); + scj = MEM_callocN("SolveCameraJob data"); if (!solve_camera_initjob(C, scj, op, error_msg, sizeof(error_msg))) { if (error_msg[0]) { BKE_report(op->reports, RPT_ERROR, error_msg); diff --git a/source/blender/editors/space_clip/tracking_ops_track.cc b/source/blender/editors/space_clip/tracking_ops_track.cc index 82b0a2b0a13..7c447f0f3d6 100644 --- a/source/blender/editors/space_clip/tracking_ops_track.cc +++ b/source/blender/editors/space_clip/tracking_ops_track.cc @@ -306,7 +306,7 @@ static int track_markers(bContext *C, wmOperator *op, bool use_job) return OPERATOR_CANCELLED; } - tmj = MEM_cnew("TrackMarkersJob data"); + tmj = MEM_callocN("TrackMarkersJob data"); if (!track_markers_initjob(C, tmj, backwards, sequence)) { track_markers_freejob(tmj); return OPERATOR_CANCELLED; diff --git a/source/blender/editors/space_file/filelist.cc b/source/blender/editors/space_file/filelist.cc index 14000045641..cf60fbcb730 100644 --- a/source/blender/editors/space_file/filelist.cc +++ b/source/blender/editors/space_file/filelist.cc @@ -1115,7 +1115,7 @@ void filelist_setlibrary(FileList *filelist, const AssetLibraryReference *asset_ } if (!filelist->asset_library_ref) { - filelist->asset_library_ref = MEM_cnew("filelist asset library"); + filelist->asset_library_ref = MEM_callocN("filelist asset library"); *filelist->asset_library_ref = *asset_library_ref; filelist->flags |= FL_FORCE_RESET; @@ -1690,7 +1690,7 @@ static bool filelist_cache_previews_push(FileList *filelist, FileDirEntry *entry filelist_cache_preview_ensure_running(cache); entry->flags |= FILE_ENTRY_PREVIEW_LOADING; - FileListEntryPreview *preview = MEM_cnew(__func__); + FileListEntryPreview *preview = MEM_callocN(__func__); preview->index = index; preview->flags = entry->typeflag; preview->icon_id = 0; @@ -1714,7 +1714,7 @@ static bool filelist_cache_previews_push(FileList *filelist, FileDirEntry *entry } // printf("%s: %d - %s\n", __func__, preview->index, preview->filepath); - FileListEntryPreviewTaskData *preview_taskdata = MEM_cnew( + FileListEntryPreviewTaskData *preview_taskdata = MEM_callocN( __func__); preview_taskdata->preview = preview; BLI_task_pool_push(cache->previews_pool, @@ -1807,7 +1807,7 @@ static void filelist_cache_clear(FileListEntryCache *cache, size_t new_size) FileList *filelist_new(short type) { - FileList *p = MEM_cnew(__func__); + FileList *p = MEM_callocN(__func__); filelist_cache_init(&p->filelist_cache, FILELIST_ENTRYCACHESIZE_DEFAULT); @@ -2139,7 +2139,7 @@ static FileDirEntry *filelist_file_create_entry(FileList *filelist, const int in FileListEntryCache *cache = &filelist->filelist_cache; FileDirEntry *ret; - ret = MEM_cnew(__func__); + ret = MEM_callocN(__func__); ret->size = uint64_t(entry->st.st_size); ret->time = int64_t(entry->st.st_mtime); @@ -3141,7 +3141,7 @@ static int filelist_readjob_list_dir(FileListReadJob *job_params, /* Is this a file that points to another file? */ if (entry->attributes & FILE_ATTR_ALIAS) { - entry->redirection_path = MEM_cnew_array(FILE_MAXDIR, __func__); + entry->redirection_path = MEM_calloc_arrayN(FILE_MAXDIR, __func__); if (BLI_file_alias_target(full_path, entry->redirection_path)) { if (BLI_is_dir(entry->redirection_path)) { entry->typeflag = FILE_TYPE_DIR; @@ -4239,7 +4239,7 @@ void filelist_readjob_start(FileList *filelist, const int space_notifier, const } /* prepare job data */ - flrj = MEM_cnew(__func__); + flrj = MEM_callocN(__func__); flrj->filelist = filelist; flrj->current_main = bmain; STRNCPY(flrj->main_filepath, BKE_main_blendfile_path(bmain)); diff --git a/source/blender/editors/space_file/folder_history.cc b/source/blender/editors/space_file/folder_history.cc index af58470d77b..275311e1eb6 100644 --- a/source/blender/editors/space_file/folder_history.cc +++ b/source/blender/editors/space_file/folder_history.cc @@ -68,7 +68,7 @@ void folderlist_pushdir(ListBase *folderlist, const char *dir) } /* create next folder element */ - folder = MEM_cnew(__func__); + folder = MEM_callocN(__func__); folder->foldername = BLI_strdup(dir); /* add it to the end of the list */ @@ -153,7 +153,7 @@ void folder_history_list_ensure_for_active_browse_mode(SpaceFile *sfile) FileFolderHistory *history = folder_history_find(sfile, (eFileBrowse_Mode)sfile->browse_mode); if (!history) { - history = MEM_cnew(__func__); + history = MEM_callocN(__func__); history->browse_mode = sfile->browse_mode; BLI_addtail(&sfile->folder_histories, history); } diff --git a/source/blender/editors/space_file/fsmenu.cc b/source/blender/editors/space_file/fsmenu.cc index 82ec51e2f3d..cd1d3970913 100644 --- a/source/blender/editors/space_file/fsmenu.cc +++ b/source/blender/editors/space_file/fsmenu.cc @@ -46,7 +46,7 @@ static FSMenu *g_fsmenu = nullptr; FSMenu *ED_fsmenu_get() { if (!g_fsmenu) { - g_fsmenu = MEM_cnew(__func__); + g_fsmenu = MEM_callocN(__func__); } return g_fsmenu; } diff --git a/source/blender/editors/space_image/space_image.cc b/source/blender/editors/space_image/space_image.cc index b008e0a4d3f..4db95765424 100644 --- a/source/blender/editors/space_image/space_image.cc +++ b/source/blender/editors/space_image/space_image.cc @@ -1225,7 +1225,7 @@ void ED_spacetype_image() BLI_addhead(&st->regiontypes, art); /* regions: asset shelf */ - art = MEM_cnew("spacetype image asset shelf region"); + art = MEM_callocN("spacetype image asset shelf region"); art->regionid = RGN_TYPE_ASSET_SHELF; art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_ASSET_SHELF | ED_KEYMAP_FRAMES; art->duplicate = asset::shelf::region_duplicate; @@ -1243,7 +1243,7 @@ void ED_spacetype_image() BLI_addhead(&st->regiontypes, art); /* regions: asset shelf header */ - art = MEM_cnew("spacetype image asset shelf header region"); + art = MEM_callocN("spacetype image asset shelf header region"); art->regionid = RGN_TYPE_ASSET_SHELF_HEADER; art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_ASSET_SHELF | ED_KEYMAP_VIEW2D | ED_KEYMAP_FOOTER; art->init = asset::shelf::header_region_init; diff --git a/source/blender/editors/space_nla/nla_buttons.cc b/source/blender/editors/space_nla/nla_buttons.cc index 6bbf3a97463..30229493af9 100644 --- a/source/blender/editors/space_nla/nla_buttons.cc +++ b/source/blender/editors/space_nla/nla_buttons.cc @@ -660,7 +660,7 @@ void nla_buttons_register(ARegionType *art) { PanelType *pt; - pt = MEM_cnew("spacetype nla panel animdata"); + pt = MEM_callocN("spacetype nla panel animdata"); STRNCPY(pt->idname, "NLA_PT_animdata"); STRNCPY(pt->label, N_("Animation Data")); STRNCPY(pt->category, "Edited Action"); @@ -670,7 +670,7 @@ void nla_buttons_register(ARegionType *art) pt->poll = nla_animdata_panel_poll; BLI_addtail(&art->paneltypes, pt); - pt = MEM_cnew("spacetype nla panel properties"); + pt = MEM_callocN("spacetype nla panel properties"); STRNCPY(pt->idname, "NLA_PT_stripname"); STRNCPY(pt->label, N_("Active Strip Name")); STRNCPY(pt->category, "Strip"); @@ -680,7 +680,7 @@ void nla_buttons_register(ARegionType *art) pt->poll = nla_strip_panel_poll; BLI_addtail(&art->paneltypes, pt); - PanelType *pt_properties = pt = MEM_cnew("spacetype nla panel properties"); + PanelType *pt_properties = pt = MEM_callocN("spacetype nla panel properties"); STRNCPY(pt->idname, "NLA_PT_properties"); STRNCPY(pt->label, N_("Active Strip")); STRNCPY(pt->category, "Strip"); @@ -689,7 +689,7 @@ void nla_buttons_register(ARegionType *art) pt->poll = nla_strip_panel_poll; BLI_addtail(&art->paneltypes, pt); - pt = MEM_cnew("spacetype nla panel properties"); + pt = MEM_callocN("spacetype nla panel properties"); STRNCPY(pt->idname, "NLA_PT_actionclip"); STRNCPY(pt->label, N_("Action Clip")); STRNCPY(pt->category, "Strip"); @@ -699,7 +699,7 @@ void nla_buttons_register(ARegionType *art) pt->poll = nla_strip_actclip_panel_poll; BLI_addtail(&art->paneltypes, pt); - pt = MEM_cnew("spacetype nla panel evaluation"); + pt = MEM_callocN("spacetype nla panel evaluation"); STRNCPY(pt->idname, "NLA_PT_evaluation"); STRNCPY(pt->parent_id, "NLA_PT_properties"); STRNCPY(pt->label, N_("Animated Influence")); @@ -713,7 +713,7 @@ void nla_buttons_register(ARegionType *art) BLI_addtail(&pt_properties->children, BLI_genericNodeN(pt)); BLI_addtail(&art->paneltypes, pt); - pt = MEM_cnew("spacetype nla panel animated strip time"); + pt = MEM_callocN("spacetype nla panel animated strip time"); STRNCPY(pt->idname, "NLA_PT_animated_strip_time"); STRNCPY(pt->parent_id, "NLA_PT_properties"); STRNCPY(pt->label, N_("Animated Strip Time")); @@ -727,7 +727,7 @@ void nla_buttons_register(ARegionType *art) BLI_addtail(&pt_properties->children, BLI_genericNodeN(pt)); BLI_addtail(&art->paneltypes, pt); - pt = MEM_cnew("spacetype nla panel modifiers"); + pt = MEM_callocN("spacetype nla panel modifiers"); STRNCPY(pt->idname, "NLA_PT_modifiers"); STRNCPY(pt->label, N_("Modifiers")); STRNCPY(pt->category, "Modifiers"); diff --git a/source/blender/editors/space_nla/nla_edit.cc b/source/blender/editors/space_nla/nla_edit.cc index 2372b40ed9a..0bc124d7c31 100644 --- a/source/blender/editors/space_nla/nla_edit.cc +++ b/source/blender/editors/space_nla/nla_edit.cc @@ -838,7 +838,7 @@ static int nlaedit_add_transition_exec(bContext *C, wmOperator *op) } /* allocate new strip */ - strip = MEM_cnew("NlaStrip"); + strip = MEM_callocN("NlaStrip"); BLI_insertlinkafter(&nlt->strips, s1, strip); /* set the type */ diff --git a/source/blender/editors/space_nla/space_nla.cc b/source/blender/editors/space_nla/space_nla.cc index bafaa10ceb6..62323b5de0f 100644 --- a/source/blender/editors/space_nla/space_nla.cc +++ b/source/blender/editors/space_nla/space_nla.cc @@ -51,11 +51,11 @@ static SpaceLink *nla_create(const ScrArea *area, const Scene *scene) ARegion *region; SpaceNla *snla; - snla = MEM_cnew("initnla"); + snla = MEM_callocN("initnla"); snla->spacetype = SPACE_NLA; /* allocate DopeSheet data for NLA Editor */ - snla->ads = MEM_cnew("NlaEdit DopeSheet"); + snla->ads = MEM_callocN("NlaEdit DopeSheet"); snla->ads->source = (ID *)(scene); /* set auto-snapping settings */ @@ -134,7 +134,7 @@ static void nla_init(wmWindowManager *wm, ScrArea *area) /* init dopesheet data if non-existent (i.e. for old files) */ if (snla->ads == nullptr) { - snla->ads = MEM_cnew("NlaEdit DopeSheet"); + snla->ads = MEM_callocN("NlaEdit DopeSheet"); wmWindow *win = WM_window_find_by_area(wm, area); snla->ads->source = win ? reinterpret_cast(WM_window_get_active_scene(win)) : nullptr; } @@ -630,7 +630,7 @@ void ED_spacetype_nla() st->blend_write = nla_space_blend_write; /* regions: main window */ - art = MEM_cnew("spacetype nla region"); + art = MEM_callocN("spacetype nla region"); art->regionid = RGN_TYPE_WINDOW; art->init = nla_main_region_init; art->draw = nla_main_region_draw; @@ -642,7 +642,7 @@ void ED_spacetype_nla() BLI_addhead(&st->regiontypes, art); /* regions: header */ - art = MEM_cnew("spacetype nla region"); + art = MEM_callocN("spacetype nla region"); art->regionid = RGN_TYPE_HEADER; art->prefsizey = HEADERY; art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_HEADER; @@ -653,7 +653,7 @@ void ED_spacetype_nla() BLI_addhead(&st->regiontypes, art); /* regions: tracks */ - art = MEM_cnew("spacetype nla region"); + art = MEM_callocN("spacetype nla region"); art->regionid = RGN_TYPE_CHANNELS; art->prefsizex = 200; art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES; @@ -666,7 +666,7 @@ void ED_spacetype_nla() BLI_addhead(&st->regiontypes, art); /* regions: UI buttons */ - art = MEM_cnew("spacetype nla region"); + art = MEM_callocN("spacetype nla region"); art->regionid = RGN_TYPE_UI; art->prefsizex = UI_SIDEBAR_PANEL_WIDTH; art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_FRAMES; diff --git a/source/blender/editors/space_node/node_draw.cc b/source/blender/editors/space_node/node_draw.cc index 6d2db3094e6..f864278f29d 100644 --- a/source/blender/editors/space_node/node_draw.cc +++ b/source/blender/editors/space_node/node_draw.cc @@ -2171,7 +2171,7 @@ void node_socket_add_tooltip(const bNodeTree &ntree, const bNodeSocket &sock, ui const bNodeSocket *socket; }; - SocketTooltipData *data = MEM_cnew(__func__); + SocketTooltipData *data = MEM_callocN(__func__); data->ntree = &ntree; data->socket = &sock; diff --git a/source/blender/editors/space_node/node_edit.cc b/source/blender/editors/space_node/node_edit.cc index 3665011020f..f410eaac9f4 100644 --- a/source/blender/editors/space_node/node_edit.cc +++ b/source/blender/editors/space_node/node_edit.cc @@ -947,7 +947,7 @@ static void node_resize_init( bContext *C, wmOperator *op, const float2 &cursor, const bNode *node, NodeResizeDirection dir) { Scene *scene = CTX_data_scene(C); - NodeSizeWidget *nsw = MEM_cnew(__func__); + NodeSizeWidget *nsw = MEM_callocN(__func__); op->customdata = nsw; @@ -1476,7 +1476,7 @@ static int node_duplicate_exec(bContext *C, wmOperator *op) if (link->tonode && (link->tonode->flag & NODE_SELECT) && (keep_inputs || (link->fromnode && (link->fromnode->flag & NODE_SELECT)))) { - bNodeLink *newlink = MEM_cnew("bNodeLink"); + bNodeLink *newlink = MEM_callocN("bNodeLink"); newlink->flag = link->flag; newlink->tonode = node_map.lookup(link->tonode); newlink->tosock = socket_map.lookup(link->tosock); diff --git a/source/blender/editors/space_node/node_geometry_attribute_search.cc b/source/blender/editors/space_node/node_geometry_attribute_search.cc index c8fd21c2ede..cc71dd3e9a2 100644 --- a/source/blender/editors/space_node/node_geometry_attribute_search.cc +++ b/source/blender/editors/space_node/node_geometry_attribute_search.cc @@ -248,7 +248,7 @@ void node_geometry_add_attribute_search_button(const bContext & /*C*/, UI_but_placeholder_set(but, placeholder.c_str()); const bNodeSocket &socket = *static_cast(socket_ptr.data); - AttributeSearchData *data = MEM_cnew(__func__); + AttributeSearchData *data = MEM_callocN(__func__); data->node_id = node.identifier; STRNCPY(data->socket_identifier, socket.identifier); diff --git a/source/blender/editors/space_node/node_relationships.cc b/source/blender/editors/space_node/node_relationships.cc index 28a69d2fc57..fafd043148d 100644 --- a/source/blender/editors/space_node/node_relationships.cc +++ b/source/blender/editors/space_node/node_relationships.cc @@ -2481,7 +2481,7 @@ void node_insert_on_link_flags(Main &bmain, SpaceNode &snode, bool is_new_node) /* Set up insert offset data, it needs stuff from here. */ if (U.uiflag & USER_NODE_AUTO_OFFSET) { BLI_assert(snode.runtime->iofsd == nullptr); - NodeInsertOfsData *iofsd = MEM_cnew(__func__); + NodeInsertOfsData *iofsd = MEM_callocN(__func__); iofsd->insert = node_to_insert; iofsd->prev = from_node; diff --git a/source/blender/editors/space_node/node_shader_preview.cc b/source/blender/editors/space_node/node_shader_preview.cc index d2933e1ac18..d585b730320 100644 --- a/source/blender/editors/space_node/node_shader_preview.cc +++ b/source/blender/editors/space_node/node_shader_preview.cc @@ -806,7 +806,7 @@ static void ensure_nodetree_previews(const bContext &C, job_data->preview_type = preview_type; /* Update the treepath copied to fit the structure of the nodetree copied. */ - bNodeTreePath *root_path = MEM_cnew(__func__); + bNodeTreePath *root_path = MEM_callocN(__func__); root_path->nodetree = job_data->mat_copy->nodetree; job_data->treepath_copy.append(root_path); for (bNodeTreePath *original_path = static_cast(treepath.first)->next; @@ -820,7 +820,7 @@ static void ensure_nodetree_previews(const bContext &C, * nodetree. In that case, just skip the node. */ continue; } - bNodeTreePath *new_path = MEM_cnew(__func__); + bNodeTreePath *new_path = MEM_callocN(__func__); memcpy(new_path, original_path, sizeof(bNodeTreePath)); new_path->nodetree = reinterpret_cast(parent->id); job_data->treepath_copy.append(new_path); diff --git a/source/blender/editors/space_node/node_templates.cc b/source/blender/editors/space_node/node_templates.cc index 75abb5b1921..2fc87d339de 100644 --- a/source/blender/editors/space_node/node_templates.cc +++ b/source/blender/editors/space_node/node_templates.cc @@ -677,7 +677,7 @@ void uiTemplateNodeLink( uiBut *but; float socket_col[4]; - arg = MEM_cnew("NodeLinkArg"); + arg = MEM_callocN("NodeLinkArg"); arg->ntree = ntree; arg->node = node; arg->sock = input; diff --git a/source/blender/editors/space_node/node_view.cc b/source/blender/editors/space_node/node_view.cc index c12e155ba7d..4a1abd77fbf 100644 --- a/source/blender/editors/space_node/node_view.cc +++ b/source/blender/editors/space_node/node_view.cc @@ -280,7 +280,7 @@ static int snode_bg_viewmove_invoke(bContext *C, wmOperator *op, const wmEvent * return OPERATOR_CANCELLED; } - nvm = MEM_cnew(__func__); + nvm = MEM_callocN(__func__); op->customdata = nvm; nvm->mvalo.x = event->mval[0]; nvm->mvalo.y = event->mval[1]; @@ -661,7 +661,7 @@ static int sample_invoke(bContext *C, wmOperator *op, const wmEvent *event) return OPERATOR_CANCELLED; } - info = MEM_cnew("ImageSampleInfo"); + info = MEM_callocN("ImageSampleInfo"); info->art = region->runtime->type; info->draw_handle = ED_region_draw_cb_activate( region->runtime->type, sample_draw, info, REGION_DRAW_POST_PIXEL); diff --git a/source/blender/editors/space_node/space_node.cc b/source/blender/editors/space_node/space_node.cc index 97700aae1be..f0965e48f03 100644 --- a/source/blender/editors/space_node/space_node.cc +++ b/source/blender/editors/space_node/space_node.cc @@ -76,7 +76,7 @@ void ED_node_tree_start(SpaceNode *snode, bNodeTree *ntree, ID *id, ID *from) BLI_listbase_clear(&snode->treepath); if (ntree) { - bNodeTreePath *path = MEM_cnew("node tree path"); + bNodeTreePath *path = MEM_callocN("node tree path"); path->nodetree = ntree; path->parent_key = blender::bke::NODE_INSTANCE_KEY_BASE; @@ -109,7 +109,7 @@ void ED_node_tree_start(SpaceNode *snode, bNodeTree *ntree, ID *id, ID *from) void ED_node_tree_push(SpaceNode *snode, bNodeTree *ntree, bNode *gnode) { - bNodeTreePath *path = MEM_cnew("node tree path"); + bNodeTreePath *path = MEM_callocN("node tree path"); bNodeTreePath *prev_path = (bNodeTreePath *)snode->treepath.last; path->nodetree = ntree; if (gnode) { @@ -396,7 +396,7 @@ bool push_compute_context_for_tree_path(const SpaceNode &snode, static SpaceLink *node_create(const ScrArea * /*area*/, const Scene * /*scene*/) { - SpaceNode *snode = MEM_cnew(__func__); + SpaceNode *snode = MEM_callocN(__func__); snode->spacetype = SPACE_NODE; snode->flag = SNODE_SHOW_GPENCIL | SNODE_USE_ALPHA; @@ -1444,7 +1444,7 @@ void ED_spacetype_node() st->blend_write = node_space_blend_write; /* regions: main window */ - art = MEM_cnew("spacetype node region"); + art = MEM_callocN("spacetype node region"); art->regionid = RGN_TYPE_WINDOW; art->init = node_main_region_init; art->draw = node_main_region_draw; @@ -1459,7 +1459,7 @@ void ED_spacetype_node() BLI_addhead(&st->regiontypes, art); /* regions: header */ - art = MEM_cnew("spacetype node region"); + art = MEM_callocN("spacetype node region"); art->regionid = RGN_TYPE_HEADER; art->prefsizey = HEADERY; art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_HEADER; @@ -1470,7 +1470,7 @@ void ED_spacetype_node() BLI_addhead(&st->regiontypes, art); /* regions: list-view/buttons */ - art = MEM_cnew("spacetype node region"); + art = MEM_callocN("spacetype node region"); art->regionid = RGN_TYPE_UI; art->prefsizex = UI_SIDEBAR_PANEL_WIDTH; art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_FRAMES; @@ -1481,7 +1481,7 @@ void ED_spacetype_node() BLI_addhead(&st->regiontypes, art); /* regions: toolbar */ - art = MEM_cnew("spacetype view3d tools region"); + art = MEM_callocN("spacetype view3d tools region"); art->regionid = RGN_TYPE_TOOLS; art->prefsizex = int(UI_TOOLBAR_WIDTH); art->prefsizey = 50; /* XXX */ @@ -1493,9 +1493,9 @@ void ED_spacetype_node() art->draw = node_toolbar_region_draw; BLI_addhead(&st->regiontypes, art); - WM_menutype_add(MEM_cnew(__func__, add_catalog_assets_menu_type())); - WM_menutype_add(MEM_cnew(__func__, add_unassigned_assets_menu_type())); - WM_menutype_add(MEM_cnew(__func__, add_root_catalogs_menu_type())); + WM_menutype_add(MEM_dupallocN(__func__, add_catalog_assets_menu_type())); + WM_menutype_add(MEM_dupallocN(__func__, add_unassigned_assets_menu_type())); + WM_menutype_add(MEM_dupallocN(__func__, add_root_catalogs_menu_type())); BKE_spacetype_register(std::move(st)); } diff --git a/source/blender/editors/space_outliner/outliner_dragdrop.cc b/source/blender/editors/space_outliner/outliner_dragdrop.cc index 4d3d0a46199..ee1948c36b1 100644 --- a/source/blender/editors/space_outliner/outliner_dragdrop.cc +++ b/source/blender/editors/space_outliner/outliner_dragdrop.cc @@ -711,7 +711,7 @@ static void datastack_drop_data_init(wmDrag *drag, TreeStoreElem *tselem, void *directdata) { - StackDropData *drop_data = MEM_cnew("datastack drop data"); + StackDropData *drop_data = MEM_callocN("datastack drop data"); drop_data->ob_parent = ob; drop_data->pchan_parent = pchan; diff --git a/source/blender/editors/space_outliner/outliner_edit.cc b/source/blender/editors/space_outliner/outliner_edit.cc index 259302a5fda..9123af194ea 100644 --- a/source/blender/editors/space_outliner/outliner_edit.cc +++ b/source/blender/editors/space_outliner/outliner_edit.cc @@ -274,7 +274,7 @@ static int outliner_item_openclose_invoke(bContext *C, wmOperator *op, const wmE } /* Store last expanded tselem and x coordinate of disclosure triangle */ - OpenCloseData *toggle_data = MEM_cnew("open_close_data"); + OpenCloseData *toggle_data = MEM_callocN("open_close_data"); toggle_data->prev_tselem = tselem; toggle_data->open = open; toggle_data->x_location = te->xs; @@ -1701,7 +1701,7 @@ static void tree_element_to_path(TreeElement *te, /* step 1: flatten out hierarchy of parents into a flat chain */ for (TreeElement *tem = te->parent; tem; tem = tem->parent) { - LinkData *ld = MEM_cnew("LinkData for tree_element_to_path()"); + LinkData *ld = MEM_callocN("LinkData for tree_element_to_path()"); ld->data = tem; BLI_addhead(&hierarchy, ld); } diff --git a/source/blender/editors/space_outliner/outliner_tools.cc b/source/blender/editors/space_outliner/outliner_tools.cc index f1576557073..7e6f45546a7 100644 --- a/source/blender/editors/space_outliner/outliner_tools.cc +++ b/source/blender/editors/space_outliner/outliner_tools.cc @@ -891,7 +891,7 @@ void merged_element_search_menu_invoke(bContext *C, TreeElement *parent_te, TreeElement *activate_te) { - MergedSearchData *select_data = MEM_cnew("merge_search_data"); + MergedSearchData *select_data = MEM_callocN("merge_search_data"); select_data->parent_element = parent_te; select_data->select_element = activate_te; diff --git a/source/blender/editors/space_outliner/space_outliner.cc b/source/blender/editors/space_outliner/space_outliner.cc index 5eed5481e29..fe703c6d451 100644 --- a/source/blender/editors/space_outliner/space_outliner.cc +++ b/source/blender/editors/space_outliner/space_outliner.cc @@ -379,7 +379,7 @@ static SpaceLink *outliner_create(const ScrArea * /*area*/, const Scene * /*scen ARegion *region; SpaceOutliner *space_outliner; - space_outliner = MEM_cnew("initoutliner"); + space_outliner = MEM_callocN("initoutliner"); space_outliner->spacetype = SPACE_OUTLINER; space_outliner->filter_id_type = ID_GR; space_outliner->show_restrict_flags = SO_RESTRICT_ENABLE | SO_RESTRICT_HIDE | SO_RESTRICT_RENDER; @@ -430,7 +430,7 @@ static void outliner_init(wmWindowManager * /*wm*/, ScrArea *area) static SpaceLink *outliner_duplicate(SpaceLink *sl) { SpaceOutliner *space_outliner = (SpaceOutliner *)sl; - SpaceOutliner *space_outliner_new = MEM_cnew(__func__, *space_outliner); + SpaceOutliner *space_outliner_new = MEM_dupallocN(__func__, *space_outliner); BLI_listbase_clear(&space_outliner_new->tree); space_outliner_new->treestore = nullptr; @@ -676,7 +676,7 @@ void ED_spacetype_outliner() st->blend_write = outliner_space_blend_write; /* regions: main window */ - art = MEM_cnew("spacetype outliner region"); + art = MEM_callocN("spacetype outliner region"); art->regionid = RGN_TYPE_WINDOW; art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D; @@ -689,7 +689,7 @@ void ED_spacetype_outliner() BLI_addhead(&st->regiontypes, art); /* regions: header */ - art = MEM_cnew("spacetype outliner header region"); + art = MEM_callocN("spacetype outliner header region"); art->regionid = RGN_TYPE_HEADER; art->prefsizey = HEADERY; art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_HEADER; diff --git a/source/blender/editors/space_sequencer/sequencer_buttons.cc b/source/blender/editors/space_sequencer/sequencer_buttons.cc index 551a9027a23..4121406fbca 100644 --- a/source/blender/editors/space_sequencer/sequencer_buttons.cc +++ b/source/blender/editors/space_sequencer/sequencer_buttons.cc @@ -90,7 +90,7 @@ void sequencer_buttons_register(ARegionType *art) BLI_addtail(&art->paneltypes, pt); #endif - pt = MEM_cnew("spacetype sequencer panel metadata"); + pt = MEM_callocN("spacetype sequencer panel metadata"); STRNCPY(pt->idname, "SEQUENCER_PT_metadata"); STRNCPY(pt->label, N_("Metadata")); STRNCPY(pt->category, "Metadata"); diff --git a/source/blender/editors/space_sequencer/sequencer_clipboard.cc b/source/blender/editors/space_sequencer/sequencer_clipboard.cc index 4844c00a416..7009006edb8 100644 --- a/source/blender/editors/space_sequencer/sequencer_clipboard.cc +++ b/source/blender/editors/space_sequencer/sequencer_clipboard.cc @@ -165,7 +165,7 @@ static bool sequencer_write_copy_paste_file(Main *bmain_src, PartialWriteContext::IDAddOperations::SET_CLIPBOARD_MARK)})); /* Create an empty sequence editor data to store all copied strips. */ - scene_dst->ed = MEM_cnew(__func__); + scene_dst->ed = MEM_callocN(__func__); scene_dst->ed->seqbasep = &scene_dst->ed->seqbase; SEQ_sequence_base_dupli_recursive( scene_src, scene_dst, &scene_dst->ed->seqbase, scene_src->ed->seqbasep, 0, 0); diff --git a/source/blender/editors/space_sequencer/sequencer_edit.cc b/source/blender/editors/space_sequencer/sequencer_edit.cc index c0a0fbb297f..3feeecf273e 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.cc +++ b/source/blender/editors/space_sequencer/sequencer_edit.cc @@ -517,9 +517,9 @@ static int sequencer_slip_invoke(bContext *C, wmOperator *op, const wmEvent *eve return OPERATOR_CANCELLED; } - data = MEM_cnew("trimdata"); + data = MEM_callocN("trimdata"); op->customdata = static_cast(data); - data->strip_array = MEM_cnew_array(num_seq, "trimdata_strips"); + data->strip_array = MEM_calloc_arrayN(num_seq, "trimdata_strips"); data->num_seq = num_seq; data->previous_offset = 0; @@ -603,9 +603,9 @@ static int sequencer_slip_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - SlipData *data = MEM_cnew("trimdata"); + SlipData *data = MEM_callocN("trimdata"); op->customdata = static_cast(data); - data->strip_array = MEM_cnew_array(num_seq, "trimdata_strips"); + data->strip_array = MEM_calloc_arrayN(num_seq, "trimdata_strips"); data->num_seq = num_seq; slip_add_sequences(ed->seqbasep, data->strip_array); @@ -2786,7 +2786,7 @@ static int sequencer_change_path_exec(bContext *C, wmOperator *op) if (strip->data->stripdata) { MEM_freeN(strip->data->stripdata); } - strip->data->stripdata = se = MEM_cnew_array(len, "stripelem"); + strip->data->stripdata = se = MEM_calloc_arrayN(len, "stripelem"); if (use_placeholders) { sequencer_image_seq_reserve_frames(op, se, len, minext_frameme, numdigits); diff --git a/source/blender/editors/space_sequencer/sequencer_preview.cc b/source/blender/editors/space_sequencer/sequencer_preview.cc index e02d5b9a75f..3a35a194970 100644 --- a/source/blender/editors/space_sequencer/sequencer_preview.cc +++ b/source/blender/editors/space_sequencer/sequencer_preview.cc @@ -104,7 +104,7 @@ static void push_preview_job_audio_task(TaskPool *__restrict task_pool, PreviewJobAudio *previewjb, bool *stop) { - ReadSoundWaveformTask *task = MEM_cnew("read sound waveform task"); + ReadSoundWaveformTask *task = MEM_callocN("read sound waveform task"); task->wm_job = pj; task->preview_job_audio = previewjb; task->stop = stop; @@ -208,7 +208,7 @@ void sequencer_preview_add_sound(const bContext *C, const Strip *strip) } } else { /* There's no existing preview job. */ - pj = MEM_cnew("preview rebuild job"); + pj = MEM_callocN("preview rebuild job"); pj->mutex = BLI_mutex_alloc(); BLI_condition_init(&pj->preview_suspend_cond); @@ -221,7 +221,7 @@ void sequencer_preview_add_sound(const bContext *C, const Strip *strip) WM_jobs_callbacks(wm_job, preview_startjob, nullptr, nullptr, preview_endjob); } - PreviewJobAudio *audiojob = MEM_cnew("preview_audio"); + PreviewJobAudio *audiojob = MEM_callocN("preview_audio"); audiojob->bmain = CTX_data_main(C); audiojob->sound = strip->sound; diff --git a/source/blender/editors/space_sequencer/sequencer_select.cc b/source/blender/editors/space_sequencer/sequencer_select.cc index ef39b070d44..3d91a41a2b3 100644 --- a/source/blender/editors/space_sequencer/sequencer_select.cc +++ b/source/blender/editors/space_sequencer/sequencer_select.cc @@ -745,7 +745,7 @@ static Strip *strip_select_seq_from_preview( } if (isect) { - SeqSelect_Link *slink = MEM_cnew(__func__); + SeqSelect_Link *slink = MEM_callocN(__func__); slink->strip = strip; slink->center_dist_sq = center_dist_sq_test; BLI_addtail(&strips_ordered, slink); diff --git a/source/blender/editors/space_sequencer/space_sequencer.cc b/source/blender/editors/space_sequencer/space_sequencer.cc index d8728b1a931..41986276056 100644 --- a/source/blender/editors/space_sequencer/space_sequencer.cc +++ b/source/blender/editors/space_sequencer/space_sequencer.cc @@ -91,7 +91,7 @@ static SpaceLink *sequencer_create(const ScrArea * /*area*/, const Scene *scene) ARegion *region; SpaceSeq *sseq; - sseq = MEM_cnew("initsequencer"); + sseq = MEM_callocN("initsequencer"); sseq->spacetype = SPACE_SEQ; sseq->chanshown = 0; sseq->view = SEQ_VIEW_SEQUENCE; @@ -1189,7 +1189,7 @@ void ED_spacetype_sequencer() /* Create regions: */ /* Main window. */ - art = MEM_cnew("spacetype sequencer region"); + art = MEM_callocN("spacetype sequencer region"); art->regionid = RGN_TYPE_WINDOW; art->poll = sequencer_main_region_poll; art->init = sequencer_main_region_init; @@ -1207,7 +1207,7 @@ void ED_spacetype_sequencer() BLI_addhead(&st->regiontypes, art); /* Preview. */ - art = MEM_cnew("spacetype sequencer region"); + art = MEM_callocN("spacetype sequencer region"); art->regionid = RGN_TYPE_PREVIEW; art->poll = sequencer_preview_region_poll; art->init = sequencer_preview_region_init; @@ -1219,7 +1219,7 @@ void ED_spacetype_sequencer() BLI_addhead(&st->regiontypes, art); /* List-view/buttons. */ - art = MEM_cnew("spacetype sequencer region"); + art = MEM_callocN("spacetype sequencer region"); art->regionid = RGN_TYPE_UI; art->prefsizex = UI_SIDEBAR_PANEL_WIDTH * 1.3f; art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_FRAMES; @@ -1231,7 +1231,7 @@ void ED_spacetype_sequencer() sequencer_buttons_register(art); /* Toolbar. */ - art = MEM_cnew("spacetype sequencer tools region"); + art = MEM_callocN("spacetype sequencer tools region"); art->regionid = RGN_TYPE_TOOLS; art->prefsizex = int(UI_TOOLBAR_WIDTH); art->prefsizey = 50; /* XXX */ @@ -1244,7 +1244,7 @@ void ED_spacetype_sequencer() BLI_addhead(&st->regiontypes, art); /* Channels. */ - art = MEM_cnew("spacetype sequencer channels"); + art = MEM_callocN("spacetype sequencer channels"); art->regionid = RGN_TYPE_CHANNELS; art->prefsizex = UI_COMPACT_PANEL_WIDTH; art->keymapflag = ED_KEYMAP_UI; @@ -1255,7 +1255,7 @@ void ED_spacetype_sequencer() BLI_addhead(&st->regiontypes, art); /* Tool header. */ - art = MEM_cnew("spacetype sequencer tool header region"); + art = MEM_callocN("spacetype sequencer tool header region"); art->regionid = RGN_TYPE_TOOL_HEADER; art->prefsizey = HEADERY; art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_HEADER; @@ -1266,7 +1266,7 @@ void ED_spacetype_sequencer() BLI_addhead(&st->regiontypes, art); /* Header. */ - art = MEM_cnew("spacetype sequencer region"); + art = MEM_callocN("spacetype sequencer region"); art->regionid = RGN_TYPE_HEADER; art->prefsizey = HEADERY; art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_HEADER; diff --git a/source/blender/editors/space_spreadsheet/space_spreadsheet.cc b/source/blender/editors/space_spreadsheet/space_spreadsheet.cc index e3a7b545dea..9a5ff472486 100644 --- a/source/blender/editors/space_spreadsheet/space_spreadsheet.cc +++ b/source/blender/editors/space_spreadsheet/space_spreadsheet.cc @@ -49,7 +49,7 @@ namespace blender::ed::spreadsheet { static SpaceLink *spreadsheet_create(const ScrArea * /*area*/, const Scene * /*scene*/) { - SpaceSpreadsheet *spreadsheet_space = MEM_cnew("spreadsheet space"); + SpaceSpreadsheet *spreadsheet_space = MEM_callocN("spreadsheet space"); spreadsheet_space->spacetype = SPACE_SPREADSHEET; spreadsheet_space->filter_flag = SPREADSHEET_FILTER_ENABLE; @@ -745,7 +745,7 @@ void register_spacetype() st->blend_write = spreadsheet_blend_write; /* regions: main window */ - art = MEM_cnew("spacetype spreadsheet region"); + art = MEM_callocN("spacetype spreadsheet region"); art->regionid = RGN_TYPE_WINDOW; art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES; art->lock = 1; @@ -756,7 +756,7 @@ void register_spacetype() BLI_addhead(&st->regiontypes, art); /* regions: header */ - art = MEM_cnew("spacetype spreadsheet header region"); + art = MEM_callocN("spacetype spreadsheet header region"); art->regionid = RGN_TYPE_HEADER; art->prefsizey = HEADERY; art->keymapflag = 0; @@ -770,7 +770,7 @@ void register_spacetype() BLI_addhead(&st->regiontypes, art); /* regions: footer */ - art = MEM_cnew("spacetype spreadsheet footer region"); + art = MEM_callocN("spacetype spreadsheet footer region"); art->regionid = RGN_TYPE_FOOTER; art->prefsizey = HEADERY; art->keymapflag = 0; @@ -784,7 +784,7 @@ void register_spacetype() BLI_addhead(&st->regiontypes, art); /* regions: right panel buttons */ - art = MEM_cnew("spacetype spreadsheet right region"); + art = MEM_callocN("spacetype spreadsheet right region"); art->regionid = RGN_TYPE_UI; art->prefsizex = UI_SIDEBAR_PANEL_WIDTH; art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_FRAMES; @@ -800,7 +800,7 @@ void register_spacetype() register_row_filter_panels(*art); /* regions: channels */ - art = MEM_cnew("spreadsheet dataset region"); + art = MEM_callocN("spreadsheet dataset region"); art->regionid = RGN_TYPE_TOOLS; art->prefsizex = 150 + V2D_SCROLL_WIDTH; art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_FRAMES; diff --git a/source/blender/editors/space_spreadsheet/spreadsheet_column.cc b/source/blender/editors/space_spreadsheet/spreadsheet_column.cc index 9e0045da3db..6ca4630782c 100644 --- a/source/blender/editors/space_spreadsheet/spreadsheet_column.cc +++ b/source/blender/editors/space_spreadsheet/spreadsheet_column.cc @@ -69,7 +69,7 @@ eSpreadsheetColumnValueType cpp_type_to_column_type(const CPPType &type) SpreadsheetColumnID *spreadsheet_column_id_new() { - SpreadsheetColumnID *column_id = MEM_cnew(__func__); + SpreadsheetColumnID *column_id = MEM_callocN(__func__); return column_id; } @@ -90,7 +90,7 @@ void spreadsheet_column_id_free(SpreadsheetColumnID *column_id) SpreadsheetColumn *spreadsheet_column_new(SpreadsheetColumnID *column_id) { - SpreadsheetColumn *column = MEM_cnew(__func__); + SpreadsheetColumn *column = MEM_callocN(__func__); column->id = column_id; return column; } diff --git a/source/blender/editors/space_spreadsheet/spreadsheet_dataset_draw.cc b/source/blender/editors/space_spreadsheet/spreadsheet_dataset_draw.cc index ca583689c43..544260b4dcf 100644 --- a/source/blender/editors/space_spreadsheet/spreadsheet_dataset_draw.cc +++ b/source/blender/editors/space_spreadsheet/spreadsheet_dataset_draw.cc @@ -637,7 +637,8 @@ void InstancesTreeViewItem::on_activate(bContext &C) SpaceSpreadsheet &sspreadsheet = *CTX_wm_space_spreadsheet(&C); MEM_SAFE_FREE(sspreadsheet.instance_ids); - sspreadsheet.instance_ids = MEM_cnew_array(instance_ids.size(), __func__); + sspreadsheet.instance_ids = MEM_calloc_arrayN(instance_ids.size(), + __func__); sspreadsheet.instance_ids_num = instance_ids.size(); initialized_copy_n(instance_ids.data(), instance_ids.size(), sspreadsheet.instance_ids); diff --git a/source/blender/editors/space_spreadsheet/spreadsheet_layout.cc b/source/blender/editors/space_spreadsheet/spreadsheet_layout.cc index f65f165f189..848bef4f712 100644 --- a/source/blender/editors/space_spreadsheet/spreadsheet_layout.cc +++ b/source/blender/editors/space_spreadsheet/spreadsheet_layout.cc @@ -113,7 +113,7 @@ class SpreadsheetLayoutDrawer : public SpreadsheetDrawer { [](bContext * /*C*/, void *argN, const StringRef /*tip*/) { return fmt::format("{}", *((int *)argN)); }, - MEM_cnew(__func__, value), + MEM_dupallocN(__func__, value), MEM_freeN); /* Right-align Integers. */ UI_but_drawflag_disable(but, UI_BUT_TEXT_LEFT); @@ -170,7 +170,7 @@ class SpreadsheetLayoutDrawer : public SpreadsheetDrawer { [](bContext * /*C*/, void *argN, const StringRef /*tip*/) { return fmt::format("{:f}", *((float *)argN)); }, - MEM_cnew(__func__, value), + MEM_dupallocN(__func__, value), MEM_freeN); /* Right-align Floats. */ UI_but_drawflag_disable(but, UI_BUT_TEXT_LEFT); @@ -251,7 +251,7 @@ class SpreadsheetLayoutDrawer : public SpreadsheetDrawer { std::nullopt); } else if (data.type().is()) { - MStringProperty *prop = MEM_cnew(__func__); + MStringProperty *prop = MEM_callocN(__func__); data.get_to_uninitialized(real_index, prop); uiBut *but = uiDefIconTextBut(params.block, UI_BTYPE_LABEL, @@ -306,7 +306,7 @@ class SpreadsheetLayoutDrawer : public SpreadsheetDrawer { [](bContext * /*C*/, void *argN, const StringRef /*tip*/) { return fmt::format("{:f}", *((float *)argN)); }, - MEM_cnew(__func__, value), + MEM_dupallocN(__func__, value), MEM_freeN); /* Right-align Floats. */ UI_but_drawflag_disable(but, UI_BUT_TEXT_LEFT); @@ -341,7 +341,7 @@ class SpreadsheetLayoutDrawer : public SpreadsheetDrawer { [](bContext * /*C*/, void *argN, const StringRef /*tip*/) { return fmt::format("{}", *((int *)argN)); }, - MEM_cnew(__func__, value), + MEM_dupallocN(__func__, value), MEM_freeN); /* Right-align Floats. */ UI_but_drawflag_disable(but, UI_BUT_TEXT_LEFT); @@ -422,7 +422,7 @@ class SpreadsheetLayoutDrawer : public SpreadsheetDrawer { ss << value[3]; return ss.str(); }, - MEM_cnew(__func__, value), + MEM_dupallocN(__func__, value), MEM_freeN); } diff --git a/source/blender/editors/space_spreadsheet/spreadsheet_panels.cc b/source/blender/editors/space_spreadsheet/spreadsheet_panels.cc index 21d562acfdb..57f64a026be 100644 --- a/source/blender/editors/space_spreadsheet/spreadsheet_panels.cc +++ b/source/blender/editors/space_spreadsheet/spreadsheet_panels.cc @@ -16,7 +16,7 @@ namespace blender::ed::spreadsheet { void spreadsheet_data_set_region_panels_register(ARegionType ®ion_type) { - PanelType *panel_type = MEM_cnew(__func__); + PanelType *panel_type = MEM_callocN(__func__); STRNCPY(panel_type->idname, "SPREADSHEET_PT_data_set"); STRNCPY(panel_type->label, N_("Data Set")); STRNCPY(panel_type->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA); diff --git a/source/blender/editors/space_spreadsheet/spreadsheet_row_filter.cc b/source/blender/editors/space_spreadsheet/spreadsheet_row_filter.cc index 91e979e4476..dc4d2e11de9 100644 --- a/source/blender/editors/space_spreadsheet/spreadsheet_row_filter.cc +++ b/source/blender/editors/space_spreadsheet/spreadsheet_row_filter.cc @@ -428,7 +428,7 @@ IndexMask spreadsheet_filter_rows(const SpaceSpreadsheet &sspreadsheet, SpreadsheetRowFilter *spreadsheet_row_filter_new() { - SpreadsheetRowFilter *row_filter = MEM_cnew(__func__); + SpreadsheetRowFilter *row_filter = MEM_callocN(__func__); row_filter->flag = (SPREADSHEET_ROW_FILTER_UI_EXPAND | SPREADSHEET_ROW_FILTER_ENABLED); row_filter->operation = SPREADSHEET_ROW_FILTER_LESS; row_filter->threshold = 0.01f; diff --git a/source/blender/editors/space_spreadsheet/spreadsheet_row_filter_ui.cc b/source/blender/editors/space_spreadsheet/spreadsheet_row_filter_ui.cc index 87caa28b146..acf39bc79a8 100644 --- a/source/blender/editors/space_spreadsheet/spreadsheet_row_filter_ui.cc +++ b/source/blender/editors/space_spreadsheet/spreadsheet_row_filter_ui.cc @@ -343,7 +343,7 @@ static void set_filter_expand_flag(const bContext * /*C*/, Panel *panel, short e void register_row_filter_panels(ARegionType ®ion_type) { { - PanelType *panel_type = MEM_cnew(__func__); + PanelType *panel_type = MEM_callocN(__func__); STRNCPY(panel_type->idname, "SPREADSHEET_PT_row_filters"); STRNCPY(panel_type->label, N_("Filters")); STRNCPY(panel_type->category, "Filters"); @@ -354,7 +354,7 @@ void register_row_filter_panels(ARegionType ®ion_type) } { - PanelType *panel_type = MEM_cnew(__func__); + PanelType *panel_type = MEM_callocN(__func__); STRNCPY(panel_type->idname, "SPREADSHEET_PT_filter"); STRNCPY(panel_type->label, ""); STRNCPY(panel_type->category, "Filters"); diff --git a/source/blender/editors/space_view3d/space_view3d.cc b/source/blender/editors/space_view3d/space_view3d.cc index 96eadb77f40..4b0283ffb89 100644 --- a/source/blender/editors/space_view3d/space_view3d.cc +++ b/source/blender/editors/space_view3d/space_view3d.cc @@ -259,7 +259,7 @@ static SpaceLink *view3d_create(const ScrArea * /*area*/, const Scene *scene) BLI_addtail(&v3d->regionbase, region); region->regiontype = RGN_TYPE_WINDOW; - region->regiondata = MEM_cnew("region view3d"); + region->regiondata = MEM_callocN("region view3d"); rv3d = static_cast(region->regiondata); rv3d->viewquat[0] = 1.0f; rv3d->persp = RV3D_PERSP; @@ -2173,7 +2173,7 @@ void ED_spacetype_view3d() st->blend_write = view3d_space_blend_write; /* regions: main window */ - art = MEM_cnew("spacetype view3d main region"); + art = MEM_callocN("spacetype view3d main region"); art->regionid = RGN_TYPE_WINDOW; art->keymapflag = ED_KEYMAP_GIZMO | ED_KEYMAP_TOOL | ED_KEYMAP_GPENCIL; art->draw = view3d_main_region_draw; @@ -2188,7 +2188,7 @@ void ED_spacetype_view3d() BLI_addhead(&st->regiontypes, art); /* regions: list-view/buttons */ - art = MEM_cnew("spacetype view3d buttons region"); + art = MEM_callocN("spacetype view3d buttons region"); art->regionid = RGN_TYPE_UI; art->prefsizex = UI_SIDEBAR_PANEL_WIDTH; art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_FRAMES; @@ -2202,7 +2202,7 @@ void ED_spacetype_view3d() view3d_buttons_register(art); /* regions: tool(bar) */ - art = MEM_cnew("spacetype view3d tools region"); + art = MEM_callocN("spacetype view3d tools region"); art->regionid = RGN_TYPE_TOOLS; art->prefsizex = int(UI_TOOLBAR_WIDTH); art->prefsizey = 50; /* XXX */ @@ -2215,7 +2215,7 @@ void ED_spacetype_view3d() BLI_addhead(&st->regiontypes, art); /* regions: tool header */ - art = MEM_cnew("spacetype view3d tool header region"); + art = MEM_callocN("spacetype view3d tool header region"); art->regionid = RGN_TYPE_TOOL_HEADER; art->prefsizey = HEADERY; art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_HEADER; @@ -2226,7 +2226,7 @@ void ED_spacetype_view3d() BLI_addhead(&st->regiontypes, art); /* regions: header */ - art = MEM_cnew("spacetype view3d header region"); + art = MEM_callocN("spacetype view3d header region"); art->regionid = RGN_TYPE_HEADER; art->prefsizey = HEADERY; art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_HEADER; @@ -2237,7 +2237,7 @@ void ED_spacetype_view3d() BLI_addhead(&st->regiontypes, art); /* regions: asset shelf */ - art = MEM_cnew("spacetype view3d asset shelf region"); + art = MEM_callocN("spacetype view3d asset shelf region"); art->regionid = RGN_TYPE_ASSET_SHELF; art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_ASSET_SHELF | ED_KEYMAP_FRAMES; art->duplicate = asset::shelf::region_duplicate; @@ -2255,7 +2255,7 @@ void ED_spacetype_view3d() BLI_addhead(&st->regiontypes, art); /* regions: asset shelf header */ - art = MEM_cnew("spacetype view3d asset shelf header region"); + art = MEM_callocN("spacetype view3d asset shelf header region"); art->regionid = RGN_TYPE_ASSET_SHELF_HEADER; art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_ASSET_SHELF | ED_KEYMAP_VIEW2D | ED_KEYMAP_FOOTER; art->init = asset::shelf::header_region_init; @@ -2271,13 +2271,13 @@ void ED_spacetype_view3d() BLI_addhead(&st->regiontypes, art); /* regions: xr */ - art = MEM_cnew("spacetype view3d xr region"); + art = MEM_callocN("spacetype view3d xr region"); art->regionid = RGN_TYPE_XR; BLI_addhead(&st->regiontypes, art); WM_menutype_add( - MEM_cnew(__func__, blender::ed::geometry::node_group_operator_assets_menu())); - WM_menutype_add(MEM_cnew( + MEM_dupallocN(__func__, blender::ed::geometry::node_group_operator_assets_menu())); + WM_menutype_add(MEM_dupallocN( __func__, blender::ed::geometry::node_group_operator_assets_menu_unassigned())); BKE_spacetype_register(std::move(st)); diff --git a/source/blender/editors/space_view3d/view3d_draw.cc b/source/blender/editors/space_view3d/view3d_draw.cc index d3eaa6ff9bb..554ee193572 100644 --- a/source/blender/editors/space_view3d/view3d_draw.cc +++ b/source/blender/editors/space_view3d/view3d_draw.cc @@ -2423,7 +2423,7 @@ void view3d_depths_rect_create(ARegion *region, rcti *rect, ViewDepths *r_d) /* NOTE: with NOUVEAU drivers the #glReadPixels() is very slow. #24339. */ static ViewDepths *view3d_depths_create(ARegion *region) { - ViewDepths *d = MEM_cnew("ViewDepths"); + ViewDepths *d = MEM_callocN("ViewDepths"); { GPUViewport *viewport = WM_draw_region_get_viewport(region); diff --git a/source/blender/editors/space_view3d/view3d_navigate_fly.cc b/source/blender/editors/space_view3d/view3d_navigate_fly.cc index ff529250944..484ebb19650 100644 --- a/source/blender/editors/space_view3d/view3d_navigate_fly.cc +++ b/source/blender/editors/space_view3d/view3d_navigate_fly.cc @@ -1107,7 +1107,7 @@ static int fly_invoke(bContext *C, wmOperator *op, const wmEvent *event) return OPERATOR_CANCELLED; } - FlyInfo *fly = MEM_cnew("FlyOperation"); + FlyInfo *fly = MEM_callocN("FlyOperation"); op->customdata = fly; diff --git a/source/blender/editors/space_view3d/view3d_navigate_walk.cc b/source/blender/editors/space_view3d/view3d_navigate_walk.cc index fbf7766b002..ea3b5c5f294 100644 --- a/source/blender/editors/space_view3d/view3d_navigate_walk.cc +++ b/source/blender/editors/space_view3d/view3d_navigate_walk.cc @@ -1534,7 +1534,7 @@ static int walk_invoke(bContext *C, wmOperator *op, const wmEvent *event) return OPERATOR_CANCELLED; } - WalkInfo *walk = MEM_cnew("NavigationWalkOperation"); + WalkInfo *walk = MEM_callocN("NavigationWalkOperation"); op->customdata = walk; diff --git a/source/blender/editors/space_view3d/view3d_select.cc b/source/blender/editors/space_view3d/view3d_select.cc index cef127d8fc5..d94bdc2b2fe 100644 --- a/source/blender/editors/space_view3d/view3d_select.cc +++ b/source/blender/editors/space_view3d/view3d_select.cc @@ -236,7 +236,7 @@ static void editselect_buf_cache_init_with_generic_userdata(wmGenericUserData *w const ViewContext *vc, short select_mode) { - EditSelectBuf_Cache *esel = MEM_cnew(__func__); + EditSelectBuf_Cache *esel = MEM_callocN(__func__); wm_userdata->data = esel; wm_userdata->free_fn = editselect_buf_cache_free_voidp; wm_userdata->use_free = true; @@ -1741,7 +1741,7 @@ static bool object_mouse_select_menu(bContext *C, if (ok) { base_count++; - BaseRefWithDepth *base_ref = MEM_cnew(__func__); + BaseRefWithDepth *base_ref = MEM_callocN(__func__); base_ref->base = base; base_ref->depth_id = depth_id; BLI_addtail(&base_ref_list, (void *)base_ref); @@ -1981,7 +1981,7 @@ static bool bone_mouse_select_menu(bContext *C, if (!is_duplicate_bone) { bone_count++; - BoneRefWithDepth *bone_ref = MEM_cnew(__func__); + BoneRefWithDepth *bone_ref = MEM_callocN(__func__); bone_ref->base = bone_base; bone_ref->bone_ptr = bone_ptr; bone_ref->depth_id = hit_result.depth; diff --git a/source/blender/editors/transform/transform_convert_curves.cc b/source/blender/editors/transform/transform_convert_curves.cc index dd6c9d56f13..2095a98acc9 100644 --- a/source/blender/editors/transform/transform_convert_curves.cc +++ b/source/blender/editors/transform/transform_convert_curves.cc @@ -276,7 +276,7 @@ static void createTransCurvesVerts(bContext *C, TransInfo *t) } if (tc.data_len > 0) { - tc.data = MEM_cnew_array(tc.data_len, __func__); + tc.data = MEM_calloc_arrayN(tc.data_len, __func__); curves_transform_data->positions.reinitialize(tc.data_len); } else { diff --git a/source/blender/editors/transform/transform_convert_grease_pencil.cc b/source/blender/editors/transform/transform_convert_grease_pencil.cc index d725b81557c..5cfeeec2668 100644 --- a/source/blender/editors/transform/transform_convert_grease_pencil.cc +++ b/source/blender/editors/transform/transform_convert_grease_pencil.cc @@ -163,7 +163,7 @@ static void createTransGreasePencilVerts(bContext *C, TransInfo *t) } if (tc.data_len > 0) { - tc.data = MEM_cnew_array(tc.data_len, __func__); + tc.data = MEM_calloc_arrayN(tc.data_len, __func__); curves_transform_data->positions.reinitialize(tc.data_len); } else { diff --git a/source/blender/editors/transform/transform_convert_node.cc b/source/blender/editors/transform/transform_convert_node.cc index 28edd053534..d4cde57c3c9 100644 --- a/source/blender/editors/transform/transform_convert_node.cc +++ b/source/blender/editors/transform/transform_convert_node.cc @@ -103,7 +103,7 @@ static void createTransNodeData(bContext * /*C*/, TransInfo *t) } /* Custom data to enable edge panning during the node transform. */ - TransCustomDataNode *customdata = MEM_cnew(__func__); + TransCustomDataNode *customdata = MEM_callocN(__func__); UI_view2d_edge_pan_init(t->context, &customdata->edgepan_data, NODE_EDGE_PAN_INSIDE_PAD, @@ -133,8 +133,8 @@ static void createTransNodeData(bContext * /*C*/, TransInfo *t) } tc->data_len = nodes.size(); - tc->data = MEM_cnew_array(tc->data_len, __func__); - tc->data_2d = MEM_cnew_array(tc->data_len, __func__); + tc->data = MEM_calloc_arrayN(tc->data_len, __func__); + tc->data_2d = MEM_calloc_arrayN(tc->data_len, __func__); for (const int i : nodes.index_range()) { create_transform_data_for_node(tc->data[i], tc->data_2d[i], *nodes[i], UI_SCALE_FAC); diff --git a/source/blender/editors/transform/transform_convert_pointcloud.cc b/source/blender/editors/transform/transform_convert_pointcloud.cc index 71deaaa37af..7724b3ca073 100644 --- a/source/blender/editors/transform/transform_convert_pointcloud.cc +++ b/source/blender/editors/transform/transform_convert_pointcloud.cc @@ -68,7 +68,7 @@ static void createTransPointCloudVerts(bContext * /*C*/, TransInfo *t) continue; } - tc.data = MEM_cnew_array(tc.data_len, __func__); + tc.data = MEM_calloc_arrayN(tc.data_len, __func__); MutableSpan tc_data = MutableSpan(tc.data, tc.data_len); transform_data.positions.reinitialize(tc.data_len); diff --git a/source/blender/editors/transform/transform_convert_sculpt.cc b/source/blender/editors/transform/transform_convert_sculpt.cc index 3c2dba7df89..4c2f365c836 100644 --- a/source/blender/editors/transform/transform_convert_sculpt.cc +++ b/source/blender/editors/transform/transform_convert_sculpt.cc @@ -53,8 +53,8 @@ static void createTransSculpt(bContext *C, TransInfo *t) TransDataContainer *tc = t->data_container; tc->data_len = 1; tc->is_active = true; - td = tc->data = MEM_cnew(__func__); - td->ext = tc->data_ext = MEM_cnew(__func__); + td = tc->data = MEM_callocN(__func__); + td->ext = tc->data_ext = MEM_callocN(__func__); } td->flag = TD_SELECTED; diff --git a/source/blender/editors/transform/transform_convert_sequencer_retiming.cc b/source/blender/editors/transform/transform_convert_sequencer_retiming.cc index cf52805593d..81c33988e49 100644 --- a/source/blender/editors/transform/transform_convert_sequencer_retiming.cc +++ b/source/blender/editors/transform/transform_convert_sequencer_retiming.cc @@ -114,9 +114,9 @@ static void createTransSeqRetimingData(bContext * /*C*/, TransInfo *t) tc->custom.type.free_cb = freeSeqData; tc->data_len = selection.size(); - tc->data = MEM_cnew_array(tc->data_len, "TransSeq TransData"); - tc->data_2d = MEM_cnew_array(tc->data_len, "TransSeq TransData2D"); - TransDataSeq *tdseq = MEM_cnew_array(tc->data_len, "TransSeq TransDataSeq"); + tc->data = MEM_calloc_arrayN(tc->data_len, "TransSeq TransData"); + tc->data_2d = MEM_calloc_arrayN(tc->data_len, "TransSeq TransData2D"); + TransDataSeq *tdseq = MEM_calloc_arrayN(tc->data_len, "TransSeq TransDataSeq"); TransData *td = tc->data; TransData2D *td2d = tc->data_2d; diff --git a/source/blender/editors/transform/transform_gizmo_3d.cc b/source/blender/editors/transform/transform_gizmo_3d.cc index d7421ae2415..e4a0ec18ca2 100644 --- a/source/blender/editors/transform/transform_gizmo_3d.cc +++ b/source/blender/editors/transform/transform_gizmo_3d.cc @@ -1581,7 +1581,7 @@ static void gizmo_3d_setup_draw_modal(wmGizmo *axis, const int axis_idx, const i static GizmoGroup *gizmogroup_init(wmGizmoGroup *gzgroup) { - GizmoGroup *ggd = MEM_cnew(__func__); + GizmoGroup *ggd = MEM_callocN(__func__); const wmGizmoType *gzt_arrow = WM_gizmotype_find("GIZMO_GT_arrow_3d", true); const wmGizmoType *gzt_dial = WM_gizmotype_find("GIZMO_GT_dial_3d", true); diff --git a/source/blender/editors/transform/transform_mode_edge_seq_slide.cc b/source/blender/editors/transform/transform_mode_edge_seq_slide.cc index bc27d0376db..9551fec6c0e 100644 --- a/source/blender/editors/transform/transform_mode_edge_seq_slide.cc +++ b/source/blender/editors/transform/transform_mode_edge_seq_slide.cc @@ -116,7 +116,7 @@ struct SeqSlideParams { static void initSeqSlide(TransInfo *t, wmOperator *op) { - SeqSlideParams *ssp = MEM_cnew(__func__); + SeqSlideParams *ssp = MEM_callocN(__func__); t->custom.mode.data = ssp; t->custom.mode.use_free = true; PropertyRNA *prop = RNA_struct_find_property(op->ptr, "use_restore_handle_selection"); diff --git a/source/blender/editors/transform/transform_snap.cc b/source/blender/editors/transform/transform_snap.cc index 6350b922f25..33beacf9098 100644 --- a/source/blender/editors/transform/transform_snap.cc +++ b/source/blender/editors/transform/transform_snap.cc @@ -1078,7 +1078,7 @@ void addSnapPoint(TransInfo *t) { /* Currently only 3D viewport works for snapping points. */ if (t->tsnap.status & SNAP_TARGET_FOUND && t->spacetype == SPACE_VIEW3D) { - TransSnapPoint *p = MEM_cnew("SnapPoint"); + TransSnapPoint *p = MEM_callocN("SnapPoint"); t->tsnap.selectedPoint = p; diff --git a/source/blender/editors/uvedit/uvedit_buttons.cc b/source/blender/editors/uvedit/uvedit_buttons.cc index ec9f47defcf..a8e0437b606 100644 --- a/source/blender/editors/uvedit/uvedit_buttons.cc +++ b/source/blender/editors/uvedit/uvedit_buttons.cc @@ -247,7 +247,7 @@ static void image_panel_uv(const bContext *C, Panel *panel) void ED_uvedit_buttons_register(ARegionType *art) { - PanelType *pt = MEM_cnew(__func__); + PanelType *pt = MEM_callocN(__func__); STRNCPY(pt->idname, "IMAGE_PT_uv"); STRNCPY(pt->label, N_("UV Vertex")); /* XXX C panels unavailable through RNA bpy.types! */ diff --git a/source/blender/editors/uvedit/uvedit_rip.cc b/source/blender/editors/uvedit/uvedit_rip.cc index cf56f17474b..06cc178a7e3 100644 --- a/source/blender/editors/uvedit/uvedit_rip.cc +++ b/source/blender/editors/uvedit/uvedit_rip.cc @@ -304,7 +304,7 @@ static UVRipSingle *uv_rip_single_from_loop(BMLoop *l_init_orig, const float aspect_y, const int cd_loop_uv_offset) { - UVRipSingle *rip = MEM_cnew(__func__); + UVRipSingle *rip = MEM_callocN(__func__); const float *co_center = BM_ELEM_CD_GET_FLOAT_P(l_init_orig, cd_loop_uv_offset); rip->loops = BLI_gset_ptr_new(__func__); @@ -557,7 +557,7 @@ static UVRipPairs *uv_rip_pairs_from_loop(BMLoop *l_init, const float aspect_y, const int cd_loop_uv_offset) { - UVRipPairs *rip = MEM_cnew(__func__); + UVRipPairs *rip = MEM_callocN(__func__); rip->loops = BLI_gset_ptr_new(__func__); /* We can rely on this stack being small, as we're walking down two sides of an edge loop, diff --git a/source/blender/editors/uvedit/uvedit_smart_stitch.cc b/source/blender/editors/uvedit/uvedit_smart_stitch.cc index 2d168cb8166..42300cc2f6b 100644 --- a/source/blender/editors/uvedit/uvedit_smart_stitch.cc +++ b/source/blender/editors/uvedit/uvedit_smart_stitch.cc @@ -1849,7 +1849,7 @@ static StitchState *stitch_init(bContext *C, BMEditMesh *em = BKE_editmesh_from_object(obedit); const BMUVOffsets offsets = BM_uv_map_get_offsets(em->bm); - state = MEM_cnew("stitch state obj"); + state = MEM_callocN("stitch state obj"); /* initialize state */ state->obedit = obedit; @@ -2205,7 +2205,7 @@ static int stitch_init_all(bContext *C, wmOperator *op) return 0; } - StitchStateContainer *ssc = MEM_cnew("stitch collection"); + StitchStateContainer *ssc = MEM_callocN("stitch collection"); op->customdata = ssc; diff --git a/source/blender/geometry/intern/mesh_triangulate.cc b/source/blender/geometry/intern/mesh_triangulate.cc index 240eb2dba5b..f44ed2aeb21 100644 --- a/source/blender/geometry/intern/mesh_triangulate.cc +++ b/source/blender/geometry/intern/mesh_triangulate.cc @@ -516,7 +516,7 @@ static GroupedSpan build_vert_to_tri_map(const int verts_num, const OffsetIndices offsets(r_offsets.as_span()); r_indices.reinitialize(offsets.total_size()); - int *counts = MEM_cnew_array(size_t(offsets.size()), __func__); + int *counts = MEM_calloc_arrayN(size_t(offsets.size()), __func__); BLI_SCOPED_DEFER([&]() { MEM_freeN(counts); }) threading::parallel_for(vert_tris.index_range(), 1024, [&](const IndexRange range) { for (const int tri : range) { diff --git a/source/blender/geometry/intern/realize_instances.cc b/source/blender/geometry/intern/realize_instances.cc index 37de1823693..527d93972de 100644 --- a/source/blender/geometry/intern/realize_instances.cc +++ b/source/blender/geometry/intern/realize_instances.cc @@ -1544,7 +1544,7 @@ static void copy_vertex_group_names(Mesh &dst_mesh, if (existing_names.contains(src_name)) { continue; } - bDeformGroup *dst = MEM_cnew(__func__); + bDeformGroup *dst = MEM_callocN(__func__); src_name.copy_utf8_truncated(dst->name); BLI_addtail(&dst_mesh.vertex_group_names, dst); } @@ -2180,7 +2180,7 @@ static void execute_realize_grease_pencil_tasks( if (!all_grease_pencils_info.materials.is_empty()) { MEM_SAFE_FREE(dst_grease_pencil->material_array); dst_grease_pencil->material_array_num = all_grease_pencils_info.materials.size(); - dst_grease_pencil->material_array = MEM_cnew_array( + dst_grease_pencil->material_array = MEM_calloc_arrayN( dst_grease_pencil->material_array_num, __func__); uninitialized_copy_n(all_grease_pencils_info.materials.data(), dst_grease_pencil->material_array_num, diff --git a/source/blender/gpu/intern/gpu_framebuffer.cc b/source/blender/gpu/intern/gpu_framebuffer.cc index 1c7c5638f2e..508a36a9094 100644 --- a/source/blender/gpu/intern/gpu_framebuffer.cc +++ b/source/blender/gpu/intern/gpu_framebuffer.cc @@ -732,7 +732,7 @@ GPUOffScreen *GPU_offscreen_create(int width, eGPUTextureUsage usage, char err_out[256]) { - GPUOffScreen *ofs = MEM_cnew(__func__); + GPUOffScreen *ofs = MEM_callocN(__func__); /* Sometimes areas can have 0 height or width and this will * create a 1D texture which we don't want. */ diff --git a/source/blender/gpu/intern/gpu_node_graph.cc b/source/blender/gpu/intern/gpu_node_graph.cc index 004b46c3d43..df70d1f928f 100644 --- a/source/blender/gpu/intern/gpu_node_graph.cc +++ b/source/blender/gpu/intern/gpu_node_graph.cc @@ -30,7 +30,7 @@ static GPUNodeLink *gpu_node_link_create() { - GPUNodeLink *link = MEM_cnew("GPUNodeLink"); + GPUNodeLink *link = MEM_callocN("GPUNodeLink"); link->users++; return link; @@ -56,7 +56,7 @@ static void gpu_node_link_free(GPUNodeLink *link) static GPUNode *gpu_node_create(const char *name) { - GPUNode *node = MEM_cnew("GPUNode"); + GPUNode *node = MEM_callocN("GPUNode"); node->name = name; @@ -105,7 +105,7 @@ static void gpu_node_input_link(GPUNode *node, GPUNodeLink *link, const eGPUType } } - input = MEM_cnew("GPUInput"); + input = MEM_callocN("GPUInput"); input->node = node; input->type = type; @@ -245,7 +245,7 @@ static void gpu_node_input_socket( static void gpu_node_output(GPUNode *node, const eGPUType type, GPUNodeLink **link) { - GPUOutput *output = MEM_cnew("GPUOutput"); + GPUOutput *output = MEM_callocN("GPUOutput"); output->type = type; output->node = node; @@ -401,7 +401,7 @@ static GPUMaterialAttribute *gpu_node_graph_add_attribute(GPUNodeGraph *graph, /* Add new requested attribute if it's within GPU limits. */ if (attr == nullptr) { - attr = MEM_cnew(__func__); + attr = MEM_callocN(__func__); attr->is_default_color = is_default_color; attr->is_hair_length = is_hair_length; attr->type = type; @@ -435,7 +435,7 @@ static GPUUniformAttr *gpu_node_graph_add_uniform_attribute(GPUNodeGraph *graph, /* Add new requested attribute if it's within GPU limits. */ if (attr == nullptr && attrs->count < GPU_MAX_UNIFORM_ATTR) { - attr = MEM_cnew(__func__); + attr = MEM_callocN(__func__); STRNCPY(attr->name, name); attr->use_dupli = use_dupli; attr->hash_code = BLI_ghashutil_strhash_p(attr->name) << 1 | (attr->use_dupli ? 0 : 1); @@ -466,7 +466,7 @@ static GPULayerAttr *gpu_node_graph_add_layer_attribute(GPUNodeGraph *graph, con /* Add new requested attribute to the list. */ if (attr == nullptr) { - attr = MEM_cnew(__func__); + attr = MEM_callocN(__func__); STRNCPY(attr->name, name); attr->hash_code = BLI_ghashutil_strhash_p(attr->name); BLI_addtail(attrs, attr); @@ -501,7 +501,7 @@ static GPUMaterialTexture *gpu_node_graph_add_texture(GPUNodeGraph *graph, /* Add new requested texture. */ if (tex == nullptr) { - tex = MEM_cnew(__func__); + tex = MEM_callocN(__func__); tex->ima = ima; if (iuser != nullptr) { tex->iuser = *iuser; diff --git a/source/blender/ikplugin/intern/itasc_plugin.cc b/source/blender/ikplugin/intern/itasc_plugin.cc index c37f47b0196..adf2494b058 100644 --- a/source/blender/ikplugin/intern/itasc_plugin.cc +++ b/source/blender/ikplugin/intern/itasc_plugin.cc @@ -270,7 +270,7 @@ static int initialize_chain(Object * /*ob*/, bPoseChannel *pchan_tip, bConstrain /* setup the chain data */ /* create a target */ - target = MEM_cnew("posetarget"); + target = MEM_callocN("posetarget"); target->con = con; /* by construction there can be only one tree per channel * and each channel can be part of at most one tree. */ @@ -278,7 +278,7 @@ static int initialize_chain(Object * /*ob*/, bPoseChannel *pchan_tip, bConstrain if (tree == nullptr) { /* make new tree */ - tree = MEM_cnew("posetree"); + tree = MEM_callocN("posetree"); tree->iterations = data->iterations; tree->totchannel = segcount; diff --git a/source/blender/imbuf/intern/allocimbuf.cc b/source/blender/imbuf/intern/allocimbuf.cc index 019140c2b6f..0843f400c9c 100644 --- a/source/blender/imbuf/intern/allocimbuf.cc +++ b/source/blender/imbuf/intern/allocimbuf.cc @@ -573,7 +573,7 @@ ImBuf *IMB_allocFromBuffer( ImBuf *IMB_allocImBuf(uint x, uint y, uchar planes, uint flags) { - ImBuf *ibuf = MEM_cnew("ImBuf_struct"); + ImBuf *ibuf = MEM_callocN("ImBuf_struct"); if (ibuf) { if (!IMB_initImBuf(ibuf, x, y, planes, flags)) { diff --git a/source/blender/imbuf/intern/colormanagement.cc b/source/blender/imbuf/intern/colormanagement.cc index b78e3543cb8..540b8194d11 100644 --- a/source/blender/imbuf/intern/colormanagement.cc +++ b/source/blender/imbuf/intern/colormanagement.cc @@ -268,7 +268,7 @@ static bool colormanage_hashcmp(const void *av, const void *bv) static MovieCache *colormanage_moviecache_ensure(ImBuf *ibuf) { if (!ibuf->colormanage_cache) { - ibuf->colormanage_cache = MEM_cnew("imbuf colormanage cache"); + ibuf->colormanage_cache = MEM_callocN("imbuf colormanage cache"); } if (!ibuf->colormanage_cache->moviecache) { @@ -288,7 +288,7 @@ static MovieCache *colormanage_moviecache_ensure(ImBuf *ibuf) static void colormanage_cachedata_set(ImBuf *ibuf, ColormanageCacheData *data) { if (!ibuf->colormanage_cache) { - ibuf->colormanage_cache = MEM_cnew("imbuf colormanage cache"); + ibuf->colormanage_cache = MEM_callocN("imbuf colormanage cache"); } ibuf->colormanage_cache->data = data; @@ -430,7 +430,7 @@ static void colormanage_cache_put(ImBuf *ibuf, /* Store data which is needed to check whether cached buffer * could be used for color managed display settings. */ - cache_data = MEM_cnew("color manage cache imbuf data"); + cache_data = MEM_callocN("color manage cache imbuf data"); cache_data->look = view_settings->look; cache_data->exposure = view_settings->exposure; cache_data->gamma = view_settings->gamma; @@ -2956,7 +2956,7 @@ ColorManagedDisplay *colormanage_display_add(const char *name) index = last_display->index; } - display = MEM_cnew("ColorManagedDisplay"); + display = MEM_callocN("ColorManagedDisplay"); display->index = index + 1; @@ -3069,7 +3069,7 @@ ColorManagedView *colormanage_view_add(const char *name) ColorManagedView *view; int index = global_tot_view; - view = MEM_cnew("ColorManagedView"); + view = MEM_callocN("ColorManagedView"); view->index = index + 1; STRNCPY(view->name, name); @@ -3209,7 +3209,7 @@ ColorSpace *colormanage_colorspace_add(const char *name, ColorSpace *colorspace, *prev_space; int counter = 1; - colorspace = MEM_cnew("ColorSpace"); + colorspace = MEM_callocN("ColorSpace"); STRNCPY(colorspace->name, name); @@ -3338,7 +3338,7 @@ ColorManagedLook *colormanage_look_add(const char *name, const char *process_spa ColorManagedLook *look; int index = global_tot_looks; - look = MEM_cnew("ColorManagedLook"); + look = MEM_callocN("ColorManagedLook"); look->index = index + 1; STRNCPY(look->name, name); STRNCPY(look->ui_name, name); @@ -3883,7 +3883,7 @@ ColormanageProcessor *IMB_colormanagement_display_processor_new( const ColorManagedViewSettings *applied_view_settings; ColorSpace *display_space; - cm_processor = MEM_cnew("colormanagement processor"); + cm_processor = MEM_callocN("colormanagement processor"); if (view_settings) { applied_view_settings = view_settings; @@ -3923,7 +3923,7 @@ ColormanageProcessor *IMB_colormanagement_colorspace_processor_new(const char *f { ColormanageProcessor *cm_processor; - cm_processor = MEM_cnew("colormanagement processor"); + cm_processor = MEM_callocN("colormanagement processor"); cm_processor->is_data_result = IMB_colormanagement_space_name_is_data(to_colorspace); OCIO_ConstProcessorRcPtr *processor = create_colorspace_transform_processor(from_colorspace, diff --git a/source/blender/imbuf/intern/conversion.cc b/source/blender/imbuf/intern/conversion.cc index cc7ad15696e..b9249276b3b 100644 --- a/source/blender/imbuf/intern/conversion.cc +++ b/source/blender/imbuf/intern/conversion.cc @@ -20,6 +20,7 @@ #include "MEM_guardedalloc.h" /* -------------------------------------------------------------------- */ + /** \name Generic Buffer Conversion * \{ */ diff --git a/source/blender/imbuf/intern/openexr/openexr_api.cpp b/source/blender/imbuf/intern/openexr/openexr_api.cpp index 826b6666e2b..88cf3ac6504 100644 --- a/source/blender/imbuf/intern/openexr/openexr_api.cpp +++ b/source/blender/imbuf/intern/openexr/openexr_api.cpp @@ -738,7 +738,7 @@ static bool imb_exr_multilayer_parse_channels_from_file(ExrHandle *data); void *IMB_exr_get_handle() { - ExrHandle *data = MEM_cnew("exr handle"); + ExrHandle *data = MEM_callocN("exr handle"); data->multiView = new StringVector(); BLI_addtail(&exrhandles, data); @@ -845,7 +845,7 @@ void IMB_exr_add_channel(void *handle, ExrHandle *data = (ExrHandle *)handle; ExrChannel *echan; - echan = MEM_cnew("exr channel"); + echan = MEM_callocN("exr channel"); echan->m = new MultiViewChannelName(); if (layname && layname[0] != '\0') { @@ -1593,7 +1593,7 @@ static ExrLayer *imb_exr_get_layer(ListBase *lb, const char *layname) ExrLayer *lay = (ExrLayer *)BLI_findstring(lb, layname, offsetof(ExrLayer, name)); if (lay == nullptr) { - lay = MEM_cnew("exr layer"); + lay = MEM_callocN("exr layer"); BLI_addtail(lb, lay); BLI_strncpy(lay->name, layname, EXR_LAY_MAXNAME); } @@ -1606,7 +1606,7 @@ static ExrPass *imb_exr_get_pass(ListBase *lb, const char *passname) ExrPass *pass = (ExrPass *)BLI_findstring(lb, passname, offsetof(ExrPass, name)); if (pass == nullptr) { - pass = MEM_cnew("exr pass"); + pass = MEM_callocN("exr pass"); if (STREQ(passname, "Combined")) { BLI_addhead(lb, pass); diff --git a/source/blender/imbuf/movie/intern/movie_proxy_indexer.cc b/source/blender/imbuf/movie/intern/movie_proxy_indexer.cc index 42f7ea0b7e2..c4f633b7d18 100644 --- a/source/blender/imbuf/movie/intern/movie_proxy_indexer.cc +++ b/source/blender/imbuf/movie/intern/movie_proxy_indexer.cc @@ -60,7 +60,7 @@ struct MovieIndexBuilder { static MovieIndexBuilder *index_builder_create(const char *filepath) { - MovieIndexBuilder *rv = MEM_cnew("index builder"); + MovieIndexBuilder *rv = MEM_callocN("index builder"); STRNCPY(rv->filepath, filepath); @@ -372,7 +372,7 @@ static proxy_output_ctx *alloc_proxy_output_ffmpeg(MovieReader *anim, int height, int quality) { - proxy_output_ctx *rv = MEM_cnew("alloc_proxy_output"); + proxy_output_ctx *rv = MEM_callocN("alloc_proxy_output"); char filepath[FILE_MAX]; @@ -705,7 +705,7 @@ static MovieProxyBuilder *index_ffmpeg_create_context(MovieReader *anim, return nullptr; } - MovieProxyBuilder *context = MEM_cnew("FFmpeg index builder context"); + MovieProxyBuilder *context = MEM_callocN("FFmpeg index builder context"); int num_proxy_sizes = IMB_PROXY_MAX_SLOT; int i, streamcount; diff --git a/source/blender/io/alembic/intern/alembic_capi.cc b/source/blender/io/alembic/intern/alembic_capi.cc index 7b04915ff83..b2e8c918e53 100644 --- a/source/blender/io/alembic/intern/alembic_capi.cc +++ b/source/blender/io/alembic/intern/alembic_capi.cc @@ -94,7 +94,7 @@ BLI_INLINE CacheArchiveHandle *handle_from_archive(ArchiveReader *archive) */ static void add_object_path(ListBase *object_paths, const IObject &object) { - CacheObjectPath *abc_path = MEM_cnew("CacheObjectPath"); + CacheObjectPath *abc_path = MEM_callocN("CacheObjectPath"); STRNCPY(abc_path->path, object.getFullName().c_str()); BLI_addtail(object_paths, abc_path); } diff --git a/source/blender/makesdna/DNA_array_utils.hh b/source/blender/makesdna/DNA_array_utils.hh index cf4e303195d..eb3dee48937 100644 --- a/source/blender/makesdna/DNA_array_utils.hh +++ b/source/blender/makesdna/DNA_array_utils.hh @@ -32,7 +32,7 @@ inline void remove_index( const int new_items_num = old_items_num - 1; T *old_items = *items; - T *new_items = MEM_cnew_array(new_items_num, __func__); + T *new_items = MEM_calloc_arrayN(new_items_num, __func__); std::copy_n(old_items, index, new_items); std::copy_n(old_items + index + 1, old_items_num - index - 1, new_items + index); diff --git a/source/blender/makesrna/intern/rna_action.cc b/source/blender/makesrna/intern/rna_action.cc index 58546c4666f..e033d881687 100644 --- a/source/blender/makesrna/intern/rna_action.cc +++ b/source/blender/makesrna/intern/rna_action.cc @@ -784,7 +784,7 @@ static void rna_ActionGroup_channels_begin(CollectionPropertyIterator *iter, Poi { bActionGroup *group = (bActionGroup *)ptr->data; - ActionGroupChannelsIterator *custom_iter = MEM_cnew(__func__); + ActionGroupChannelsIterator *custom_iter = MEM_callocN(__func__); iter->internal.custom = custom_iter; diff --git a/source/blender/makesrna/intern/rna_nodetree.cc b/source/blender/makesrna/intern/rna_nodetree.cc index 1905e85caa2..573172a27b7 100644 --- a/source/blender/makesrna/intern/rna_nodetree.cc +++ b/source/blender/makesrna/intern/rna_nodetree.cc @@ -2126,7 +2126,7 @@ static void geometry_node_asset_trait_flag_set(PointerRNA *ptr, { bNodeTree *ntree = static_cast(ptr->data); if (!ntree->geometry_node_asset_traits) { - ntree->geometry_node_asset_traits = MEM_cnew(__func__); + ntree->geometry_node_asset_traits = MEM_callocN(__func__); } SET_FLAG_FROM_TEST(ntree->geometry_node_asset_traits->flag, value, flag); } diff --git a/source/blender/makesrna/intern/rna_scene.cc b/source/blender/makesrna/intern/rna_scene.cc index f0ea3d322d1..18b936b8dc4 100644 --- a/source/blender/makesrna/intern/rna_scene.cc +++ b/source/blender/makesrna/intern/rna_scene.cc @@ -2309,7 +2309,7 @@ static std::optional rna_View3DCursor_path(const PointerRNA * /*ptr static TimeMarker *rna_TimeLine_add(Scene *scene, const char name[], int frame) { - TimeMarker *marker = MEM_cnew("TimeMarker"); + TimeMarker *marker = MEM_callocN("TimeMarker"); marker->flag = SELECT; marker->frame = frame; STRNCPY_UTF8(marker->name, name); diff --git a/source/blender/makesrna/intern/rna_ui.cc b/source/blender/makesrna/intern/rna_ui.cc index c64d48b34be..e606db165ad 100644 --- a/source/blender/makesrna/intern/rna_ui.cc +++ b/source/blender/makesrna/intern/rna_ui.cc @@ -889,7 +889,7 @@ static StructRNA *rna_Header_register(Main *bmain, } /* create a new header type */ - ht = MEM_cnew(__func__); + ht = MEM_callocN(__func__); memcpy(ht, &dummy_ht, sizeof(dummy_ht)); ht->rna_ext.srna = RNA_def_struct_ptr(&BLENDER_RNA, ht->idname, &RNA_Header); diff --git a/source/blender/modifiers/intern/MOD_correctivesmooth.cc b/source/blender/modifiers/intern/MOD_correctivesmooth.cc index cc9d54d2eb2..e12d40263b8 100644 --- a/source/blender/modifiers/intern/MOD_correctivesmooth.cc +++ b/source/blender/modifiers/intern/MOD_correctivesmooth.cc @@ -167,7 +167,7 @@ static void smooth_iter__simple(CorrectiveSmoothModifierData *csmd, struct SmoothingData_Simple { float delta[3]; }; - SmoothingData_Simple *smooth_data = MEM_cnew_array( + SmoothingData_Simple *smooth_data = MEM_calloc_arrayN( size_t(vertexCos.size()), __func__); float *vertex_edge_count_div = static_cast( @@ -247,7 +247,7 @@ static void smooth_iter__length_weight(CorrectiveSmoothModifierData *csmd, float delta[3]; float edge_length_sum; }; - SmoothingData_Weighted *smooth_data = MEM_cnew_array( + SmoothingData_Weighted *smooth_data = MEM_calloc_arrayN( size_t(vertexCos.size()), __func__); /* calculate as floats to avoid int->float conversion in #smooth_iter */ diff --git a/source/blender/modifiers/intern/MOD_laplaciandeform.cc b/source/blender/modifiers/intern/MOD_laplaciandeform.cc index 322aa71f159..3748ce468f6 100644 --- a/source/blender/modifiers/intern/MOD_laplaciandeform.cc +++ b/source/blender/modifiers/intern/MOD_laplaciandeform.cc @@ -94,7 +94,7 @@ struct LaplacianSystem { static LaplacianSystem *newLaplacianSystem() { - LaplacianSystem *sys = MEM_cnew(__func__); + LaplacianSystem *sys = MEM_callocN(__func__); sys->is_matrix_computed = false; sys->has_solution = false; @@ -161,7 +161,7 @@ static void createFaceRingMap(const int mvert_tot, { int indices_num = 0; int *indices, *index_iter; - MeshElemMap *map = MEM_cnew_array(mvert_tot, __func__); + MeshElemMap *map = MEM_calloc_arrayN(mvert_tot, __func__); for (const int i : corner_tris.index_range()) { const blender::int3 &tri = corner_tris[i]; @@ -171,7 +171,7 @@ static void createFaceRingMap(const int mvert_tot, indices_num++; } } - indices = MEM_cnew_array(indices_num, __func__); + indices = MEM_calloc_arrayN(indices_num, __func__); index_iter = indices; for (int i = 0; i < mvert_tot; i++) { map[i].indices = index_iter; @@ -195,7 +195,7 @@ static void createVertRingMap(const int mvert_tot, MeshElemMap **r_map, int **r_indices) { - MeshElemMap *map = MEM_cnew_array(mvert_tot, __func__); + MeshElemMap *map = MEM_calloc_arrayN(mvert_tot, __func__); int i, vid[2], indices_num = 0; int *indices, *index_iter; @@ -206,7 +206,7 @@ static void createVertRingMap(const int mvert_tot, map[vid[1]].count++; indices_num += 2; } - indices = MEM_cnew_array(indices_num, __func__); + indices = MEM_calloc_arrayN(indices_num, __func__); index_iter = indices; for (i = 0; i < mvert_tot; i++) { map[i].indices = index_iter; diff --git a/source/blender/modifiers/intern/MOD_laplaciansmooth.cc b/source/blender/modifiers/intern/MOD_laplaciansmooth.cc index 72e18916cfe..4090b3989a6 100644 --- a/source/blender/modifiers/intern/MOD_laplaciansmooth.cc +++ b/source/blender/modifiers/intern/MOD_laplaciansmooth.cc @@ -95,14 +95,14 @@ static LaplacianSystem *init_laplacian_system(int a_numEdges, int a_numLoops, in sys = MEM_new(__func__); sys->verts_num = a_numVerts; - sys->eweights = MEM_cnew_array(a_numEdges, __func__); - sys->fweights = MEM_cnew_array(a_numLoops, __func__); - sys->ne_ed_num = MEM_cnew_array(sys->verts_num, __func__); - sys->ne_fa_num = MEM_cnew_array(sys->verts_num, __func__); - sys->ring_areas = MEM_cnew_array(sys->verts_num, __func__); - sys->vlengths = MEM_cnew_array(sys->verts_num, __func__); - sys->vweights = MEM_cnew_array(sys->verts_num, __func__); - sys->zerola = MEM_cnew_array(sys->verts_num, __func__); + sys->eweights = MEM_calloc_arrayN(a_numEdges, __func__); + sys->fweights = MEM_calloc_arrayN(a_numLoops, __func__); + sys->ne_ed_num = MEM_calloc_arrayN(sys->verts_num, __func__); + sys->ne_fa_num = MEM_calloc_arrayN(sys->verts_num, __func__); + sys->ring_areas = MEM_calloc_arrayN(sys->verts_num, __func__); + sys->vlengths = MEM_calloc_arrayN(sys->verts_num, __func__); + sys->vweights = MEM_calloc_arrayN(sys->verts_num, __func__); + sys->zerola = MEM_calloc_arrayN(sys->verts_num, __func__); return sys; } diff --git a/source/blender/modifiers/intern/MOD_nodes.cc b/source/blender/modifiers/intern/MOD_nodes.cc index a9bd8739f9f..a7568024259 100644 --- a/source/blender/modifiers/intern/MOD_nodes.cc +++ b/source/blender/modifiers/intern/MOD_nodes.cc @@ -358,8 +358,8 @@ static void update_bakes_from_node_group(NodesModifierData &nmd) } } - NodesModifierBake *new_bake_data = MEM_cnew_array(new_bake_ids.size(), - __func__); + NodesModifierBake *new_bake_data = MEM_calloc_arrayN(new_bake_ids.size(), + __func__); for (const int i : new_bake_ids.index_range()) { const int id = new_bake_ids[i]; NodesModifierBake *old_bake = old_bake_by_id.lookup_default(id, nullptr); @@ -410,8 +410,8 @@ static void update_panels_from_node_group(NodesModifierData &nmd) }); } - NodesModifierPanel *new_panels = MEM_cnew_array(interface_panels.size(), - __func__); + NodesModifierPanel *new_panels = MEM_calloc_arrayN(interface_panels.size(), + __func__); for (const int i : interface_panels.index_range()) { const bNodeTreeInterfacePanel &interface_panel = *interface_panels[i]; @@ -2038,7 +2038,7 @@ static void add_attribute_search_button(DrawGroupInputsContext &ctx, return; } - AttributeSearchData *data = MEM_cnew(__func__); + AttributeSearchData *data = MEM_callocN(__func__); data->object_session_uid = object->id.session_uid; STRNCPY(data->modifier_name, ctx.nmd.modifier.name); STRNCPY(data->socket_identifier, socket.identifier); diff --git a/source/blender/modifiers/intern/MOD_particleinstance.cc b/source/blender/modifiers/intern/MOD_particleinstance.cc index d772ff57327..802166bb1e3 100644 --- a/source/blender/modifiers/intern/MOD_particleinstance.cc +++ b/source/blender/modifiers/intern/MOD_particleinstance.cc @@ -325,10 +325,10 @@ static Mesh *modify_mesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh int *vert_part_index = nullptr; float *vert_part_value = nullptr; if (mloopcols_index != nullptr) { - vert_part_index = MEM_cnew_array(maxvert, "vertex part index array"); + vert_part_index = MEM_calloc_arrayN(maxvert, "vertex part index array"); } if (mloopcols_value) { - vert_part_value = MEM_cnew_array(maxvert, "vertex part value array"); + vert_part_value = MEM_calloc_arrayN(maxvert, "vertex part value array"); } for (p = part_start, p_skip = 0; p < part_end; p++) { diff --git a/source/blender/modifiers/intern/MOD_remesh.cc b/source/blender/modifiers/intern/MOD_remesh.cc index b23a46e1ad8..eb19f6f9852 100644 --- a/source/blender/modifiers/intern/MOD_remesh.cc +++ b/source/blender/modifiers/intern/MOD_remesh.cc @@ -86,7 +86,7 @@ struct DualConOutput { /* allocate and initialize a DualConOutput */ static void *dualcon_alloc_output(int totvert, int totquad) { - DualConOutput *output = MEM_cnew(__func__); + DualConOutput *output = MEM_callocN(__func__); if (!output) { return nullptr; diff --git a/source/blender/modifiers/intern/MOD_skin.cc b/source/blender/modifiers/intern/MOD_skin.cc index edf18d8bb36..2788d08aee6 100644 --- a/source/blender/modifiers/intern/MOD_skin.cc +++ b/source/blender/modifiers/intern/MOD_skin.cc @@ -461,7 +461,7 @@ static Frame **collect_hull_frames(int v, int hull_frames_num, i; (*tothullframe) = emap[v].size(); - hull_frames = MEM_cnew_array(*tothullframe, __func__); + hull_frames = MEM_calloc_arrayN(*tothullframe, __func__); hull_frames_num = 0; for (i = 0; i < emap[v].size(); i++) { const blender::int2 &edge = edges[emap[v][i]]; @@ -663,7 +663,7 @@ static SkinNode *build_frames(const blender::Span vert_position { int v; - SkinNode *skin_nodes = MEM_cnew_array(verts_num, __func__); + SkinNode *skin_nodes = MEM_calloc_arrayN(verts_num, __func__); for (v = 0; v < verts_num; v++) { if (emap[v].size() <= 1) { @@ -789,7 +789,7 @@ static EMat *build_edge_mats(const MVertSkin *vs, stack = BLI_stack_new(sizeof(stack_elem), "build_edge_mats.stack"); visited_e = BLI_BITMAP_NEW(edges.size(), "build_edge_mats.visited_e"); - emat = MEM_cnew_array(edges.size(), __func__); + emat = MEM_calloc_arrayN(edges.size(), __func__); /* Edge matrices are built from the root nodes, add all roots with * children to the stack */ @@ -950,7 +950,7 @@ static Mesh *subdivide_base(const Mesh *orig) if (origdvert) { const MDeformVert *dv1 = &origdvert[edge[0]]; const MDeformVert *dv2 = &origdvert[edge[1]]; - vgroups = MEM_cnew_array(dv1->totweight, __func__); + vgroups = MEM_calloc_arrayN(dv1->totweight, __func__); /* Only want vertex groups used by both vertices */ for (j = 0; j < dv1->totweight; j++) { diff --git a/source/blender/modifiers/intern/MOD_solidify_extrude.cc b/source/blender/modifiers/intern/MOD_solidify_extrude.cc index ff9d0e84466..6213d0b79bc 100644 --- a/source/blender/modifiers/intern/MOD_solidify_extrude.cc +++ b/source/blender/modifiers/intern/MOD_solidify_extrude.cc @@ -68,7 +68,7 @@ static void mesh_calc_hq_normal(Mesh *mesh, const blender::Span corner_edges = mesh->corner_edges(); { - EdgeFaceRef *edge_ref_array = MEM_cnew_array(size_t(edges.size()), __func__); + EdgeFaceRef *edge_ref_array = MEM_calloc_arrayN(size_t(edges.size()), __func__); EdgeFaceRef *edge_ref; float edge_normal[3]; @@ -169,7 +169,7 @@ Mesh *MOD_solidify_extrude_modifyMesh(ModifierData *md, const ModifierEvalContex uint *new_edge_arr = nullptr; STACK_DECLARE(new_edge_arr); - uint *old_vert_arr = MEM_cnew_array(verts_num, "old_vert_arr in solidify"); + uint *old_vert_arr = MEM_calloc_arrayN(verts_num, "old_vert_arr in solidify"); uint *edge_users = nullptr; int *edge_order = nullptr; diff --git a/source/blender/modifiers/intern/MOD_ui_common.cc b/source/blender/modifiers/intern/MOD_ui_common.cc index 6bcc2f6f193..77ae4319357 100644 --- a/source/blender/modifiers/intern/MOD_ui_common.cc +++ b/source/blender/modifiers/intern/MOD_ui_common.cc @@ -482,7 +482,7 @@ static void modifier_panel_header(const bContext *C, Panel *panel) PanelType *modifier_panel_register(ARegionType *region_type, ModifierType type, PanelDrawFn draw) { - PanelType *panel_type = MEM_cnew(__func__); + PanelType *panel_type = MEM_callocN(__func__); BKE_modifier_type_panel_id(type, panel_type->idname); STRNCPY(panel_type->label, ""); @@ -514,7 +514,7 @@ PanelType *modifier_subpanel_register(ARegionType *region_type, PanelDrawFn draw, PanelType *parent) { - PanelType *panel_type = MEM_cnew(__func__); + PanelType *panel_type = MEM_callocN(__func__); BLI_assert(parent != nullptr); SNPRINTF(panel_type->idname, "%s_%s", parent->idname, name); diff --git a/source/blender/nodes/NOD_socket_items.hh b/source/blender/nodes/NOD_socket_items.hh index b847a696894..a25d685202b 100644 --- a/source/blender/nodes/NOD_socket_items.hh +++ b/source/blender/nodes/NOD_socket_items.hh @@ -78,7 +78,7 @@ template inline void copy_array(const bNode &src_node, bNode SocketItemsRef src_ref = Accessor::get_items_from_node(const_cast(src_node)); SocketItemsRef dst_ref = Accessor::get_items_from_node(dst_node); const int items_num = *src_ref.items_num; - *dst_ref.items = MEM_cnew_array(items_num, __func__); + *dst_ref.items = MEM_calloc_arrayN(items_num, __func__); for (const int i : IndexRange(items_num)) { Accessor::copy_item((*src_ref.items)[i], (*dst_ref.items)[i]); } @@ -141,7 +141,7 @@ template inline typename Accessor::ItemT &add_item_to_array(b const int old_items_num = *array.items_num; const int new_items_num = old_items_num + 1; - ItemT *new_items = MEM_cnew_array(new_items_num, __func__); + ItemT *new_items = MEM_calloc_arrayN(new_items_num, __func__); std::copy_n(old_items, old_items_num, new_items); ItemT &new_item = new_items[old_items_num]; diff --git a/source/blender/nodes/NOD_socket_items_ui.hh b/source/blender/nodes/NOD_socket_items_ui.hh index ad6808b2609..1c305455c14 100644 --- a/source/blender/nodes/NOD_socket_items_ui.hh +++ b/source/blender/nodes/NOD_socket_items_ui.hh @@ -56,7 +56,7 @@ static void draw_items_list_with_operators(const bContext *C, const_cast(&tree.id), &RNA_Node, const_cast(&node)); static const uiListType *items_list = []() { - uiListType *list = MEM_cnew(Accessor::ui_idnames::list); + uiListType *list = MEM_callocN(Accessor::ui_idnames::list); STRNCPY(list->idname, Accessor::ui_idnames::list); list->draw_item = draw_item_in_list; WM_uilisttype_add(list); diff --git a/source/blender/nodes/composite/nodes/node_composite_alpha_over.cc b/source/blender/nodes/composite/nodes/node_composite_alpha_over.cc index 9e15921b540..0ed90c197c6 100644 --- a/source/blender/nodes/composite/nodes/node_composite_alpha_over.cc +++ b/source/blender/nodes/composite/nodes/node_composite_alpha_over.cc @@ -45,7 +45,7 @@ static void cmp_node_alphaover_declare(NodeDeclarationBuilder &b) static void node_alphaover_init(bNodeTree * /*ntree*/, bNode *node) { - node->storage = MEM_cnew(__func__); + node->storage = MEM_callocN(__func__); } static void node_composit_buts_alphaover(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr) diff --git a/source/blender/nodes/composite/nodes/node_composite_antialiasing.cc b/source/blender/nodes/composite/nodes/node_composite_antialiasing.cc index 3d93f712ba8..21c5bb905de 100644 --- a/source/blender/nodes/composite/nodes/node_composite_antialiasing.cc +++ b/source/blender/nodes/composite/nodes/node_composite_antialiasing.cc @@ -30,7 +30,7 @@ static void cmp_node_antialiasing_declare(NodeDeclarationBuilder &b) static void node_composit_init_antialiasing(bNodeTree * /*ntree*/, bNode *node) { - NodeAntiAliasingData *data = MEM_cnew(__func__); + NodeAntiAliasingData *data = MEM_callocN(__func__); data->threshold = CMP_DEFAULT_SMAA_THRESHOLD; data->contrast_limit = CMP_DEFAULT_SMAA_CONTRAST_LIMIT; diff --git a/source/blender/nodes/composite/nodes/node_composite_bilateralblur.cc b/source/blender/nodes/composite/nodes/node_composite_bilateralblur.cc index 15359250f5a..2bea6e6dbb3 100644 --- a/source/blender/nodes/composite/nodes/node_composite_bilateralblur.cc +++ b/source/blender/nodes/composite/nodes/node_composite_bilateralblur.cc @@ -38,7 +38,7 @@ static void cmp_node_bilateralblur_declare(NodeDeclarationBuilder &b) static void node_composit_init_bilateralblur(bNodeTree * /*ntree*/, bNode *node) { - NodeBilateralBlurData *nbbd = MEM_cnew(__func__); + NodeBilateralBlurData *nbbd = MEM_callocN(__func__); node->storage = nbbd; nbbd->iter = 1; nbbd->sigma_color = 0.3; diff --git a/source/blender/nodes/composite/nodes/node_composite_blur.cc b/source/blender/nodes/composite/nodes/node_composite_blur.cc index 5fe9db0840b..ed487127aa4 100644 --- a/source/blender/nodes/composite/nodes/node_composite_blur.cc +++ b/source/blender/nodes/composite/nodes/node_composite_blur.cc @@ -48,7 +48,7 @@ static void cmp_node_blur_declare(NodeDeclarationBuilder &b) static void node_composit_init_blur(bNodeTree * /*ntree*/, bNode *node) { - NodeBlurData *data = MEM_cnew(__func__); + NodeBlurData *data = MEM_callocN(__func__); data->filtertype = R_FILTER_GAUSS; node->storage = data; } diff --git a/source/blender/nodes/composite/nodes/node_composite_bokehimage.cc b/source/blender/nodes/composite/nodes/node_composite_bokehimage.cc index b8b4a6112cf..acb232e36cc 100644 --- a/source/blender/nodes/composite/nodes/node_composite_bokehimage.cc +++ b/source/blender/nodes/composite/nodes/node_composite_bokehimage.cc @@ -29,7 +29,7 @@ static void cmp_node_bokehimage_declare(NodeDeclarationBuilder &b) static void node_composit_init_bokehimage(bNodeTree * /*ntree*/, bNode *node) { - NodeBokehImage *data = MEM_cnew(__func__); + NodeBokehImage *data = MEM_callocN(__func__); data->angle = 0.0f; data->flaps = 5; data->rounding = 0.0f; diff --git a/source/blender/nodes/composite/nodes/node_composite_boxmask.cc b/source/blender/nodes/composite/nodes/node_composite_boxmask.cc index b0274f91a9b..383351b3f1e 100644 --- a/source/blender/nodes/composite/nodes/node_composite_boxmask.cc +++ b/source/blender/nodes/composite/nodes/node_composite_boxmask.cc @@ -46,7 +46,7 @@ static void cmp_node_boxmask_declare(NodeDeclarationBuilder &b) static void node_composit_init_boxmask(bNodeTree * /*ntree*/, bNode *node) { - NodeBoxMask *data = MEM_cnew(__func__); + NodeBoxMask *data = MEM_callocN(__func__); data->x = 0.5; data->y = 0.5; data->width = 0.2; diff --git a/source/blender/nodes/composite/nodes/node_composite_channel_matte.cc b/source/blender/nodes/composite/nodes/node_composite_channel_matte.cc index 7fdbda77f2f..d035a0e9237 100644 --- a/source/blender/nodes/composite/nodes/node_composite_channel_matte.cc +++ b/source/blender/nodes/composite/nodes/node_composite_channel_matte.cc @@ -41,7 +41,7 @@ static void cmp_node_channel_matte_declare(NodeDeclarationBuilder &b) static void node_composit_init_channel_matte(bNodeTree * /*ntree*/, bNode *node) { - NodeChroma *c = MEM_cnew(__func__); + NodeChroma *c = MEM_callocN(__func__); node->storage = c; c->t1 = 1.0f; c->t2 = 0.0f; diff --git a/source/blender/nodes/composite/nodes/node_composite_chroma_matte.cc b/source/blender/nodes/composite/nodes/node_composite_chroma_matte.cc index 09c101541ed..8885a9e7755 100644 --- a/source/blender/nodes/composite/nodes/node_composite_chroma_matte.cc +++ b/source/blender/nodes/composite/nodes/node_composite_chroma_matte.cc @@ -45,7 +45,7 @@ static void cmp_node_chroma_matte_declare(NodeDeclarationBuilder &b) static void node_composit_init_chroma_matte(bNodeTree * /*ntree*/, bNode *node) { - NodeChroma *c = MEM_cnew(__func__); + NodeChroma *c = MEM_callocN(__func__); node->storage = c; c->t1 = DEG2RADF(30.0f); c->t2 = DEG2RADF(10.0f); diff --git a/source/blender/nodes/composite/nodes/node_composite_color_matte.cc b/source/blender/nodes/composite/nodes/node_composite_color_matte.cc index 6ae10e2ec30..b8b0a9e1a65 100644 --- a/source/blender/nodes/composite/nodes/node_composite_color_matte.cc +++ b/source/blender/nodes/composite/nodes/node_composite_color_matte.cc @@ -42,7 +42,7 @@ static void cmp_node_color_matte_declare(NodeDeclarationBuilder &b) static void node_composit_init_color_matte(bNodeTree * /*ntree*/, bNode *node) { - NodeChroma *c = MEM_cnew(__func__); + NodeChroma *c = MEM_callocN(__func__); node->storage = c; c->t1 = 0.01f; c->t2 = 0.1f; diff --git a/source/blender/nodes/composite/nodes/node_composite_color_spill.cc b/source/blender/nodes/composite/nodes/node_composite_color_spill.cc index 7adc7d79764..4ecc7aad436 100644 --- a/source/blender/nodes/composite/nodes/node_composite_color_spill.cc +++ b/source/blender/nodes/composite/nodes/node_composite_color_spill.cc @@ -43,7 +43,7 @@ static void cmp_node_color_spill_declare(NodeDeclarationBuilder &b) static void node_composit_init_color_spill(bNodeTree * /*ntree*/, bNode *node) { - NodeColorspill *ncs = MEM_cnew(__func__); + NodeColorspill *ncs = MEM_callocN(__func__); node->storage = ncs; node->custom2 = CMP_NODE_COLOR_SPILL_LIMIT_ALGORITHM_SINGLE; node->custom1 = 2; /* green channel */ diff --git a/source/blender/nodes/composite/nodes/node_composite_colorbalance.cc b/source/blender/nodes/composite/nodes/node_composite_colorbalance.cc index fb4517b913b..eeb60a142d5 100644 --- a/source/blender/nodes/composite/nodes/node_composite_colorbalance.cc +++ b/source/blender/nodes/composite/nodes/node_composite_colorbalance.cc @@ -80,7 +80,7 @@ static void cmp_node_colorbalance_declare(NodeDeclarationBuilder &b) static void node_composit_init_colorbalance(bNodeTree * /*ntree*/, bNode *node) { - NodeColorBalance *n = MEM_cnew(__func__); + NodeColorBalance *n = MEM_callocN(__func__); n->lift[0] = n->lift[1] = n->lift[2] = 1.0f; n->gamma[0] = n->gamma[1] = n->gamma[2] = 1.0f; diff --git a/source/blender/nodes/composite/nodes/node_composite_colorcorrection.cc b/source/blender/nodes/composite/nodes/node_composite_colorcorrection.cc index eac9ceae9e6..03a7e8471e9 100644 --- a/source/blender/nodes/composite/nodes/node_composite_colorcorrection.cc +++ b/source/blender/nodes/composite/nodes/node_composite_colorcorrection.cc @@ -44,7 +44,7 @@ static void cmp_node_colorcorrection_declare(NodeDeclarationBuilder &b) static void node_composit_init_colorcorrection(bNodeTree * /*ntree*/, bNode *node) { - NodeColorCorrection *n = MEM_cnew(__func__); + NodeColorCorrection *n = MEM_callocN(__func__); n->startmidtones = 0.2f; n->endmidtones = 0.7f; n->master.contrast = 1.0f; diff --git a/source/blender/nodes/composite/nodes/node_composite_crop.cc b/source/blender/nodes/composite/nodes/node_composite_crop.cc index 2fdc8ef95f0..b6ba4ce6fb8 100644 --- a/source/blender/nodes/composite/nodes/node_composite_crop.cc +++ b/source/blender/nodes/composite/nodes/node_composite_crop.cc @@ -40,7 +40,7 @@ static void cmp_node_crop_declare(NodeDeclarationBuilder &b) static void node_composit_init_crop(bNodeTree * /*ntree*/, bNode *node) { - NodeTwoXYs *nxy = MEM_cnew(__func__); + NodeTwoXYs *nxy = MEM_callocN(__func__); node->storage = nxy; nxy->x1 = 0; nxy->x2 = 0; diff --git a/source/blender/nodes/composite/nodes/node_composite_cryptomatte.cc b/source/blender/nodes/composite/nodes/node_composite_cryptomatte.cc index 568a1a37203..8c32f16d217 100644 --- a/source/blender/nodes/composite/nodes/node_composite_cryptomatte.cc +++ b/source/blender/nodes/composite/nodes/node_composite_cryptomatte.cc @@ -132,7 +132,7 @@ static void cryptomatte_add(bNode &node, NodeCryptomatte &node_cryptomatte, floa return; } - CryptomatteEntry *entry = MEM_cnew(__func__); + CryptomatteEntry *entry = MEM_callocN(__func__); entry->encoded_hash = encoded_hash; blender::bke::cryptomatte::CryptomatteSessionPtr session = cryptomatte_init_from_node(node, true); @@ -185,7 +185,7 @@ void ntreeCompositCryptomatteUpdateLayerNames(bNode *node) for (blender::StringRef layer_name : blender::bke::cryptomatte::BKE_cryptomatte_layer_names_get(*session)) { - CryptomatteLayer *layer = MEM_cnew(__func__); + CryptomatteLayer *layer = MEM_callocN(__func__); layer_name.copy_utf8_truncated(layer->name); BLI_addtail(&n->runtime.layers, layer); } @@ -590,7 +590,7 @@ static void cmp_node_cryptomatte_declare(NodeDeclarationBuilder &b) static void node_init_cryptomatte(bNodeTree * /*ntree*/, bNode *node) { - NodeCryptomatte *user = MEM_cnew(__func__); + NodeCryptomatte *user = MEM_callocN(__func__); node->storage = user; } diff --git a/source/blender/nodes/composite/nodes/node_composite_defocus.cc b/source/blender/nodes/composite/nodes/node_composite_defocus.cc index 45e23e8ac2d..d4de15e7f59 100644 --- a/source/blender/nodes/composite/nodes/node_composite_defocus.cc +++ b/source/blender/nodes/composite/nodes/node_composite_defocus.cc @@ -47,7 +47,7 @@ static void cmp_node_defocus_declare(NodeDeclarationBuilder &b) static void node_composit_init_defocus(bNodeTree * /*ntree*/, bNode *node) { /* defocus node */ - NodeDefocus *nbd = MEM_cnew(__func__); + NodeDefocus *nbd = MEM_callocN(__func__); nbd->bktype = 0; nbd->rotation = 0.0f; nbd->preview = 1; diff --git a/source/blender/nodes/composite/nodes/node_composite_denoise.cc b/source/blender/nodes/composite/nodes/node_composite_denoise.cc index 938e69f3dc2..0fc360574ea 100644 --- a/source/blender/nodes/composite/nodes/node_composite_denoise.cc +++ b/source/blender/nodes/composite/nodes/node_composite_denoise.cc @@ -55,7 +55,7 @@ static void cmp_node_denoise_declare(NodeDeclarationBuilder &b) static void node_composit_init_denonise(bNodeTree * /*ntree*/, bNode *node) { - NodeDenoise *ndg = MEM_cnew(__func__); + NodeDenoise *ndg = MEM_callocN(__func__); ndg->hdr = true; ndg->prefilter = CMP_NODE_DENOISE_PREFILTER_ACCURATE; ndg->quality = CMP_NODE_DENOISE_QUALITY_SCENE; diff --git a/source/blender/nodes/composite/nodes/node_composite_diff_matte.cc b/source/blender/nodes/composite/nodes/node_composite_diff_matte.cc index f9c7a209291..175cca621ff 100644 --- a/source/blender/nodes/composite/nodes/node_composite_diff_matte.cc +++ b/source/blender/nodes/composite/nodes/node_composite_diff_matte.cc @@ -41,7 +41,7 @@ static void cmp_node_diff_matte_declare(NodeDeclarationBuilder &b) static void node_composit_init_diff_matte(bNodeTree * /*ntree*/, bNode *node) { - NodeChroma *c = MEM_cnew(__func__); + NodeChroma *c = MEM_callocN(__func__); node->storage = c; c->t1 = 0.1f; c->t2 = 0.1f; diff --git a/source/blender/nodes/composite/nodes/node_composite_dilate.cc b/source/blender/nodes/composite/nodes/node_composite_dilate.cc index 8fbe568ed2e..7f7ca66ffc4 100644 --- a/source/blender/nodes/composite/nodes/node_composite_dilate.cc +++ b/source/blender/nodes/composite/nodes/node_composite_dilate.cc @@ -43,7 +43,7 @@ static void cmp_node_dilate_declare(NodeDeclarationBuilder &b) static void node_composit_init_dilateerode(bNodeTree * /*ntree*/, bNode *node) { - NodeDilateErode *data = MEM_cnew(__func__); + NodeDilateErode *data = MEM_callocN(__func__); data->falloff = PROP_SMOOTH; node->storage = data; } diff --git a/source/blender/nodes/composite/nodes/node_composite_directionalblur.cc b/source/blender/nodes/composite/nodes/node_composite_directionalblur.cc index 12909d8d15f..d13984adf52 100644 --- a/source/blender/nodes/composite/nodes/node_composite_directionalblur.cc +++ b/source/blender/nodes/composite/nodes/node_composite_directionalblur.cc @@ -33,7 +33,7 @@ static void cmp_node_directional_blur_declare(NodeDeclarationBuilder &b) static void node_composit_init_dblur(bNodeTree * /*ntree*/, bNode *node) { - NodeDBlurData *ndbd = MEM_cnew(__func__); + NodeDBlurData *ndbd = MEM_callocN(__func__); node->storage = ndbd; ndbd->iter = 1; ndbd->center_x = 0.5; diff --git a/source/blender/nodes/composite/nodes/node_composite_distance_matte.cc b/source/blender/nodes/composite/nodes/node_composite_distance_matte.cc index 132288f0750..f3ed676b328 100644 --- a/source/blender/nodes/composite/nodes/node_composite_distance_matte.cc +++ b/source/blender/nodes/composite/nodes/node_composite_distance_matte.cc @@ -42,7 +42,7 @@ static void cmp_node_distance_matte_declare(NodeDeclarationBuilder &b) static void node_composit_init_distance_matte(bNodeTree * /*ntree*/, bNode *node) { - NodeChroma *c = MEM_cnew(__func__); + NodeChroma *c = MEM_callocN(__func__); node->storage = c; c->channel = CMP_NODE_DISTANCE_MATTE_COLOR_SPACE_RGBA; c->t1 = 0.1f; diff --git a/source/blender/nodes/composite/nodes/node_composite_ellipsemask.cc b/source/blender/nodes/composite/nodes/node_composite_ellipsemask.cc index d02da497a39..e2f88b6f100 100644 --- a/source/blender/nodes/composite/nodes/node_composite_ellipsemask.cc +++ b/source/blender/nodes/composite/nodes/node_composite_ellipsemask.cc @@ -45,7 +45,7 @@ static void cmp_node_ellipsemask_declare(NodeDeclarationBuilder &b) static void node_composit_init_ellipsemask(bNodeTree * /*ntree*/, bNode *node) { - NodeEllipseMask *data = MEM_cnew(__func__); + NodeEllipseMask *data = MEM_callocN(__func__); data->x = 0.5; data->y = 0.5; data->width = 0.2; diff --git a/source/blender/nodes/composite/nodes/node_composite_file_output.cc b/source/blender/nodes/composite/nodes/node_composite_file_output.cc index 392f7ea2775..d99ccbf6a36 100644 --- a/source/blender/nodes/composite/nodes/node_composite_file_output.cc +++ b/source/blender/nodes/composite/nodes/node_composite_file_output.cc @@ -146,7 +146,7 @@ bNodeSocket *ntreeCompositOutputFileAddSocket(bNodeTree *ntree, *ntree, *node, SOCK_IN, SOCK_RGBA, PROP_NONE, "", name); /* create format data for the input socket */ - NodeImageMultiFileSocket *sockdata = MEM_cnew(__func__); + NodeImageMultiFileSocket *sockdata = MEM_callocN(__func__); sock->storage = sockdata; STRNCPY_UTF8(sockdata->path, name); @@ -220,7 +220,7 @@ static void init_output_file(const bContext *C, PointerRNA *ptr) Scene *scene = CTX_data_scene(C); bNodeTree *ntree = (bNodeTree *)ptr->owner_id; bNode *node = (bNode *)ptr->data; - NodeImageMultiFile *nimf = MEM_cnew(__func__); + NodeImageMultiFile *nimf = MEM_callocN(__func__); nimf->save_as_render = true; ImageFormatData *format = nullptr; node->storage = nimf; diff --git a/source/blender/nodes/composite/nodes/node_composite_glare.cc b/source/blender/nodes/composite/nodes/node_composite_glare.cc index 3d0cc463241..dde5ada303d 100644 --- a/source/blender/nodes/composite/nodes/node_composite_glare.cc +++ b/source/blender/nodes/composite/nodes/node_composite_glare.cc @@ -172,7 +172,7 @@ static void cmp_node_glare_declare(NodeDeclarationBuilder &b) static void node_composit_init_glare(bNodeTree * /*ntree*/, bNode *node) { - NodeGlare *ndg = MEM_cnew(__func__); + NodeGlare *ndg = MEM_callocN(__func__); ndg->quality = 1; ndg->type = CMP_NODE_GLARE_STREAKS; ndg->star_45 = true; diff --git a/source/blender/nodes/composite/nodes/node_composite_image.cc b/source/blender/nodes/composite/nodes/node_composite_image.cc index ab3b796483e..55adfd5e5af 100644 --- a/source/blender/nodes/composite/nodes/node_composite_image.cc +++ b/source/blender/nodes/composite/nodes/node_composite_image.cc @@ -111,7 +111,7 @@ static void cmp_node_image_add_pass_output(bNodeTree *ntree, *ntree, *node, SOCK_OUT, type, PROP_NONE, name, name); } /* extra socket info */ - NodeImageLayer *sockdata = MEM_cnew(__func__); + NodeImageLayer *sockdata = MEM_callocN(__func__); sock->storage = sockdata; } @@ -425,7 +425,7 @@ static void cmp_node_image_update(bNodeTree *ntree, bNode *node) static void node_composit_init_image(bNodeTree *ntree, bNode *node) { - ImageUser *iuser = MEM_cnew(__func__); + ImageUser *iuser = MEM_callocN(__func__); node->storage = iuser; iuser->frames = 1; iuser->sfra = 1; @@ -578,7 +578,7 @@ static void node_composit_init_rlayers(const bContext *C, PointerRNA *ptr) for (bNodeSocket *sock = (bNodeSocket *)node->outputs.first; sock; sock = sock->next, sock_index++) { - NodeImageLayer *sockdata = MEM_cnew(__func__); + NodeImageLayer *sockdata = MEM_callocN(__func__); sock->storage = sockdata; STRNCPY(sockdata->pass_name, node_cmp_rlayers_sock_to_pass(sock_index)); diff --git a/source/blender/nodes/composite/nodes/node_composite_keying.cc b/source/blender/nodes/composite/nodes/node_composite_keying.cc index 09080e2ca1f..0e0d4d6f638 100644 --- a/source/blender/nodes/composite/nodes/node_composite_keying.cc +++ b/source/blender/nodes/composite/nodes/node_composite_keying.cc @@ -47,7 +47,7 @@ static void cmp_node_keying_declare(NodeDeclarationBuilder &b) static void node_composit_init_keying(bNodeTree * /*ntree*/, bNode *node) { - NodeKeyingData *data = MEM_cnew(__func__); + NodeKeyingData *data = MEM_callocN(__func__); data->screen_balance = 0.5f; data->despill_balance = 0.5f; diff --git a/source/blender/nodes/composite/nodes/node_composite_keyingscreen.cc b/source/blender/nodes/composite/nodes/node_composite_keyingscreen.cc index 8af9beaca2a..73fd56b20e5 100644 --- a/source/blender/nodes/composite/nodes/node_composite_keyingscreen.cc +++ b/source/blender/nodes/composite/nodes/node_composite_keyingscreen.cc @@ -45,7 +45,7 @@ static void node_composit_init_keyingscreen(const bContext *C, PointerRNA *ptr) { bNode *node = (bNode *)ptr->data; - NodeKeyingScreenData *data = MEM_cnew(__func__); + NodeKeyingScreenData *data = MEM_callocN(__func__); data->smoothness = 0.0f; node->storage = data; diff --git a/source/blender/nodes/composite/nodes/node_composite_kuwahara.cc b/source/blender/nodes/composite/nodes/node_composite_kuwahara.cc index d6769068997..9e01ce3cdfe 100644 --- a/source/blender/nodes/composite/nodes/node_composite_kuwahara.cc +++ b/source/blender/nodes/composite/nodes/node_composite_kuwahara.cc @@ -44,7 +44,7 @@ static void cmp_node_kuwahara_declare(NodeDeclarationBuilder &b) static void node_composit_init_kuwahara(bNodeTree * /*ntree*/, bNode *node) { - NodeKuwaharaData *data = MEM_cnew(__func__); + NodeKuwaharaData *data = MEM_callocN(__func__); node->storage = data; /* Set defaults. */ diff --git a/source/blender/nodes/composite/nodes/node_composite_lensdist.cc b/source/blender/nodes/composite/nodes/node_composite_lensdist.cc index 20364e123af..a0b86d2d0a7 100644 --- a/source/blender/nodes/composite/nodes/node_composite_lensdist.cc +++ b/source/blender/nodes/composite/nodes/node_composite_lensdist.cc @@ -58,7 +58,7 @@ static void cmp_node_lensdist_declare(NodeDeclarationBuilder &b) static void node_composit_init_lensdist(bNodeTree * /*ntree*/, bNode *node) { - NodeLensDist *nld = MEM_cnew(__func__); + NodeLensDist *nld = MEM_callocN(__func__); nld->jit = nld->proj = nld->fit = 0; node->storage = nld; } diff --git a/source/blender/nodes/composite/nodes/node_composite_luma_matte.cc b/source/blender/nodes/composite/nodes/node_composite_luma_matte.cc index 7765a2a1b3d..c04b3b3d4d9 100644 --- a/source/blender/nodes/composite/nodes/node_composite_luma_matte.cc +++ b/source/blender/nodes/composite/nodes/node_composite_luma_matte.cc @@ -40,7 +40,7 @@ static void cmp_node_luma_matte_declare(NodeDeclarationBuilder &b) static void node_composit_init_luma_matte(bNodeTree * /*ntree*/, bNode *node) { - NodeChroma *c = MEM_cnew(__func__); + NodeChroma *c = MEM_callocN(__func__); node->storage = c; c->t1 = 1.0f; c->t2 = 0.0f; diff --git a/source/blender/nodes/composite/nodes/node_composite_mask.cc b/source/blender/nodes/composite/nodes/node_composite_mask.cc index dd7aa775a6f..a83591cf6e8 100644 --- a/source/blender/nodes/composite/nodes/node_composite_mask.cc +++ b/source/blender/nodes/composite/nodes/node_composite_mask.cc @@ -31,7 +31,7 @@ static void cmp_node_mask_declare(NodeDeclarationBuilder &b) static void node_composit_init_mask(bNodeTree * /*ntree*/, bNode *node) { - NodeMask *data = MEM_cnew(__func__); + NodeMask *data = MEM_callocN(__func__); data->size_x = data->size_y = 256; node->storage = data; diff --git a/source/blender/nodes/composite/nodes/node_composite_planetrackdeform.cc b/source/blender/nodes/composite/nodes/node_composite_planetrackdeform.cc index 77de89a03d4..18baaeb2fbf 100644 --- a/source/blender/nodes/composite/nodes/node_composite_planetrackdeform.cc +++ b/source/blender/nodes/composite/nodes/node_composite_planetrackdeform.cc @@ -52,7 +52,7 @@ static void init(const bContext *C, PointerRNA *ptr) { bNode *node = (bNode *)ptr->data; - NodePlaneTrackDeformData *data = MEM_cnew(__func__); + NodePlaneTrackDeformData *data = MEM_callocN(__func__); data->motion_blur_samples = 16; data->motion_blur_shutter = 0.5f; node->storage = data; diff --git a/source/blender/nodes/composite/nodes/node_composite_sepcomb_color.cc b/source/blender/nodes/composite/nodes/node_composite_sepcomb_color.cc index b4ade27d0c0..8824c2fce8a 100644 --- a/source/blender/nodes/composite/nodes/node_composite_sepcomb_color.cc +++ b/source/blender/nodes/composite/nodes/node_composite_sepcomb_color.cc @@ -16,7 +16,7 @@ static void node_cmp_combsep_color_init(bNodeTree * /*ntree*/, bNode *node) { - NodeCMPCombSepColor *data = MEM_cnew(__func__); + NodeCMPCombSepColor *data = MEM_callocN(__func__); data->mode = CMP_NODE_COMBSEP_COLOR_RGB; data->ycc_mode = BLI_YCC_ITU_BT709; node->storage = data; diff --git a/source/blender/nodes/composite/nodes/node_composite_setalpha.cc b/source/blender/nodes/composite/nodes/node_composite_setalpha.cc index cea1e975c87..7f9d2f16681 100644 --- a/source/blender/nodes/composite/nodes/node_composite_setalpha.cc +++ b/source/blender/nodes/composite/nodes/node_composite_setalpha.cc @@ -40,7 +40,7 @@ static void cmp_node_setalpha_declare(NodeDeclarationBuilder &b) static void node_composit_init_setalpha(bNodeTree * /*ntree*/, bNode *node) { - NodeSetAlpha *settings = MEM_cnew(__func__); + NodeSetAlpha *settings = MEM_callocN(__func__); node->storage = settings; settings->mode = CMP_NODE_SETALPHA_MODE_APPLY; } diff --git a/source/blender/nodes/composite/nodes/node_composite_sunbeams.cc b/source/blender/nodes/composite/nodes/node_composite_sunbeams.cc index 7532549c0aa..9bc2a31613f 100644 --- a/source/blender/nodes/composite/nodes/node_composite_sunbeams.cc +++ b/source/blender/nodes/composite/nodes/node_composite_sunbeams.cc @@ -34,7 +34,7 @@ static void cmp_node_sunbeams_declare(NodeDeclarationBuilder &b) static void init(bNodeTree * /*ntree*/, bNode *node) { - NodeSunBeams *data = MEM_cnew(__func__); + NodeSunBeams *data = MEM_callocN(__func__); data->source[0] = 0.5f; data->source[1] = 0.5f; diff --git a/source/blender/nodes/composite/nodes/node_composite_tonemap.cc b/source/blender/nodes/composite/nodes/node_composite_tonemap.cc index b1d4f983245..32e3c086871 100644 --- a/source/blender/nodes/composite/nodes/node_composite_tonemap.cc +++ b/source/blender/nodes/composite/nodes/node_composite_tonemap.cc @@ -40,7 +40,7 @@ static void cmp_node_tonemap_declare(NodeDeclarationBuilder &b) static void node_composit_init_tonemap(bNodeTree * /*ntree*/, bNode *node) { - NodeTonemap *ntm = MEM_cnew(__func__); + NodeTonemap *ntm = MEM_callocN(__func__); ntm->type = 1; ntm->key = 0.18; ntm->offset = 1; diff --git a/source/blender/nodes/composite/nodes/node_composite_trackpos.cc b/source/blender/nodes/composite/nodes/node_composite_trackpos.cc index 2de219a6e1f..31db4f98dab 100644 --- a/source/blender/nodes/composite/nodes/node_composite_trackpos.cc +++ b/source/blender/nodes/composite/nodes/node_composite_trackpos.cc @@ -44,7 +44,7 @@ static void init(const bContext *C, PointerRNA *ptr) { bNode *node = (bNode *)ptr->data; - NodeTrackPosData *data = MEM_cnew(__func__); + NodeTrackPosData *data = MEM_callocN(__func__); node->storage = data; const Scene *scene = CTX_data_scene(C); diff --git a/source/blender/nodes/composite/nodes/node_composite_translate.cc b/source/blender/nodes/composite/nodes/node_composite_translate.cc index ee600cf4e59..8c2d616a36c 100644 --- a/source/blender/nodes/composite/nodes/node_composite_translate.cc +++ b/source/blender/nodes/composite/nodes/node_composite_translate.cc @@ -44,7 +44,7 @@ static void cmp_node_translate_declare(NodeDeclarationBuilder &b) static void node_composit_init_translate(bNodeTree * /*ntree*/, bNode *node) { - NodeTranslateData *data = MEM_cnew(__func__); + NodeTranslateData *data = MEM_callocN(__func__); node->storage = data; } diff --git a/source/blender/nodes/composite/nodes/node_composite_vec_blur.cc b/source/blender/nodes/composite/nodes/node_composite_vec_blur.cc index 595af481d88..ccb1d1baf98 100644 --- a/source/blender/nodes/composite/nodes/node_composite_vec_blur.cc +++ b/source/blender/nodes/composite/nodes/node_composite_vec_blur.cc @@ -53,7 +53,7 @@ static void cmp_node_vec_blur_declare(NodeDeclarationBuilder &b) /* custom1: iterations, custom2: max_speed (0 = no_limit). */ static void node_composit_init_vecblur(bNodeTree * /*ntree*/, bNode *node) { - NodeBlurData *nbd = MEM_cnew(__func__); + NodeBlurData *nbd = MEM_callocN(__func__); node->storage = nbd; nbd->samples = 32; nbd->fac = 0.25f; diff --git a/source/blender/nodes/composite/nodes/node_composite_viewer.cc b/source/blender/nodes/composite/nodes/node_composite_viewer.cc index 608a187dc56..0c22b8c1032 100644 --- a/source/blender/nodes/composite/nodes/node_composite_viewer.cc +++ b/source/blender/nodes/composite/nodes/node_composite_viewer.cc @@ -37,7 +37,7 @@ static void cmp_node_viewer_declare(NodeDeclarationBuilder &b) static void node_composit_init_viewer(bNodeTree * /*ntree*/, bNode *node) { - ImageUser *iuser = MEM_cnew(__func__); + ImageUser *iuser = MEM_callocN(__func__); node->storage = iuser; iuser->sfra = 1; node->custom1 = NODE_VIEWER_SHORTCUT_NONE; diff --git a/source/blender/nodes/function/nodes/node_fn_combine_color.cc b/source/blender/nodes/function/nodes/node_fn_combine_color.cc index fc7dbfb1247..79a46987bb2 100644 --- a/source/blender/nodes/function/nodes/node_fn_combine_color.cc +++ b/source/blender/nodes/function/nodes/node_fn_combine_color.cc @@ -38,7 +38,7 @@ static void node_update(bNodeTree * /*tree*/, bNode *node) static void node_init(bNodeTree * /*tree*/, bNode *node) { - NodeCombSepColor *data = MEM_cnew(__func__); + NodeCombSepColor *data = MEM_callocN(__func__); data->mode = NODE_COMBSEP_COLOR_RGB; node->storage = data; } diff --git a/source/blender/nodes/function/nodes/node_fn_compare.cc b/source/blender/nodes/function/nodes/node_fn_compare.cc index b40d9e35a65..fb1a2c3a400 100644 --- a/source/blender/nodes/function/nodes/node_fn_compare.cc +++ b/source/blender/nodes/function/nodes/node_fn_compare.cc @@ -99,7 +99,7 @@ static void node_update(bNodeTree *ntree, bNode *node) static void node_init(bNodeTree * /*tree*/, bNode *node) { - NodeFunctionCompare *data = MEM_cnew(__func__); + NodeFunctionCompare *data = MEM_callocN(__func__); data->operation = NODE_COMPARE_GREATER_THAN; data->data_type = SOCK_FLOAT; data->mode = NODE_COMPARE_MODE_ELEMENT; diff --git a/source/blender/nodes/function/nodes/node_fn_input_bool.cc b/source/blender/nodes/function/nodes/node_fn_input_bool.cc index daccbe4caa0..0ebefaed84f 100644 --- a/source/blender/nodes/function/nodes/node_fn_input_bool.cc +++ b/source/blender/nodes/function/nodes/node_fn_input_bool.cc @@ -29,7 +29,7 @@ static void node_build_multi_function(NodeMultiFunctionBuilder &builder) static void node_init(bNodeTree * /*tree*/, bNode *node) { - NodeInputBool *data = MEM_cnew(__func__); + NodeInputBool *data = MEM_callocN(__func__); node->storage = data; } diff --git a/source/blender/nodes/function/nodes/node_fn_input_color.cc b/source/blender/nodes/function/nodes/node_fn_input_color.cc index bb7e428d3c5..2d10db68894 100644 --- a/source/blender/nodes/function/nodes/node_fn_input_color.cc +++ b/source/blender/nodes/function/nodes/node_fn_input_color.cc @@ -32,7 +32,7 @@ static void node_build_multi_function(blender::nodes::NodeMultiFunctionBuilder & static void node_init(bNodeTree * /*tree*/, bNode *node) { - NodeInputColor *data = MEM_cnew(__func__); + NodeInputColor *data = MEM_callocN(__func__); copy_v4_fl4(data->color, 0.5f, 0.5f, 0.5f, 1.0f); node->storage = data; } diff --git a/source/blender/nodes/function/nodes/node_fn_input_int.cc b/source/blender/nodes/function/nodes/node_fn_input_int.cc index 147969897c5..f185fa219b8 100644 --- a/source/blender/nodes/function/nodes/node_fn_input_int.cc +++ b/source/blender/nodes/function/nodes/node_fn_input_int.cc @@ -29,7 +29,7 @@ static void node_build_multi_function(NodeMultiFunctionBuilder &builder) static void node_init(bNodeTree * /*tree*/, bNode *node) { - NodeInputInt *data = MEM_cnew(__func__); + NodeInputInt *data = MEM_callocN(__func__); node->storage = data; } diff --git a/source/blender/nodes/function/nodes/node_fn_input_rotation.cc b/source/blender/nodes/function/nodes/node_fn_input_rotation.cc index d333245b520..108e03b564d 100644 --- a/source/blender/nodes/function/nodes/node_fn_input_rotation.cc +++ b/source/blender/nodes/function/nodes/node_fn_input_rotation.cc @@ -37,7 +37,7 @@ static void node_build_multi_function(NodeMultiFunctionBuilder &builder) static void node_init(bNodeTree * /*tree*/, bNode *node) { - NodeInputRotation *data = MEM_cnew(__func__); + NodeInputRotation *data = MEM_callocN(__func__); node->storage = data; } diff --git a/source/blender/nodes/function/nodes/node_fn_input_vector.cc b/source/blender/nodes/function/nodes/node_fn_input_vector.cc index a2eec27ca2e..483578e65c8 100644 --- a/source/blender/nodes/function/nodes/node_fn_input_vector.cc +++ b/source/blender/nodes/function/nodes/node_fn_input_vector.cc @@ -30,7 +30,7 @@ static void node_build_multi_function(NodeMultiFunctionBuilder &builder) static void node_init(bNodeTree * /*tree*/, bNode *node) { - NodeInputVector *data = MEM_cnew(__func__); + NodeInputVector *data = MEM_callocN(__func__); node->storage = data; } diff --git a/source/blender/nodes/function/nodes/node_fn_random_value.cc b/source/blender/nodes/function/nodes/node_fn_random_value.cc index e8bb8564a3c..666359cd89a 100644 --- a/source/blender/nodes/function/nodes/node_fn_random_value.cc +++ b/source/blender/nodes/function/nodes/node_fn_random_value.cc @@ -51,7 +51,7 @@ static void node_layout(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr) static void fn_node_random_value_init(bNodeTree * /*tree*/, bNode *node) { - NodeRandomValue *data = MEM_cnew(__func__); + NodeRandomValue *data = MEM_callocN(__func__); data->data_type = CD_PROP_FLOAT; node->storage = data; } diff --git a/source/blender/nodes/function/nodes/node_fn_separate_color.cc b/source/blender/nodes/function/nodes/node_fn_separate_color.cc index 4a9a3b00a53..aabe3b9245c 100644 --- a/source/blender/nodes/function/nodes/node_fn_separate_color.cc +++ b/source/blender/nodes/function/nodes/node_fn_separate_color.cc @@ -38,7 +38,7 @@ static void node_update(bNodeTree * /*tree*/, bNode *node) static void node_init(bNodeTree * /*tree*/, bNode *node) { - NodeCombSepColor *data = MEM_cnew(__func__); + NodeCombSepColor *data = MEM_callocN(__func__); data->mode = NODE_COMBSEP_COLOR_RGB; node->storage = data; } diff --git a/source/blender/nodes/geometry/nodes/node_geo_accumulate_field.cc b/source/blender/nodes/geometry/nodes/node_geo_accumulate_field.cc index 424a285ac0c..6d5a7a7770d 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_accumulate_field.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_accumulate_field.cc @@ -76,7 +76,7 @@ static void node_layout(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr) static void node_init(bNodeTree * /*tree*/, bNode *node) { - NodeAccumulateField *data = MEM_cnew(__func__); + NodeAccumulateField *data = MEM_callocN(__func__); data->data_type = CD_PROP_FLOAT; data->domain = int16_t(AttrDomain::Point); node->storage = data; diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_capture.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_capture.cc index bd3194ef1d1..3fc64fae46b 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_attribute_capture.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_capture.cc @@ -63,7 +63,7 @@ static void node_layout(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr) static void node_init(bNodeTree * /*tree*/, bNode *node) { - NodeGeometryAttributeCapture *data = MEM_cnew(__func__); + NodeGeometryAttributeCapture *data = MEM_callocN(__func__); data->domain = int8_t(AttrDomain::Point); node->storage = data; } @@ -217,8 +217,8 @@ static void node_free_storage(bNode *node) static void node_copy_storage(bNodeTree * /*dst_tree*/, bNode *dst_node, const bNode *src_node) { const NodeGeometryAttributeCapture &src_storage = node_storage(*src_node); - NodeGeometryAttributeCapture *dst_storage = MEM_cnew(__func__, - src_storage); + NodeGeometryAttributeCapture *dst_storage = MEM_dupallocN( + __func__, src_storage); dst_node->storage = dst_storage; socket_items::copy_array(*src_node, *dst_node); diff --git a/source/blender/nodes/geometry/nodes/node_geo_bake.cc b/source/blender/nodes/geometry/nodes/node_geo_bake.cc index 0e5d3d7dce3..eafca0c2d44 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_bake.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_bake.cc @@ -85,9 +85,9 @@ static void node_declare(NodeDeclarationBuilder &b) static void node_init(bNodeTree * /*tree*/, bNode *node) { - NodeGeometryBake *data = MEM_cnew(__func__); + NodeGeometryBake *data = MEM_callocN(__func__); - data->items = MEM_cnew_array(1, __func__); + data->items = MEM_calloc_arrayN(1, __func__); data->items_num = 1; NodeGeometryBakeItem &item = data->items[0]; @@ -108,7 +108,7 @@ static void node_free_storage(bNode *node) static void node_copy_storage(bNodeTree * /*tree*/, bNode *dst_node, const bNode *src_node) { const NodeGeometryBake &src_storage = node_storage(*src_node); - auto *dst_storage = MEM_cnew(__func__, src_storage); + auto *dst_storage = MEM_dupallocN(__func__, src_storage); dst_node->storage = dst_storage; socket_items::copy_array(*src_node, *dst_node); @@ -867,7 +867,7 @@ static void draw_bake_data_block_list_item(uiList * /*ui_list*/, void draw_data_blocks(const bContext *C, uiLayout *layout, PointerRNA &bake_rna) { static const uiListType *data_block_list = []() { - uiListType *list = MEM_cnew(__func__); + uiListType *list = MEM_callocN(__func__); STRNCPY(list->idname, "DATA_UL_nodes_modifier_data_blocks"); list->draw_item = draw_bake_data_block_list_item; WM_uilisttype_add(list); diff --git a/source/blender/nodes/geometry/nodes/node_geo_collection_info.cc b/source/blender/nodes/geometry/nodes/node_geo_collection_info.cc index a0f068613e9..0d84f87237c 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_collection_info.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_collection_info.cc @@ -45,7 +45,7 @@ static void node_layout(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr) static void node_node_init(bNodeTree * /*tree*/, bNode *node) { - NodeGeometryCollectionInfo *data = MEM_cnew(__func__); + NodeGeometryCollectionInfo *data = MEM_callocN(__func__); data->transform_space = GEO_NODE_TRANSFORM_SPACE_ORIGINAL; node->storage = data; } diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_fill.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_fill.cc index a479de44713..d9122d7366c 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_fill.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_fill.cc @@ -44,7 +44,7 @@ static void node_layout(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr) static void node_init(bNodeTree * /*tree*/, bNode *node) { - NodeGeometryCurveFill *data = MEM_cnew(__func__); + NodeGeometryCurveFill *data = MEM_callocN(__func__); data->mode = GEO_NODE_CURVE_FILL_MODE_TRIANGULATED; node->storage = data; diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_fillet.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_fillet.cc index 1ea91be59eb..da09e9377cd 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_fillet.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_fillet.cc @@ -55,7 +55,7 @@ static void node_layout(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr) static void node_init(bNodeTree * /*tree*/, bNode *node) { - NodeGeometryCurveFillet *data = MEM_cnew(__func__); + NodeGeometryCurveFillet *data = MEM_callocN(__func__); data->mode = GEO_NODE_CURVE_FILLET_BEZIER; node->storage = data; } diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_handle_type_selection.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_handle_type_selection.cc index 60817383012..ac4a0597a3d 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_handle_type_selection.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_handle_type_selection.cc @@ -26,7 +26,7 @@ static void node_layout(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr) static void node_init(bNodeTree * /*tree*/, bNode *node) { - NodeGeometryCurveSelectHandles *data = MEM_cnew(__func__); + NodeGeometryCurveSelectHandles *data = MEM_callocN(__func__); data->handle_type = GEO_NODE_CURVE_HANDLE_AUTO; data->mode = GEO_NODE_CURVE_HANDLE_LEFT | GEO_NODE_CURVE_HANDLE_RIGHT; diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_arc.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_arc.cc index cc97303e74d..43e5518a3c1 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_arc.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_arc.cc @@ -123,7 +123,7 @@ static void node_layout(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr) static void node_init(bNodeTree * /*tree*/, bNode *node) { - NodeGeometryCurvePrimitiveArc *data = MEM_cnew(__func__); + NodeGeometryCurvePrimitiveArc *data = MEM_callocN(__func__); data->mode = GEO_NODE_CURVE_PRIMITIVE_ARC_TYPE_RADIUS; node->storage = data; diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_bezier_segment.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_bezier_segment.cc index 2e4a5b59d01..7e354ed2150 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_bezier_segment.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_bezier_segment.cc @@ -53,7 +53,7 @@ static void node_layout(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr) static void node_init(bNodeTree * /*tree*/, bNode *node) { NodeGeometryCurvePrimitiveBezierSegment *data = - MEM_cnew(__func__); + MEM_callocN(__func__); data->mode = GEO_NODE_CURVE_PRIMITIVE_BEZIER_SEGMENT_POSITION; node->storage = data; diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_circle.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_circle.cc index e721e241b5e..fd0fd766203 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_circle.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_circle.cc @@ -83,7 +83,7 @@ static void node_layout(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr) static void node_init(bNodeTree * /*tree*/, bNode *node) { - NodeGeometryCurvePrimitiveCircle *data = MEM_cnew(__func__); + NodeGeometryCurvePrimitiveCircle *data = MEM_callocN(__func__); data->mode = GEO_NODE_CURVE_PRIMITIVE_CIRCLE_TYPE_RADIUS; node->storage = data; diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_line.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_line.cc index a4894c10978..bff5d61f31e 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_line.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_line.cc @@ -62,7 +62,7 @@ static void node_layout(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr) static void node_init(bNodeTree * /*tree*/, bNode *node) { - NodeGeometryCurvePrimitiveLine *data = MEM_cnew(__func__); + NodeGeometryCurvePrimitiveLine *data = MEM_callocN(__func__); data->mode = GEO_NODE_CURVE_PRIMITIVE_LINE_MODE_POINTS; node->storage = data; diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_quadrilateral.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_quadrilateral.cc index b3546d45549..e43bdd560a2 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_quadrilateral.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_quadrilateral.cc @@ -123,7 +123,7 @@ static void node_layout(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr) static void node_init(bNodeTree * /*tree*/, bNode *node) { - NodeGeometryCurvePrimitiveQuad *data = MEM_cnew(__func__); + NodeGeometryCurvePrimitiveQuad *data = MEM_callocN(__func__); data->mode = GEO_NODE_CURVE_PRIMITIVE_QUAD_MODE_RECTANGLE; node->storage = data; } diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_resample.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_resample.cc index 41710719f37..8c038639e85 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_resample.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_resample.cc @@ -54,7 +54,7 @@ static void node_layout_ex(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr) static void node_init(bNodeTree * /*tree*/, bNode *node) { - NodeGeometryCurveResample *data = MEM_cnew(__func__); + NodeGeometryCurveResample *data = MEM_callocN(__func__); data->mode = GEO_NODE_CURVE_RESAMPLE_COUNT; data->keep_last_segment = true; diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_sample.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_sample.cc index 7928a8c62eb..57f5ffeed08 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_sample.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_sample.cc @@ -76,7 +76,7 @@ static void node_layout(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr) static void node_init(bNodeTree * /*tree*/, bNode *node) { - NodeGeometryCurveSample *data = MEM_cnew(__func__); + NodeGeometryCurveSample *data = MEM_callocN(__func__); data->mode = GEO_NODE_CURVE_SAMPLE_FACTOR; data->use_all_curves = false; data->data_type = CD_PROP_FLOAT; diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_set_handle_type.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_set_handle_type.cc index a53213840b6..2449523470b 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_set_handle_type.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_set_handle_type.cc @@ -30,7 +30,7 @@ static void node_layout(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr) static void node_init(bNodeTree * /*tree*/, bNode *node) { - NodeGeometryCurveSetHandles *data = MEM_cnew(__func__); + NodeGeometryCurveSetHandles *data = MEM_callocN(__func__); data->handle_type = GEO_NODE_CURVE_HANDLE_AUTO; data->mode = GEO_NODE_CURVE_HANDLE_LEFT | GEO_NODE_CURVE_HANDLE_RIGHT; diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_spline_type.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_spline_type.cc index b1b23c88678..a808c1c1c67 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_spline_type.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_spline_type.cc @@ -33,7 +33,7 @@ static void node_layout(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr) static void node_init(bNodeTree * /*tree*/, bNode *node) { - NodeGeometryCurveSplineType *data = MEM_cnew(__func__); + NodeGeometryCurveSplineType *data = MEM_callocN(__func__); data->spline_type = CURVE_TYPE_POLY; node->storage = data; diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_to_points.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_to_points.cc index 17335b796ac..67cfb62ce3c 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_to_points.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_to_points.cc @@ -66,7 +66,7 @@ static void node_layout(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr) static void node_init(bNodeTree * /*tree*/, bNode *node) { - NodeGeometryCurveToPoints *data = MEM_cnew(__func__); + NodeGeometryCurveToPoints *data = MEM_callocN(__func__); data->mode = GEO_NODE_CURVE_RESAMPLE_COUNT; node->storage = data; diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_trim.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_trim.cc index 2203d3afc8d..3035e663686 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_trim.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_trim.cc @@ -78,7 +78,7 @@ static void node_layout(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr) static void node_init(bNodeTree * /*tree*/, bNode *node) { - NodeGeometryCurveTrim *data = MEM_cnew(__func__); + NodeGeometryCurveTrim *data = MEM_callocN(__func__); data->mode = GEO_NODE_CURVE_SAMPLE_FACTOR; node->storage = data; diff --git a/source/blender/nodes/geometry/nodes/node_geo_curves_to_grease_pencil.cc b/source/blender/nodes/geometry/nodes/node_geo_curves_to_grease_pencil.cc index 1716e2daf6e..9e8fdc81276 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curves_to_grease_pencil.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curves_to_grease_pencil.cc @@ -53,7 +53,7 @@ static GreasePencil *curves_to_grease_pencil_with_one_layer( /* Transfer materials. */ const int materials_num = curves_id.totcol; grease_pencil->material_array_num = materials_num; - grease_pencil->material_array = MEM_cnew_array(materials_num, __func__); + grease_pencil->material_array = MEM_calloc_arrayN(materials_num, __func__); initialized_copy_n(curves_id.mat, materials_num, grease_pencil->material_array); return grease_pencil; @@ -124,7 +124,7 @@ static GreasePencil *curve_instances_to_grease_pencil_layers( }); grease_pencil->material_array_num = all_materials.size(); - grease_pencil->material_array = MEM_cnew_array(all_materials.size(), __func__); + grease_pencil->material_array = MEM_calloc_arrayN(all_materials.size(), __func__); initialized_copy_n(all_materials.data(), all_materials.size(), grease_pencil->material_array); const bke::AttributeAccessor instances_attributes = instances.attributes(); diff --git a/source/blender/nodes/geometry/nodes/node_geo_delete_geometry.cc b/source/blender/nodes/geometry/nodes/node_geo_delete_geometry.cc index 35bce79bb4b..b76dcadb5ac 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_delete_geometry.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_delete_geometry.cc @@ -43,7 +43,7 @@ static void node_layout(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr) static void node_init(bNodeTree * /*tree*/, bNode *node) { - NodeGeometryDeleteGeometry *data = MEM_cnew(__func__); + NodeGeometryDeleteGeometry *data = MEM_callocN(__func__); data->domain = int(AttrDomain::Point); data->mode = GEO_NODE_DELETE_GEOMETRY_MODE_ALL; diff --git a/source/blender/nodes/geometry/nodes/node_geo_distribute_points_in_volume.cc b/source/blender/nodes/geometry/nodes/node_geo_distribute_points_in_volume.cc index b4b586b9538..920e6d7b850 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_distribute_points_in_volume.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_distribute_points_in_volume.cc @@ -75,7 +75,7 @@ static void node_layout(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr) static void node_init(bNodeTree * /*tree*/, bNode *node) { - NodeGeometryDistributePointsInVolume *data = MEM_cnew( + NodeGeometryDistributePointsInVolume *data = MEM_callocN( __func__); data->mode = GEO_NODE_DISTRIBUTE_POINTS_IN_VOLUME_DENSITY_RANDOM; node->storage = data; diff --git a/source/blender/nodes/geometry/nodes/node_geo_duplicate_elements.cc b/source/blender/nodes/geometry/nodes/node_geo_duplicate_elements.cc index c7af019ee18..2bb595d16cc 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_duplicate_elements.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_duplicate_elements.cc @@ -47,7 +47,7 @@ static void node_declare(NodeDeclarationBuilder &b) static void node_init(bNodeTree * /*tree*/, bNode *node) { - NodeGeometryDuplicateElements *data = MEM_cnew(__func__); + NodeGeometryDuplicateElements *data = MEM_callocN(__func__); data->domain = int8_t(AttrDomain::Point); node->storage = data; } diff --git a/source/blender/nodes/geometry/nodes/node_geo_extrude_mesh.cc b/source/blender/nodes/geometry/nodes/node_geo_extrude_mesh.cc index 13ff8e49ef3..38650dad003 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_extrude_mesh.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_extrude_mesh.cc @@ -67,7 +67,7 @@ static void node_layout(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr) static void node_init(bNodeTree * /*tree*/, bNode *node) { - NodeGeometryExtrudeMesh *data = MEM_cnew(__func__); + NodeGeometryExtrudeMesh *data = MEM_callocN(__func__); data->mode = GEO_NODE_EXTRUDE_MESH_FACES; node->storage = data; } diff --git a/source/blender/nodes/geometry/nodes/node_geo_foreach_geometry_element.cc b/source/blender/nodes/geometry/nodes/node_geo_foreach_geometry_element.cc index 664584c8286..f54ebcb951c 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_foreach_geometry_element.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_foreach_geometry_element.cc @@ -174,7 +174,7 @@ static void node_layout(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr) static void node_init(bNodeTree * /*tree*/, bNode *node) { NodeGeometryForeachGeometryElementInput *data = - MEM_cnew(__func__); + MEM_callocN(__func__); /* Needs to be initialized for the node to work. */ data->output_node_id = 0; node->storage = data; @@ -307,9 +307,9 @@ static void node_declare(NodeDeclarationBuilder &b) static void node_init(bNodeTree * /*tree*/, bNode *node) { NodeGeometryForeachGeometryElementOutput *data = - MEM_cnew(__func__); + MEM_callocN(__func__); - data->generation_items.items = MEM_cnew_array( + data->generation_items.items = MEM_calloc_arrayN( 1, __func__); NodeForeachGeometryElementGenerationItem &item = data->generation_items.items[0]; item.name = BLI_strdup(DATA_("Geometry")); @@ -331,7 +331,8 @@ static void node_free_storage(bNode *node) static void node_copy_storage(bNodeTree * /*dst_tree*/, bNode *dst_node, const bNode *src_node) { const NodeGeometryForeachGeometryElementOutput &src_storage = node_storage(*src_node); - auto *dst_storage = MEM_cnew(__func__, src_storage); + auto *dst_storage = MEM_dupallocN(__func__, + src_storage); dst_node->storage = dst_storage; socket_items::copy_array(*src_node, *dst_node); diff --git a/source/blender/nodes/geometry/nodes/node_geo_gizmo_dial.cc b/source/blender/nodes/geometry/nodes/node_geo_gizmo_dial.cc index 09b50eb9945..f83f49faaf9 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_gizmo_dial.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_gizmo_dial.cc @@ -30,7 +30,7 @@ static void node_declare(NodeDeclarationBuilder &b) static void node_init(bNodeTree * /*tree*/, bNode *node) { - NodeGeometryDialGizmo *storage = MEM_cnew(__func__); + NodeGeometryDialGizmo *storage = MEM_callocN(__func__); node->storage = storage; } diff --git a/source/blender/nodes/geometry/nodes/node_geo_gizmo_linear.cc b/source/blender/nodes/geometry/nodes/node_geo_gizmo_linear.cc index 9def116b0eb..d464a490024 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_gizmo_linear.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_gizmo_linear.cc @@ -25,7 +25,7 @@ static void node_declare(NodeDeclarationBuilder &b) static void node_init(bNodeTree * /*tree*/, bNode *node) { - NodeGeometryLinearGizmo *storage = MEM_cnew(__func__); + NodeGeometryLinearGizmo *storage = MEM_callocN(__func__); node->storage = storage; } diff --git a/source/blender/nodes/geometry/nodes/node_geo_gizmo_transform.cc b/source/blender/nodes/geometry/nodes/node_geo_gizmo_transform.cc index eac9747cc10..20630244123 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_gizmo_transform.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_gizmo_transform.cc @@ -26,7 +26,7 @@ static void node_declare(NodeDeclarationBuilder &b) static void node_init(bNodeTree * /*tree*/, bNode *node) { - NodeGeometryTransformGizmo *storage = MEM_cnew(__func__); + NodeGeometryTransformGizmo *storage = MEM_callocN(__func__); storage->flag = (GEO_NODE_TRANSFORM_GIZMO_USE_TRANSLATION_X | GEO_NODE_TRANSFORM_GIZMO_USE_TRANSLATION_Y | GEO_NODE_TRANSFORM_GIZMO_USE_TRANSLATION_Z | diff --git a/source/blender/nodes/geometry/nodes/node_geo_image_texture.cc b/source/blender/nodes/geometry/nodes/node_geo_image_texture.cc index ed2189470b4..2115e8d349d 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_image_texture.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_image_texture.cc @@ -39,7 +39,7 @@ static void node_layout(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr) static void node_init(bNodeTree * /*tree*/, bNode *node) { - NodeGeometryImageTexture *tex = MEM_cnew(__func__); + NodeGeometryImageTexture *tex = MEM_callocN(__func__); tex->interpolation = SHD_INTERP_LINEAR; tex->extension = SHD_IMAGE_EXTENSION_REPEAT; node->storage = tex; diff --git a/source/blender/nodes/geometry/nodes/node_geo_index_switch.cc b/source/blender/nodes/geometry/nodes/node_geo_index_switch.cc index fee63fba9ae..7fab14b2a59 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_index_switch.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_index_switch.cc @@ -100,13 +100,13 @@ static void node_operators() static void node_init(bNodeTree * /*tree*/, bNode *node) { - NodeIndexSwitch *data = MEM_cnew(__func__); + NodeIndexSwitch *data = MEM_callocN(__func__); data->data_type = SOCK_GEOMETRY; data->next_identifier = 0; BLI_assert(data->items == nullptr); const int default_items_num = 2; - data->items = MEM_cnew_array(default_items_num, __func__); + data->items = MEM_calloc_arrayN(default_items_num, __func__); for (const int i : IndexRange(default_items_num)) { data->items[i].identifier = data->next_identifier++; } @@ -354,7 +354,7 @@ static void node_free_storage(bNode *node) static void node_copy_storage(bNodeTree * /*dst_tree*/, bNode *dst_node, const bNode *src_node) { const NodeIndexSwitch &src_storage = node_storage(*src_node); - auto *dst_storage = MEM_cnew(__func__, src_storage); + auto *dst_storage = MEM_dupallocN(__func__, src_storage); dst_node->storage = dst_storage; socket_items::copy_array(*src_node, *dst_node); diff --git a/source/blender/nodes/geometry/nodes/node_geo_input_named_attribute.cc b/source/blender/nodes/geometry/nodes/node_geo_input_named_attribute.cc index 0816022df07..1d91dc22166 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_input_named_attribute.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_input_named_attribute.cc @@ -38,7 +38,7 @@ static void node_layout(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr) static void node_init(bNodeTree * /*tree*/, bNode *node) { - NodeGeometryInputNamedAttribute *data = MEM_cnew(__func__); + NodeGeometryInputNamedAttribute *data = MEM_callocN(__func__); data->data_type = CD_PROP_FLOAT; node->storage = data; } diff --git a/source/blender/nodes/geometry/nodes/node_geo_menu_switch.cc b/source/blender/nodes/geometry/nodes/node_geo_menu_switch.cc index 9e666d3344e..91e579dd478 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_menu_switch.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_menu_switch.cc @@ -96,7 +96,7 @@ static void node_layout(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr) static void node_init(bNodeTree * /*tree*/, bNode *node) { - NodeMenuSwitch *data = MEM_cnew(__func__); + NodeMenuSwitch *data = MEM_callocN(__func__); data->data_type = SOCK_GEOMETRY; data->enum_definition.next_identifier = 0; data->enum_definition.items_array = nullptr; @@ -116,7 +116,7 @@ static void node_free_storage(bNode *node) static void node_copy_storage(bNodeTree * /*dst_tree*/, bNode *dst_node, const bNode *src_node) { const NodeMenuSwitch &src_storage = node_storage(*src_node); - NodeMenuSwitch *dst_storage = MEM_cnew(__func__, src_storage); + NodeMenuSwitch *dst_storage = MEM_dupallocN(__func__, src_storage); dst_node->storage = dst_storage; socket_items::copy_array(*src_node, *dst_node); diff --git a/source/blender/nodes/geometry/nodes/node_geo_merge_by_distance.cc b/source/blender/nodes/geometry/nodes/node_geo_merge_by_distance.cc index 398b0d73422..0f518576389 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_merge_by_distance.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_merge_by_distance.cc @@ -37,7 +37,7 @@ static void node_layout(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr) static void node_init(bNodeTree * /*tree*/, bNode *node) { - NodeGeometryMergeByDistance *data = MEM_cnew(__func__); + NodeGeometryMergeByDistance *data = MEM_callocN(__func__); data->mode = GEO_NODE_MERGE_BY_DISTANCE_MODE_ALL; node->storage = data; } diff --git a/source/blender/nodes/geometry/nodes/node_geo_merge_layers.cc b/source/blender/nodes/geometry/nodes/node_geo_merge_layers.cc index 3da659ab9f8..37a859ec86e 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_merge_layers.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_merge_layers.cc @@ -40,7 +40,7 @@ static void node_declare(NodeDeclarationBuilder &b) static void node_init(bNodeTree * /*tree*/, bNode *node) { - auto *data = MEM_cnew(__func__); + auto *data = MEM_callocN(__func__); data->mode = int8_t(MergeLayerMode::ByName); node->storage = data; } diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_circle.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_circle.cc index 6942cbb41e7..724fd4abcb9 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_circle.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_circle.cc @@ -45,7 +45,7 @@ static void node_layout(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr) static void node_init(bNodeTree * /*tree*/, bNode *node) { - NodeGeometryMeshCircle *node_storage = MEM_cnew(__func__); + NodeGeometryMeshCircle *node_storage = MEM_callocN(__func__); node_storage->fill_type = GEO_NODE_MESH_CIRCLE_FILL_NONE; diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cone.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cone.cc index ae69987c714..dbe2ad7a711 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cone.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cone.cc @@ -69,7 +69,7 @@ static void node_declare(NodeDeclarationBuilder &b) static void node_init(bNodeTree * /*tree*/, bNode *node) { - NodeGeometryMeshCone *node_storage = MEM_cnew(__func__); + NodeGeometryMeshCone *node_storage = MEM_callocN(__func__); node_storage->fill_type = GEO_NODE_MESH_CIRCLE_FILL_NGON; diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cylinder.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cylinder.cc index 2cf26bb2148..adbcfe8e7bc 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cylinder.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cylinder.cc @@ -71,7 +71,7 @@ static void node_layout(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr) static void node_init(bNodeTree * /*tree*/, bNode *node) { - NodeGeometryMeshCylinder *node_storage = MEM_cnew(__func__); + NodeGeometryMeshCylinder *node_storage = MEM_callocN(__func__); node_storage->fill_type = GEO_NODE_MESH_CIRCLE_FILL_NGON; diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_line.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_line.cc index 4c4730c7325..e0300184a7f 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_line.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_line.cc @@ -56,7 +56,7 @@ static void node_layout(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr) static void node_init(bNodeTree * /*tree*/, bNode *node) { - NodeGeometryMeshLine *node_storage = MEM_cnew(__func__); + NodeGeometryMeshLine *node_storage = MEM_callocN(__func__); node_storage->mode = GEO_NODE_MESH_LINE_MODE_OFFSET; node_storage->count_mode = GEO_NODE_MESH_LINE_COUNT_TOTAL; diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_to_points.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_to_points.cc index 367f889f259..fecfd17d4d3 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_mesh_to_points.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_to_points.cc @@ -44,7 +44,7 @@ static void node_layout(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr) static void node_init(bNodeTree * /*tree*/, bNode *node) { - NodeGeometryMeshToPoints *data = MEM_cnew(__func__); + NodeGeometryMeshToPoints *data = MEM_callocN(__func__); data->mode = GEO_NODE_MESH_TO_POINTS_VERTICES; node->storage = data; } diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_to_volume.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_to_volume.cc index 4d4bee59eb1..2d9d7f9f164 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_mesh_to_volume.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_to_volume.cc @@ -55,7 +55,7 @@ static void node_layout(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr) static void node_init(bNodeTree * /*tree*/, bNode *node) { - NodeGeometryMeshToVolume *data = MEM_cnew(__func__); + NodeGeometryMeshToVolume *data = MEM_callocN(__func__); data->resolution_mode = MESH_TO_VOLUME_RESOLUTION_MODE_VOXEL_AMOUNT; node->storage = data; } diff --git a/source/blender/nodes/geometry/nodes/node_geo_object_info.cc b/source/blender/nodes/geometry/nodes/node_geo_object_info.cc index 0b064181546..965bc9ec5ef 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_object_info.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_object_info.cc @@ -161,7 +161,7 @@ static void node_geo_exec(GeoNodeExecParams params) static void node_node_init(bNodeTree * /*tree*/, bNode *node) { - NodeGeometryObjectInfo *data = MEM_cnew(__func__); + NodeGeometryObjectInfo *data = MEM_callocN(__func__); data->transform_space = GEO_NODE_TRANSFORM_SPACE_ORIGINAL; node->storage = data; } diff --git a/source/blender/nodes/geometry/nodes/node_geo_points_to_volume.cc b/source/blender/nodes/geometry/nodes/node_geo_points_to_volume.cc index 8c04b0dea1d..0f3913731b4 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_points_to_volume.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_points_to_volume.cc @@ -171,7 +171,7 @@ static void node_layout(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr) static void node_init(bNodeTree * /*tree*/, bNode *node) { - NodeGeometryPointsToVolume *data = MEM_cnew(__func__); + NodeGeometryPointsToVolume *data = MEM_callocN(__func__); data->resolution_mode = GEO_NODE_POINTS_TO_VOLUME_RESOLUTION_MODE_AMOUNT; node->storage = data; } diff --git a/source/blender/nodes/geometry/nodes/node_geo_proximity.cc b/source/blender/nodes/geometry/nodes/node_geo_proximity.cc index cfd5622d7d3..62cfbfbe9ec 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_proximity.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_proximity.cc @@ -50,7 +50,7 @@ static void node_layout(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr) static void geo_proximity_init(bNodeTree * /*tree*/, bNode *node) { - NodeGeometryProximity *node_storage = MEM_cnew(__func__); + NodeGeometryProximity *node_storage = MEM_callocN(__func__); node_storage->target_element = GEO_NODE_PROX_TARGET_FACES; node->storage = node_storage; } diff --git a/source/blender/nodes/geometry/nodes/node_geo_raycast.cc b/source/blender/nodes/geometry/nodes/node_geo_raycast.cc index eb17b4739b2..2c79be10919 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_raycast.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_raycast.cc @@ -65,7 +65,7 @@ static void node_layout(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr) static void node_init(bNodeTree * /*tree*/, bNode *node) { - NodeGeometryRaycast *data = MEM_cnew(__func__); + NodeGeometryRaycast *data = MEM_callocN(__func__); data->mapping = GEO_NODE_RAYCAST_INTERPOLATED; data->data_type = CD_PROP_FLOAT; node->storage = data; diff --git a/source/blender/nodes/geometry/nodes/node_geo_repeat.cc b/source/blender/nodes/geometry/nodes/node_geo_repeat.cc index 6b50fc9dc57..bb531193438 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_repeat.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_repeat.cc @@ -102,7 +102,7 @@ static void node_declare(NodeDeclarationBuilder &b) static void node_init(bNodeTree * /*tree*/, bNode *node) { - NodeGeometryRepeatInput *data = MEM_cnew(__func__); + NodeGeometryRepeatInput *data = MEM_callocN(__func__); /* Needs to be initialized for the node to work. */ data->output_node_id = 0; node->storage = data; @@ -181,11 +181,11 @@ static void node_declare(NodeDeclarationBuilder &b) static void node_init(bNodeTree * /*tree*/, bNode *node) { - NodeGeometryRepeatOutput *data = MEM_cnew(__func__); + NodeGeometryRepeatOutput *data = MEM_callocN(__func__); data->next_identifier = 0; - data->items = MEM_cnew_array(1, __func__); + data->items = MEM_calloc_arrayN(1, __func__); data->items[0].name = BLI_strdup(DATA_("Geometry")); data->items[0].socket_type = SOCK_GEOMETRY; data->items[0].identifier = data->next_identifier++; @@ -203,7 +203,7 @@ static void node_free_storage(bNode *node) static void node_copy_storage(bNodeTree * /*dst_tree*/, bNode *dst_node, const bNode *src_node) { const NodeGeometryRepeatOutput &src_storage = node_storage(*src_node); - auto *dst_storage = MEM_cnew(__func__, src_storage); + auto *dst_storage = MEM_dupallocN(__func__, src_storage); dst_node->storage = dst_storage; socket_items::copy_array(*src_node, *dst_node); diff --git a/source/blender/nodes/geometry/nodes/node_geo_sample_index.cc b/source/blender/nodes/geometry/nodes/node_geo_sample_index.cc index 8a3867f4dae..f35a6b4ba75 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_sample_index.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_sample_index.cc @@ -48,7 +48,7 @@ static void node_layout(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr) static void node_init(bNodeTree * /*tree*/, bNode *node) { - NodeGeometrySampleIndex *data = MEM_cnew(__func__); + NodeGeometrySampleIndex *data = MEM_callocN(__func__); data->data_type = CD_PROP_FLOAT; data->domain = int8_t(AttrDomain::Point); data->clamp = 0; diff --git a/source/blender/nodes/geometry/nodes/node_geo_scale_elements.cc b/source/blender/nodes/geometry/nodes/node_geo_scale_elements.cc index 8f3d7563ad6..9a900f739e9 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_scale_elements.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_scale_elements.cc @@ -136,7 +136,7 @@ static Array reverse_indices_in_groups(const Span group_indices, * atomically by many threads in parallel. `calloc` can be measurably faster than a parallel fill * of zero. Alternatively the offsets could be copied and incremented directly, but the cost of * the copy is slightly higher than the cost of `calloc`. */ - int *counts = MEM_cnew_array(size_t(offsets.size()), __func__); + int *counts = MEM_calloc_arrayN(size_t(offsets.size()), __func__); BLI_SCOPED_DEFER([&]() { MEM_freeN(counts); }) Array results(group_indices.size()); threading::parallel_for(group_indices.index_range(), 1024, [&](const IndexRange range) { diff --git a/source/blender/nodes/geometry/nodes/node_geo_separate_geometry.cc b/source/blender/nodes/geometry/nodes/node_geo_separate_geometry.cc index e825ed4ead6..225be155fdf 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_separate_geometry.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_separate_geometry.cc @@ -40,7 +40,7 @@ static void node_layout(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr) static void node_init(bNodeTree * /*tree*/, bNode *node) { - NodeGeometrySeparateGeometry *data = MEM_cnew(__func__); + NodeGeometrySeparateGeometry *data = MEM_callocN(__func__); data->domain = int8_t(AttrDomain::Point); node->storage = data; } diff --git a/source/blender/nodes/geometry/nodes/node_geo_set_curve_handles.cc b/source/blender/nodes/geometry/nodes/node_geo_set_curve_handles.cc index 03b45b8cb8f..fe5ed145388 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_set_curve_handles.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_set_curve_handles.cc @@ -43,7 +43,7 @@ static void node_layout(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr) static void node_init(bNodeTree * /*tree*/, bNode *node) { - NodeGeometrySetCurveHandlePositions *data = MEM_cnew( + NodeGeometrySetCurveHandlePositions *data = MEM_callocN( __func__); data->mode = GEO_NODE_CURVE_HANDLE_LEFT; diff --git a/source/blender/nodes/geometry/nodes/node_geo_simulation.cc b/source/blender/nodes/geometry/nodes/node_geo_simulation.cc index 7dde30cc198..331c5c4d8a6 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_simulation.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_simulation.cc @@ -446,7 +446,7 @@ static void node_declare(NodeDeclarationBuilder &b) static void node_init(bNodeTree * /*tree*/, bNode *node) { - NodeGeometrySimulationInput *data = MEM_cnew(__func__); + NodeGeometrySimulationInput *data = MEM_callocN(__func__); /* Needs to be initialized for the node to work. */ data->output_node_id = 0; node->storage = data; @@ -795,11 +795,11 @@ static void node_declare(NodeDeclarationBuilder &b) static void node_init(bNodeTree * /*tree*/, bNode *node) { - NodeGeometrySimulationOutput *data = MEM_cnew(__func__); + NodeGeometrySimulationOutput *data = MEM_callocN(__func__); data->next_identifier = 0; - data->items = MEM_cnew_array(1, __func__); + data->items = MEM_calloc_arrayN(1, __func__); data->items[0].name = BLI_strdup(DATA_("Geometry")); data->items[0].socket_type = SOCK_GEOMETRY; data->items[0].identifier = data->next_identifier++; @@ -817,7 +817,7 @@ static void node_free_storage(bNode *node) static void node_copy_storage(bNodeTree * /*dst_tree*/, bNode *dst_node, const bNode *src_node) { const NodeGeometrySimulationOutput &src_storage = node_storage(*src_node); - auto *dst_storage = MEM_cnew(__func__, src_storage); + auto *dst_storage = MEM_dupallocN(__func__, src_storage); dst_node->storage = dst_storage; socket_items::copy_array(*src_node, *dst_node); diff --git a/source/blender/nodes/geometry/nodes/node_geo_store_named_attribute.cc b/source/blender/nodes/geometry/nodes/node_geo_store_named_attribute.cc index fe2667470db..0296a102fe4 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_store_named_attribute.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_store_named_attribute.cc @@ -52,7 +52,7 @@ static void node_layout(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr) static void node_init(bNodeTree * /*tree*/, bNode *node) { - NodeGeometryStoreNamedAttribute *data = MEM_cnew(__func__); + NodeGeometryStoreNamedAttribute *data = MEM_callocN(__func__); data->data_type = CD_PROP_FLOAT; data->domain = int8_t(AttrDomain::Point); node->storage = data; diff --git a/source/blender/nodes/geometry/nodes/node_geo_string_to_curves.cc b/source/blender/nodes/geometry/nodes/node_geo_string_to_curves.cc index b77d3235d4f..67b2750f5ab 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_string_to_curves.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_string_to_curves.cc @@ -72,7 +72,7 @@ static void node_layout(uiLayout *layout, bContext *C, PointerRNA *ptr) static void node_init(bNodeTree * /*tree*/, bNode *node) { - NodeGeometryStringToCurves *data = MEM_cnew(__func__); + NodeGeometryStringToCurves *data = MEM_callocN(__func__); data->overflow = GEO_NODE_STRING_TO_CURVES_MODE_OVERFLOW; data->align_x = GEO_NODE_STRING_TO_CURVES_ALIGN_X_LEFT; diff --git a/source/blender/nodes/geometry/nodes/node_geo_subdivision_surface.cc b/source/blender/nodes/geometry/nodes/node_geo_subdivision_surface.cc index 65070d3763e..f8a64baafbd 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_subdivision_surface.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_subdivision_surface.cc @@ -59,7 +59,7 @@ static void node_layout(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr) static void node_init(bNodeTree * /*tree*/, bNode *node) { - NodeGeometrySubdivisionSurface *data = MEM_cnew(__func__); + NodeGeometrySubdivisionSurface *data = MEM_callocN(__func__); data->uv_smooth = SUBSURF_UV_SMOOTH_PRESERVE_BOUNDARIES; data->boundary_smooth = SUBSURF_BOUNDARY_SMOOTH_ALL; node->storage = data; diff --git a/source/blender/nodes/geometry/nodes/node_geo_switch.cc b/source/blender/nodes/geometry/nodes/node_geo_switch.cc index b508efafcd4..6fe43c39ce6 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_switch.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_switch.cc @@ -51,7 +51,7 @@ static void node_layout(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr) static void node_init(bNodeTree * /*tree*/, bNode *node) { - NodeSwitch *data = MEM_cnew(__func__); + NodeSwitch *data = MEM_callocN(__func__); data->input_type = SOCK_GEOMETRY; node->storage = data; } diff --git a/source/blender/nodes/geometry/nodes/node_geo_uv_unwrap.cc b/source/blender/nodes/geometry/nodes/node_geo_uv_unwrap.cc index 0fd228c8aca..9564fe9f63f 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_uv_unwrap.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_uv_unwrap.cc @@ -46,7 +46,7 @@ static void node_layout(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr) static void node_init(bNodeTree * /*tree*/, bNode *node) { - NodeGeometryUVUnwrap *data = MEM_cnew(__func__); + NodeGeometryUVUnwrap *data = MEM_callocN(__func__); data->method = GEO_NODE_UV_UNWRAP_METHOD_ANGLE_BASED; node->storage = data; } diff --git a/source/blender/nodes/geometry/nodes/node_geo_viewer.cc b/source/blender/nodes/geometry/nodes/node_geo_viewer.cc index 87bb25ad20e..8c142f1f360 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_viewer.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_viewer.cc @@ -37,7 +37,7 @@ static void node_declare(NodeDeclarationBuilder &b) static void node_init(bNodeTree * /*tree*/, bNode *node) { - NodeGeometryViewer *data = MEM_cnew(__func__); + NodeGeometryViewer *data = MEM_callocN(__func__); data->data_type = CD_PROP_FLOAT; data->domain = int8_t(AttrDomain::Auto); node->storage = data; diff --git a/source/blender/nodes/geometry/nodes/node_geo_volume_to_mesh.cc b/source/blender/nodes/geometry/nodes/node_geo_volume_to_mesh.cc index 94af3d30673..1244a7edb60 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_volume_to_mesh.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_volume_to_mesh.cc @@ -70,7 +70,7 @@ static void node_layout(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr) static void node_init(bNodeTree * /*tree*/, bNode *node) { - NodeGeometryVolumeToMesh *data = MEM_cnew(__func__); + NodeGeometryVolumeToMesh *data = MEM_callocN(__func__); data->resolution_mode = VOLUME_TO_MESH_RESOLUTION_MODE_GRID; node->storage = data; } diff --git a/source/blender/nodes/intern/geometry_nodes_execute.cc b/source/blender/nodes/intern/geometry_nodes_execute.cc index 74a8797acd0..75339632cb6 100644 --- a/source/blender/nodes/intern/geometry_nodes_execute.cc +++ b/source/blender/nodes/intern/geometry_nodes_execute.cc @@ -62,7 +62,7 @@ static void id_property_int_update_enum_items(const bNodeSocketValueMenu *value, if (value->enum_items && !value->enum_items->items.is_empty()) { const Span items = value->enum_items->items; idprop_items_num = items.size(); - idprop_items = MEM_cnew_array(items.size(), __func__); + idprop_items = MEM_calloc_arrayN(items.size(), __func__); for (const int i : items.index_range()) { const bke::RuntimeNodeEnumItem &item = items[i]; IDPropertyUIDataEnumItem &idprop_item = idprop_items[i]; @@ -81,7 +81,7 @@ static void id_property_int_update_enum_items(const bNodeSocketValueMenu *value, * int value. */ if (idprop_items_num == 0) { idprop_items_num = 1; - idprop_items = MEM_cnew_array(1, __func__); + idprop_items = MEM_calloc_arrayN(1, __func__); idprop_items->value = 0; idprop_items->identifier = BLI_strdup("DUMMY"); idprop_items->name = BLI_strdup(""); diff --git a/source/blender/nodes/intern/node_common.cc b/source/blender/nodes/intern/node_common.cc index 357c5f48e7b..dd15fcf6487 100644 --- a/source/blender/nodes/intern/node_common.cc +++ b/source/blender/nodes/intern/node_common.cc @@ -498,7 +498,7 @@ void node_group_declare(NodeDeclarationBuilder &b) static void node_frame_init(bNodeTree * /*ntree*/, bNode *node) { - NodeFrame *data = MEM_cnew("frame node storage"); + NodeFrame *data = MEM_callocN("frame node storage"); node->storage = data; data->flag |= NODE_FRAME_SHRINK; @@ -549,7 +549,7 @@ static void node_reroute_declare(blender::nodes::NodeDeclarationBuilder &b) static void node_reroute_init(bNodeTree * /*ntree*/, bNode *node) { - NodeReroute *data = MEM_cnew(__func__); + NodeReroute *data = MEM_callocN(__func__); STRNCPY(data->type_idname, "NodeSocketColor"); node->storage = data; } diff --git a/source/blender/nodes/intern/node_exec.cc b/source/blender/nodes/intern/node_exec.cc index 63257ca15d6..2197bb3de2a 100644 --- a/source/blender/nodes/intern/node_exec.cc +++ b/source/blender/nodes/intern/node_exec.cc @@ -159,7 +159,7 @@ bNodeTreeExec *ntree_exec_begin(bNodeExecContext *context, const Span nodelist = ntree->toposort_left_to_right(); /* XXX could let callbacks do this for specialized data */ - exec = MEM_cnew("node tree execution data"); + exec = MEM_callocN("node tree execution data"); /* Back-pointer to node tree. */ exec->nodetree = ntree; diff --git a/source/blender/nodes/intern/node_socket.cc b/source/blender/nodes/intern/node_socket.cc index a64eb301259..7b19224ac64 100644 --- a/source/blender/nodes/intern/node_socket.cc +++ b/source/blender/nodes/intern/node_socket.cc @@ -442,7 +442,7 @@ static void refresh_node_sockets_and_panels(bNodeTree &ntree, /* New panel states buffer. */ MEM_SAFE_FREE(node.panel_states_array); node.num_panel_states = new_num_panels; - node.panel_states_array = MEM_cnew_array(new_num_panels, __func__); + node.panel_states_array = MEM_calloc_arrayN(new_num_panels, __func__); /* Find list of sockets to add, mixture of old and new sockets. */ VectorSet new_inputs; @@ -571,7 +571,7 @@ void node_socket_init_default_value_data(eNodeSocketDatatype datatype, int subty switch (datatype) { case SOCK_FLOAT: { - bNodeSocketValueFloat *dval = MEM_cnew("node socket value float"); + bNodeSocketValueFloat *dval = MEM_callocN("node socket value float"); dval->subtype = subtype; dval->value = 0.0f; dval->min = -FLT_MAX; @@ -581,7 +581,7 @@ void node_socket_init_default_value_data(eNodeSocketDatatype datatype, int subty break; } case SOCK_INT: { - bNodeSocketValueInt *dval = MEM_cnew("node socket value int"); + bNodeSocketValueInt *dval = MEM_callocN("node socket value int"); dval->subtype = subtype; dval->value = 0; dval->min = INT_MIN; @@ -591,20 +591,22 @@ void node_socket_init_default_value_data(eNodeSocketDatatype datatype, int subty break; } case SOCK_BOOLEAN: { - bNodeSocketValueBoolean *dval = MEM_cnew("node socket value bool"); + bNodeSocketValueBoolean *dval = MEM_callocN( + "node socket value bool"); dval->value = false; *data = dval; break; } case SOCK_ROTATION: { - bNodeSocketValueRotation *dval = MEM_cnew(__func__); + bNodeSocketValueRotation *dval = MEM_callocN(__func__); *data = dval; break; } case SOCK_VECTOR: { static float default_value[] = {0.0f, 0.0f, 0.0f}; - bNodeSocketValueVector *dval = MEM_cnew("node socket value vector"); + bNodeSocketValueVector *dval = MEM_callocN( + "node socket value vector"); dval->subtype = subtype; copy_v3_v3(dval->value, default_value); dval->min = -FLT_MAX; @@ -615,14 +617,15 @@ void node_socket_init_default_value_data(eNodeSocketDatatype datatype, int subty } case SOCK_RGBA: { static float default_value[] = {0.0f, 0.0f, 0.0f, 1.0f}; - bNodeSocketValueRGBA *dval = MEM_cnew("node socket value color"); + bNodeSocketValueRGBA *dval = MEM_callocN("node socket value color"); copy_v4_v4(dval->value, default_value); *data = dval; break; } case SOCK_STRING: { - bNodeSocketValueString *dval = MEM_cnew("node socket value string"); + bNodeSocketValueString *dval = MEM_callocN( + "node socket value string"); dval->subtype = subtype; dval->value[0] = '\0'; @@ -630,28 +633,29 @@ void node_socket_init_default_value_data(eNodeSocketDatatype datatype, int subty break; } case SOCK_MENU: { - bNodeSocketValueMenu *dval = MEM_cnew("node socket value menu"); + bNodeSocketValueMenu *dval = MEM_callocN("node socket value menu"); dval->value = -1; *data = dval; break; } case SOCK_OBJECT: { - bNodeSocketValueObject *dval = MEM_cnew("node socket value object"); + bNodeSocketValueObject *dval = MEM_callocN( + "node socket value object"); dval->value = nullptr; *data = dval; break; } case SOCK_IMAGE: { - bNodeSocketValueImage *dval = MEM_cnew("node socket value image"); + bNodeSocketValueImage *dval = MEM_callocN("node socket value image"); dval->value = nullptr; *data = dval; break; } case SOCK_COLLECTION: { - bNodeSocketValueCollection *dval = MEM_cnew( + bNodeSocketValueCollection *dval = MEM_callocN( "node socket value object"); dval->value = nullptr; @@ -659,7 +663,7 @@ void node_socket_init_default_value_data(eNodeSocketDatatype datatype, int subty break; } case SOCK_TEXTURE: { - bNodeSocketValueTexture *dval = MEM_cnew( + bNodeSocketValueTexture *dval = MEM_callocN( "node socket value texture"); dval->value = nullptr; @@ -667,7 +671,7 @@ void node_socket_init_default_value_data(eNodeSocketDatatype datatype, int subty break; } case SOCK_MATERIAL: { - bNodeSocketValueMaterial *dval = MEM_cnew( + bNodeSocketValueMaterial *dval = MEM_callocN( "node socket value material"); dval->value = nullptr; diff --git a/source/blender/nodes/shader/nodes/node_shader_attribute.cc b/source/blender/nodes/shader/nodes/node_shader_attribute.cc index ab580a616b1..6e3e40a3f80 100644 --- a/source/blender/nodes/shader/nodes/node_shader_attribute.cc +++ b/source/blender/nodes/shader/nodes/node_shader_attribute.cc @@ -37,7 +37,7 @@ static void node_shader_buts_attribute(uiLayout *layout, bContext * /*C*/, Point static void node_shader_init_attribute(bNodeTree * /*ntree*/, bNode *node) { - NodeShaderAttribute *attr = MEM_cnew("NodeShaderAttribute"); + NodeShaderAttribute *attr = MEM_callocN("NodeShaderAttribute"); node->storage = attr; } diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_hair_principled.cc b/source/blender/nodes/shader/nodes/node_shader_bsdf_hair_principled.cc index c198bc2d887..12741251d20 100644 --- a/source/blender/nodes/shader/nodes/node_shader_bsdf_hair_principled.cc +++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_hair_principled.cc @@ -136,7 +136,7 @@ static void node_shader_buts_principled_hair(uiLayout *layout, bContext * /*C*/, /* Initialize custom properties. */ static void node_shader_init_hair_principled(bNodeTree * /*ntree*/, bNode *node) { - NodeShaderHairPrincipled *data = MEM_cnew(__func__); + NodeShaderHairPrincipled *data = MEM_callocN(__func__); data->model = SHD_PRINCIPLED_HAIR_CHIANG; data->parametrization = SHD_PRINCIPLED_HAIR_REFLECTANCE; diff --git a/source/blender/nodes/shader/nodes/node_shader_ies_light.cc b/source/blender/nodes/shader/nodes/node_shader_ies_light.cc index 23efbfb6225..215f136ec44 100644 --- a/source/blender/nodes/shader/nodes/node_shader_ies_light.cc +++ b/source/blender/nodes/shader/nodes/node_shader_ies_light.cc @@ -44,7 +44,7 @@ static void node_shader_buts_ies(uiLayout *layout, bContext * /*C*/, PointerRNA static void node_shader_init_tex_ies(bNodeTree * /*ntree*/, bNode *node) { - NodeShaderTexIES *tex = MEM_cnew("NodeShaderIESLight"); + NodeShaderTexIES *tex = MEM_callocN("NodeShaderIESLight"); node->storage = tex; } diff --git a/source/blender/nodes/shader/nodes/node_shader_map_range.cc b/source/blender/nodes/shader/nodes/node_shader_map_range.cc index e38d2a900df..5455052b89c 100644 --- a/source/blender/nodes/shader/nodes/node_shader_map_range.cc +++ b/source/blender/nodes/shader/nodes/node_shader_map_range.cc @@ -106,7 +106,7 @@ static void node_shader_update_map_range(bNodeTree *ntree, bNode *node) static void node_shader_init_map_range(bNodeTree * /*ntree*/, bNode *node) { - NodeMapRange *data = MEM_cnew(__func__); + NodeMapRange *data = MEM_callocN(__func__); data->clamp = 1; data->data_type = CD_PROP_FLOAT; data->interpolation_type = NODE_MAP_RANGE_LINEAR; diff --git a/source/blender/nodes/shader/nodes/node_shader_mix.cc b/source/blender/nodes/shader/nodes/node_shader_mix.cc index b5fb7f245ee..7093551c2de 100644 --- a/source/blender/nodes/shader/nodes/node_shader_mix.cc +++ b/source/blender/nodes/shader/nodes/node_shader_mix.cc @@ -277,7 +277,7 @@ static void node_mix_gather_link_searches(GatherLinkSearchOpParams ¶ms) static void node_mix_init(bNodeTree * /*tree*/, bNode *node) { - NodeShaderMix *data = MEM_cnew(__func__); + NodeShaderMix *data = MEM_callocN(__func__); data->data_type = SOCK_FLOAT; data->factor_mode = NODE_MIX_MODE_UNIFORM; data->clamp_factor = 1; diff --git a/source/blender/nodes/shader/nodes/node_shader_normal_map.cc b/source/blender/nodes/shader/nodes/node_shader_normal_map.cc index 96f7cebda33..197fabf8ea3 100644 --- a/source/blender/nodes/shader/nodes/node_shader_normal_map.cc +++ b/source/blender/nodes/shader/nodes/node_shader_normal_map.cc @@ -57,7 +57,7 @@ static void node_shader_buts_normal_map(uiLayout *layout, bContext *C, PointerRN static void node_shader_init_normal_map(bNodeTree * /*ntree*/, bNode *node) { - NodeShaderNormalMap *attr = MEM_cnew("NodeShaderNormalMap"); + NodeShaderNormalMap *attr = MEM_callocN("NodeShaderNormalMap"); node->storage = attr; } diff --git a/source/blender/nodes/shader/nodes/node_shader_output_aov.cc b/source/blender/nodes/shader/nodes/node_shader_output_aov.cc index 3f6c3a1b75a..6a5db737237 100644 --- a/source/blender/nodes/shader/nodes/node_shader_output_aov.cc +++ b/source/blender/nodes/shader/nodes/node_shader_output_aov.cc @@ -25,7 +25,7 @@ static void node_shader_buts_output_aov(uiLayout *layout, bContext * /*C*/, Poin static void node_shader_init_output_aov(bNodeTree * /*ntree*/, bNode *node) { - NodeShaderOutputAOV *aov = MEM_cnew("NodeShaderOutputAOV"); + NodeShaderOutputAOV *aov = MEM_callocN("NodeShaderOutputAOV"); node->storage = aov; } diff --git a/source/blender/nodes/shader/nodes/node_shader_script.cc b/source/blender/nodes/shader/nodes/node_shader_script.cc index 92e0e59c149..31c80f9a2d4 100644 --- a/source/blender/nodes/shader/nodes/node_shader_script.cc +++ b/source/blender/nodes/shader/nodes/node_shader_script.cc @@ -50,7 +50,7 @@ static void node_shader_buts_script_ex(uiLayout *layout, bContext *C, PointerRNA static void init(bNodeTree * /*ntree*/, bNode *node) { - NodeShaderScript *nss = MEM_cnew("shader script node"); + NodeShaderScript *nss = MEM_callocN("shader script node"); node->storage = nss; } diff --git a/source/blender/nodes/shader/nodes/node_shader_sepcomb_color.cc b/source/blender/nodes/shader/nodes/node_shader_sepcomb_color.cc index eef7790cf86..d7a74a35ede 100644 --- a/source/blender/nodes/shader/nodes/node_shader_sepcomb_color.cc +++ b/source/blender/nodes/shader/nodes/node_shader_sepcomb_color.cc @@ -11,7 +11,7 @@ static void node_combsep_color_init(bNodeTree * /*tree*/, bNode *node) { - NodeCombSepColor *data = MEM_cnew(__func__); + NodeCombSepColor *data = MEM_callocN(__func__); data->mode = NODE_COMBSEP_COLOR_RGB; node->storage = data; } diff --git a/source/blender/nodes/shader/nodes/node_shader_tangent.cc b/source/blender/nodes/shader/nodes/node_shader_tangent.cc index 64c26bc324f..63f21ea3568 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tangent.cc +++ b/source/blender/nodes/shader/nodes/node_shader_tangent.cc @@ -54,7 +54,7 @@ static void node_shader_buts_tangent(uiLayout *layout, bContext *C, PointerRNA * static void node_shader_init_tangent(bNodeTree * /*ntree*/, bNode *node) { - NodeShaderTangent *attr = MEM_cnew("NodeShaderTangent"); + NodeShaderTangent *attr = MEM_callocN("NodeShaderTangent"); attr->axis = SHD_TANGENT_AXIS_Z; node->storage = attr; } diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_brick.cc b/source/blender/nodes/shader/nodes/node_shader_tex_brick.cc index 428caec09cb..907eaba0cb3 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_brick.cc +++ b/source/blender/nodes/shader/nodes/node_shader_tex_brick.cc @@ -98,7 +98,7 @@ static void node_shader_buts_tex_brick(uiLayout *layout, bContext * /*C*/, Point static void node_shader_init_tex_brick(bNodeTree * /*ntree*/, bNode *node) { - NodeTexBrick *tex = MEM_cnew(__func__); + NodeTexBrick *tex = MEM_callocN(__func__); BKE_texture_mapping_default(&tex->base.tex_mapping, TEXMAP_TYPE_POINT); BKE_texture_colormapping_default(&tex->base.color_mapping); diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_checker.cc b/source/blender/nodes/shader/nodes/node_shader_tex_checker.cc index 39257fbd8cb..1f6c05a13b5 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_checker.cc +++ b/source/blender/nodes/shader/nodes/node_shader_tex_checker.cc @@ -36,7 +36,7 @@ static void sh_node_tex_checker_declare(NodeDeclarationBuilder &b) static void node_shader_init_tex_checker(bNodeTree * /*ntree*/, bNode *node) { - NodeTexChecker *tex = MEM_cnew(__func__); + NodeTexChecker *tex = MEM_callocN(__func__); BKE_texture_mapping_default(&tex->base.tex_mapping, TEXMAP_TYPE_POINT); BKE_texture_colormapping_default(&tex->base.color_mapping); diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_environment.cc b/source/blender/nodes/shader/nodes/node_shader_tex_environment.cc index 33eeea69b6d..7c907f54ff9 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_environment.cc +++ b/source/blender/nodes/shader/nodes/node_shader_tex_environment.cc @@ -23,7 +23,7 @@ static void node_declare(NodeDeclarationBuilder &b) static void node_shader_init_tex_environment(bNodeTree * /*ntree*/, bNode *node) { - NodeTexEnvironment *tex = MEM_cnew("NodeTexEnvironment"); + NodeTexEnvironment *tex = MEM_callocN("NodeTexEnvironment"); BKE_texture_mapping_default(&tex->base.tex_mapping, TEXMAP_TYPE_POINT); BKE_texture_colormapping_default(&tex->base.color_mapping); tex->projection = SHD_PROJ_EQUIRECTANGULAR; diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_gabor.cc b/source/blender/nodes/shader/nodes/node_shader_tex_gabor.cc index a3f1647dbe4..d2fba524b1f 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_gabor.cc +++ b/source/blender/nodes/shader/nodes/node_shader_tex_gabor.cc @@ -67,7 +67,7 @@ static void node_shader_buts_tex_gabor(uiLayout *layout, bContext * /*C*/, Point static void node_shader_init_tex_gabor(bNodeTree * /*ntree*/, bNode *node) { - NodeTexGabor *storage = MEM_cnew(__func__); + NodeTexGabor *storage = MEM_callocN(__func__); BKE_texture_mapping_default(&storage->base.tex_mapping, TEXMAP_TYPE_POINT); BKE_texture_colormapping_default(&storage->base.color_mapping); diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_gradient.cc b/source/blender/nodes/shader/nodes/node_shader_tex_gradient.cc index dbd82401272..c028534ff0e 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_gradient.cc +++ b/source/blender/nodes/shader/nodes/node_shader_tex_gradient.cc @@ -31,7 +31,7 @@ static void node_shader_buts_tex_gradient(uiLayout *layout, bContext * /*C*/, Po static void node_shader_init_tex_gradient(bNodeTree * /*ntree*/, bNode *node) { - NodeTexGradient *tex = MEM_cnew(__func__); + NodeTexGradient *tex = MEM_callocN(__func__); BKE_texture_mapping_default(&tex->base.tex_mapping, TEXMAP_TYPE_POINT); BKE_texture_colormapping_default(&tex->base.color_mapping); tex->gradient_type = SHD_BLEND_LINEAR; diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_image.cc b/source/blender/nodes/shader/nodes/node_shader_tex_image.cc index 3f4e1629b45..6a2a068c729 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_image.cc +++ b/source/blender/nodes/shader/nodes/node_shader_tex_image.cc @@ -25,7 +25,7 @@ static void sh_node_tex_image_declare(NodeDeclarationBuilder &b) static void node_shader_init_tex_image(bNodeTree * /*ntree*/, bNode *node) { - NodeTexImage *tex = MEM_cnew(__func__); + NodeTexImage *tex = MEM_callocN(__func__); BKE_texture_mapping_default(&tex->base.tex_mapping, TEXMAP_TYPE_POINT); BKE_texture_colormapping_default(&tex->base.color_mapping); BKE_imageuser_default(&tex->iuser); diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_magic.cc b/source/blender/nodes/shader/nodes/node_shader_tex_magic.cc index 1aa74ad603d..f5ac46fd714 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_magic.cc +++ b/source/blender/nodes/shader/nodes/node_shader_tex_magic.cc @@ -36,7 +36,7 @@ static void node_shader_buts_tex_magic(uiLayout *layout, bContext * /*C*/, Point static void node_shader_init_tex_magic(bNodeTree * /*ntree*/, bNode *node) { - NodeTexMagic *tex = MEM_cnew(__func__); + NodeTexMagic *tex = MEM_callocN(__func__); BKE_texture_mapping_default(&tex->base.tex_mapping, TEXMAP_TYPE_POINT); BKE_texture_colormapping_default(&tex->base.color_mapping); tex->depth = 2; diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_noise.cc b/source/blender/nodes/shader/nodes/node_shader_tex_noise.cc index a005d45630a..bff446aa01c 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_noise.cc +++ b/source/blender/nodes/shader/nodes/node_shader_tex_noise.cc @@ -82,7 +82,7 @@ static void node_shader_buts_tex_noise(uiLayout *layout, bContext * /*C*/, Point static void node_shader_init_tex_noise(bNodeTree * /*ntree*/, bNode *node) { - NodeTexNoise *tex = MEM_cnew(__func__); + NodeTexNoise *tex = MEM_callocN(__func__); BKE_texture_mapping_default(&tex->base.tex_mapping, TEXMAP_TYPE_POINT); BKE_texture_colormapping_default(&tex->base.color_mapping); tex->dimensions = 3; diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_sky.cc b/source/blender/nodes/shader/nodes/node_shader_tex_sky.cc index bfe284e66dd..6f3e06ea428 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_sky.cc +++ b/source/blender/nodes/shader/nodes/node_shader_tex_sky.cc @@ -70,7 +70,7 @@ static void node_shader_buts_tex_sky(uiLayout *layout, bContext *C, PointerRNA * static void node_shader_init_tex_sky(bNodeTree * /*ntree*/, bNode *node) { - NodeTexSky *tex = MEM_cnew("NodeTexSky"); + NodeTexSky *tex = MEM_callocN("NodeTexSky"); BKE_texture_mapping_default(&tex->base.tex_mapping, TEXMAP_TYPE_POINT); BKE_texture_colormapping_default(&tex->base.color_mapping); tex->sun_direction[0] = 0.0f; diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_voronoi.cc b/source/blender/nodes/shader/nodes/node_shader_tex_voronoi.cc index b54e58e0df1..0a5c318309c 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_voronoi.cc +++ b/source/blender/nodes/shader/nodes/node_shader_tex_voronoi.cc @@ -92,7 +92,7 @@ static void node_shader_buts_tex_voronoi(uiLayout *layout, bContext * /*C*/, Poi static void node_shader_init_tex_voronoi(bNodeTree * /*ntree*/, bNode *node) { - NodeTexVoronoi *tex = MEM_cnew(__func__); + NodeTexVoronoi *tex = MEM_callocN(__func__); BKE_texture_mapping_default(&tex->base.tex_mapping, TEXMAP_TYPE_POINT); BKE_texture_colormapping_default(&tex->base.color_mapping); tex->dimensions = 3; diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_wave.cc b/source/blender/nodes/shader/nodes/node_shader_tex_wave.cc index df2a68f6065..2b51ef853a3 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_wave.cc +++ b/source/blender/nodes/shader/nodes/node_shader_tex_wave.cc @@ -70,7 +70,7 @@ static void node_shader_buts_tex_wave(uiLayout *layout, bContext * /*C*/, Pointe static void node_shader_init_tex_wave(bNodeTree * /*ntree*/, bNode *node) { - NodeTexWave *tex = MEM_cnew(__func__); + NodeTexWave *tex = MEM_callocN(__func__); BKE_texture_mapping_default(&tex->base.tex_mapping, TEXMAP_TYPE_POINT); BKE_texture_colormapping_default(&tex->base.color_mapping); tex->wave_type = SHD_WAVE_BANDS; diff --git a/source/blender/nodes/shader/nodes/node_shader_uvmap.cc b/source/blender/nodes/shader/nodes/node_shader_uvmap.cc index f2318330a5f..46f46063ff2 100644 --- a/source/blender/nodes/shader/nodes/node_shader_uvmap.cc +++ b/source/blender/nodes/shader/nodes/node_shader_uvmap.cc @@ -49,7 +49,7 @@ static void node_shader_buts_uvmap(uiLayout *layout, bContext *C, PointerRNA *pt static void node_shader_init_uvmap(bNodeTree * /*ntree*/, bNode *node) { - NodeShaderUVMap *attr = MEM_cnew("NodeShaderUVMap"); + NodeShaderUVMap *attr = MEM_callocN("NodeShaderUVMap"); node->storage = attr; } diff --git a/source/blender/nodes/shader/nodes/node_shader_vector_transform.cc b/source/blender/nodes/shader/nodes/node_shader_vector_transform.cc index 55388e75fa4..4a046d4f0f4 100644 --- a/source/blender/nodes/shader/nodes/node_shader_vector_transform.cc +++ b/source/blender/nodes/shader/nodes/node_shader_vector_transform.cc @@ -38,7 +38,7 @@ static void node_shader_buts_vect_transform(uiLayout *layout, bContext * /*C*/, static void node_shader_init_vect_transform(bNodeTree * /*ntree*/, bNode *node) { - NodeShaderVectTransform *vect = MEM_cnew("NodeShaderVectTransform"); + NodeShaderVectTransform *vect = MEM_callocN("NodeShaderVectTransform"); /* Convert World into Object Space per default */ vect->convert_to = 1; diff --git a/source/blender/nodes/shader/nodes/node_shader_vertex_color.cc b/source/blender/nodes/shader/nodes/node_shader_vertex_color.cc index 1f815326df3..e1fad759cd6 100644 --- a/source/blender/nodes/shader/nodes/node_shader_vertex_color.cc +++ b/source/blender/nodes/shader/nodes/node_shader_vertex_color.cc @@ -43,7 +43,7 @@ static void node_shader_buts_vertex_color(uiLayout *layout, bContext *C, Pointer static void node_shader_init_vertex_color(bNodeTree * /*ntree*/, bNode *node) { - NodeShaderVertexColor *vertexColor = MEM_cnew("NodeShaderVertexColor"); + NodeShaderVertexColor *vertexColor = MEM_callocN("NodeShaderVertexColor"); node->storage = vertexColor; } diff --git a/source/blender/nodes/texture/node_texture_tree.cc b/source/blender/nodes/texture/node_texture_tree.cc index 51e7938c160..84cb859c4fd 100644 --- a/source/blender/nodes/texture/node_texture_tree.cc +++ b/source/blender/nodes/texture/node_texture_tree.cc @@ -167,7 +167,7 @@ bNodeThreadStack *ntreeGetThreadStack(bNodeTreeExec *exec, int thread) } if (!nts) { - nts = MEM_cnew("bNodeThreadStack"); + nts = MEM_callocN("bNodeThreadStack"); nts->stack = (bNodeStack *)MEM_dupallocN(exec->stack); nts->used = true; BLI_addtail(lb, nts); @@ -219,7 +219,7 @@ bNodeTreeExec *ntreeTexBeginExecTree_internal(bNodeExecContext *context, exec = ntree_exec_begin(context, ntree, parent_key); /* allocate the thread stack listbase array */ - exec->threadstack = MEM_cnew_array(BLENDER_MAX_THREADS, "thread stack array"); + exec->threadstack = MEM_calloc_arrayN(BLENDER_MAX_THREADS, "thread stack array"); LISTBASE_FOREACH (bNode *, node, &exec->nodetree->nodes) { node->runtime->need_exec = 1; diff --git a/source/blender/nodes/texture/node_texture_util.cc b/source/blender/nodes/texture/node_texture_util.cc index 9ac9e8cf6de..7cdd6612011 100644 --- a/source/blender/nodes/texture/node_texture_util.cc +++ b/source/blender/nodes/texture/node_texture_util.cc @@ -129,7 +129,7 @@ void tex_output(bNode *node, if (!out->data) { /* Freed in tex_end_exec (node.cc) */ - dg = MEM_cnew("tex delegate"); + dg = MEM_callocN("tex delegate"); out->data = dg; } else { diff --git a/source/blender/nodes/texture/nodes/node_texture_image.cc b/source/blender/nodes/texture/nodes/node_texture_image.cc index 851e31c48f0..fe758f230d5 100644 --- a/source/blender/nodes/texture/nodes/node_texture_image.cc +++ b/source/blender/nodes/texture/nodes/node_texture_image.cc @@ -86,7 +86,7 @@ static void exec(void *data, static void init(bNodeTree * /*ntree*/, bNode *node) { - ImageUser *iuser = MEM_cnew("node image user"); + ImageUser *iuser = MEM_callocN("node image user"); node->storage = iuser; iuser->sfra = 1; iuser->flag |= IMA_ANIM_ALWAYS; diff --git a/source/blender/nodes/texture/nodes/node_texture_output.cc b/source/blender/nodes/texture/nodes/node_texture_output.cc index 10c425e84aa..c581fb90d22 100644 --- a/source/blender/nodes/texture/nodes/node_texture_output.cc +++ b/source/blender/nodes/texture/nodes/node_texture_output.cc @@ -119,7 +119,7 @@ check_index: static void init(bNodeTree * /*ntree*/, bNode *node) { - TexNodeOutput *tno = MEM_cnew("TEX_output"); + TexNodeOutput *tno = MEM_callocN("TEX_output"); node->storage = tno; STRNCPY(tno->name, "Default"); diff --git a/source/blender/python/generic/idprop_py_ui_api.cc b/source/blender/python/generic/idprop_py_ui_api.cc index 0c823e66215..525123f1cc9 100644 --- a/source/blender/python/generic/idprop_py_ui_api.cc +++ b/source/blender/python/generic/idprop_py_ui_api.cc @@ -138,7 +138,7 @@ static IDPropertyUIDataEnumItem *idprop_enum_items_from_py(PyObject *seq_fast, i PyObject **seq_fast_items = PySequence_Fast_ITEMS(seq_fast); int i; - items = MEM_cnew_array(seq_len, __func__); + items = MEM_calloc_arrayN(seq_len, __func__); r_items_num = seq_len; for (i = 0; i < seq_len; i++) { diff --git a/source/blender/render/intern/bake.cc b/source/blender/render/intern/bake.cc index 3692a217280..eba361303eb 100644 --- a/source/blender/render/intern/bake.cc +++ b/source/blender/render/intern/bake.cc @@ -567,7 +567,7 @@ bool RE_bake_pixels_populate_from_objects(Mesh *me_low, TriTessFace **tris_high; /* Assume all low-poly tessfaces can be quads. */ - tris_high = MEM_cnew_array(highpoly_num, "MVerts Highpoly Mesh Array"); + tris_high = MEM_calloc_arrayN(highpoly_num, "MVerts Highpoly Mesh Array"); /* Assume all high-poly tessfaces are triangles. */ me_highpoly = static_cast( @@ -731,7 +731,7 @@ void RE_bake_pixels_populate(Mesh *mesh, BakeDataZSpan bd; bd.pixel_array = pixel_array; - bd.zspan = MEM_cnew_array(targets->images_num, "bake zspan"); + bd.zspan = MEM_calloc_arrayN(targets->images_num, "bake zspan"); /* initialize all pixel arrays so we know which ones are 'blank' */ for (int i = 0; i < pixels_num; i++) { diff --git a/source/blender/render/intern/engine.cc b/source/blender/render/intern/engine.cc index 67acca332ba..8caddfd2275 100644 --- a/source/blender/render/intern/engine.cc +++ b/source/blender/render/intern/engine.cc @@ -121,7 +121,7 @@ bool RE_engine_supports_alembic_procedural(const RenderEngineType *render_type, RenderEngine *RE_engine_create(RenderEngineType *type) { - RenderEngine *engine = MEM_cnew("RenderEngine"); + RenderEngine *engine = MEM_callocN("RenderEngine"); engine->type = type; BLI_mutex_init(&engine->update_render_passes_mutex); @@ -192,7 +192,7 @@ static RenderResult *render_result_from_bake( } /* Create render result with specified size. */ - RenderResult *rr = MEM_cnew(__func__); + RenderResult *rr = MEM_callocN(__func__); rr->rectx = w; rr->recty = h; @@ -202,7 +202,7 @@ static RenderResult *render_result_from_bake( rr->tilerect.ymax = y + h; /* Add single baking render layer. */ - RenderLayer *rl = MEM_cnew("bake render layer"); + RenderLayer *rl = MEM_callocN("bake render layer"); STRNCPY(rl->name, layername); rl->rectx = w; rl->recty = h; diff --git a/source/blender/render/intern/multires_bake.cc b/source/blender/render/intern/multires_bake.cc index 0857431ca00..951297b24f4 100644 --- a/source/blender/render/intern/multires_bake.cc +++ b/source/blender/render/intern/multires_bake.cc @@ -817,11 +817,11 @@ static void *init_heights_data(MultiresBakeRender *bkr, ImBuf *ibuf) BakeImBufuserData *userdata = static_cast(ibuf->userdata); if (userdata->displacement_buffer == nullptr) { - userdata->displacement_buffer = MEM_cnew_array(ibuf->x * ibuf->y, - "MultiresBake heights"); + userdata->displacement_buffer = MEM_calloc_arrayN(ibuf->x * ibuf->y, + "MultiresBake heights"); } - height_data = MEM_cnew("MultiresBake heightData"); + height_data = MEM_callocN("MultiresBake heightData"); height_data->heights = userdata->displacement_buffer; @@ -965,7 +965,7 @@ static void *init_normal_data(MultiresBakeRender *bkr, ImBuf * /*ibuf*/) MNormalBakeData *normal_data; DerivedMesh *lodm = bkr->lores_dm; - normal_data = MEM_cnew("MultiresBake normalData"); + normal_data = MEM_callocN("MultiresBake normalData"); normal_data->orig_index_mp_to_orig = static_cast( lodm->getPolyDataArray(lodm, CD_ORIGINDEX)); @@ -1508,8 +1508,9 @@ static void bake_images(MultiresBakeRender *bkr, MultiresBakeResult *result) ImBuf *ibuf = BKE_image_acquire_ibuf(ima, &iuser, nullptr); if (ibuf->x > 0 && ibuf->y > 0) { - BakeImBufuserData *userdata = MEM_cnew("MultiresBake userdata"); - userdata->mask_buffer = MEM_cnew_array(ibuf->y * ibuf->x, "MultiresBake imbuf mask"); + BakeImBufuserData *userdata = MEM_callocN("MultiresBake userdata"); + userdata->mask_buffer = MEM_calloc_arrayN(ibuf->y * ibuf->x, + "MultiresBake imbuf mask"); ibuf->userdata = userdata; switch (bkr->mode) { diff --git a/source/blender/render/intern/pipeline.cc b/source/blender/render/intern/pipeline.cc index 89f9a949dc0..1018d861966 100644 --- a/source/blender/render/intern/pipeline.cc +++ b/source/blender/render/intern/pipeline.cc @@ -918,7 +918,7 @@ void RE_InitState(Render *re, /* make empty render result, so display callbacks can initialize */ render_result_free(re->result); - re->result = MEM_cnew("new render result"); + re->result = MEM_callocN("new render result"); re->result->rectx = re->rectx; re->result->recty = re->recty; render_result_view_new(re->result, ""); @@ -2898,7 +2898,7 @@ RenderPass *RE_create_gp_pass(RenderResult *rr, const char *layername, const cha RenderLayer *rl = RE_GetRenderLayer(rr, layername); /* only create render layer if not exist */ if (!rl) { - rl = MEM_cnew(layername); + rl = MEM_callocN(layername); BLI_addtail(&rr->layers, rl); STRNCPY(rl->name, layername); rl->layflag = SCE_LAY_SOLID; diff --git a/source/blender/render/intern/render_result.cc b/source/blender/render/intern/render_result.cc index 37dc863de34..ccece02c12d 100644 --- a/source/blender/render/intern/render_result.cc +++ b/source/blender/render/intern/render_result.cc @@ -143,7 +143,7 @@ void render_result_views_shallowcopy(RenderResult *dst, RenderResult *src) LISTBASE_FOREACH (RenderView *, rview, &src->views) { RenderView *rv; - rv = MEM_cnew("new render view"); + rv = MEM_callocN("new render view"); BLI_addtail(&dst->views, rv); STRNCPY(rv->name, rview->name); @@ -206,7 +206,7 @@ static void render_layer_allocate_pass(RenderResult *rr, RenderPass *rp) * channels. */ const size_t rectsize = size_t(rr->rectx) * rr->recty * rp->channels; - float *buffer_data = MEM_cnew_array(rectsize, rp->name); + float *buffer_data = MEM_calloc_arrayN(rectsize, rp->name); rp->ibuf = IMB_allocImBuf(rr->rectx, rr->recty, get_num_planes_for_pass_ibuf(*rp), 0); rp->ibuf->channels = rp->channels; @@ -235,7 +235,7 @@ RenderPass *render_layer_add_pass(RenderResult *rr, const bool allocate) { const int view_id = BLI_findstringindex(&rr->views, viewname, offsetof(RenderView, name)); - RenderPass *rpass = MEM_cnew(name); + RenderPass *rpass = MEM_callocN(name); rpass->channels = channels; rpass->rectx = rl->rectx; @@ -287,7 +287,7 @@ RenderResult *render_result_new(Render *re, return nullptr; } - rr = MEM_cnew("new render result"); + rr = MEM_callocN("new render result"); rr->rectx = rectx; rr->recty = recty; @@ -309,7 +309,7 @@ RenderResult *render_result_new(Render *re, } } - rl = MEM_cnew("new render layer"); + rl = MEM_callocN("new render layer"); BLI_addtail(&rr->layers, rl); STRNCPY(rl->name, view_layer->name); @@ -337,7 +337,7 @@ RenderResult *render_result_new(Render *re, /* Preview-render doesn't do layers, so we make a default one. */ if (BLI_listbase_is_empty(&rr->layers) && !(layername && layername[0])) { - rl = MEM_cnew("new render layer"); + rl = MEM_callocN("new render layer"); BLI_addtail(&rr->layers, rl); rl->rectx = rectx; @@ -575,7 +575,7 @@ static void *ml_addlayer_cb(void *base, const char *str) { RenderResult *rr = static_cast(base); - RenderLayer *rl = MEM_cnew("new render layer"); + RenderLayer *rl = MEM_callocN("new render layer"); BLI_addtail(&rr->layers, rl); BLI_strncpy(rl->name, str, EXR_LAY_MAXNAME); @@ -592,7 +592,7 @@ static void ml_addpass_cb(void *base, { RenderResult *rr = static_cast(base); RenderLayer *rl = static_cast(lay); - RenderPass *rpass = MEM_cnew("loaded pass"); + RenderPass *rpass = MEM_callocN("loaded pass"); BLI_addtail(&rl->passes, rpass); rpass->rectx = rr->rectx; @@ -621,7 +621,7 @@ static void *ml_addview_cb(void *base, const char *str) { RenderResult *rr = static_cast(base); - RenderView *rv = MEM_cnew("new render view"); + RenderView *rv = MEM_callocN("new render view"); STRNCPY(rv->name, str); /* For stereo drawing we need to ensure: @@ -707,7 +707,7 @@ static int order_render_passes(const void *a, const void *b) RenderResult *render_result_new_from_exr( void *exrhandle, const char *colorspace, bool predivide, int rectx, int recty) { - RenderResult *rr = MEM_cnew(__func__); + RenderResult *rr = MEM_callocN(__func__); const char *to_colorspace = IMB_colormanagement_role_colorspace_name_get( COLOR_ROLE_SCENE_LINEAR); const char *data_colorspace = IMB_colormanagement_role_colorspace_name_get(COLOR_ROLE_DATA); @@ -747,7 +747,7 @@ RenderResult *render_result_new_from_exr( void render_result_view_new(RenderResult *rr, const char *viewname) { - RenderView *rv = MEM_cnew("new render view"); + RenderView *rv = MEM_callocN("new render view"); BLI_addtail(&rr->views, rv); STRNCPY(rv->name, viewname); } @@ -1185,7 +1185,7 @@ void render_result_rect_fill_zero(RenderResult *rr, const int view_id) ImBuf *ibuf = RE_RenderViewEnsureImBuf(rr, rv); if (!ibuf->float_buffer.data && !ibuf->byte_buffer.data) { - uint8_t *data = MEM_cnew_array(4 * rr->rectx * rr->recty, "render_seq rect"); + uint8_t *data = MEM_calloc_arrayN(4 * rr->rectx * rr->recty, "render_seq rect"); IMB_assign_byte_buffer(ibuf, data, IB_TAKE_OWNERSHIP); return; } @@ -1295,7 +1295,7 @@ RenderView *RE_RenderViewGetByName(RenderResult *rr, const char *viewname) static RenderPass *duplicate_render_pass(RenderPass *rpass) { - RenderPass *new_rpass = MEM_cnew("new render pass", *rpass); + RenderPass *new_rpass = MEM_dupallocN("new render pass", *rpass); new_rpass->next = new_rpass->prev = nullptr; new_rpass->ibuf = IMB_dupImBuf(rpass->ibuf); @@ -1305,7 +1305,7 @@ static RenderPass *duplicate_render_pass(RenderPass *rpass) static RenderLayer *duplicate_render_layer(RenderLayer *rl) { - RenderLayer *new_rl = MEM_cnew("new render layer", *rl); + RenderLayer *new_rl = MEM_dupallocN("new render layer", *rl); new_rl->next = new_rl->prev = nullptr; new_rl->passes.first = new_rl->passes.last = nullptr; new_rl->exrhandle = nullptr; @@ -1318,7 +1318,7 @@ static RenderLayer *duplicate_render_layer(RenderLayer *rl) static RenderView *duplicate_render_view(RenderView *rview) { - RenderView *new_rview = MEM_cnew("new render view", *rview); + RenderView *new_rview = MEM_dupallocN("new render view", *rview); new_rview->ibuf = IMB_dupImBuf(rview->ibuf); @@ -1327,7 +1327,7 @@ static RenderView *duplicate_render_view(RenderView *rview) RenderResult *RE_DuplicateRenderResult(RenderResult *rr) { - RenderResult *new_rr = MEM_cnew("new duplicated render result", *rr); + RenderResult *new_rr = MEM_dupallocN("new duplicated render result", *rr); new_rr->next = new_rr->prev = nullptr; new_rr->layers.first = new_rr->layers.last = nullptr; new_rr->views.first = new_rr->views.last = nullptr; diff --git a/source/blender/sequencer/intern/sound.cc b/source/blender/sequencer/intern/sound.cc index 7ccb28b77a0..2421dfb6b81 100644 --- a/source/blender/sequencer/intern/sound.cc +++ b/source/blender/sequencer/intern/sound.cc @@ -166,7 +166,7 @@ EQCurveMappingData *SEQ_sound_equalizer_add(SoundEqualizerModifierData *semd, minX = 0.0; } /* It's the same as #BKE_curvemapping_add, but changing the name. */ - eqcmd = MEM_cnew("Equalizer"); + eqcmd = MEM_callocN("Equalizer"); BKE_curvemapping_set_defaults(&eqcmd->curve_mapping, 1, /* Total. */ minX, diff --git a/source/blender/sequencer/intern/strip_connect.cc b/source/blender/sequencer/intern/strip_connect.cc index dda9b34a4d9..2cc1c2e27c7 100644 --- a/source/blender/sequencer/intern/strip_connect.cc +++ b/source/blender/sequencer/intern/strip_connect.cc @@ -27,7 +27,7 @@ static void strip_connections_free(Strip *strip) void SEQ_connections_duplicate(ListBase *connections_dst, ListBase *connections_src) { LISTBASE_FOREACH (StripConnection *, con, connections_src) { - StripConnection *con_duplicate = MEM_cnew(__func__, *con); + StripConnection *con_duplicate = MEM_dupallocN(__func__, *con); BLI_addtail(connections_dst, con_duplicate); } } @@ -107,7 +107,7 @@ void SEQ_connect(blender::VectorSet &strip_list) if (seq1 == seq2) { continue; } - StripConnection *con = MEM_cnew("stripconnection"); + StripConnection *con = MEM_callocN("stripconnection"); con->strip_ref = seq2; BLI_addtail(&seq1->connections, con); } diff --git a/source/blender/simulation/intern/SIM_mass_spring.cc b/source/blender/simulation/intern/SIM_mass_spring.cc index 165559dbee5..2a9593d3e6e 100644 --- a/source/blender/simulation/intern/SIM_mass_spring.cc +++ b/source/blender/simulation/intern/SIM_mass_spring.cc @@ -1280,7 +1280,7 @@ int SIM_cloth_solve( BKE_sim_debug_data_clear_category("collision"); if (!clmd->solver_result) { - clmd->solver_result = MEM_cnew("cloth solver result"); + clmd->solver_result = MEM_callocN("cloth solver result"); } cloth_clear_result(clmd); diff --git a/source/blender/simulation/intern/hair_volume.cc b/source/blender/simulation/intern/hair_volume.cc index b9b42865d20..12583ad5f23 100644 --- a/source/blender/simulation/intern/hair_volume.cc +++ b/source/blender/simulation/intern/hair_volume.cc @@ -1141,7 +1141,7 @@ HairGrid *SIM_hair_volume_create_vertex_grid(float cellsize, } size = hair_grid_size(res); - grid = MEM_cnew("hair grid"); + grid = MEM_callocN("hair grid"); grid->res[0] = res[0]; grid->res[1] = res[1]; grid->res[2] = res[2]; diff --git a/source/blender/windowmanager/intern/wm_dragdrop.cc b/source/blender/windowmanager/intern/wm_dragdrop.cc index 261041cb2ed..09c355a6934 100644 --- a/source/blender/windowmanager/intern/wm_dragdrop.cc +++ b/source/blender/windowmanager/intern/wm_dragdrop.cc @@ -97,7 +97,7 @@ ListBase *WM_dropboxmap_find(const char *idname, int spaceid, int regionid) } } - wmDropBoxMap *dm = MEM_cnew(__func__); + wmDropBoxMap *dm = MEM_callocN(__func__); STRNCPY_UTF8(dm->idname, idname); dm->spaceid = spaceid; dm->regionid = regionid; @@ -119,7 +119,7 @@ wmDropBox *WM_dropbox_add(ListBase *lb, return nullptr; } - wmDropBox *drop = MEM_cnew(__func__); + wmDropBox *drop = MEM_callocN(__func__); drop->poll = poll; drop->copy = copy; drop->cancel = cancel; @@ -617,7 +617,7 @@ void WM_drag_add_local_ID(wmDrag *drag, ID *id, ID *from_parent) } /* Add to list. */ - wmDragID *drag_id = MEM_cnew(__func__); + wmDragID *drag_id = MEM_callocN(__func__); drag_id->id = id; drag_id->from_parent = from_parent; BLI_addtail(&drag->ids, drag_id); @@ -826,7 +826,7 @@ void WM_drag_add_asset_list_item(wmDrag *drag, /* No guarantee that the same asset isn't added twice. */ /* Add to list. */ - wmDragAssetListItem *drag_asset = MEM_cnew(__func__); + wmDragAssetListItem *drag_asset = MEM_callocN(__func__); ID *local_id = asset->local_id(); if (local_id) { drag_asset->is_external = false; diff --git a/source/blender/windowmanager/intern/wm_event_system.cc b/source/blender/windowmanager/intern/wm_event_system.cc index ae58b6c3b85..fffead3bf5a 100644 --- a/source/blender/windowmanager/intern/wm_event_system.cc +++ b/source/blender/windowmanager/intern/wm_event_system.cc @@ -181,7 +181,7 @@ wmEvent *wm_event_add_ex(wmWindow *win, const wmEvent *event_to_add, const wmEvent *event_to_add_after) { - wmEvent *event = MEM_cnew(__func__); + wmEvent *event = MEM_callocN(__func__); *event = *event_to_add; @@ -386,7 +386,7 @@ void WM_event_add_notifier_ex(wmWindowManager *wm, const wmWindow *win, uint typ if (BLI_gset_ensure_p_ex(wm->notifier_queue_set, ¬e_test, ¬e_p)) { return; } - wmNotifier *note = MEM_cnew(__func__); + wmNotifier *note = MEM_callocN(__func__); *note = note_test; *note_p = note; BLI_addtail(&wm->notifier_queue, note); @@ -982,7 +982,7 @@ void WM_report_banner_show(wmWindowManager *wm, wmWindow *win) /* Records time since last report was added. */ wm_reports->reporttimer = WM_event_timer_add(wm, win, TIMERREPORT, 0.05); - ReportTimerInfo *rti = MEM_cnew(__func__); + ReportTimerInfo *rti = MEM_callocN(__func__); wm_reports->reporttimer->customdata = rti; } @@ -1449,7 +1449,7 @@ static wmOperator *wm_operator_create(wmWindowManager *wm, { /* Operator-type names are static still (for C++ defined operators). * Pass to allocation name for debugging. */ - wmOperator *op = MEM_cnew(ot->rna_ext.srna ? __func__ : ot->idname); + wmOperator *op = MEM_callocN(ot->rna_ext.srna ? __func__ : ot->idname); /* Adding new operator could be function, only happens here now. */ op->type = ot; @@ -1470,7 +1470,7 @@ static wmOperator *wm_operator_create(wmWindowManager *wm, op->reports = reports; /* Must be initialized already. */ } else { - op->reports = MEM_cnew("wmOperatorReportList"); + op->reports = MEM_callocN("wmOperatorReportList"); BKE_reports_init(op->reports, RPT_STORE | RPT_FREE); } @@ -4408,7 +4408,7 @@ void WM_event_add_fileselect(bContext *C, wmOperator *op) root_region = CTX_wm_region(C); } - wmEventHandler_Op *handler = MEM_cnew(__func__); + wmEventHandler_Op *handler = MEM_callocN(__func__); handler->head.type = WM_HANDLER_TYPE_OP; handler->is_fileselect = true; @@ -4501,7 +4501,7 @@ wmEventHandler_Op *WM_event_add_modal_handler_ex(wmWindow *win, ARegion *region, wmOperator *op) { - wmEventHandler_Op *handler = MEM_cnew(__func__); + wmEventHandler_Op *handler = MEM_callocN(__func__); handler->head.type = WM_HANDLER_TYPE_OP; /* Operator was part of macro. */ @@ -4628,7 +4628,7 @@ wmEventHandler_Keymap *WM_event_add_keymap_handler(ListBase *handlers, wmKeyMap } } - wmEventHandler_Keymap *handler = MEM_cnew(__func__); + wmEventHandler_Keymap *handler = MEM_callocN(__func__); handler->head.type = WM_HANDLER_TYPE_KEYMAP; BLI_addtail(handlers, handler); handler->keymap = keymap; @@ -4776,7 +4776,7 @@ wmEventHandler_Keymap *WM_event_add_keymap_handler_dynamic( } } - wmEventHandler_Keymap *handler = MEM_cnew(__func__); + wmEventHandler_Keymap *handler = MEM_callocN(__func__); handler->head.type = WM_HANDLER_TYPE_KEYMAP; BLI_addtail(handlers, handler); handler->dynamic.keymap_fn = keymap_fn; @@ -4791,7 +4791,7 @@ wmEventHandler_Keymap *WM_event_add_keymap_handler_priority(ListBase *handlers, { WM_event_remove_keymap_handler(handlers, keymap); - wmEventHandler_Keymap *handler = MEM_cnew("event key-map handler"); + wmEventHandler_Keymap *handler = MEM_callocN("event key-map handler"); handler->head.type = WM_HANDLER_TYPE_KEYMAP; BLI_addhead(handlers, handler); @@ -4899,7 +4899,7 @@ wmEventHandler_UI *WM_event_add_ui_handler(const bContext *C, void *user_data, const eWM_EventHandlerFlag flag) { - wmEventHandler_UI *handler = MEM_cnew(__func__); + wmEventHandler_UI *handler = MEM_callocN(__func__); handler->head.type = WM_HANDLER_TYPE_UI; handler->handle_fn = handle_fn; handler->remove_fn = remove_fn; @@ -4978,7 +4978,7 @@ wmEventHandler_Dropbox *WM_event_add_dropbox_handler(ListBase *handlers, ListBas } } - wmEventHandler_Dropbox *handler = MEM_cnew(__func__); + wmEventHandler_Dropbox *handler = MEM_callocN(__func__); handler->head.type = WM_HANDLER_TYPE_DROPBOX; /* Dropbox stored static, no free or copy. */ @@ -5453,7 +5453,7 @@ void wm_tablet_data_from_ghost(const GHOST_TabletData *tablet_data, wmTabletData /* Adds custom-data to event. */ static void attach_ndof_data(wmEvent *event, const GHOST_TEventNDOFMotionData *ghost) { - wmNDOFMotionData *data = MEM_cnew("Custom-data NDOF"); + wmNDOFMotionData *data = MEM_callocN("Custom-data NDOF"); const float ts = U.ndof_sensitivity; const float rs = U.ndof_orbit_sensitivity; diff --git a/source/blender/windowmanager/intern/wm_files.cc b/source/blender/windowmanager/intern/wm_files.cc index 9de63d8a7d9..1690a9cf853 100644 --- a/source/blender/windowmanager/intern/wm_files.cc +++ b/source/blender/windowmanager/intern/wm_files.cc @@ -212,7 +212,7 @@ static BlendFileReadWMSetupData *wm_file_read_setup_wm_init(bContext *C, using namespace blender; BLI_assert(BLI_listbase_count_at_most(&bmain->wm, 2) <= 1); wmWindowManager *wm = static_cast(bmain->wm.first); - BlendFileReadWMSetupData *wm_setup_data = MEM_cnew(__func__); + BlendFileReadWMSetupData *wm_setup_data = MEM_callocN(__func__); wm_setup_data->is_read_homefile = is_read_homefile; /* This info is not always known yet when this function is called. */ wm_setup_data->is_factory_startup = false; @@ -4481,7 +4481,7 @@ static uiBlock *block_create_save_file_overwrite_dialog(bContext *C, ARegion *re void wm_save_file_overwrite_dialog(bContext *C, wmOperator *op) { if (!UI_popup_block_name_exists(CTX_wm_screen(C), save_file_overwrite_dialog_name)) { - wmGenericCallback *callback = MEM_cnew(__func__); + wmGenericCallback *callback = MEM_callocN(__func__); callback->exec = nullptr; callback->user_data = IDP_CopyProperty(op->properties); callback->free_user_data = wm_free_operator_properties_callback; @@ -4820,7 +4820,7 @@ bool wm_operator_close_file_dialog_if_needed(bContext *C, if (U.uiflag & USER_SAVE_PROMPT && wm_file_or_session_data_has_unsaved_changes(CTX_data_main(C), CTX_wm_manager(C))) { - wmGenericCallback *callback = MEM_cnew(__func__); + wmGenericCallback *callback = MEM_callocN(__func__); callback->exec = post_action_fn; callback->user_data = IDP_CopyProperty(op->properties); callback->free_user_data = wm_free_operator_properties_callback; diff --git a/source/blender/windowmanager/intern/wm_jobs.cc b/source/blender/windowmanager/intern/wm_jobs.cc index a9515278492..77e2006f81a 100644 --- a/source/blender/windowmanager/intern/wm_jobs.cc +++ b/source/blender/windowmanager/intern/wm_jobs.cc @@ -209,7 +209,7 @@ wmJob *WM_jobs_get(wmWindowManager *wm, wm_job->main_thread_mutex = BLI_ticket_mutex_alloc(); WM_job_main_thread_lock_acquire(wm_job); - wm_job->worker_status.reports = MEM_cnew(__func__); + wm_job->worker_status.reports = MEM_callocN(__func__); BKE_reports_init(wm_job->worker_status.reports, RPT_STORE | RPT_PRINT); BKE_report_print_level_set(wm_job->worker_status.reports, RPT_WARNING); } diff --git a/source/blender/windowmanager/intern/wm_toolsystem.cc b/source/blender/windowmanager/intern/wm_toolsystem.cc index e14b5fdd2c8..d0cc3d909f7 100644 --- a/source/blender/windowmanager/intern/wm_toolsystem.cc +++ b/source/blender/windowmanager/intern/wm_toolsystem.cc @@ -269,7 +269,7 @@ static void toolsystem_brush_type_binding_update(Paint *paint, } /* Add new reference. */ else { - NamedBrushAssetReference *new_brush_ref = MEM_cnew(__func__); + NamedBrushAssetReference *new_brush_ref = MEM_callocN(__func__); new_brush_ref->name = BLI_strdup(brush_type_name); new_brush_ref->brush_asset_reference = MEM_new( diff --git a/source/blender/windowmanager/message_bus/intern/wm_message_bus_static.cc b/source/blender/windowmanager/message_bus/intern/wm_message_bus_static.cc index f766d52ab03..3f1799c51f8 100644 --- a/source/blender/windowmanager/message_bus/intern/wm_message_bus_static.cc +++ b/source/blender/windowmanager/message_bus/intern/wm_message_bus_static.cc @@ -38,7 +38,7 @@ static bool wm_msg_static_gset_cmp(const void *key_a_p, const void *key_b_p) static void *wm_msg_static_gset_key_duplicate(const void *key_p) { const wmMsgSubscribeKey *key_src = static_cast(key_p); - return MEM_cnew(__func__, *key_src); + return MEM_dupallocN(__func__, *key_src); } static void wm_msg_static_gset_key_free(void *key_p) {