DNA: Use C++ default member initialization

The default values were moved from DNA_*_defaults.h to the struct
definitions themselves. All members without default values were zero
initialized, so that they can be safely allocated with MEM_new.

This simplifies setting default values, and resolves the last major
blocker to switch all code in source/blender to C++.

A few types do not have default initializers:
* DNA_listBase.h, DNA_vec_types.h: Used in many structs outside DNA.
* DNA_meshdata_types, DNA_particle_types.h, DNA_curve_types.h: Avoid
  performance impact for attribute allocations.
* DNA_theme_types.h: Still used by C code in userdef_default_theme.c

Also:
* Change DNA_DEPRECATED to use C++ style [[deprecated]] compatible with
  these changes.
* Remove typedef from structs now that it's C++.
* Add DNA_DEFINE_CXX_METHODS to various structs to silence deprecation
  warnings on copy.
* DNA_defaults.h no longer exists, as regular constructors now provide
  acces to the defaults. For RNA, a new dna_defaults.cc is auto
  generated to initialize the default for each property based on DNA.

This then also required changes in other parts of the code:
* Change MEM_callocN and MEM_dupallocN to MEM_new_for_free and
  MEM_new_array_for_free for DNA structs.
* Remove usage of DNA_defaults.h, rely on constructor.
* Use dna::shallow_copy to silence deprecation warnings.
* Add INIT_DEFAULT_STRUCT_AFTER to replace MEMCPY_STRUCT_AFTER in most
  most cases, asserting if it's either zero or default initialized
  already.

Ref #139113

Pull Request: https://projects.blender.org/blender/blender/pulls/134531
This commit is contained in:
Brecht Van Lommel 2025-12-08 05:59:33 +01:00
parent 82788b3f13
commit 9550baa99a
659 changed files with 11902 additions and 16537 deletions

View file

@ -1,258 +0,0 @@
/* SPDX-FileCopyrightText: 2019-2023 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
/* Preferences Data File 'U_default'. */
/* For constants. */
#include "BLI_math_constants.h"
#include "DNA_ID.h"
#include "DNA_anim_enums.h"
#include "DNA_curve_enums.h"
#include "DNA_space_enums.h"
#include "BKE_blender_version.h"
#include "GPU_platform_backend_enum.h"
#include "BLO_userdef_default.h" /* own include */
const UserDef U_default = {
.versionfile = BLENDER_FILE_VERSION,
.subversionfile = BLENDER_FILE_SUBVERSION,
.flag = (USER_AUTOSAVE | USER_TOOLTIPS | USER_RELPATHS | USER_RELEASECONFIRM |
USER_SCRIPT_AUTOEXEC_DISABLE | USER_NONEGFRAMES | USER_FILECOMPRESS),
.dupflag = USER_DUP_MESH | USER_DUP_CURVE | USER_DUP_SURF | USER_DUP_LATTICE | USER_DUP_FONT |
USER_DUP_MBALL | USER_DUP_LAMP | USER_DUP_ARM | USER_DUP_CAMERA | USER_DUP_SPEAKER |
USER_DUP_ACT | USER_DUP_LIGHTPROBE | USER_DUP_GPENCIL | USER_DUP_CURVES |
USER_DUP_POINTCLOUD,
.pref_flag = USER_PREF_FLAG_SAVE,
.savetime = 2,
.tempdir = "",
/* Overwritten by #BKE_appdir_font_folder_default(..)
* unless the system font's cannot be found. */
.fontdir = "//",
.renderdir = "//",
.render_cachedir = "",
.textudir = "//",
.script_directories = {NULL, NULL},
.sounddir = "//",
.i18ndir = "",
.image_editor = "",
.text_editor = "",
.text_editor_args = "",
.anim_player = "",
.anim_player_preset = 0,
.v2d_min_gridsize = 45,
.timecode_style = USER_TIMECODE_MINIMAL,
.versions = 1,
.dbl_click_time = 350,
.mini_axis_type = USER_MINI_AXIS_TYPE_GIZMO,
.uiflag = (USER_FILTERFILEEXTS | USER_DRAWVIEWINFO | USER_PLAINMENUS |
USER_LOCK_CURSOR_ADJUST | USER_DEPTH_CURSOR | USER_AUTOPERSP |
USER_NODE_AUTO_OFFSET | USER_GLOBALUNDO | USER_SHOW_GIZMO_NAVIGATE |
USER_SHOW_VIEWPORTNAME | USER_SHOW_FPS | USER_CONTINUOUS_MOUSE | USER_SAVE_PROMPT),
.uiflag2 = USER_REGION_OVERLAP,
.gpu_flag = USER_GPU_FLAG_OVERLAY_SMOOTH_WIRE | USER_GPU_FLAG_SUBDIVISION_EVALUATION,
.app_flag = 0,
/** Default language of English (1), not Automatic (0). */
.language = 1,
.viewzoom = USER_ZOOM_DOLLY,
.mixbufsize = 2048,
.audiodevice = 0,
.audiorate = 48000,
.audioformat = 0x24,
.audiochannels = 2,
.ui_scale = 1.0,
.ui_line_width = 0,
.border_width = 2,
/** Default so DPI is detected automatically. */
.dpi = 0,
.scale_factor = 0.0,
.inv_scale_factor = 0.0, /* run-time. */
.pixelsize = 1,
.virtual_pixel = 0,
.scrollback = 256,
.node_margin = 40,
.node_preview_res = 120,
.transopts = USER_TR_TOOLTIPS | USER_TR_IFACE | USER_TR_REPORTS | USER_TR_NEWDATANAME,
.menuthreshold1 = 5,
.menuthreshold2 = 2,
.app_template = "",
/** Initialized by #ui::theme::init_default. */
.themes = {NULL},
/** Initialized by #style_init. */
.uifonts = {NULL},
.uistyles = {NULL},
.user_keymaps = {NULL},
.user_keyconfig_prefs = {NULL},
/** Initialized by #BKE_blendfile_userdef_from_defaults. */
.addons = {NULL},
.autoexec_paths = {NULL},
.user_menus = {NULL},
.keyconfigstr = "Blender",
.network_timeout = 10,
.network_connection_limit = 5,
.undosteps = 32,
.undomemory = 0,
.gp_manhattandist = 1,
.gp_euclideandist = 2,
.gp_eraser = 25,
.gp_settings = 0,
.playback_fps_samples = 8,
#ifdef __APPLE__
.gpu_backend = GPU_BACKEND_METAL,
#else
.gpu_backend = GPU_BACKEND_OPENGL,
#endif
.gpu_shader_workers = 0,
.shader_compilation_method = USER_SHADER_COMPILE_THREAD,
/** Initialized by: #BKE_studiolight_default. */
.light_param = {{0}},
.light_ambient = {0, 0, 0},
.gizmo_flag = USER_GIZMO_DRAW,
.gizmo_size = 75,
.gizmo_size_navigate_v3d = 80,
.edit_studio_light = 0,
.lookdev_sphere_size = 150,
.vbotimeout = 120,
.vbocollectrate = 60,
.textimeout = 120,
.texcollectrate = 60,
/** Clamped by half the systems memory. */
.memcachelimit = 4096,
.prefetchframes = 0,
.pad_rot_angle = 15,
.rvisize = 25,
.rvibright = 8,
.recent_files = 200,
.smooth_viewtx = 200,
.glreslimit = 0,
.color_picker_type = USER_CP_CIRCLE_HSV,
.auto_smoothing_new = FCURVE_SMOOTH_CONT_ACCEL,
.ipo_new = BEZT_IPO_BEZ,
.keyhandles_new = HD_AUTO_ANIM,
.view_frame_type = ZOOM_FRAME_MODE_KEEP_RANGE,
.view_frame_keyframes = 0,
.view_frame_seconds = 0.0,
.widget_unit = 0, /* run-time initialized. */
.anisotropic_filter = 2,
.tablet_api = USER_TABLET_AUTOMATIC,
.pressure_threshold_max = 1.0,
.pressure_softness = 0.0,
.ndof_translation_sensitivity = 4.0,
.ndof_rotation_sensitivity = 4.0,
.ndof_deadzone = 0.0,
.ndof_flag = (NDOF_SHOW_GUIDE_ORBIT_CENTER | NDOF_ORBIT_CENTER_AUTO | NDOF_LOCK_HORIZON |
NDOF_SHOULD_PAN | NDOF_SHOULD_ZOOM | NDOF_SHOULD_ROTATE | NDOF_CAMERA_PAN_ZOOM),
.image_draw_method = IMAGE_DRAW_METHOD_AUTO,
.glalphaclip = 0.004,
.autokey_mode = (AUTOKEY_MODE_NORMAL & ~AUTOKEY_ON),
.keying_flag = KEYING_FLAG_XYZ2RGB | AUTOKEY_FLAG_INSERTNEEDED,
.key_insert_channels = (USER_ANIM_KEY_CHANNEL_LOCATION | USER_ANIM_KEY_CHANNEL_ROTATION |
USER_ANIM_KEY_CHANNEL_SCALE | USER_ANIM_KEY_CHANNEL_CUSTOM_PROPERTIES),
.animation_flag = USER_ANIM_HIGH_QUALITY_DRAWING,
.text_render = 0,
.navigation_mode = VIEW_NAVIGATION_WALK,
.view_rotate_sensitivity_turntable = DEG2RAD(0.4),
.view_rotate_sensitivity_trackball = 1.0f,
/** Initialized by #BKE_colorband_init. */
.coba_weight = {0},
.sculpt_paint_overlay_col = {0, 0, 0},
.gpencil_new_layer_col = {0.38, 0.61, 0.78, 0.9},
.drag_threshold_mouse = 3,
.drag_threshold_tablet = 10,
.drag_threshold = 30,
.move_threshold = 2,
.font_path_ui = "",
.font_path_ui_mono = "",
.compute_device_type = 0,
.fcu_inactive_alpha = 0.25,
.pie_tap_timeout = 20,
.pie_initial_timeout = 0,
.pie_animation_timeout = 6,
.pie_menu_confirm = 0,
.pie_menu_radius = 100,
.pie_menu_threshold = 12,
.factor_display_type = USER_FACTOR_AS_FACTOR,
.render_display_type = USER_RENDER_DISPLAY_WINDOW,
.filebrowser_display_type = USER_TEMP_SPACE_DISPLAY_WINDOW,
.preferences_display_type = USER_TEMP_SPACE_DISPLAY_WINDOW,
.viewport_aa = 8,
.walk_navigation =
{
.mouse_speed = 1,
.walk_speed = 2.5,
.walk_speed_factor = 5,
.view_height = 1.6,
.jump_height = 0.4,
.teleport_time = 0.2,
.flag = 0,
},
.xr_navigation =
{
.vignette_intensity = 60.0f,
.turn_amount = DEG2RAD(30),
.turn_speed = DEG2RAD(60),
.flag = USER_XR_NAV_SNAP_TURN,
},
.space_data =
{
.section_active = USER_SECTION_INTERFACE,
},
.file_space_data =
{
.display_type = FILE_VERTICALDISPLAY,
.thumbnail_size = 96,
.sort_type = FILE_SORT_ALPHA,
.details_flags = FILE_DETAILS_SIZE | FILE_DETAILS_DATETIME,
.flag = FILE_HIDE_DOT,
.filter_id = FILTER_ID_ALL,
},
.stored_bounds =
{
.file = {100.0f, 1160.0f, 350.0f, 950.0f},
.userpref = {100.0f, 940.0f, 350.0f, 900.0f},
.image = {50.0f, 1360.0f, 50.0f, 830.0f},
.graph = {50.0f, 950.0f, 200.0f, 780.0f},
.info = {100.0f, 1000.0f, 300.0f, 880.0f},
.outliner = {100.0f, 550.0f, 350.0f, 800.0f},
},
.sequencer_proxy_setup = USER_SEQ_PROXY_SETUP_AUTOMATIC,
.collection_instance_empty_size = 1.0f,
.statusbar_flag = STATUSBAR_SHOW_VERSION | STATUSBAR_SHOW_EXTENSIONS_UPDATES,
.file_preview_type = USER_FILE_PREVIEW_AUTO,
.sequencer_editor_flag = USER_SEQ_ED_CONNECT_STRIPS_BY_DEFAULT,
.runtime =
{
.is_dirty = 0,
},
};

View file

@ -8,9 +8,7 @@
* Do not hand edit this file!
*/
#include "DNA_userdef_types.h"
#include "BLO_userdef_default.h"
#include "DNA_theme_types.h"
/* clang-format off */

View file

@ -100,50 +100,12 @@ set(SRC_DNA_INC
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_xr_types.h
)
set(SRC_DNA_DEFAULTS_INC
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_action_defaults.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_armature_defaults.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_asset_defaults.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_brush_defaults.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_cachefile_defaults.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_camera_defaults.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_collection_defaults.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_curve_defaults.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_curves_defaults.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_defaults.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_fluid_defaults.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_gpencil_modifier_defaults.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_grease_pencil_defaults.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_image_defaults.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_lattice_defaults.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_layer_defaults.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_light_defaults.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_lightprobe_defaults.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_linestyle_defaults.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_material_defaults.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_mesh_defaults.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_meta_defaults.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_modifier_defaults.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_movieclip_defaults.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_object_defaults.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_particle_defaults.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_pointcloud_defaults.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_scene_defaults.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_space_defaults.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_speaker_defaults.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_texture_defaults.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_userdef_defaults.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_vec_defaults.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_view3d_defaults.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_volume_defaults.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_world_defaults.h
)
# Utility & other headers.
set(SRC_DNA_OTHER_INC
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_array_utils.hh
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_print.hh
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_sdna_type_ids.hh
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_vec_defaults.h
)
add_subdirectory(datatoc)

View file

@ -9,7 +9,6 @@
#include "DNA_action_types.h"
#include "DNA_anim_types.h"
#include "DNA_array_utils.hh"
#include "DNA_defaults.h"
#include "DNA_scene_types.h"
#include "BLI_listbase.h"
@ -78,7 +77,7 @@ constexpr const char *layer_default_name = "Layer";
static animrig::Layer &ActionLayer_alloc()
{
ActionLayer *layer = DNA_struct_default_alloc(ActionLayer);
ActionLayer *layer = MEM_new_for_free<ActionLayer>(__func__);
return layer->wrap();
}
@ -893,7 +892,7 @@ static float2 get_frame_range_of_fcurves(Span<const FCurve *> fcurves,
Layer *Layer::duplicate_with_shallow_strip_copies(const StringRefNull allocation_name) const
{
ActionLayer *copy = MEM_callocN<ActionLayer>(allocation_name.c_str());
ActionLayer *copy = MEM_new_for_free<ActionLayer>(allocation_name.c_str());
*copy = *reinterpret_cast<const ActionLayer *>(this);
/* Make a shallow copy of the Strips, without copying their data. */
@ -991,7 +990,7 @@ int64_t Layer::find_strip_index(const Strip &strip) const
Slot::Slot()
{
/* Zero-initialize the DNA struct. 'this' is a C++ class, and shouldn't be memset like this. */
memset(static_cast<ActionSlot *>(this), 0, sizeof(ActionSlot));
_DNA_internal_memzero(this, sizeof(ActionSlot));
this->runtime = MEM_new<SlotRuntime>(__func__);
}
@ -1566,8 +1565,7 @@ std::optional<std::pair<Action *, Slot *>> get_action_slot_pair(ID &animated_id)
Strip &Strip::create(Action &owning_action, const Strip::Type type)
{
/* Create the strip. */
ActionStrip *strip = MEM_callocN<ActionStrip>(__func__);
*strip = *DNA_struct_default_get(ActionStrip);
ActionStrip *strip = MEM_new_for_free<ActionStrip>(__func__);
strip->strip_type = int8_t(type);
/* Create the strip's data on the owning Action. */
@ -2299,7 +2297,7 @@ int Channelbag::channel_group_containing_index(const int fcurve_array_index)
bActionGroup &Channelbag::channel_group_create(StringRefNull name)
{
bActionGroup *new_group = MEM_callocN<bActionGroup>(__func__);
bActionGroup *new_group = MEM_new_for_free<bActionGroup>(__func__);
/* Find the end fcurve index of the current channel groups, to be used as the
* start of the new channel group. */

View file

@ -53,7 +53,7 @@ class ActionLegacyTest : public testing::Test {
FCurve *fcurve_add_legacy(bAction *action, const StringRefNull rna_path, const int array_index)
{
FCurve *fcurve = MEM_callocN<FCurve>(__func__);
FCurve *fcurve = MEM_new_for_free<FCurve>(__func__);
BKE_fcurve_rnapath_set(*fcurve, rna_path);
fcurve->array_index = array_index;
BLI_addtail(&action->curves, fcurve);

View file

@ -12,7 +12,6 @@
#include "BKE_main.hh"
#include "BKE_object.hh"
#include "DNA_action_defaults.h"
#include "DNA_anim_types.h"
#include "DNA_object_types.h"
@ -1493,7 +1492,7 @@ TEST_F(ActionQueryTest, BKE_action_frame_range_calc)
/* One curve with one key. */
{
FCurve &fcu = *MEM_callocN<FCurve>(__func__);
FCurve &fcu = *MEM_new_for_free<FCurve>(__func__);
allocate_keyframes(fcu, 1);
add_keyframe(fcu, 1.0f, 2.0f);
@ -1507,8 +1506,8 @@ TEST_F(ActionQueryTest, BKE_action_frame_range_calc)
/* Two curves with one key each on different frames. */
{
FCurve &fcu1 = *MEM_callocN<FCurve>(__func__);
FCurve &fcu2 = *MEM_callocN<FCurve>(__func__);
FCurve &fcu1 = *MEM_new_for_free<FCurve>(__func__);
FCurve &fcu2 = *MEM_new_for_free<FCurve>(__func__);
allocate_keyframes(fcu1, 1);
allocate_keyframes(fcu2, 1);
add_keyframe(fcu1, 1.0f, 2.0f);
@ -1525,7 +1524,7 @@ TEST_F(ActionQueryTest, BKE_action_frame_range_calc)
/* One curve with two keys. */
{
FCurve &fcu = *MEM_callocN<FCurve>(__func__);
FCurve &fcu = *MEM_new_for_free<FCurve>(__func__);
allocate_keyframes(fcu, 2);
add_keyframe(fcu, 1.0f, 2.0f);
add_keyframe(fcu, 1.5f, 2.0f);
@ -1552,7 +1551,7 @@ TEST_F(ActionQueryTest, action_has_single_frame)
/* One curve with one key. */
{
FCurve &fcu = *MEM_callocN<FCurve>(__func__);
FCurve &fcu = *MEM_new_for_free<FCurve>(__func__);
allocate_keyframes(fcu, 1);
add_keyframe(fcu, 1.0f, 2.0f);
@ -1566,8 +1565,8 @@ TEST_F(ActionQueryTest, action_has_single_frame)
/* Two curves with one key each. */
{
FCurve &fcu1 = *MEM_callocN<FCurve>(__func__);
FCurve &fcu2 = *MEM_callocN<FCurve>(__func__);
FCurve &fcu1 = *MEM_new_for_free<FCurve>(__func__);
FCurve &fcu2 = *MEM_new_for_free<FCurve>(__func__);
allocate_keyframes(fcu1, 1);
allocate_keyframes(fcu2, 1);
add_keyframe(fcu1, 1.0f, 327.0f);
@ -1588,7 +1587,7 @@ TEST_F(ActionQueryTest, action_has_single_frame)
/* One curve with two keys. */
{
FCurve &fcu = *MEM_callocN<FCurve>(__func__);
FCurve &fcu = *MEM_new_for_free<FCurve>(__func__);
allocate_keyframes(fcu, 2);
add_keyframe(fcu, 1.0f, 2.0f);
add_keyframe(fcu, 2.0f, 2.5f);

View file

@ -59,7 +59,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_callocN<BoneCollection>(__func__);
BoneCollection *bcoll = MEM_new_for_free<BoneCollection>(__func__);
STRNCPY_UTF8(bcoll->name, name);
bcoll->flags = default_flags;
@ -89,7 +89,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_callocN<BoneCollectionReference>(__func__);
BoneCollectionReference *ref = MEM_new_for_free<BoneCollectionReference>(__func__);
ref->bcoll = bcoll;
BLI_addtail(&member->bone->runtime.collections, ref);
}
@ -865,14 +865,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_callocN<BoneCollectionMember>(__func__);
BoneCollectionMember *member = MEM_new_for_free<BoneCollectionMember>(__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_callocN<BoneCollectionReference>(__func__);
BoneCollectionReference *ref = MEM_new_for_free<BoneCollectionReference>(__func__);
ref->bcoll = bcoll;
BLI_addtail(&bone->runtime.collections, ref);
}
@ -904,7 +904,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_callocN<BoneCollectionReference>(__func__);
BoneCollectionReference *ref = MEM_new_for_free<BoneCollectionReference>(__func__);
ref->bcoll = bcoll;
BLI_addtail(&ebone->bone_collections, ref);

View file

@ -81,7 +81,7 @@ class KeyframingTest : public testing::Test {
object = BKE_object_add_only_object(bmain, OB_EMPTY, "Empty");
object_rna_pointer = RNA_id_pointer_create(&object->id);
Bone *bone = MEM_callocN<Bone>("BONE");
Bone *bone = MEM_new_for_free<Bone>("BONE");
STRNCPY(bone->name, "Bone");
armature = BKE_armature_add(bmain, "Armature");

View file

@ -69,11 +69,11 @@ class PoseTest : public testing::Test {
bArmature *armature = BKE_armature_add(bmain, "ArmatureA");
obj_armature_a->data = armature;
Bone *bone = MEM_callocN<Bone>("BONE");
Bone *bone = MEM_new_for_free<Bone>("BONE");
STRNCPY(bone->name, "BoneA");
BLI_addtail(&armature->bonebase, bone);
bone = MEM_callocN<Bone>("BONE");
bone = MEM_new_for_free<Bone>("BONE");
STRNCPY(bone->name, "BoneB");
BLI_addtail(&armature->bonebase, bone);
@ -82,11 +82,11 @@ class PoseTest : public testing::Test {
armature = BKE_armature_add(bmain, "ArmatureB");
obj_armature_b->data = armature;
bone = MEM_callocN<Bone>("BONE");
bone = MEM_new_for_free<Bone>("BONE");
STRNCPY(bone->name, "BoneA");
BLI_addtail(&armature->bonebase, bone);
bone = MEM_callocN<Bone>("BONE");
bone = MEM_new_for_free<Bone>("BONE");
STRNCPY(bone->name, "BoneB");
BLI_addtail(&armature->bonebase, bone);

View file

@ -15,7 +15,6 @@
#include "ANIM_action_legacy.hh"
#include "ANIM_versioning.hh"
#include "DNA_action_defaults.h"
#include "DNA_action_types.h"
#include "BKE_lib_id.hh"

View file

@ -1717,7 +1717,7 @@ static void blf_glyph_to_curves(const FT_Outline &ftoutline,
contour_prev = ftoutline.contours[j];
/* add new curve */
nu = MEM_callocN<Nurb>("objfnt_nurb");
nu = MEM_new_for_free<Nurb>("objfnt_nurb");
bezt = MEM_calloc_arrayN<BezTriple>(size_t(onpoints[j]), "objfnt_bezt");
BLI_addtail(nurbsbase, nu);

View file

@ -40,36 +40,36 @@ float BKE_camera_sensor_size(int sensor_fit, float sensor_x, float sensor_y);
* Intermediate struct for storing camera parameters from various sources,
* to unify computation of view-plane, window matrix, ... etc.
*/
typedef struct CameraParams {
struct CameraParams {
/* lens */
bool is_ortho;
float lens;
float ortho_scale;
float zoom;
bool is_ortho = false;
float lens = 0.0f;
float ortho_scale = 1.0f;
float zoom = 1.0f;
float shiftx;
float shifty;
float offsetx;
float offsety;
float shiftx = 0.0f;
float shifty = 0.0f;
float offsetx = 0.0f;
float offsety = 0.0f;
/* sensor */
float sensor_x;
float sensor_y;
int sensor_fit;
float sensor_x = 0.0f;
float sensor_y = 0.0f;
int sensor_fit = 0;
/* clipping */
float clip_start;
float clip_end;
float clip_start = 0.1f;
float clip_end = 100.0f;
/* computed viewplane */
float ycor;
float viewdx;
float viewdy;
float ycor = 0.0f;
float viewdx = 0.0f;
float viewdy = 0.0f;
rctf viewplane;
/* computed matrix */
float winmat[4][4];
} CameraParams;
float winmat[4][4] = {};
};
/* Values for CameraParams.zoom, need to be taken into account for some operations. */
#define CAMERA_PARAM_ZOOM_INIT_CAMOB 1.0f

View file

@ -33,7 +33,6 @@ set(INC_SYS
)
set(SRC
${CMAKE_SOURCE_DIR}/release/datafiles/userdef/userdef_default.c
intern/action.cc
intern/action_bones.cc
intern/action_mirror.cc

View file

@ -20,7 +20,6 @@
#include "DNA_anim_types.h"
#include "DNA_armature_types.h"
#include "DNA_constraint_types.h"
#include "DNA_defaults.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
@ -102,8 +101,7 @@ static void action_init_data(ID *action_id)
BLI_assert(GS(action_id->name) == ID_AC);
bAction *action = reinterpret_cast<bAction *>(action_id);
BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(action, id));
MEMCPY_STRUCT_AFTER(action, DNA_struct_default_get(bAction), id);
INIT_DEFAULT_STRUCT_AFTER(action, id);
}
/**
@ -885,7 +883,7 @@ bActionGroup *action_groups_add_new(bAction *act, const char name[])
BLI_assert(act->wrap().is_action_legacy());
/* allocate a new one */
agrp = MEM_callocN<bActionGroup>("bActionGroup");
agrp = MEM_new_for_free<bActionGroup>("bActionGroup");
/* make it selected, with default name */
agrp->flag = AGRP_SELECTED;
@ -1118,7 +1116,7 @@ bPoseChannel *BKE_pose_channel_ensure(bPose *pose, const char *name)
}
/* If not, create it and add it */
chan = MEM_callocN<bPoseChannel>("verifyPoseChannel");
chan = MEM_new_for_free<bPoseChannel>("verifyPoseChannel");
BKE_pose_channel_session_uid_generate(chan);
@ -1261,7 +1259,7 @@ void BKE_pose_copy_data_ex(bPose **dst,
return;
}
outPose = MEM_callocN<bPose>("pose");
outPose = MEM_new_for_free<bPose>("pose");
BLI_duplicatelist(&outPose->chanbase, &src->chanbase);
@ -1358,7 +1356,7 @@ void BKE_pose_ikparam_init(bPose *pose)
bItasc *itasc;
switch (pose->iksolver) {
case IKSOLVER_ITASC:
itasc = MEM_callocN<bItasc>("itasc");
itasc = MEM_new_for_free<bItasc>("itasc");
BKE_pose_itasc_init(itasc);
pose->ikparam = itasc;
break;
@ -1809,7 +1807,7 @@ bActionGroup *BKE_pose_add_group(bPose *pose, const char *name)
name = DATA_("Group");
}
grp = MEM_callocN<bActionGroup>("PoseGroup");
grp = MEM_new_for_free<bActionGroup>("PoseGroup");
STRNCPY_UTF8(grp->name, name);
BLI_addtail(&pose->agroups, grp);
BLI_uniquename(&pose->agroups, grp, name, '.', offsetof(bActionGroup, name), sizeof(grp->name));

View file

@ -33,7 +33,7 @@ static CLG_LogRef LOG = {"addon"};
bAddon *BKE_addon_new()
{
bAddon *addon = MEM_callocN<bAddon>("bAddon");
bAddon *addon = MEM_new_for_free<bAddon>("bAddon");
return addon;
}

View file

@ -110,7 +110,7 @@ AnimData *BKE_animdata_ensure_id(ID *id)
AnimData *adt;
/* add animdata */
adt = iat->adt = MEM_callocN<AnimData>("AnimData");
adt = iat->adt = MEM_new_for_free<AnimData>("AnimData");
/* set default settings */
adt->act_influence = 1.0f;

View file

@ -137,7 +137,7 @@ KeyingSet *BKE_keyingset_add(
KeyingSet *ks;
/* allocate new KeyingSet */
ks = MEM_callocN<KeyingSet>("KeyingSet");
ks = MEM_new_for_free<KeyingSet>("KeyingSet");
STRNCPY_UTF8(ks->idname, (idname) ? idname : (name) ? name : DATA_("KeyingSet"));
STRNCPY_UTF8(ks->name, (name) ? name : (idname) ? idname : DATA_("Keying Set"));
@ -192,7 +192,7 @@ KS_Path *BKE_keyingset_add_path(KeyingSet *ks,
}
/* allocate a new KeyingSet Path */
ksp = MEM_callocN<KS_Path>("KeyingSet Path");
ksp = MEM_new_for_free<KS_Path>("KeyingSet Path");
/* just store absolute info */
ksp->id = id;
@ -3717,7 +3717,7 @@ NlaKeyframingContext *BKE_animsys_get_nla_keyframing_context(
if (ctx == nullptr) {
/* Allocate and evaluate a new context. */
ctx = MEM_callocN<NlaKeyframingContext>("NlaKeyframingContext");
ctx = MEM_new_for_free<NlaKeyframingContext>("NlaKeyframingContext");
ctx->adt = adt;
nlaeval_init(&ctx->lower_eval_data);

View file

@ -166,7 +166,7 @@ bMotionPath *animviz_verify_motionpaths(ReportList *reports,
animviz_free_motionpath_cache(mpath);
}
else {
mpath = MEM_callocN<bMotionPath>("bMotionPath");
mpath = MEM_new_for_free<bMotionPath>("bMotionPath");
*dst = mpath;
}
@ -202,7 +202,7 @@ bMotionPath *animviz_verify_motionpaths(ReportList *reports,
mpath->flag |= MOTIONPATH_FLAG_LINES;
/* Allocate a cache. */
mpath->points = MEM_calloc_arrayN<bMotionPathVert>(mpath->length, "bMotionPathVerts");
mpath->points = MEM_new_array_for_free<bMotionPathVert>(mpath->length, "bMotionPathVerts");
/* Tag viz settings as currently having some path(s) which use it. */
avs->path_bakeflag |= MOTIONPATH_BAKE_HAS_PATHS;

View file

@ -30,8 +30,6 @@
#include "BLI_utildefines.h"
#include "BLT_translation.hh"
#include "DNA_defaults.h"
#include "DNA_armature_types.h"
#include "DNA_constraint_types.h"
#include "DNA_listBase.h"
@ -85,9 +83,7 @@ static void copy_bonechildren_custom_handles(Bone *bone_dst, bArmature *arm_dst)
static void armature_init_data(ID *id)
{
bArmature *armature = (bArmature *)id;
BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(armature, id));
MEMCPY_STRUCT_AFTER(armature, DNA_struct_default_get(bArmature), id);
INIT_DEFAULT_STRUCT_AFTER(armature, id);
}
/**
@ -1668,13 +1664,13 @@ static void allocate_bbone_cache(bPoseChannel *pchan,
"bPoseChannel_Runtime::bbone_pose_mats");
runtime->bbone_deform_mats = MEM_malloc_arrayN<Mat4>(
2 + uint(segments), "bPoseChannel_Runtime::bbone_deform_mats");
runtime->bbone_dual_quats = MEM_malloc_arrayN<DualQuat>(
runtime->bbone_dual_quats = MEM_new_array_for_free<DualQuat>(
1 + uint(segments), "bPoseChannel_Runtime::bbone_dual_quats");
}
/* If the segment count changed, the array was deallocated and nulled above. */
if (use_boundaries && !runtime->bbone_segment_boundaries) {
runtime->bbone_segment_boundaries = MEM_malloc_arrayN<bPoseChannel_BBoneSegmentBoundary>(
runtime->bbone_segment_boundaries = MEM_new_array_for_free<bPoseChannel_BBoneSegmentBoundary>(
1 + uint(segments), "bPoseChannel_Runtime::bbone_segment_boundaries");
}
else if (!use_boundaries) {
@ -2885,7 +2881,7 @@ void BKE_pose_rebuild(Main *bmain, Object *ob, bArmature *arm, const bool do_id_
/* only done here */
if (ob->pose == nullptr) {
/* create new pose */
ob->pose = MEM_callocN<bPose>("new pose");
ob->pose = MEM_new_for_free<bPose>("new pose");
/* set default settings for animviz */
animviz_settings_init(&ob->pose->avs);

View file

@ -120,7 +120,7 @@ class ArmatureDeformTestBase {
bArmature *arm = BKE_id_new<bArmature>(bmain, "Test Armature");
ob->data = arm;
Bone *bone1 = MEM_callocN<Bone>("Bone1");
Bone *bone1 = MEM_new_for_free<Bone>("Bone1");
STRNCPY(bone1->name, "Bone1");
copy_v3_v3(bone1->tail, float3(0, 0, 0));
copy_v3_v3(bone1->head, float3(0, 0, 1));
@ -132,7 +132,7 @@ class ArmatureDeformTestBase {
bone1->rad_head = 2.0f;
bone1->rad_tail = 2.0f;
Bone *bone2 = MEM_callocN<Bone>("Bone2");
Bone *bone2 = MEM_new_for_free<Bone>("Bone2");
STRNCPY(bone2->name, "Bone2");
copy_v3_v3(bone2->tail, float3(0, 0, 0));
copy_v3_v3(bone2->head, float3(0, 0, 1));
@ -208,8 +208,8 @@ class ArmatureDeformTestBase {
}
mesh->tag_positions_changed();
bDeformGroup *defgroup1 = MEM_callocN<bDeformGroup>(__func__);
bDeformGroup *defgroup2 = MEM_callocN<bDeformGroup>(__func__);
bDeformGroup *defgroup1 = MEM_new_for_free<bDeformGroup>(__func__);
bDeformGroup *defgroup2 = MEM_new_for_free<bDeformGroup>(__func__);
STRNCPY(defgroup1->name, "Bone1");
STRNCPY(defgroup2->name, "Bone2");
BLI_addtail(&mesh->vertex_group_names, defgroup1);

View file

@ -10,7 +10,6 @@
#include <utility>
#include "DNA_ID.h"
#include "DNA_defaults.h"
#include "BLI_listbase.h"
#include "BLI_string.h"
@ -31,8 +30,7 @@ using namespace blender;
AssetMetaData *BKE_asset_metadata_create()
{
const AssetMetaData *default_metadata = DNA_struct_default_get(AssetMetaData);
return MEM_new<AssetMetaData>(__func__, *default_metadata);
return MEM_new<AssetMetaData>(__func__);
}
void BKE_asset_metadata_free(AssetMetaData **asset_data)
@ -97,7 +95,7 @@ AssetMetaData::~AssetMetaData()
static AssetTag *asset_metadata_tag_add(AssetMetaData *asset_data, const char *const name)
{
AssetTag *tag = MEM_callocN<AssetTag>(__func__);
AssetTag *tag = MEM_new_for_free<AssetTag>(__func__);
STRNCPY_UTF8(tag->name, name);
BLI_addtail(&asset_data->tags, tag);
@ -148,7 +146,7 @@ void BKE_asset_metadata_tag_remove(AssetMetaData *asset_data, AssetTag *tag)
void BKE_asset_library_reference_init_default(AssetLibraryReference *library_ref)
{
memcpy(library_ref, DNA_struct_default_get(AssetLibraryReference), sizeof(*library_ref));
*library_ref = AssetLibraryReference();
}
void BKE_asset_metadata_catalog_id_clear(AssetMetaData *asset_data)

View file

@ -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_callocN<AssetCatalogPathLink>(__func__);
AssetCatalogPathLink *copied_path = MEM_new_for_free<AssetCatalogPathLink>(__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_callocN<AssetCatalogPathLink>(__func__);
AssetCatalogPathLink *new_path = MEM_new_for_free<AssetCatalogPathLink>(__func__);
new_path->path = BLI_strdup(catalog_path);
BLI_addtail(&catalog_path_list, new_path);
}

View file

@ -64,14 +64,14 @@ NodesModifierPackedBake *pack_bake_from_disk(const BakePath &bake_path, ReportLi
const Vector<NodesModifierBakeFile> blob_bake_files = pack_files_from_directory(
bake_path.blobs_dir, reports);
NodesModifierPackedBake *packed_bake = MEM_callocN<NodesModifierPackedBake>(__func__);
NodesModifierPackedBake *packed_bake = MEM_new_for_free<NodesModifierPackedBake>(__func__);
packed_bake->meta_files_num = meta_bake_files.size();
packed_bake->blob_files_num = blob_bake_files.size();
packed_bake->meta_files = MEM_calloc_arrayN<NodesModifierBakeFile>(packed_bake->meta_files_num,
__func__);
packed_bake->blob_files = MEM_calloc_arrayN<NodesModifierBakeFile>(packed_bake->blob_files_num,
__func__);
packed_bake->meta_files = MEM_new_array_for_free<NodesModifierBakeFile>(
packed_bake->meta_files_num, __func__);
packed_bake->blob_files = MEM_new_array_for_free<NodesModifierBakeFile>(
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);

View file

@ -856,7 +856,7 @@ static Mesh *try_load_mesh(const DictionaryValue &io_geometry,
if (value->type() != io::serialize::eValueType::String) {
return cancel();
}
bDeformGroup *defgroup = MEM_callocN<bDeformGroup>(__func__);
bDeformGroup *defgroup = MEM_new_for_free<bDeformGroup>(__func__);
STRNCPY_UTF8(defgroup->name, value->as_string_value()->value().c_str());
BLI_addtail(&mesh->vertex_group_names, defgroup);
}

View file

@ -38,7 +38,7 @@ bUserMenu *BKE_blender_user_menu_ensure(ListBase *lb, char space_type, const cha
{
bUserMenu *um = BKE_blender_user_menu_find(lb, space_type, context);
if (um == nullptr) {
um = MEM_callocN<bUserMenu>(__func__);
um = MEM_new_for_free<bUserMenu>(__func__);
um->space_type = space_type;
STRNCPY(um->context, context);
BLI_addhead(lb, um);

View file

@ -1506,8 +1506,10 @@ UserDef *BKE_blendfile_userdef_read_from_memory(const void *file_buf,
UserDef *BKE_blendfile_userdef_from_defaults()
{
UserDef *userdef = MEM_callocN<UserDef>(__func__);
*userdef = blender::dna::shallow_copy(U_default);
UserDef *userdef = MEM_new_for_free<UserDef>(__func__);
userdef->versionfile = BLENDER_FILE_VERSION;
userdef->subversionfile = BLENDER_FILE_SUBVERSION;
/* Add-ons. */
{

View file

@ -1593,40 +1593,40 @@ BoidRule *boid_new_rule(int type)
switch (type) {
case eBoidRuleType_Goal:
case eBoidRuleType_Avoid: {
BoidRuleGoalAvoid *rule_goal = MEM_callocN<BoidRuleGoalAvoid>("BoidRuleGoalAvoid");
BoidRuleGoalAvoid *rule_goal = MEM_new_for_free<BoidRuleGoalAvoid>("BoidRuleGoalAvoid");
rule = reinterpret_cast<BoidRule *>(rule_goal);
break;
}
case eBoidRuleType_AvoidCollision: {
BoidRuleAvoidCollision *rule_avoid = MEM_callocN<BoidRuleAvoidCollision>(
BoidRuleAvoidCollision *rule_avoid = MEM_new_for_free<BoidRuleAvoidCollision>(
"BoidRuleAvoidCollision");
rule_avoid->look_ahead = 2.0f;
rule = reinterpret_cast<BoidRule *>(rule_avoid);
break;
}
case eBoidRuleType_FollowLeader: {
BoidRuleFollowLeader *rule_follow = MEM_callocN<BoidRuleFollowLeader>(
BoidRuleFollowLeader *rule_follow = MEM_new_for_free<BoidRuleFollowLeader>(
"BoidRuleFollowLeader");
rule_follow->distance = 1.0f;
rule = reinterpret_cast<BoidRule *>(rule_follow);
break;
}
case eBoidRuleType_AverageSpeed: {
BoidRuleAverageSpeed *rule_avgspeed = MEM_callocN<BoidRuleAverageSpeed>(
BoidRuleAverageSpeed *rule_avgspeed = MEM_new_for_free<BoidRuleAverageSpeed>(
"BoidRuleAverageSpeed");
rule_avgspeed->speed = 0.5f;
rule = reinterpret_cast<BoidRule *>(rule_avgspeed);
break;
}
case eBoidRuleType_Fight: {
BoidRuleFight *rule_fight = MEM_callocN<BoidRuleFight>("BoidRuleFight");
BoidRuleFight *rule_fight = MEM_new_for_free<BoidRuleFight>("BoidRuleFight");
rule_fight->distance = 100.0f;
rule_fight->flee_distance = 100.0f;
rule = reinterpret_cast<BoidRule *>(rule_fight);
break;
}
default:
rule = MEM_callocN<BoidRule>("BoidRule");
rule = MEM_new_for_free<BoidRule>("BoidRule");
break;
}
@ -1664,7 +1664,7 @@ void boid_default_settings(BoidSettings *boids)
BoidState *boid_new_state(BoidSettings *boids)
{
BoidState *state = MEM_callocN<BoidState>("BoidState");
BoidState *state = MEM_new_for_free<BoidState>("BoidState");
state->id = boids->last_state_id++;
if (state->id) {

View file

@ -15,7 +15,6 @@
#include "DNA_ID.h"
#include "DNA_brush_types.h"
#include "DNA_defaults.h"
#include "DNA_material_types.h"
#include "DNA_scene_types.h"
@ -55,9 +54,7 @@
static void brush_init_data(ID *id)
{
Brush *brush = reinterpret_cast<Brush *>(id);
BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(brush, id));
MEMCPY_STRUCT_AFTER(brush, DNA_struct_default_get(Brush), id);
INIT_DEFAULT_STRUCT_AFTER(brush, id);
/* enable fake user by default */
id_fake_user_set(&brush->id);
@ -104,8 +101,8 @@ static void brush_copy_data(Main * /*bmain*/,
brush_dst->curve_jitter = BKE_curvemapping_copy(brush_src->curve_jitter);
if (brush_src->gpencil_settings != nullptr) {
brush_dst->gpencil_settings = MEM_dupallocN<BrushGpencilSettings>(
__func__, *(brush_src->gpencil_settings));
brush_dst->gpencil_settings = MEM_new_for_free<BrushGpencilSettings>(
__func__, blender::dna::shallow_copy(*(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(
@ -127,7 +124,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_dupallocN<BrushCurvesSculptSettings>(
brush_dst->curves_sculpt_settings = MEM_new_for_free<BrushCurvesSculptSettings>(
__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);
@ -647,7 +644,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_callocN<BrushGpencilSettings>("BrushGpencilSettings");
brush->gpencil_settings = MEM_new_for_free<BrushGpencilSettings>("BrushGpencilSettings");
}
brush->gpencil_settings->draw_smoothlvl = 1;
@ -747,7 +744,7 @@ Brush *BKE_brush_duplicate(Main *bmain,
void BKE_brush_init_curves_sculpt_settings(Brush *brush)
{
if (brush->curves_sculpt_settings == nullptr) {
brush->curves_sculpt_settings = MEM_callocN<BrushCurvesSculptSettings>(__func__);
brush->curves_sculpt_settings = MEM_new_for_free<BrushCurvesSculptSettings>(__func__);
}
BrushCurvesSculptSettings *settings = brush->curves_sculpt_settings;
settings->flag = BRUSH_CURVES_SCULPT_FLAG_INTERPOLATE_RADIUS;

View file

@ -53,8 +53,6 @@ static void cache_file_init_data(ID *id)
{
CacheFile *cache_file = (CacheFile *)id;
BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(cache_file, id));
cache_file->scale = 1.0f;
cache_file->velocity_unit = CACHEFILE_VELOCITY_UNIT_SECOND;
STRNCPY(cache_file->velocity_name, ".velocities");
@ -423,7 +421,7 @@ CacheFileLayer *BKE_cachefile_add_layer(CacheFile *cache_file, const char filepa
const int num_layers = BLI_listbase_count(&cache_file->layers);
CacheFileLayer *layer = MEM_callocN<CacheFileLayer>("CacheFileLayer");
CacheFileLayer *layer = MEM_new_for_free<CacheFileLayer>("CacheFileLayer");
STRNCPY(layer->filepath, filepath);
BLI_addtail(&cache_file->layers, layer);

View file

@ -14,7 +14,6 @@
#include "DNA_ID.h"
#include "DNA_camera_types.h"
#include "DNA_defaults.h"
#include "DNA_light_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
@ -55,9 +54,7 @@
static void camera_init_data(ID *id)
{
Camera *cam = (Camera *)id;
BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(cam, id));
MEMCPY_STRUCT_AFTER(cam, DNA_struct_default_get(Camera), id);
INIT_DEFAULT_STRUCT_AFTER(cam, id);
}
/**
@ -353,7 +350,7 @@ int BKE_camera_sensor_fit(int sensor_fit, float sizex, float sizey)
void BKE_camera_params_init(CameraParams *params)
{
memset(params, 0, sizeof(CameraParams));
*params = CameraParams();
/* defaults */
params->sensor_x = DEFAULT_SENSOR_WIDTH;
@ -1241,7 +1238,7 @@ void BKE_camera_multiview_params(const RenderData *rd,
CameraBGImage *BKE_camera_background_image_new(Camera *cam)
{
CameraBGImage *bgpic = MEM_callocN<CameraBGImage>("Background Image");
CameraBGImage *bgpic = MEM_new_for_free<CameraBGImage>("Background Image");
bgpic->scale = 1.0f;
bgpic->alpha = 0.5f;

View file

@ -40,8 +40,6 @@
#include "BKE_rigidbody.h"
#include "BKE_scene.hh"
#include "DNA_defaults.h"
#include "DNA_ID.h"
#include "DNA_collection_types.h"
#include "DNA_layer_types.h"
@ -123,9 +121,7 @@ static void collection_exporter_copy(Collection *collection, CollectionExport *d
static void collection_init_data(ID *id)
{
Collection *collection = (Collection *)id;
BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(collection, id));
MEMCPY_STRUCT_AFTER(collection, DNA_struct_default_get(Collection), id);
INIT_DEFAULT_STRUCT_AFTER(collection, id);
collection->runtime = MEM_new<blender::bke::CollectionRuntime>(__func__);
}
@ -850,7 +846,7 @@ static void collection_object_cache_fill(ListBase *lb,
Base *base = static_cast<Base *>(BLI_findptr(lb, cob->ob, offsetof(Base, object)));
if (base == nullptr) {
base = MEM_callocN<Base>("Object Base");
base = MEM_new_for_free<Base>("Object Base");
base->object = cob->ob;
BLI_addtail(lb, base);
if (with_instances && cob->ob->instance_collection) {
@ -1419,7 +1415,7 @@ static bool collection_object_add(Main *bmain,
bool newly_added = false;
CollectionObject *cob = collection->runtime->gobject_hash->lookup_or_add_cb(ob, [&]() {
newly_added = true;
return MEM_callocN<CollectionObject>(__func__);
return MEM_new_for_free<CollectionObject>(__func__);
});
if (!newly_added) {
return false;
@ -1481,7 +1477,7 @@ CollectionExport *BKE_collection_exporter_add(Collection *collection, char *idna
{
/* 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_callocN<CollectionExport>("CollectionExport");
CollectionExport *data = MEM_new_for_free<CollectionExport>("CollectionExport");
STRNCPY(data->fh_idname, idname);
BKE_collection_exporter_name_set(&collection->exporters, data, label);
@ -1520,7 +1516,7 @@ bool BKE_collection_exporter_move(Collection *collection, const int from, const
static void collection_exporter_copy(Collection *collection, CollectionExport *data)
{
CollectionExport *new_data = MEM_callocN<CollectionExport>("CollectionExport");
CollectionExport *new_data = MEM_new_for_free<CollectionExport>("CollectionExport");
STRNCPY(new_data->fh_idname, data->fh_idname);
new_data->export_properties = IDP_CopyProperty(data->export_properties);
new_data->flag = data->flag;
@ -1957,7 +1953,7 @@ static bool collection_child_add(Main *bmain,
return false;
}
child = MEM_callocN<CollectionChild>("CollectionChild");
child = MEM_new_for_free<CollectionChild>("CollectionChild");
child->collection = collection;
if (light_linking) {
child->light_linking = *light_linking;

View file

@ -11,6 +11,7 @@
#include "MEM_guardedalloc.h"
#include "DNA_cloth_types.h"
#include "DNA_layer_types.h"
#include "DNA_object_force_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"

View file

@ -299,7 +299,7 @@ ColorBand *BKE_colorband_add(bool rangetype)
{
ColorBand *coba;
coba = MEM_callocN<ColorBand>("colorband");
coba = MEM_new_for_free<ColorBand>("colorband");
BKE_colorband_init(coba, rangetype);
return coba;

View file

@ -73,7 +73,7 @@ void BKE_curvemapping_set_defaults(CurveMapping *cumap,
}
cumap->cm[a].totpoint = 2;
cumap->cm[a].curve = MEM_calloc_arrayN<CurveMapPoint>(2, "curve points");
cumap->cm[a].curve = MEM_new_array_for_free<CurveMapPoint>(2, "curve points");
cumap->cm[a].curve[0].x = minx;
cumap->cm[a].curve[0].y = miny;
@ -90,7 +90,7 @@ CurveMapping *BKE_curvemapping_add(int tot, float minx, float miny, float maxx,
{
CurveMapping *cumap;
cumap = MEM_callocN<CurveMapping>("new curvemap");
cumap = MEM_new_for_free<CurveMapping>("new curvemap");
BKE_curvemapping_set_defaults(cumap, tot, minx, miny, maxx, maxy, HD_AUTO);
@ -129,7 +129,7 @@ void BKE_curvemapping_copy_data(CurveMapping *target, const CurveMapping *cumap)
{
int a;
*target = *cumap;
*target = blender::dna::shallow_copy(*cumap);
for (a = 0; a < CM_TOT; a++) {
if (cumap->cm[a].curve) {
@ -195,7 +195,7 @@ bool BKE_curvemap_remove_point(CurveMap *cuma, CurveMapPoint *point)
return false;
}
cmp = MEM_malloc_arrayN<CurveMapPoint>(size_t(cuma->totpoint), "curve points");
cmp = MEM_new_array_for_free<CurveMapPoint>(size_t(cuma->totpoint), "curve points");
/* well, lets keep the two outer points! */
for (a = 0, b = 0; a < cuma->totpoint; a++) {
@ -216,7 +216,8 @@ bool BKE_curvemap_remove_point(CurveMap *cuma, CurveMapPoint *point)
void BKE_curvemap_remove(CurveMap *cuma, const short flag)
{
CurveMapPoint *cmp = MEM_malloc_arrayN<CurveMapPoint>(size_t(cuma->totpoint), "curve points");
CurveMapPoint *cmp = MEM_new_array_for_free<CurveMapPoint>(size_t(cuma->totpoint),
"curve points");
int a, b, removed = 0;
/* well, lets keep the two outer points! */
@ -239,8 +240,8 @@ void BKE_curvemap_remove(CurveMap *cuma, const short flag)
CurveMapPoint *BKE_curvemap_insert(CurveMap *cuma, float x, float y)
{
CurveMapPoint *cmp = MEM_calloc_arrayN<CurveMapPoint>(size_t(cuma->totpoint) + 1,
"curve points");
CurveMapPoint *cmp = MEM_new_array_for_free<CurveMapPoint>(size_t(cuma->totpoint) + 1,
"curve points");
CurveMapPoint *newcmp = nullptr;
int a, b;
bool foundloc = false;
@ -310,7 +311,7 @@ void BKE_curvemap_reset(CurveMap *cuma, const rctf *clipr, int preset, CurveMapS
break;
}
cuma->curve = MEM_calloc_arrayN<CurveMapPoint>(cuma->totpoint, "curve points");
cuma->curve = MEM_new_array_for_free<CurveMapPoint>(cuma->totpoint, "curve points");
for (int i = 0; i < cuma->totpoint; i++) {
cuma->curve[i].flag = cuma->default_handle_type;
@ -474,8 +475,8 @@ void BKE_curvemap_reset(CurveMap *cuma, const rctf *clipr, int preset, CurveMapS
}
else if (slope == CurveMapSlopeType::PositiveNegative) {
const int num_points = cuma->totpoint * 2 - 1;
CurveMapPoint *new_points = MEM_malloc_arrayN<CurveMapPoint>(size_t(num_points),
"curve symmetric points");
CurveMapPoint *new_points = MEM_new_array_for_free<CurveMapPoint>(size_t(num_points),
"curve symmetric points");
for (int i = 0; i < cuma->totpoint; i++) {
const int src_last_point = cuma->totpoint - i - 1;
const int dst_last_point = num_points - i - 1;
@ -873,7 +874,7 @@ static void curvemap_make_table(const CurveMapping *cumap, CurveMap *cuma)
float *lastpoint = allpoints + 2 * (totpoint - 1);
point = allpoints;
CurveMapPoint *cmp = MEM_calloc_arrayN<CurveMapPoint>(CM_TABLE + 1, "dist table");
CurveMapPoint *cmp = MEM_new_array_for_free<CurveMapPoint>(CM_TABLE + 1, "dist table");
for (int a = 0; a <= CM_TABLE; a++) {
float cur_x = cuma->mintable + range * float(a);
@ -942,7 +943,7 @@ void BKE_curvemapping_premultiply(CurveMapping *cumap, bool restore)
curvemap_make_table(cumap, cumap->cm + a);
}
cumap->cm[a].premultable = cumap->cm[a].table;
cumap->cm[a].table = MEM_malloc_arrayN<CurveMapPoint>(CM_TABLE + 1, "premul table");
cumap->cm[a].table = MEM_new_array_for_free<CurveMapPoint>(CM_TABLE + 1, "premul table");
memcpy(
cumap->cm[a].table, cumap->cm[a].premultable, (CM_TABLE + 1) * sizeof(CurveMapPoint));
}

View file

@ -878,7 +878,7 @@ static bool default_get_tarmat_full_bbone(Depsgraph * /*depsgraph*/,
/* TODO: cope with getting rotation order... */
#define SINGLETARGET_GET_TARS(con, datatar, datasubtarget, ct, list) \
{ \
ct = MEM_callocN<bConstraintTarget>("tempConstraintTarget"); \
ct = MEM_new_for_free<bConstraintTarget>("tempConstraintTarget"); \
\
ct->tar = datatar; \
STRNCPY_UTF8(ct->subtarget, datasubtarget); \
@ -913,7 +913,7 @@ static bool default_get_tarmat_full_bbone(Depsgraph * /*depsgraph*/,
/* TODO: cope with getting rotation order... */
#define SINGLETARGETNS_GET_TARS(con, datatar, ct, list) \
{ \
ct = MEM_callocN<bConstraintTarget>("tempConstraintTarget"); \
ct = MEM_new_for_free<bConstraintTarget>("tempConstraintTarget"); \
\
ct->tar = datatar; \
ct->space = con->tarspace; \
@ -6034,7 +6034,7 @@ void BKE_constraint_panel_expand(bConstraint *con)
/* Creates a new constraint, initializes its data, and returns it */
static bConstraint *add_new_constraint_internal(const char *name, short type)
{
bConstraint *con = MEM_callocN<bConstraint>("Constraint");
bConstraint *con = MEM_new_for_free<bConstraint>("Constraint");
const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_from_type(type);
const char *newName;

View file

@ -332,13 +332,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_callocN<CryptomatteEntry>(__func__);
entry = MEM_new_for_free<CryptomatteEntry>(__func__);
entry->encoded_hash = encoded_hash;
}
else {
const char *name = token.c_str();
int name_len = token.length();
entry = MEM_callocN<CryptomatteEntry>(__func__);
entry = MEM_new_for_free<CryptomatteEntry>(__func__);
STRNCPY(entry->name, name);
uint32_t hash = BKE_cryptomatte_hash(name, name_len);
entry->encoded_hash = BKE_cryptomatte_hash_to_float(hash);

View file

@ -134,7 +134,7 @@ static void validate_cryptomatte_session_from_stamp_data(void * /*data*/,
TEST(cryptomatte, session_from_stamp_data)
{
/* Create CryptomatteSession from stamp data. */
RenderResult *render_result = MEM_callocN<RenderResult>(__func__);
RenderResult *render_result = MEM_new_for_free<RenderResult>(__func__);
BKE_render_result_stamp_data(render_result, "cryptomatte/qwerty/name", "layer1");
BKE_render_result_stamp_data(
render_result, "cryptomatte/qwerty/manifest", R"({"Object":"12345678"})");
@ -146,7 +146,7 @@ TEST(cryptomatte, session_from_stamp_data)
RE_FreeRenderResult(render_result);
/* Create StampData from CryptomatteSession. */
RenderResult *render_result2 = MEM_callocN<RenderResult>(__func__);
RenderResult *render_result2 = MEM_new_for_free<RenderResult>(__func__);
BKE_cryptomatte_store_metadata(session.get(), render_result2);
/* Validate StampData. */

View file

@ -34,7 +34,6 @@
#include "DNA_anim_types.h"
#include "DNA_curve_types.h"
#include "DNA_defaults.h"
#include "DNA_material_types.h"
/* For dereferencing pointers. */
@ -80,9 +79,7 @@ static void curve_init_data(ID *id)
{
Curve *curve = (Curve *)id;
BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(curve, id));
MEMCPY_STRUCT_AFTER(curve, DNA_struct_default_get(Curve), id);
INIT_DEFAULT_STRUCT_AFTER(curve, id);
}
static void curve_copy_data(Main *bmain,
@ -241,10 +238,10 @@ static void curve_blend_read_data(BlendDataReader *reader, ID *id)
cu->str = MEM_calloc_arrayN<char>(cu->len_char32 + 1, "str new");
}
if (UNLIKELY(cu->strinfo == nullptr)) {
cu->strinfo = MEM_calloc_arrayN<CharInfo>(cu->len_char32 + 1, "strinfo new");
cu->strinfo = MEM_new_array_for_free<CharInfo>(cu->len_char32 + 1, "strinfo new");
}
TextBox *tb = MEM_calloc_arrayN<TextBox>(MAXTEXTBOX, "TextBoxread");
TextBox *tb = MEM_new_array_for_free<TextBox>(MAXTEXTBOX, "TextBoxread");
if (cu->tb) {
memcpy(tb, cu->tb, cu->totbox * sizeof(TextBox));
MEM_freeN(cu->tb);
@ -391,10 +388,10 @@ void BKE_curve_init(Curve *cu, const short curve_type)
cu->len = len_bytes;
cu->len_char32 = cu->pos = len_char32;
cu->strinfo = MEM_calloc_arrayN<CharInfo>(len_char32 + 1, "strinfo new");
cu->strinfo = MEM_new_array_for_free<CharInfo>(len_char32 + 1, "strinfo new");
cu->totbox = cu->actbox = 1;
cu->tb = MEM_calloc_arrayN<TextBox>(MAXTEXTBOX, "textbox");
cu->tb = MEM_new_array_for_free<TextBox>(MAXTEXTBOX, "textbox");
cu->tb[0].w = cu->tb[0].h = 0.0;
}
else if (cu->ob_type == OB_SURF) {
@ -615,7 +612,7 @@ Nurb *BKE_nurb_duplicate(const Nurb *nu)
Nurb *newnu;
int len;
newnu = MEM_mallocN<Nurb>("duplicateNurb");
newnu = MEM_new_for_free<Nurb>("duplicateNurb");
if (newnu == nullptr) {
return nullptr;
}
@ -652,7 +649,7 @@ Nurb *BKE_nurb_duplicate(const Nurb *nu)
Nurb *BKE_nurb_copy(Nurb *src, int pntsu, int pntsv)
{
Nurb *newnu = MEM_mallocN<Nurb>("copyNurb");
Nurb *newnu = MEM_new_for_free<Nurb>("copyNurb");
*newnu = blender::dna::shallow_copy(*src);
if (pntsu == 1) {
@ -2587,7 +2584,7 @@ void BKE_curve_bevelList_make(Object *ob, const ListBase *nurbs, const bool for_
/* check we are a single point? also check we are not a surface and that the orderu is sane,
* enforced in the UI but can go wrong possibly */
if (!BKE_nurb_check_valid_u(nu)) {
BevList *bl = MEM_callocN<BevList>("makeBevelList1");
BevList *bl = MEM_new_for_free<BevList>("makeBevelList1");
bl->bevpoints = MEM_calloc_arrayN<BevPoint>(1, "makeBevelPoints1");
BLI_addtail(bev, bl);
bl->nr = 0;
@ -2617,7 +2614,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_callocN<BevList>(__func__);
BevList *bl = MEM_new_for_free<BevList>(__func__);
bl->bevpoints = MEM_calloc_arrayN<BevPoint>(len, __func__);
if (need_seglen && (nu->flagu & CU_NURB_CYCLIC) == 0) {
bl->seglen = MEM_malloc_arrayN<float>(size_t(segcount), __func__);
@ -2667,7 +2664,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_callocN<BevList>(__func__);
BevList *bl = MEM_new_for_free<BevList>(__func__);
bl->bevpoints = MEM_calloc_arrayN<BevPoint>(len, __func__);
if (need_seglen && (nu->flagu & CU_NURB_CYCLIC) == 0) {
bl->seglen = MEM_malloc_arrayN<float>(size_t(segcount), __func__);
@ -2803,7 +2800,7 @@ void BKE_curve_bevelList_make(Object *ob, const ListBase *nurbs, const bool for_
if (nu->pntsv == 1) {
len = (resolu * segcount);
BevList *bl = MEM_callocN<BevList>(__func__);
BevList *bl = MEM_new_for_free<BevList>(__func__);
bl->bevpoints = MEM_calloc_arrayN<BevPoint>(len, __func__);
if (need_seglen && (nu->flagu & CU_NURB_CYCLIC) == 0) {
bl->seglen = MEM_malloc_arrayN<float>(size_t(segcount), __func__);
@ -2903,8 +2900,7 @@ void BKE_curve_bevelList_make(Object *ob, const ListBase *nurbs, const bool for_
}
nr = bl->nr - bl->dupe_nr + 1; /* +1 because vector-bezier sets flag too. */
blnew = MEM_mallocN<BevList>("makeBevelList4");
memcpy(blnew, bl, sizeof(BevList));
blnew = MEM_new_for_free<BevList>("makeBevelList4", *bl);
blnew->bevpoints = MEM_calloc_arrayN<BevPoint>(nr, "makeBevelPoints4");
if (!blnew->bevpoints) {
MEM_freeN(blnew);

View file

@ -32,7 +32,7 @@
CurveProfile *BKE_curveprofile_add(eCurveProfilePresets preset)
{
CurveProfile *profile = MEM_callocN<CurveProfile>(__func__);
CurveProfile *profile = MEM_new_for_free<CurveProfile>(__func__);
BKE_curveprofile_set_defaults(profile);
profile->preset = preset;
@ -206,8 +206,8 @@ bool BKE_curveprofile_remove_point(CurveProfile *profile, CurveProfilePoint *poi
return false;
}
CurveProfilePoint *new_path = MEM_malloc_arrayN<CurveProfilePoint>(size_t(profile->path_len),
__func__);
CurveProfilePoint *new_path = MEM_new_array_for_free<CurveProfilePoint>(
size_t(profile->path_len), __func__);
int i_delete = int(point - profile->path);
BLI_assert(i_delete > 0);
@ -227,8 +227,8 @@ bool BKE_curveprofile_remove_point(CurveProfile *profile, CurveProfilePoint *poi
void BKE_curveprofile_remove_by_flag(CurveProfile *profile, const short flag)
{
/* Copy every point without the flag into the new path. */
CurveProfilePoint *new_path = MEM_malloc_arrayN<CurveProfilePoint>(size_t(profile->path_len),
__func__);
CurveProfilePoint *new_path = MEM_new_array_for_free<CurveProfilePoint>(
size_t(profile->path_len), __func__);
/* Build the new list without any of the points with the flag. Keep the first and last points. */
int i_new = 1;
@ -288,8 +288,8 @@ CurveProfilePoint *BKE_curveprofile_insert(CurveProfile *profile, float x, float
/* Insert the new point at the location we found and copy all of the old points in as well. */
profile->path_len++;
CurveProfilePoint *new_path = MEM_malloc_arrayN<CurveProfilePoint>(size_t(profile->path_len),
__func__);
CurveProfilePoint *new_path = MEM_new_array_for_free<CurveProfilePoint>(
size_t(profile->path_len), __func__);
CurveProfilePoint *new_pt = nullptr;
for (int i_new = 0, i_old = 0; i_new < profile->path_len; i_new++) {
if (i_new != i_insert) {
@ -346,8 +346,8 @@ void BKE_curveprofile_reverse(CurveProfile *profile)
if (profile->path_len == 2) {
return;
}
CurveProfilePoint *new_path = MEM_malloc_arrayN<CurveProfilePoint>(size_t(profile->path_len),
__func__);
CurveProfilePoint *new_path = MEM_new_array_for_free<CurveProfilePoint>(
size_t(profile->path_len), __func__);
/* Mirror the new points across the y = x line */
for (int i = 0; i < profile->path_len; i++) {
int i_reversed = profile->path_len - i - 1;
@ -458,7 +458,7 @@ void BKE_curveprofile_reset(CurveProfile *profile)
break;
}
profile->path = MEM_calloc_arrayN<CurveProfilePoint>(profile->path_len, __func__);
profile->path = MEM_new_array_for_free<CurveProfilePoint>(profile->path_len, __func__);
switch (preset) {
case PROF_PRESET_LINE:
@ -808,7 +808,7 @@ void BKE_curveprofile_set_defaults(CurveProfile *profile)
profile->clip_rect = profile->view_rect;
profile->path_len = 2;
profile->path = MEM_calloc_arrayN<CurveProfilePoint>(2, __func__);
profile->path = MEM_new_array_for_free<CurveProfilePoint>(2, __func__);
profile->path[0].x = 1.0f;
profile->path[0].y = 0.0f;
@ -923,8 +923,8 @@ static void create_samples_even_spacing(CurveProfile *profile,
static void curveprofile_make_table(CurveProfile *profile)
{
int n_samples = BKE_curveprofile_table_size(profile);
CurveProfilePoint *new_table = MEM_calloc_arrayN<CurveProfilePoint>(size_t(n_samples) + 1,
__func__);
CurveProfilePoint *new_table = MEM_new_array_for_free<CurveProfilePoint>((n_samples + 1),
__func__);
if (n_samples > 1) {
create_samples(profile, n_samples - 1, false, new_table);
@ -948,8 +948,8 @@ static void curveprofile_make_segments_table(CurveProfile *profile)
if (n_samples <= 0) {
return;
}
CurveProfilePoint *new_table = MEM_calloc_arrayN<CurveProfilePoint>(size_t(n_samples) + 1,
__func__);
CurveProfilePoint *new_table = MEM_new_array_for_free<CurveProfilePoint>((n_samples + 1),
__func__);
if (profile->flag & PROF_SAMPLE_EVEN_LENGTHS) {
/* Even length sampling incompatible with only straight edge sampling for now. */

View file

@ -12,7 +12,6 @@
#include "MEM_guardedalloc.h"
#include "DNA_curves_types.h"
#include "DNA_defaults.h"
#include "DNA_material_types.h"
#include "DNA_object_types.h"
@ -56,9 +55,7 @@ static const char *ATTR_POSITION = "position";
static void curves_init_data(ID *id)
{
Curves *curves = (Curves *)id;
BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(curves, id));
MEMCPY_STRUCT_AFTER(curves, DNA_struct_default_get(Curves), id);
INIT_DEFAULT_STRUCT_AFTER(curves, id);
new (&curves->geometry) blender::bke::CurvesGeometry();
}

View file

@ -21,7 +21,6 @@
#include "DNA_meshdata_types.h"
#include "DNA_modifier_enums.h"
#include "DNA_userdef_types.h"
#include "DNA_vec_types.h"
#include "BLI_bit_vector.hh"
#include "BLI_bitmap.h"
@ -2409,7 +2408,7 @@ CustomData CustomData_shallow_copy_remove_non_bmesh_attributes(const CustomData
}
CustomData dst = *src;
dst.layers = MEM_calloc_arrayN<CustomDataLayer>(dst_layers.size(), __func__);
dst.layers = MEM_new_array_for_free<CustomDataLayer>(dst_layers.size(), __func__);
dst.maxlayer = dst.totlayer = dst_layers.size();
memcpy(dst.layers, dst_layers.data(), dst_layers.as_span().size_in_bytes());
@ -4557,7 +4556,7 @@ void CustomData_external_add(CustomData *data,
}
if (!external) {
external = MEM_callocN<CustomDataExternal>(__func__);
external = MEM_new_for_free<CustomDataExternal>(__func__);
data->external = external;
}
STRNCPY(external->filepath, filepath);

View file

@ -52,7 +52,7 @@ bDeformGroup *BKE_object_defgroup_new(Object *ob, const StringRef name)
BLI_assert(OB_TYPE_SUPPORT_VGROUP(ob->type));
defgroup = MEM_callocN<bDeformGroup>(__func__);
defgroup = MEM_new_for_free<bDeformGroup>(__func__);
name.copy_utf8_truncated(defgroup->name);
@ -87,7 +87,7 @@ bDeformGroup *BKE_defgroup_duplicate(const bDeformGroup *ingroup)
return nullptr;
}
bDeformGroup *outgroup = MEM_callocN<bDeformGroup>(__func__);
bDeformGroup *outgroup = MEM_new_for_free<bDeformGroup>(__func__);
/* For now, just copy everything over. */
memcpy(outgroup, ingroup, sizeof(bDeformGroup));

View file

@ -1044,7 +1044,7 @@ void dynamicPaint_Modifier_free(DynamicPaintModifierData *pmd)
DynamicPaintSurface *dynamicPaint_createNewSurface(DynamicPaintCanvasSettings *canvas,
Scene *scene)
{
DynamicPaintSurface *surface = MEM_callocN<DynamicPaintSurface>(__func__);
DynamicPaintSurface *surface = MEM_new_for_free<DynamicPaintSurface>(__func__);
if (!surface) {
return nullptr;
}
@ -1127,7 +1127,7 @@ bool dynamicPaint_createType(DynamicPaintModifierData *pmd, int type, Scene *sce
dynamicPaint_freeCanvas(pmd);
}
canvas = pmd->canvas = MEM_callocN<DynamicPaintCanvasSettings>(__func__);
canvas = pmd->canvas = MEM_new_for_free<DynamicPaintCanvasSettings>(__func__);
if (!canvas) {
return false;
}
@ -1144,7 +1144,7 @@ bool dynamicPaint_createType(DynamicPaintModifierData *pmd, int type, Scene *sce
dynamicPaint_freeBrush(pmd);
}
brush = pmd->brush = MEM_callocN<DynamicPaintBrushSettings>(__func__);
brush = pmd->brush = MEM_new_for_free<DynamicPaintBrushSettings>(__func__);
if (!brush) {
return false;
}

View file

@ -53,7 +53,7 @@ void BKE_editlattice_make(Object *obedit)
if (actkey) {
BKE_keyblock_convert_to_lattice(actkey, lt);
}
lt->editlatt = MEM_callocN<EditLatt>("editlatt");
lt->editlatt = MEM_new_for_free<EditLatt>("editlatt");
lt->editlatt->latt = static_cast<Lattice *>(MEM_dupallocN(lt));
lt->editlatt->latt->def = static_cast<BPoint *>(MEM_dupallocN(lt->def));

View file

@ -15,6 +15,7 @@
#include "MEM_guardedalloc.h"
#include "DNA_curve_types.h"
#include "DNA_layer_types.h"
#include "DNA_listBase.h"
#include "DNA_mesh_types.h"
#include "DNA_object_force_types.h"
@ -57,7 +58,7 @@
EffectorWeights *BKE_effector_add_weights(Collection *collection)
{
EffectorWeights *weights = MEM_callocN<EffectorWeights>("EffectorWeights");
EffectorWeights *weights = MEM_new_for_free<EffectorWeights>("EffectorWeights");
for (int i = 0; i < NUM_PFIELD_TYPES; i++) {
weights->weight[i] = 1.0f;
}
@ -72,7 +73,7 @@ PartDeflect *BKE_partdeflect_new(int type)
{
PartDeflect *pd;
pd = MEM_callocN<PartDeflect>("PartDeflect");
pd = MEM_new_for_free<PartDeflect>("PartDeflect");
pd->forcefield = type;
pd->pdef_sbdamp = 0.1f;

View file

@ -18,6 +18,7 @@
#include "DNA_action_types.h"
#include "DNA_anim_types.h"
#include "DNA_curve_types.h"
#include "BLI_easing.h"
#include "BLI_ghash.h"
@ -62,7 +63,7 @@ static CLG_LogRef LOG = {"anim.fcurve"};
FCurve *BKE_fcurve_create()
{
FCurve *fcu = MEM_callocN<FCurve>(__func__);
FCurve *fcu = MEM_new_for_free<FCurve>(__func__);
return fcu;
}
@ -981,8 +982,7 @@ void fcurve_store_samples(FCurve *fcu, void *data, int start, int end, FcuSample
/* Set up sample data. */
FPoint *new_fpt;
FPoint *fpt = new_fpt = MEM_calloc_arrayN<FPoint>(size_t(end) - size_t(start) + 1,
"FPoint Samples");
FPoint *fpt = new_fpt = MEM_calloc_arrayN<FPoint>((end - start + 1), "FPoint Samples");
/* Use the sampling callback at 1-frame intervals from start to end frames. */
for (int cfra = start; cfra <= end; cfra++, fpt++) {
@ -1649,7 +1649,7 @@ void BKE_fcurve_bezt_resize(FCurve *fcu, const int new_totvert)
* of the fields will actually be updated by the caller. */
const int old_totvert = fcu->totvert;
if (new_totvert > old_totvert) {
memset(&fcu->bezt[old_totvert], 0, sizeof(fcu->bezt[0]) * (new_totvert - old_totvert));
std::fill_n(fcu->bezt + old_totvert, new_totvert - old_totvert, BezTriple{});
}
fcu->totvert = new_totvert;

View file

@ -1017,7 +1017,7 @@ DriverVar *driver_add_new_variable(ChannelDriver *driver)
}
/* Make a new variable. */
dvar = MEM_callocN<DriverVar>("DriverVar");
dvar = MEM_new_for_free<DriverVar>("DriverVar");
BLI_addtail(&driver->variables, dvar);
/* Don't use translations as this is referenced as a literal in #ChannelDriver::expression. */

View file

@ -21,7 +21,6 @@
#include "BLI_utildefines.h"
#include "DNA_colorband_types.h"
#include "DNA_defaults.h"
#include "DNA_fluid_types.h"
#include "DNA_modifier_types.h"
#include "DNA_object_types.h"
@ -4427,7 +4426,7 @@ void BKE_fluid_particle_system_create(Main *bmain,
/* add particle system */
part = BKE_particlesettings_add(bmain, pset_name);
psys = MEM_callocN<ParticleSystem>(__func__);
psys = MEM_new_for_free<ParticleSystem>(__func__);
part->type = psys_type;
part->totpart = 0;
@ -4783,7 +4782,7 @@ void BKE_fluid_modifier_create_type_data(FluidModifierData *fmd)
fluid_modifier_freeDomain(fmd);
}
fmd->domain = DNA_struct_default_alloc(FluidDomainSettings);
fmd->domain = MEM_new_for_free<FluidDomainSettings>(__func__);
fmd->domain->fmd = fmd;
/* Turn off incompatible options. */
@ -4815,7 +4814,7 @@ void BKE_fluid_modifier_create_type_data(FluidModifierData *fmd)
fluid_modifier_freeFlow(fmd);
}
fmd->flow = DNA_struct_default_alloc(FluidFlowSettings);
fmd->flow = MEM_new_for_free<FluidFlowSettings>(__func__);
fmd->flow->fmd = fmd;
}
else if (fmd->type & MOD_FLUID_TYPE_EFFEC) {
@ -4823,7 +4822,7 @@ void BKE_fluid_modifier_create_type_data(FluidModifierData *fmd)
fluid_modifier_freeEffector(fmd);
}
fmd->effector = DNA_struct_default_alloc(FluidEffectorSettings);
fmd->effector = MEM_new_for_free<FluidEffectorSettings>(__func__);
fmd->effector->fmd = fmd;
}
}

View file

@ -1090,7 +1090,7 @@ FModifier *add_fmodifier(ListBase *modifiers, int type, FCurve *owner_fcu)
}
/* add modifier itself */
fcm = MEM_callocN<FModifier>("F-Curve Modifier");
fcm = MEM_new_for_free<FModifier>("F-Curve Modifier");
fcm->type = type;
fcm->ui_expand_flag = UI_PANEL_DATA_EXPAND_ROOT; /* Expand the main panel, not the sub-panels. */
fcm->curve = owner_fcu;

View file

@ -110,7 +110,7 @@ static void copy_lineset(FreestyleLineSet *new_lineset, FreestyleLineSet *linese
static FreestyleModuleConfig *alloc_module()
{
return MEM_callocN<FreestyleModuleConfig>("style module configuration");
return MEM_new_for_free<FreestyleModuleConfig>("style module configuration");
}
FreestyleModuleConfig *BKE_freestyle_module_add(FreestyleConfig *config)
@ -157,7 +157,7 @@ void BKE_freestyle_lineset_unique_name(FreestyleConfig *config, FreestyleLineSet
static FreestyleLineSet *alloc_lineset()
{
return MEM_callocN<FreestyleLineSet>("Freestyle line set");
return MEM_new_for_free<FreestyleLineSet>("Freestyle line set");
}
FreestyleLineSet *BKE_freestyle_lineset_add(Main *bmain, FreestyleConfig *config, const char *name)

View file

@ -179,8 +179,8 @@ void BKE_gpencil_stroke_fill_triangulate(bGPDstroke *gps)
/* Save triangulation data. */
if (gps->tot_triangles > 0) {
MEM_SAFE_FREE(gps->triangles);
gps->triangles = MEM_calloc_arrayN<bGPDtriangle>(gps->tot_triangles,
"GP Stroke triangulation");
gps->triangles = MEM_new_array_for_free<bGPDtriangle>(gps->tot_triangles,
"GP Stroke triangulation");
for (int i = 0; i < gps->tot_triangles; i++) {
memcpy(gps->triangles[i].verts, tmp_triangles[i], sizeof(uint[3]));
@ -260,7 +260,7 @@ static void gpencil_stroke_join_islands(bGPdata *gpd,
/* create new stroke */
bGPDstroke *join_stroke = BKE_gpencil_stroke_duplicate(gps_first, false, true);
join_stroke->points = MEM_calloc_arrayN<bGPDspoint>(totpoints, __func__);
join_stroke->points = MEM_new_array_for_free<bGPDspoint>(totpoints, __func__);
join_stroke->totpoints = totpoints;
join_stroke->flag &= ~GP_STROKE_CYCLIC;
@ -417,8 +417,8 @@ bGPDstroke *BKE_gpencil_stroke_delete_tagged_points(bGPdata *gpd,
new_stroke->totpoints = island->end_idx - island->start_idx + 1;
/* Copy over the relevant point data */
new_stroke->points = MEM_calloc_arrayN<bGPDspoint>(new_stroke->totpoints,
"gp delete stroke fragment");
new_stroke->points = MEM_new_array_for_free<bGPDspoint>(new_stroke->totpoints,
"gp delete stroke fragment");
memcpy(static_cast<void *>(new_stroke->points),
gps->points + island->start_idx,
sizeof(bGPDspoint) * new_stroke->totpoints);

View file

@ -465,7 +465,7 @@ bGPDframe *BKE_gpencil_frame_addnew(bGPDlayer *gpl, int cframe)
}
/* allocate memory for this frame */
gpf = MEM_callocN<bGPDframe>("bGPDframe");
gpf = MEM_new_for_free<bGPDframe>("bGPDframe");
gpf->framenum = cframe;
/* find appropriate place to add frame */
@ -575,7 +575,7 @@ bGPDlayer *BKE_gpencil_layer_addnew(bGPdata *gpd,
}
/* allocate memory for frame and add to end of list */
gpl = MEM_callocN<bGPDlayer>("bGPDlayer");
gpl = MEM_new_for_free<bGPDlayer>("bGPDlayer");
gpl_active = BKE_gpencil_layer_active_get(gpd);

View file

@ -66,7 +66,6 @@
#include "DNA_ID.h"
#include "DNA_ID_enums.h"
#include "DNA_brush_types.h"
#include "DNA_defaults.h"
#include "DNA_grease_pencil_types.h"
#include "DNA_material_types.h"
#include "DNA_modifier_types.h"
@ -104,9 +103,7 @@ static void grease_pencil_init_data(ID *id)
using namespace blender::bke;
GreasePencil *grease_pencil = reinterpret_cast<GreasePencil *>(id);
BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(grease_pencil, id));
MEMCPY_STRUCT_AFTER(grease_pencil, DNA_struct_default_get(GreasePencil), id);
INIT_DEFAULT_STRUCT_AFTER(grease_pencil, id);
grease_pencil->root_group_ptr = MEM_new<greasepencil::LayerGroup>(__func__);
grease_pencil->set_active_node(nullptr);
@ -1500,8 +1497,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_calloc_arrayN<int>(frames_num, __func__);
frames_storage.values = MEM_calloc_arrayN<GreasePencilFrame>(frames_num, __func__);
frames_storage.keys = MEM_new_array_for_free<int>(frames_num, __func__);
frames_storage.values = MEM_new_array_for_free<GreasePencilFrame>(frames_num, __func__);
const Span<int> sorted_keys_data = sorted_keys();
for (const int64_t i : sorted_keys_data.index_range()) {
frames_storage.keys[i] = sorted_keys_data[i];
@ -2376,7 +2373,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_calloc_arrayN<GreasePencilDrawingBase *>(
grease_pencil_dst->drawing_array = MEM_new_array_for_free<GreasePencilDrawingBase *>(
grease_pencil_src->drawing_array_num, __func__);
bke::greasepencil::copy_drawing_array(grease_pencil_src->drawings(),
grease_pencil_dst->drawings());

View file

@ -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_callocN<GeometryNodeAssetTraits>(__func__);
group->geometry_node_asset_traits = MEM_new_for_free<GeometryNodeAssetTraits>(__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_calloc_arrayN<GreasePencilDashModifierSegment>(
md_dash.segments_array = MEM_new_array_for_free<GreasePencilDashModifierSegment>(
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_calloc_arrayN<GreasePencilTimeModifierSegment>(
md_time.segments_array = MEM_new_array_for_free<GreasePencilTimeModifierSegment>(
legacy_md_time.segments_len, __func__);
for (const int i : IndexRange(md_time.segments_num)) {
GreasePencilTimeModifierSegment &dst_segment = md_time.segments_array[i];

View file

@ -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_callocN<bDeformGroup>(__func__);
bDeformGroup *defgroup = MEM_new_for_free<bDeformGroup>(__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_callocN<bDeformGroup>(__func__);
bDeformGroup *defgroup = MEM_new_for_free<bDeformGroup>(__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_callocN<bDeformGroup>(__func__);
bDeformGroup *defgroup = MEM_new_for_free<bDeformGroup>(__func__);
name.copy_utf8_truncated(defgroup->name);
BLI_addtail(&vertex_group_names, defgroup);

View file

@ -66,7 +66,7 @@ static size_t idp_size_table[] = {
IDProperty *IDP_NewIDPArray(const blender::StringRef name)
{
IDProperty *prop = MEM_callocN<IDProperty>("IDProperty prop array");
IDProperty *prop = MEM_new_for_free<IDProperty>("IDProperty prop array");
prop->type = IDP_IDPARRAY;
prop->len = 0;
name.copy_utf8_truncated(prop->name);
@ -79,8 +79,7 @@ IDProperty *IDP_CopyIDPArray(const IDProperty *array, const int flag)
/* don't use MEM_dupallocN because this may be part of an array */
BLI_assert(array->type == IDP_IDPARRAY);
IDProperty *narray = MEM_mallocN<IDProperty>(__func__);
*narray = *array;
IDProperty *narray = MEM_new_for_free<IDProperty>(__func__, *array);
narray->data.pointer = MEM_dupallocN(array->data.pointer);
for (int i = 0; i < narray->len; i++) {
@ -311,7 +310,7 @@ IDPropertyUIData *IDP_ui_data_copy(const IDProperty *prop)
static IDProperty *idp_generic_copy(const IDProperty *prop, const int /*flag*/)
{
IDProperty *newp = MEM_callocN<IDProperty>(__func__);
IDProperty *newp = MEM_new_for_free<IDProperty>(__func__);
STRNCPY(newp->name, prop->name);
newp->type = prop->type;
@ -361,7 +360,7 @@ IDProperty *IDP_NewStringMaxSize(const char *st,
const blender::StringRef name,
const eIDPropertyFlag flags)
{
IDProperty *prop = MEM_callocN<IDProperty>("IDProperty string");
IDProperty *prop = MEM_new_for_free<IDProperty>("IDProperty string");
if (st == nullptr) {
prop->data.pointer = MEM_malloc_arrayN<char>(DEFAULT_ALLOC_FOR_NULL_STRINGS,
@ -878,7 +877,7 @@ IDProperty *IDP_GetProperties(ID *id)
IDProperty *IDP_EnsureProperties(ID *id)
{
if (id->properties == nullptr) {
id->properties = MEM_callocN<IDProperty>("IDProperty");
id->properties = MEM_new_for_free<IDProperty>("IDProperty");
id->properties->type = IDP_GROUP;
/* NOTE(@ideasman42): Don't overwrite the data's name and type
* some functions might need this if they
@ -896,7 +895,7 @@ IDProperty *IDP_ID_system_properties_get(ID *id)
IDProperty *IDP_ID_system_properties_ensure(ID *id)
{
if (id->system_properties == nullptr) {
id->system_properties = MEM_callocN<IDProperty>(__func__);
id->system_properties = MEM_new_for_free<IDProperty>(__func__);
id->system_properties->type = IDP_GROUP;
/* NOTE(@ideasman42): Don't overwrite the data's name and type
* some functions might need this if they
@ -1011,19 +1010,19 @@ IDProperty *IDP_New(const char type,
switch (type) {
case IDP_INT:
prop = MEM_callocN<IDProperty>("IDProperty int");
prop = MEM_new_for_free<IDProperty>("IDProperty int");
prop->data.val = val->i;
break;
case IDP_FLOAT:
prop = MEM_callocN<IDProperty>("IDProperty float");
prop = MEM_new_for_free<IDProperty>("IDProperty float");
*(float *)&prop->data.val = val->f;
break;
case IDP_DOUBLE:
prop = MEM_callocN<IDProperty>("IDProperty double");
prop = MEM_new_for_free<IDProperty>("IDProperty double");
*(double *)&prop->data.val = val->d;
break;
case IDP_BOOLEAN:
prop = MEM_callocN<IDProperty>("IDProperty boolean");
prop = MEM_new_for_free<IDProperty>("IDProperty boolean");
prop->data.val = bool(val->i);
break;
case IDP_ARRAY: {
@ -1031,7 +1030,7 @@ IDProperty *IDP_New(const char type,
* `IDP_ARRAY`. This is most likely a mistake. `IDP_GROUP` array should be of type
* `IDP_IDPARRAY`, as done e.g. in #idp_from_PySequence_Buffer in bpy API. */
if (ELEM(val->array.type, IDP_FLOAT, IDP_INT, IDP_DOUBLE, IDP_GROUP, IDP_BOOLEAN)) {
prop = MEM_callocN<IDProperty>("IDProperty array");
prop = MEM_new_for_free<IDProperty>("IDProperty array");
prop->subtype = val->array.type;
if (val->array.len) {
prop->data.pointer = MEM_calloc_arrayN(
@ -1046,7 +1045,7 @@ IDProperty *IDP_New(const char type,
case IDP_STRING: {
const char *st = val->string.str;
prop = MEM_callocN<IDProperty>("IDProperty string");
prop = MEM_new_for_free<IDProperty>("IDProperty string");
if (val->string.subtype == IDP_STRING_SUB_BYTE) {
/* NOTE: Intentionally not null terminated. */
if (st == nullptr) {
@ -1087,18 +1086,18 @@ IDProperty *IDP_New(const char type,
}
case IDP_GROUP: {
/* Values are set properly by calloc. */
prop = MEM_callocN<IDProperty>("IDProperty group");
prop = MEM_new_for_free<IDProperty>("IDProperty group");
break;
}
case IDP_ID: {
prop = MEM_callocN<IDProperty>("IDProperty datablock");
prop = MEM_new_for_free<IDProperty>("IDProperty datablock");
prop->data.pointer = (void *)val->id;
prop->type = IDP_ID;
id_us_plus(IDP_ID_get(prop));
break;
}
default: {
prop = MEM_callocN<IDProperty>("IDProperty array");
prop = MEM_new_for_free<IDProperty>("IDProperty array");
break;
}
}
@ -1715,15 +1714,15 @@ static IDPropertyUIData *ui_data_alloc(const eIDPropertyUIDataType type)
{
switch (type) {
case IDP_UI_DATA_TYPE_STRING: {
IDPropertyUIDataString *ui_data = MEM_callocN<IDPropertyUIDataString>(__func__);
IDPropertyUIDataString *ui_data = MEM_new_for_free<IDPropertyUIDataString>(__func__);
return &ui_data->base;
}
case IDP_UI_DATA_TYPE_ID: {
IDPropertyUIDataID *ui_data = MEM_callocN<IDPropertyUIDataID>(__func__);
IDPropertyUIDataID *ui_data = MEM_new_for_free<IDPropertyUIDataID>(__func__);
return &ui_data->base;
}
case IDP_UI_DATA_TYPE_INT: {
IDPropertyUIDataInt *ui_data = MEM_callocN<IDPropertyUIDataInt>(__func__);
IDPropertyUIDataInt *ui_data = MEM_new_for_free<IDPropertyUIDataInt>(__func__);
ui_data->min = INT_MIN;
ui_data->max = INT_MAX;
ui_data->soft_min = INT_MIN;
@ -1732,11 +1731,11 @@ static IDPropertyUIData *ui_data_alloc(const eIDPropertyUIDataType type)
return &ui_data->base;
}
case IDP_UI_DATA_TYPE_BOOLEAN: {
IDPropertyUIDataBool *ui_data = MEM_callocN<IDPropertyUIDataBool>(__func__);
IDPropertyUIDataBool *ui_data = MEM_new_for_free<IDPropertyUIDataBool>(__func__);
return &ui_data->base;
}
case IDP_UI_DATA_TYPE_FLOAT: {
IDPropertyUIDataFloat *ui_data = MEM_callocN<IDPropertyUIDataFloat>(__func__);
IDPropertyUIDataFloat *ui_data = MEM_new_for_free<IDPropertyUIDataFloat>(__func__);
ui_data->min = -FLT_MAX;
ui_data->max = FLT_MAX;
ui_data->soft_min = -FLT_MAX;

View file

@ -49,7 +49,6 @@
#include "DNA_brush_types.h"
#include "DNA_camera_types.h"
#include "DNA_defaults.h"
#include "DNA_image_types.h"
#include "DNA_light_types.h"
#include "DNA_material_types.h"
@ -625,7 +624,7 @@ void BKE_image_free_data(Image *ima)
static ImageTile *imagetile_alloc(int tile_number)
{
ImageTile *tile = MEM_callocN<ImageTile>("Image Tile");
ImageTile *tile = MEM_new_for_free<ImageTile>("Image Tile");
tile->tile_number = tile_number;
tile->gen_x = 1024;
tile->gen_y = 1024;
@ -636,9 +635,7 @@ static ImageTile *imagetile_alloc(int tile_number)
/* only image block itself */
static void image_init(Image *ima, short source, short type)
{
BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(ima, id));
MEMCPY_STRUCT_AFTER(ima, DNA_struct_default_get(Image), id);
INIT_DEFAULT_STRUCT_AFTER(ima, id);
ima->source = source;
ima->type = type;
@ -659,7 +656,7 @@ static void image_init(Image *ima, short source, short type)
ima->runtime = MEM_new<blender::bke::ImageRuntime>(__func__);
BKE_color_managed_colorspace_settings_init(&ima->colorspace_settings);
ima->stereo3d_format = MEM_callocN<Stereo3dFormat>("Image Stereo Format");
ima->stereo3d_format = MEM_new_for_free<Stereo3dFormat>("Image Stereo Format");
}
static Image *image_alloc(Main *bmain,
@ -722,7 +719,7 @@ static void copy_image_packedfiles(ListBase *lb_dst, const ListBase *lb_src)
for (imapf_src = static_cast<const ImagePackedFile *>(lb_src->first); imapf_src;
imapf_src = imapf_src->next)
{
ImagePackedFile *imapf_dst = MEM_mallocN<ImagePackedFile>("Image Packed Files (copy)");
ImagePackedFile *imapf_dst = MEM_new_for_free<ImagePackedFile>("Image Packed Files (copy)");
imapf_dst->view = imapf_src->view;
imapf_dst->tile_number = imapf_src->tile_number;
@ -1380,7 +1377,7 @@ static bool image_memorypack_imbuf(
const int encoded_size = ibuf->encoded_size;
PackedFile *pf = BKE_packedfile_new_from_memory(IMB_steal_encoded_buffer(ibuf), encoded_size);
imapf = MEM_mallocN<ImagePackedFile>("Image PackedFile");
imapf = MEM_new_for_free<ImagePackedFile>("Image PackedFile");
STRNCPY(imapf->filepath, filepath);
imapf->packedfile = pf;
imapf->view = view;
@ -1472,7 +1469,7 @@ void BKE_image_packfiles(ReportList *reports, Image *ima, const char *basepath)
char filepath[FILE_MAX];
BKE_image_user_file_path(&iuser, ima, filepath);
ImagePackedFile *imapf = MEM_mallocN<ImagePackedFile>("Image packed file");
ImagePackedFile *imapf = MEM_new_for_free<ImagePackedFile>("Image packed file");
BLI_addtail(&ima->packedfiles, imapf);
imapf->packedfile = BKE_packedfile_new(reports, filepath, basepath);
@ -1502,7 +1499,7 @@ void BKE_image_packfiles_from_mem(ReportList *reports,
BKE_report(reports, RPT_ERROR, "Cannot pack tiled images from raw data currently...");
}
else {
ImagePackedFile *imapf = MEM_mallocN<ImagePackedFile>(__func__);
ImagePackedFile *imapf = MEM_new_for_free<ImagePackedFile>(__func__);
BLI_addtail(&ima->packedfiles, imapf);
imapf->packedfile = BKE_packedfile_new_from_memory(data, data_len);
imapf->view = 0;
@ -3776,7 +3773,7 @@ static void image_init_multilayer_multiview(Image *ima, RenderResult *rr)
if (rr) {
LISTBASE_FOREACH (RenderView *, rv, &rr->views) {
ImageView *iv = MEM_callocN<ImageView>("Viewer Image View");
ImageView *iv = MEM_new_for_free<ImageView>("Viewer Image View");
STRNCPY_UTF8(iv->name, rv->name);
BLI_addtail(&ima->views, iv);
}
@ -3887,9 +3884,7 @@ void BKE_image_backup_render(Scene *scene, Image *ima, bool free_current_slot)
static void image_add_view(Image *ima, const char *viewname, const char *filepath)
{
ImageView *iv;
iv = MEM_mallocN<ImageView>("Viewer Image View");
ImageView *iv = MEM_new_for_free<ImageView>("Viewer Image View");
STRNCPY_UTF8(iv->name, viewname);
STRNCPY(iv->filepath, filepath);
@ -4099,7 +4094,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_callocN<ImageAnim>("Image Anim");
ImageAnim *ia = MEM_new_for_free<ImageAnim>("Image Anim");
BLI_addtail(&ima->anims, ia);
}
}
@ -4218,7 +4213,7 @@ static ImBuf *load_image_single(Image *ima,
/* Make packed file for auto-pack. */
if (!is_sequence && (has_packed == false) && (G.fileflags & G_FILE_AUTOPACK)) {
ImagePackedFile *imapf = MEM_mallocN<ImagePackedFile>("Image Pack-file");
ImagePackedFile *imapf = MEM_new_for_free<ImagePackedFile>("Image Pack-file");
BLI_addtail(&ima->packedfiles, imapf);
STRNCPY(imapf->filepath, filepath);
@ -5576,7 +5571,7 @@ static void image_update_views_format(Image *ima, ImageUser *iuser)
RenderSlot *BKE_image_add_renderslot(Image *ima, const char *name)
{
RenderSlot *slot = MEM_callocN<RenderSlot>("Image new Render Slot");
RenderSlot *slot = MEM_new_for_free<RenderSlot>("Image new Render Slot");
if (name && name[0]) {
STRNCPY_UTF8(slot->name, name);
}

View file

@ -8,7 +8,6 @@
#include <cstring>
#include "DNA_defaults.h"
#include "DNA_scene_types.h"
#include "BLI_path_utils.hh"
@ -30,7 +29,7 @@ namespace path_templates = blender::bke::path_templates;
void BKE_image_format_init(ImageFormatData *imf)
{
*imf = *DNA_struct_default_get(ImageFormatData);
*imf = ImageFormatData();
BKE_color_managed_display_settings_init(&imf->display_settings);
@ -178,7 +177,7 @@ void BKE_image_format_set(ImageFormatData *imf, ID *owner_id, const char imtype)
int BKE_imtype_to_ftype(const char imtype, ImbFormatOptions *r_options)
{
memset(r_options, 0, sizeof(*r_options));
*r_options = ImbFormatOptions();
if (imtype == R_IMF_IMTYPE_TARGA) {
return IMB_FTYPE_TGA;

View file

@ -1574,7 +1574,7 @@ KeyBlock *BKE_keyblock_add(Key *key, const char *name)
curpos = kb->pos;
}
kb = MEM_callocN<KeyBlock>("Keyblock");
kb = MEM_new_for_free<KeyBlock>("Keyblock");
BLI_addtail(&key->block, kb);
kb->type = KEY_LINEAR;

View file

@ -36,7 +36,7 @@ wmKeyConfigPref *BKE_keyconfig_pref_ensure(UserDef *userdef, const char *kc_idna
wmKeyConfigPref *kpt = static_cast<wmKeyConfigPref *>(BLI_findstring(
&userdef->user_keyconfig_prefs, kc_idname, offsetof(wmKeyConfigPref, idname)));
if (kpt == nullptr) {
kpt = MEM_callocN<wmKeyConfigPref>(__func__);
kpt = MEM_new_for_free<wmKeyConfigPref>(__func__);
STRNCPY(kpt->idname, kc_idname);
BLI_addtail(&userdef->user_keyconfig_prefs, kpt);
}

View file

@ -25,7 +25,6 @@
#define DNA_DEPRECATED_ALLOW
#include "DNA_curve_types.h"
#include "DNA_defaults.h"
#include "DNA_key_types.h"
#include "DNA_lattice_types.h"
#include "DNA_meshdata_types.h"
@ -54,9 +53,7 @@ static void lattice_init_data(ID *id)
{
Lattice *lattice = (Lattice *)id;
BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(lattice, id));
MEMCPY_STRUCT_AFTER(lattice, DNA_struct_default_get(Lattice), id);
INIT_DEFAULT_STRUCT_AFTER(lattice, id);
lattice->def = MEM_callocN<BPoint>("lattvert"); /* temporary */
BKE_lattice_resize(lattice, 2, 2, 2, nullptr); /* creates a uniform lattice */

View file

@ -37,7 +37,6 @@
#include "DNA_ID.h"
#include "DNA_collection_types.h"
#include "DNA_defaults.h"
#include "DNA_layer_types.h"
#include "DNA_node_types.h"
#include "DNA_object_types.h"
@ -77,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_callocN<LayerCollection>("Collection Base");
LayerCollection *lc = MEM_new_for_free<LayerCollection>("Collection Base");
lc->collection = collection;
lc->local_collections_bits = ~0;
BLI_addtail(lb_parent, lc);
@ -100,7 +99,7 @@ static void layer_collection_free(ViewLayer *view_layer, LayerCollection *lc)
static Base *object_base_new(Object *ob)
{
Base *base = MEM_callocN<Base>("Object Base");
Base *base = MEM_new_for_free<Base>("Object Base");
base->object = ob;
base->local_view_bits = ~0;
if (ob->base_flag & BASE_SELECTED) {
@ -164,8 +163,7 @@ static ViewLayer *view_layer_add(const char *name)
name = DATA_("ViewLayer");
}
ViewLayer *view_layer = MEM_callocN<ViewLayer>("View Layer");
*view_layer = *DNA_struct_default_get(ViewLayer);
ViewLayer *view_layer = MEM_new_for_free<ViewLayer>("View Layer");
STRNCPY_UTF8(view_layer->name, name);
BKE_freestyle_config_init(&view_layer->freestyle_config);
@ -204,7 +202,7 @@ ViewLayer *BKE_view_layer_add(Scene *scene,
}
case VIEWLAYER_ADD_COPY: {
/* Allocate and copy view layer data */
view_layer_new = MEM_callocN<ViewLayer>("View Layer");
view_layer_new = MEM_new_for_free<ViewLayer>("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);
@ -2550,7 +2548,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_callocN<ViewLayerAOV>(__func__);
aov = MEM_new_for_free<ViewLayerAOV>(__func__);
aov->type = AOV_TYPE_COLOR;
STRNCPY_UTF8(aov->name, DATA_("AOV"));
BLI_addtail(&view_layer->aovs, aov);
@ -2664,7 +2662,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_callocN<ViewLayerLightgroup>(__func__);
lightgroup = MEM_new_for_free<ViewLayerLightgroup>(__func__);
STRNCPY_UTF8(lightgroup->name, (name && name[0]) ? name : DATA_("Lightgroup"));
BLI_addtail(&view_layer->lightgroups, lightgroup);
viewlayer_lightgroup_active_set(view_layer, lightgroup);
@ -2757,7 +2755,7 @@ void BKE_lightgroup_membership_set(LightgroupMembership **lgm, const char *name)
{
if (name[0] != '\0') {
if (*lgm == nullptr) {
*lgm = MEM_callocN<LightgroupMembership>(__func__);
*lgm = MEM_new_for_free<LightgroupMembership>(__func__);
}
BLI_strncpy_utf8((*lgm)->name, name, sizeof((*lgm)->name));
}

View file

@ -18,6 +18,7 @@
#include "CLG_log.h"
#include "DNA_defs.h"
#include "MEM_guardedalloc.h"
/* all types are needed here, in order to do memory operations */
@ -1570,7 +1571,7 @@ void BKE_libblock_copy_in_lib(Main *bmain,
/* `new_id_p` already contains pointer to allocated memory.
* Clear and initialize it similar to BKE_libblock_alloc_in_lib. */
const size_t size = BKE_libblock_get_alloc_info(GS(id->name), nullptr);
memset(new_id, 0, size);
memset((void *)new_id, 0, size);
BKE_libblock_runtime_ensure(*new_id);
STRNCPY(new_id->name, id->name);
new_id->us = 0;

View file

@ -105,7 +105,7 @@ BLI_INLINE IDOverrideLibraryRuntime *override_library_runtime_ensure(
IDOverrideLibrary *liboverride)
{
if (liboverride->runtime == nullptr) {
liboverride->runtime = MEM_callocN<IDOverrideLibraryRuntime>(__func__);
liboverride->runtime = MEM_new_for_free<IDOverrideLibraryRuntime>(__func__);
}
return liboverride->runtime;
}
@ -169,7 +169,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_callocN<IDOverrideLibrary>(__func__);
local_id->override_library = MEM_new_for_free<IDOverrideLibrary>(__func__);
local_id->override_library->reference = reference_id;
if (reference_id) {
id_us_plus(local_id->override_library->reference);
@ -4021,7 +4021,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_callocN<IDOverrideLibraryProperty>(__func__);
op = MEM_new_for_free<IDOverrideLibraryProperty>(__func__);
op->rna_path = BLI_strdup(rna_path);
BLI_addtail(&liboverride->properties, op);
@ -4312,7 +4312,7 @@ IDOverrideLibraryPropertyOperation *BKE_lib_override_library_property_operation_
r_strict);
if (opop == nullptr) {
opop = MEM_callocN<IDOverrideLibraryPropertyOperation>(__func__);
opop = MEM_new_for_free<IDOverrideLibraryPropertyOperation>(__func__);
opop->operation = operation;
if (subitem_locname) {
opop->subitem_local_name = BLI_strdup(subitem_locname);

View file

@ -14,7 +14,6 @@
/* Allow using deprecated functionality for .blend file I/O. */
#define DNA_DEPRECATED_ALLOW
#include "DNA_defaults.h"
#include "DNA_light_types.h"
#include "DNA_node_types.h"
#include "DNA_scene_types.h"
@ -45,9 +44,7 @@
static void light_init_data(ID *id)
{
Light *la = (Light *)id;
BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(la, id));
MEMCPY_STRUCT_AFTER(la, DNA_struct_default_get(Light), id);
INIT_DEFAULT_STRUCT_AFTER(la, id);
}
/**

View file

@ -30,7 +30,7 @@
void BKE_light_linking_ensure(Object *object)
{
if (object->light_linking == nullptr) {
object->light_linking = MEM_callocN<LightLinking>(__func__);
object->light_linking = MEM_new_for_free<LightLinking>(__func__);
}
}

View file

@ -9,7 +9,6 @@
#include <cstring>
#include "DNA_collection_types.h"
#include "DNA_defaults.h"
#include "DNA_lightprobe_types.h"
#include "DNA_object_types.h"
@ -28,9 +27,7 @@
static void lightprobe_init_data(ID *id)
{
LightProbe *probe = (LightProbe *)id;
BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(probe, id));
MEMCPY_STRUCT_AFTER(probe, DNA_struct_default_get(LightProbe), id);
INIT_DEFAULT_STRUCT_AFTER(probe, id);
}
static void lightprobe_foreach_id(ID *id, LibraryForeachIDData *data)
@ -205,7 +202,7 @@ template<typename DataT, typename T> static void spherical_harmonic_copy(T &dst,
LightProbeGridCacheFrame *BKE_lightprobe_grid_cache_frame_create()
{
LightProbeGridCacheFrame *cache = MEM_callocN<LightProbeGridCacheFrame>(
LightProbeGridCacheFrame *cache = MEM_new_for_free<LightProbeGridCacheFrame>(
"LightProbeGridCacheFrame");
return cache;
}
@ -246,7 +243,7 @@ void BKE_lightprobe_cache_create(Object *object)
{
BLI_assert(object->lightprobe_cache == nullptr);
object->lightprobe_cache = MEM_callocN<LightProbeObjectCache>("LightProbeObjectCache");
object->lightprobe_cache = MEM_new_for_free<LightProbeObjectCache>("LightProbeObjectCache");
}
LightProbeObjectCache *BKE_lightprobe_cache_copy(LightProbeObjectCache *src_cache)

View file

@ -15,7 +15,7 @@
#include "MEM_guardedalloc.h"
#include "DNA_defaults.h"
#include "DNA_layer_types.h"
#include "DNA_material_types.h" /* for ramp blend */
#include "DNA_object_types.h"
#include "DNA_sdna_type_ids.hh"
@ -50,10 +50,7 @@ using blender::dna::sdna_struct_id_get;
static void linestyle_init_data(ID *id)
{
FreestyleLineStyle *linestyle = (FreestyleLineStyle *)id;
BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(linestyle, id));
MEMCPY_STRUCT_AFTER(linestyle, DNA_struct_default_get(FreestyleLineStyle), id);
INIT_DEFAULT_STRUCT_AFTER(linestyle, id);
BKE_linestyle_geometry_modifier_add(linestyle, nullptr, LS_MODIFIER_SAMPLING);
}
@ -74,7 +71,7 @@ static void linestyle_copy_data(Main *bmain,
for (int a = 0; a < MAX_MTEX; a++) {
if (linestyle_src->mtex[a]) {
linestyle_dst->mtex[a] = MEM_callocN<MTex>(__func__);
linestyle_dst->mtex[a] = MEM_new_for_free<MTex>(__func__);
*linestyle_dst->mtex[a] = blender::dna::shallow_copy(*linestyle_src->mtex[a]);
}
}

View file

@ -798,7 +798,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_callocN<LibraryWeakReference>(__func__);
local_id->library_weak_reference = MEM_new_for_free<LibraryWeakReference>(__func__);
}
STRNCPY(local_id->library_weak_reference->library_filepath, library_filepath);

View file

@ -26,7 +26,6 @@
#include "BLT_translation.hh"
#include "DNA_defaults.h"
#include "DNA_mask_types.h"
#include "DNA_movieclip_types.h"
#include "DNA_object_types.h"
@ -296,7 +295,7 @@ MaskSplinePoint *BKE_mask_spline_point_array_from_point(MaskSpline *spline,
MaskLayer *BKE_mask_layer_new(Mask *mask, const char *name)
{
MaskLayer *masklay = MEM_callocN<MaskLayer>(__func__);
MaskLayer *masklay = MEM_new_for_free<MaskLayer>(__func__);
STRNCPY_UTF8(masklay->name, name && name[0] ? name : DATA_("MaskLayer"));
@ -360,7 +359,7 @@ void BKE_mask_layer_rename(Mask *mask,
MaskLayer *BKE_mask_layer_copy(const MaskLayer *masklay)
{
MaskLayer *masklay_new = MEM_callocN<MaskLayer>("new mask layer");
MaskLayer *masklay_new = MEM_new_for_free<MaskLayer>("new mask layer");
STRNCPY_UTF8(masklay_new->name, masklay->name);
@ -391,7 +390,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_callocN<MaskLayerShape>("new mask layer shape");
MaskLayerShape *masklay_shape_new = MEM_new_for_free<MaskLayerShape>("new mask layer shape");
masklay_shape_new->data = static_cast<float *>(MEM_dupallocN(masklay_shape->data));
masklay_shape_new->tot_vert = masklay_shape->tot_vert;
@ -418,12 +417,12 @@ void BKE_mask_layer_copy_list(ListBase *masklayers_new, const ListBase *masklaye
MaskSpline *BKE_mask_spline_add(MaskLayer *masklay)
{
MaskSpline *spline = MEM_callocN<MaskSpline>("new mask spline");
MaskSpline *spline = MEM_new_for_free<MaskSpline>("new mask spline");
BLI_addtail(&masklay->splines, spline);
/* spline shall have one point at least */
spline->points = MEM_callocN<MaskSplinePoint>("new mask spline point");
spline->points = MEM_new_array_for_free<MaskSplinePoint>(1, "new mask spline point");
spline->tot_point = 1;
/* cyclic shapes are more usually used */
@ -885,7 +884,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_callocN<MaskSplinePointUW>("mask point uw");
point->uw = MEM_new_array_for_free<MaskSplinePointUW>(point->tot_uw + 1, "mask point uw");
}
else {
point->uw = static_cast<MaskSplinePointUW *>(
@ -1045,7 +1044,7 @@ static MaskSplinePoint *mask_spline_points_copy(const MaskSplinePoint *points, i
MaskSpline *BKE_mask_spline_copy(const MaskSpline *spline)
{
MaskSpline *nspline = MEM_callocN<MaskSpline>("new spline");
MaskSpline *nspline = MEM_new_for_free<MaskSpline>("new spline");
*nspline = *spline;
@ -1064,7 +1063,7 @@ 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_callocN<MaskLayerShape>(__func__);
masklay_shape = MEM_new_for_free<MaskLayerShape>(__func__);
masklay_shape->frame = frame;
masklay_shape->tot_vert = tot_vert;
masklay_shape->data = (float *)MEM_calloc_arrayN<MaskLayerShapeElem>(tot_vert, __func__);
@ -1234,7 +1233,7 @@ void BKE_mask_point_parent_matrix_get(MaskSplinePoint *point,
MovieTrackingObject *ob = BKE_tracking_object_get_named(tracking, parent->parent);
if (ob) {
MovieClipUser user = *DNA_struct_default_get(MovieClipUser);
MovieClipUser user = {};
float clip_framenr = BKE_movieclip_remap_scene_to_clip_frame(clip, ctime);
BKE_movieclip_user_set_frame(&user, ctime);
@ -1487,7 +1486,7 @@ void BKE_mask_spline_ensure_deform(MaskSpline *spline)
MEM_freeN(spline->points_deform);
}
spline->points_deform = MEM_calloc_arrayN<MaskSplinePoint>(spline->tot_point, __func__);
spline->points_deform = MEM_new_array_for_free<MaskSplinePoint>(spline->tot_point, __func__);
}
else {
// printf("alloc spline done\n");

View file

@ -209,7 +209,7 @@ MaskRasterHandle *BKE_maskrasterize_handle_new()
{
MaskRasterHandle *mr_handle;
mr_handle = MEM_callocN<MaskRasterHandle>("MaskRasterHandle");
mr_handle = MEM_new_for_free<MaskRasterHandle>("MaskRasterHandle");
return mr_handle;
}
@ -580,7 +580,8 @@ 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_calloc_arrayN<MaskRasterLayer>(mr_handle->layers_tot, "MaskRasterLayer");
mr_handle->layers = MEM_new_array_for_free<MaskRasterLayer>(mr_handle->layers_tot,
"MaskRasterLayer");
BLI_rctf_init_minmax(&mr_handle->bounds);
sf_arena = BLI_memarena_new(BLI_SCANFILL_ARENA_SIZE, __func__);
@ -615,7 +616,7 @@ void BKE_maskrasterize_handle_init(MaskRasterHandle *mr_handle,
}
tot_splines = uint(BLI_listbase_count(&masklay->splines));
open_spline_ranges = MEM_calloc_arrayN<MaskRasterSplineInfo>(tot_splines, __func__);
open_spline_ranges = MEM_new_array_for_free<MaskRasterSplineInfo>(tot_splines, __func__);
BLI_scanfill_begin_arena(&sf_ctx, sf_arena);

View file

@ -11,6 +11,7 @@
#include <cstring>
#include <optional>
#include "BLI_utildefines.h"
#include "CLG_log.h"
#include "MEM_guardedalloc.h"
@ -21,7 +22,6 @@
#include "DNA_ID.h"
#include "DNA_curve_types.h"
#include "DNA_curves_types.h"
#include "DNA_defaults.h"
#include "DNA_gpencil_legacy_types.h"
#include "DNA_grease_pencil_types.h"
#include "DNA_material_types.h"
@ -83,10 +83,7 @@ static CLG_LogRef LOG = {"material"};
static void material_init_data(ID *id)
{
Material *material = (Material *)id;
BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(material, id));
MEMCPY_STRUCT_AFTER(material, DNA_struct_default_get(Material), id);
INIT_DEFAULT_STRUCT_AFTER(material, id);
}
static void material_copy_data(Main *bmain,
@ -277,7 +274,7 @@ IDTypeInfo IDType_ID_MA = {
void BKE_gpencil_material_attr_init(Material *ma)
{
if ((ma) && (ma->gp_style == nullptr)) {
ma->gp_style = MEM_callocN<MaterialGPencilStyle>("Grease Pencil Material Settings");
ma->gp_style = MEM_new_for_free<MaterialGPencilStyle>("Grease Pencil Material Settings");
MaterialGPencilStyle *gp_style = ma->gp_style;
/* set basic settings */
@ -1698,7 +1695,7 @@ void BKE_texpaint_slot_refresh_cache(Scene *scene, Material *ma, const Object *o
ma->paint_clone_slot = 0;
}
else {
ma->texpaintslot = MEM_calloc_arrayN<TexPaintSlot>(count, "texpaint_slots");
ma->texpaintslot = MEM_new_array_for_free<TexPaintSlot>(count, "texpaint_slots");
bNode *active_node = blender::bke::node_get_active_paint_canvas(*ma->nodetree);

View file

@ -21,7 +21,6 @@
/* Allow using deprecated functionality for .blend file I/O. */
#define DNA_DEPRECATED_ALLOW
#include "DNA_defaults.h"
#include "DNA_material_types.h"
#include "DNA_mesh_types.h"
#include "DNA_meta_types.h"
@ -60,10 +59,7 @@ using blender::Span;
static void metaball_init_data(ID *id)
{
MetaBall *metaball = (MetaBall *)id;
BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(metaball, id));
MEMCPY_STRUCT_AFTER(metaball, DNA_struct_default_get(MetaBall), id);
INIT_DEFAULT_STRUCT_AFTER(metaball, id);
}
static void metaball_copy_data(Main * /*bmain*/,
@ -178,7 +174,7 @@ MetaBall *BKE_mball_add(Main *bmain, const char *name)
MetaElem *BKE_mball_element_add(MetaBall *mb, const int type)
{
MetaElem *ml = MEM_callocN<MetaElem>(__func__);
MetaElem *ml = MEM_new_for_free<MetaElem>(__func__);
unit_qt(ml->quat);

View file

@ -15,6 +15,7 @@
#include "MEM_guardedalloc.h"
#include "DNA_layer_types.h"
#include "DNA_meta_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"

View file

@ -13,7 +13,6 @@
/* Allow using deprecated functionality for .blend file I/O. */
#define DNA_DEPRECATED_ALLOW
#include "DNA_defaults.h"
#include "DNA_key_types.h"
#include "DNA_material_types.h"
#include "DNA_mesh_types.h"
@ -92,10 +91,7 @@ static void mesh_tessface_clear_intern(Mesh *mesh, int free_customdata);
static void mesh_init_data(ID *id)
{
Mesh *mesh = reinterpret_cast<Mesh *>(id);
BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(mesh, id));
MEMCPY_STRUCT_AFTER(mesh, DNA_struct_default_get(Mesh), id);
INIT_DEFAULT_STRUCT_AFTER(mesh, id);
CustomData_reset(&mesh->vert_data);
CustomData_reset(&mesh->edge_data);

View file

@ -477,7 +477,7 @@ void BKE_mesh_to_curve_nurblist(const Mesh *mesh, ListBase *nurblist, const int
VertLink *vl;
/* create new 'nurb' within the curve */
nu = MEM_callocN<Nurb>(__func__);
nu = MEM_new_for_free<Nurb>(__func__);
nu->pntsu = faces_num;
nu->pntsv = 1;

View file

@ -2048,7 +2048,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_callocN<GeometryNodeAssetTraits>(__func__);
group->geometry_node_asset_traits = MEM_new_for_free<GeometryNodeAssetTraits>(__func__);
}
group->geometry_node_asset_traits->flag |= GEO_NODE_ASSET_MODIFIER;

View file

@ -25,6 +25,7 @@
#include "DNA_colorband_types.h"
#include "DNA_dynamicpaint_types.h"
#include "DNA_fluid_types.h"
#include "DNA_layer_types.h"
#include "DNA_mesh_types.h"
#include "DNA_object_fluidsim_types.h"
#include "DNA_object_force_types.h"

View file

@ -24,7 +24,6 @@
/* Allow using deprecated functionality for .blend file I/O. */
#define DNA_DEPRECATED_ALLOW
#include "DNA_defaults.h"
#include "DNA_gpencil_legacy_types.h"
#include "DNA_movieclip_types.h"
@ -87,9 +86,7 @@ static void movie_clip_runtime_reset(MovieClip *clip)
static void movie_clip_init_data(ID *id)
{
MovieClip *movie_clip = (MovieClip *)id;
BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(movie_clip, id));
MEMCPY_STRUCT_AFTER(movie_clip, DNA_struct_default_get(MovieClip), id);
INIT_DEFAULT_STRUCT_AFTER(movie_clip, id);
BKE_tracking_settings_init(&movie_clip->tracking);
BKE_color_managed_colorspace_settings_init(&movie_clip->colorspace_settings);
@ -922,7 +919,7 @@ static MovieClip *movieclip_alloc(Main *bmain, const char *name)
static void movieclip_load_get_size(MovieClip *clip)
{
int width, height;
MovieClipUser user = *DNA_struct_default_get(MovieClipUser);
MovieClipUser user = {};
user.framenr = BKE_movieclip_remap_clip_to_scene_frame(clip, 1);
BKE_movieclip_get_size(clip, &user, &width, &height);
@ -2013,7 +2010,7 @@ static blender::gpu::Texture **movieclip_get_gputexture_ptr(MovieClip *clip,
/* If not, allocate a new one. */
if (tex == nullptr) {
tex = MEM_mallocN<MovieClip_RuntimeGPUTexture>(__func__);
tex = MEM_new_for_free<MovieClip_RuntimeGPUTexture>(__func__);
for (int i = 0; i < TEXTARGET_COUNT; i++) {
tex->gputexture[i] = nullptr;

View file

@ -345,7 +345,7 @@ void BKE_nla_tracks_copy_from_adt(Main *bmain,
NlaTrack *BKE_nlatrack_new()
{
/* allocate new track */
NlaTrack *nlt = MEM_callocN<NlaTrack>("NlaTrack");
NlaTrack *nlt = MEM_new_for_free<NlaTrack>("NlaTrack");
/* set settings requiring the track to not be part of the stack yet */
nlt->flag = NLATRACK_SELECTED | NLATRACK_OVERRIDELIBRARY_LOCAL;
@ -484,7 +484,7 @@ static NlaStrip *nlastrip_new(bAction *act, ID &animated_id)
}
/* allocate new strip */
strip = MEM_callocN<NlaStrip>("NlaStrip");
strip = MEM_new_for_free<NlaStrip>("NlaStrip");
/* generic settings
* - selected flag to highlight this to the user
@ -607,7 +607,7 @@ NlaStrip *BKE_nlastack_add_strip(const OwnedAnimData owned_adt, const bool is_li
NlaStrip *BKE_nla_add_soundstrip(Main *bmain, Scene *scene, Speaker *speaker)
{
NlaStrip *strip = MEM_callocN<NlaStrip>("NlaSoundStrip");
NlaStrip *strip = MEM_new_for_free<NlaStrip>("NlaSoundStrip");
/* if speaker has a sound, set the strip length to the length of the sound,
* otherwise default to length of 10 frames
@ -969,7 +969,7 @@ void BKE_nlastrips_make_metas(ListBase *strips, bool is_temp)
/* if there is an existing meta-strip, add this strip to it, otherwise, create a new one */
if (mstrip == nullptr) {
/* add a new meta-strip, and add it before the current strip that it will replace... */
mstrip = MEM_callocN<NlaStrip>("Meta-NlaStrip");
mstrip = MEM_new_for_free<NlaStrip>("Meta-NlaStrip");
mstrip->type = NLASTRIP_TYPE_META;
BLI_insertlinkbefore(strips, strip, mstrip);

View file

@ -233,14 +233,14 @@ static void ntree_copy_data(Main * /*bmain*/,
}
if (ntree_src->geometry_node_asset_traits) {
ntree_dst->geometry_node_asset_traits = MEM_dupallocN<GeometryNodeAssetTraits>(
ntree_dst->geometry_node_asset_traits = MEM_new_for_free<GeometryNodeAssetTraits>(
__func__, *ntree_src->geometry_node_asset_traits);
ntree_dst->geometry_node_asset_traits->node_tool_idname = BLI_strdup_null(
ntree_src->geometry_node_asset_traits->node_tool_idname);
}
if (ntree_src->nested_node_refs) {
ntree_dst->nested_node_refs = MEM_malloc_arrayN<bNestedNodeRef>(
ntree_dst->nested_node_refs = MEM_new_array_for_free<bNestedNodeRef>(
size_t(ntree_src->nested_node_refs_num), __func__);
uninitialized_copy_n(
ntree_src->nested_node_refs, ntree_src->nested_node_refs_num, ntree_dst->nested_node_refs);
@ -999,7 +999,7 @@ static void initialize_legacy_socket_storage(bNode &node)
{
if (ELEM(node.type_legacy, CMP_NODE_R_LAYERS, CMP_NODE_IMAGE)) {
LISTBASE_FOREACH (bNodeSocket *, output, &node.outputs) {
NodeImageLayer *storage = MEM_callocN<NodeImageLayer>(__func__);
NodeImageLayer *storage = MEM_new_for_free<NodeImageLayer>(__func__);
output->storage = storage;
/* Alpha is derived from the combined pass. */
if (STREQ(output->identifier, "Alpha")) {
@ -1463,7 +1463,7 @@ static void direct_link_node_socket_legacy_data_version_do(
BLI_assert(MEM_allocN_len(*raw_data) >= sizeof(T_404));
T_404 *orig_data = static_cast<T_404 *>(*raw_data);
*raw_data = nullptr;
T *final_data = MEM_callocN<T>(__func__);
T *final_data = MEM_new_for_free<T>(__func__);
/* Could use `memcpy` here, since we also require historic members of these DNA structs to
* never be moved or re-ordered. But better be verbose and explicit here. */
copy_fn(*final_data, *orig_data);
@ -2749,7 +2749,7 @@ static bNodeSocket *make_socket(bNodeTree *ntree,
auto_identifier,
sizeof(auto_identifier));
bNodeSocket *sock = MEM_callocN<bNodeSocket>(__func__);
bNodeSocket *sock = MEM_new_for_free<bNodeSocket>(__func__);
sock->runtime = MEM_new<bNodeSocketRuntime>(__func__);
sock->in_out = in_out;
@ -3707,7 +3707,7 @@ bNode *node_add_node(const bContext *C,
const StringRef idname,
std::optional<int> unique_identifier)
{
bNode *node = MEM_callocN<bNode>(__func__);
bNode *node = MEM_new_for_free<bNode>(__func__);
node->runtime = MEM_new<bNodeRuntime>(__func__);
BLI_addtail(&ntree.nodes, node);
if (unique_identifier) {
@ -3786,8 +3786,7 @@ bNode *node_copy_with_mapping(bNodeTree *dst_tree,
Map<const bNodeSocket *, bNodeSocket *> &socket_map,
const bool allow_duplicate_names)
{
bNode *node_dst = MEM_mallocN<bNode>(__func__);
*node_dst = node_src;
bNode *node_dst = MEM_new_for_free<bNode>(__func__, node_src);
node_dst->runtime = MEM_new<bNodeRuntime>(__func__);
if (dst_unique_name) {
BLI_assert(dst_unique_name->size() < sizeof(node_dst->name));
@ -4059,7 +4058,7 @@ bNodeLink &node_add_link(
bNodeLink *link = nullptr;
if (eNodeSocketInOut(fromsock.in_out) == SOCK_OUT && eNodeSocketInOut(tosock.in_out) == SOCK_IN)
{
link = MEM_callocN<bNodeLink>(__func__);
link = MEM_new_for_free<bNodeLink>(__func__);
BLI_addtail(&ntree.links, link);
link->fromnode = &fromnode;
link->fromsock = &fromsock;
@ -4070,7 +4069,7 @@ bNodeLink &node_add_link(
eNodeSocketInOut(tosock.in_out) == SOCK_OUT)
{
/* OK but flip */
link = MEM_callocN<bNodeLink>(__func__);
link = MEM_new_for_free<bNodeLink>(__func__);
BLI_addtail(&ntree.links, link);
link->fromnode = &tonode;
link->fromsock = &tosock;

View file

@ -248,7 +248,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_callocN<SocketDataType>(__func__);
SocketDataType *new_socket_data = MEM_new_for_free<SocketDataType>(__func__);
socket_data_init_impl(*new_socket_data);
socket_data = new_socket_data;
});
@ -1333,7 +1333,7 @@ static bNodeTreeInterfaceSocket *make_socket(const int uid,
return nullptr;
}
bNodeTreeInterfaceSocket *new_socket = MEM_callocN<bNodeTreeInterfaceSocket>(__func__);
bNodeTreeInterfaceSocket *new_socket = MEM_new_for_free<bNodeTreeInterfaceSocket>(__func__);
BLI_assert(new_socket);
/* Init common socket properties. */
@ -1415,7 +1415,7 @@ static bNodeTreeInterfacePanel *make_panel(const int uid,
{
BLI_assert(!name.is_empty());
bNodeTreeInterfacePanel *new_panel = MEM_callocN<bNodeTreeInterfacePanel>(__func__);
bNodeTreeInterfacePanel *new_panel = MEM_new_for_free<bNodeTreeInterfacePanel>(__func__);
new_panel->item.item_type = NODE_INTERFACE_PANEL;
new_panel->name = BLI_strdupn(name.data(), name.size());
new_panel->description = description.is_empty() ?

View file

@ -1957,8 +1957,8 @@ class NodeTreeMainUpdater {
}
/* Allocate new array for the nested node references contained in the node tree. */
bNestedNodeRef *new_refs = MEM_malloc_arrayN<bNestedNodeRef>(size_t(new_path_by_id.size()),
__func__);
bNestedNodeRef *new_refs = MEM_new_array_for_free<bNestedNodeRef>(
size_t(new_path_by_id.size()), __func__);
int index = 0;
for (const auto item : new_path_by_id.items()) {
bNestedNodeRef &ref = new_refs[index];

View file

@ -24,7 +24,6 @@
#include "DNA_collection_types.h"
#include "DNA_constraint_types.h"
#include "DNA_curve_types.h"
#include "DNA_defaults.h"
#include "DNA_dynamicpaint_types.h"
#include "DNA_effect_types.h"
#include "DNA_fluid_types.h"
@ -173,9 +172,7 @@ static void copy_object_pose(Object *obn, const Object *ob, const int flag);
static void object_init_data(ID *id)
{
Object *ob = (Object *)id;
BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(ob, id));
MEMCPY_STRUCT_AFTER(ob, DNA_struct_default_get(Object), id);
INIT_DEFAULT_STRUCT_AFTER(ob, id);
ob->type = OB_EMPTY;
@ -828,7 +825,7 @@ static void object_blend_read_data(BlendDataReader *reader, ID *id)
if (ob->rigidbody_object) {
RigidBodyOb *rbo = ob->rigidbody_object;
/* Allocate runtime-only struct */
rbo->shared = MEM_callocN<RigidBodyOb_Shared>("RigidBodyObShared");
rbo->shared = MEM_new_for_free<RigidBodyOb_Shared>("RigidBodyObShared");
}
BLO_read_struct(reader, RigidBodyCon, &ob->rigidbody_constraint);
if (ob->rigidbody_constraint) {
@ -3630,7 +3627,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_callocN<ImageUser>("image user");
ob->iuser = MEM_new_for_free<ImageUser>("image user");
ob->iuser->flag |= IMA_ANIM_ALWAYS;
ob->iuser->frames = 100;
ob->iuser->sfra = 1;

View file

@ -34,6 +34,7 @@
#include "DNA_collection_types.h"
#include "DNA_curves_types.h"
#include "DNA_grease_pencil_types.h"
#include "DNA_layer_types.h"
#include "DNA_mesh_types.h"
#include "DNA_modifier_types.h"
#include "DNA_pointcloud_types.h"

View file

@ -214,7 +214,7 @@ PackedFile *BKE_packedfile_new_from_memory(const void *mem,
sharing_info = blender::implicit_sharing::info_for_mem_free(const_cast<void *>(mem));
}
PackedFile *pf = MEM_callocN<PackedFile>("PackedFile");
PackedFile *pf = MEM_new_for_free<PackedFile>("PackedFile");
pf->data = mem;
pf->size = memlen;
pf->sharing_info = sharing_info;

View file

@ -17,7 +17,6 @@
#include "DNA_asset_types.h"
#include "DNA_brush_types.h"
#include "DNA_defaults.h"
#include "DNA_key_types.h"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
@ -91,7 +90,7 @@ static void palette_init_data(ID *id)
{
Palette *palette = (Palette *)id;
BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(palette, id));
INIT_DEFAULT_STRUCT_AFTER(palette, id);
/* Enable fake user by default. */
id_fake_user_set(&palette->id);
@ -1433,7 +1432,7 @@ Palette *BKE_palette_add(Main *bmain, const char *name)
PaletteColor *BKE_palette_color_add(Palette *palette)
{
PaletteColor *color = MEM_callocN<PaletteColor>(__func__);
PaletteColor *color = MEM_new_for_free<PaletteColor>(__func__);
BLI_addtail(&palette->colors, color);
return color;
}
@ -1587,7 +1586,7 @@ bool BKE_palette_from_hash(Main *bmain, GHash *color_table, const char *name)
const int totpal = BLI_ghash_len(color_table);
if (totpal > 0) {
color_array = MEM_calloc_arrayN<tPaletteColorHSV>(totpal, __func__);
color_array = MEM_new_array_for_free<tPaletteColorHSV>(totpal, __func__);
/* Put all colors in an array. */
GHashIterator gh_iter;
int t = 0;
@ -1716,7 +1715,7 @@ eObjectMode BKE_paint_object_mode_from_paintmode(const PaintMode mode)
static void paint_init_data(Paint &paint)
{
const UnifiedPaintSettings &default_ups = *DNA_struct_default_get(UnifiedPaintSettings);
const UnifiedPaintSettings &default_ups = UnifiedPaintSettings();
paint.unified_paint_settings.size = default_ups.size;
paint.unified_paint_settings.input_samples = default_ups.input_samples;
paint.unified_paint_settings.unprojected_size = default_ups.unprojected_size;
@ -1770,40 +1769,38 @@ bool BKE_paint_ensure(ToolSettings *ts, Paint **r_paint)
}
if (((VPaint **)r_paint == &ts->vpaint) || ((VPaint **)r_paint == &ts->wpaint)) {
VPaint *data = MEM_callocN<VPaint>(__func__);
VPaint *data = MEM_new_for_free<VPaint>(__func__);
paint = &data->paint;
paint_init_data(*paint);
}
else if ((Sculpt **)r_paint == &ts->sculpt) {
Sculpt *data = MEM_callocN<Sculpt>(__func__);
*data = blender::dna::shallow_copy(*DNA_struct_default_get(Sculpt));
Sculpt *data = MEM_new_for_free<Sculpt>(__func__);
paint = &data->paint;
paint_init_data(*paint);
}
else if ((GpPaint **)r_paint == &ts->gp_paint) {
GpPaint *data = MEM_callocN<GpPaint>(__func__);
GpPaint *data = MEM_new_for_free<GpPaint>(__func__);
paint = &data->paint;
paint_init_data(*paint);
}
else if ((GpVertexPaint **)r_paint == &ts->gp_vertexpaint) {
GpVertexPaint *data = MEM_callocN<GpVertexPaint>(__func__);
GpVertexPaint *data = MEM_new_for_free<GpVertexPaint>(__func__);
paint = &data->paint;
paint_init_data(*paint);
}
else if ((GpSculptPaint **)r_paint == &ts->gp_sculptpaint) {
GpSculptPaint *data = MEM_callocN<GpSculptPaint>(__func__);
GpSculptPaint *data = MEM_new_for_free<GpSculptPaint>(__func__);
paint = &data->paint;
paint_init_data(*paint);
}
else if ((GpWeightPaint **)r_paint == &ts->gp_weightpaint) {
GpWeightPaint *data = MEM_callocN<GpWeightPaint>(__func__);
GpWeightPaint *data = MEM_new_for_free<GpWeightPaint>(__func__);
paint = &data->paint;
paint_init_data(*paint);
}
else if ((CurvesSculpt **)r_paint == &ts->curves_sculpt) {
CurvesSculpt *data = MEM_callocN<CurvesSculpt>(__func__);
CurvesSculpt *data = MEM_new_for_free<CurvesSculpt>(__func__);
paint = &data->paint;
paint_init_data(*paint);
}
@ -2905,28 +2902,28 @@ void BKE_sculpt_toolsettings_data_ensure(Main *bmain, Scene *scene)
Sculpt *sd = scene->toolsettings->sculpt;
const Sculpt *defaults = DNA_struct_default_get(Sculpt);
const Sculpt defaults = {};
/* We have file versioning code here for historical
* reasons. Don't add more checks here, do it properly
* in blenloader.
*/
if (sd->automasking_start_normal_limit == 0.0f) {
sd->automasking_start_normal_limit = defaults->automasking_start_normal_limit;
sd->automasking_start_normal_falloff = defaults->automasking_start_normal_falloff;
sd->automasking_start_normal_limit = defaults.automasking_start_normal_limit;
sd->automasking_start_normal_falloff = defaults.automasking_start_normal_falloff;
sd->automasking_view_normal_limit = defaults->automasking_view_normal_limit;
sd->automasking_view_normal_falloff = defaults->automasking_view_normal_limit;
sd->automasking_view_normal_limit = defaults.automasking_view_normal_limit;
sd->automasking_view_normal_falloff = defaults.automasking_view_normal_limit;
}
if (sd->detail_percent == 0.0f) {
sd->detail_percent = defaults->detail_percent;
sd->detail_percent = defaults.detail_percent;
}
if (sd->constant_detail == 0.0f) {
sd->constant_detail = defaults->constant_detail;
sd->constant_detail = defaults.constant_detail;
}
if (sd->detail_size == 0.0f) {
sd->detail_size = defaults->detail_size;
sd->detail_size = defaults.detail_size;
}
/* Set sane default tiling offsets. */

View file

@ -18,8 +18,6 @@
#include "MEM_guardedalloc.h"
#include "DNA_defaults.h"
#include "DNA_cloth_types.h"
#include "DNA_collection_types.h"
#include "DNA_curve_types.h"
@ -93,9 +91,7 @@ static void fluid_free_settings(SPHFluidSettings *fluid);
static void particle_settings_init(ID *id)
{
ParticleSettings *particle_settings = (ParticleSettings *)id;
BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(particle_settings, id));
MEMCPY_STRUCT_AFTER(particle_settings, DNA_struct_default_get(ParticleSettings), id);
INIT_DEFAULT_STRUCT_AFTER(particle_settings, id);
particle_settings->effector_weights = BKE_effector_add_weights(nullptr);
particle_settings->pd = BKE_partdeflect_new(PFIELD_NULL);
@ -800,7 +796,7 @@ void psys_check_group_weights(ParticleSettings *part)
}
if (!dw) {
dw = MEM_callocN<ParticleDupliWeight>("ParticleDupliWeight");
dw = MEM_new_for_free<ParticleDupliWeight>("ParticleDupliWeight");
dw->ob = object;
dw->count = 1;
BLI_addtail(&part->instance_weights, dw);
@ -3932,7 +3928,7 @@ static ModifierData *object_add_or_copy_particle_system(
psys->flag &= ~PSYS_CURRENT;
}
psys = MEM_callocN<ParticleSystem>("particle_system");
psys = MEM_new_for_free<ParticleSystem>("particle_system");
psys->pointcache = BKE_ptcache_add(&psys->ptcaches);
BLI_addtail(&ob->particlesystem, psys);
psys_unique_name(ob, psys, name);

View file

@ -203,13 +203,13 @@ static void realloc_particles(ParticleSimulationData *sim, int new_totpart)
}
if (totpart) {
newpars = MEM_calloc_arrayN<ParticleData>(totpart, "particles");
newpars = MEM_new_array_for_free<ParticleData>(totpart, "particles");
if (newpars == nullptr) {
return;
}
if (psys->part->phystype == PART_PHYS_BOIDS) {
newboids = MEM_calloc_arrayN<BoidParticle>(totpart, "boid particles");
newboids = MEM_new_array_for_free<BoidParticle>(totpart, "boid particles");
if (newboids == nullptr) {
/* allocation error! */
@ -632,7 +632,7 @@ static void free_unexisting_particles(ParticleSimulationData *sim)
int newtotpart = psys->totpart - psys->totunexist;
ParticleData *npa, *newpars;
npa = newpars = MEM_calloc_arrayN<ParticleData>(newtotpart, "particles");
npa = newpars = MEM_new_array_for_free<ParticleData>(newtotpart, "particles");
for (p = 0, pa = psys->particles; p < newtotpart; p++, pa++, npa++) {
while (pa->flag & PARS_UNEXIST) {
@ -650,7 +650,8 @@ static void free_unexisting_particles(ParticleSimulationData *sim)
psys->totpart -= psys->totunexist;
if (psys->particles->boid) {
BoidParticle *newboids = MEM_calloc_arrayN<BoidParticle>(psys->totpart, "boid particles");
BoidParticle *newboids = MEM_new_array_for_free<BoidParticle>(psys->totpart,
"boid particles");
LOOP_PARTICLES
{
@ -4670,7 +4671,7 @@ void psys_check_boid_data(ParticleSystem *psys)
if (psys->part && psys->part->phystype == PART_PHYS_BOIDS) {
if (!pa->boid) {
bpa = MEM_calloc_arrayN<BoidParticle>(psys->totpart, "Boid Data");
bpa = MEM_new_array_for_free<BoidParticle>(psys->totpart, "Boid Data");
LOOP_PARTICLES
{

View file

@ -28,6 +28,7 @@
#include "DNA_ID.h"
#include "DNA_dynamicpaint_types.h"
#include "DNA_fluid_types.h"
#include "DNA_layer_types.h"
#include "DNA_modifier_types.h"
#include "DNA_object_force_types.h"
#include "DNA_object_types.h"
@ -156,7 +157,7 @@ static int ptcache_basic_header_write(PTCacheFile *pf)
}
static void ptcache_add_extra_data(PTCacheMem *pm, uint type, uint count, void *data)
{
PTCacheExtra *extra = MEM_callocN<PTCacheExtra>("Point cache: extra data descriptor");
PTCacheExtra *extra = MEM_new_for_free<PTCacheExtra>("Point cache: extra data descriptor");
extra->type = type;
extra->totdata = count;
@ -1479,7 +1480,7 @@ static PTCacheFile *ptcache_file_open(PTCacheID *pid, int mode, int cfra)
return nullptr;
}
pf = MEM_mallocN<PTCacheFile>("PTCacheFile");
pf = MEM_new_for_free<PTCacheFile>("PTCacheFile");
pf->fp = fp;
pf->old_format = 0;
pf->frame = cfra;
@ -1893,7 +1894,7 @@ static PTCacheMem *ptcache_disk_frame_to_mem(PTCacheID *pid, int cfra)
}
if (!error) {
pm = MEM_callocN<PTCacheMem>("Pointcache mem");
pm = MEM_new_for_free<PTCacheMem>("Pointcache mem");
pm->totpoint = pf->totpoint;
pm->data_types = pf->data_types;
@ -1929,7 +1930,7 @@ static PTCacheMem *ptcache_disk_frame_to_mem(PTCacheID *pid, int cfra)
uint extratype = 0;
while (!error && ptcache_file_read(pf, &extratype, 1, sizeof(uint))) {
PTCacheExtra *extra = MEM_callocN<PTCacheExtra>("Pointcache extradata");
PTCacheExtra *extra = MEM_new_for_free<PTCacheExtra>("Pointcache extradata");
extra->type = extratype;
@ -2333,7 +2334,7 @@ static int ptcache_write(PTCacheID *pid, int cfra, int overwrite)
int totpoint = pid->totpoint(pid->calldata, cfra);
int i, error = 0;
pm = MEM_callocN<PTCacheMem>("Pointcache mem");
pm = MEM_new_for_free<PTCacheMem>("Pointcache mem");
pm->totpoint = pid->totwrite(pid->calldata, cfra);
pm->data_types = cfra ? pid->data_types : pid->info_types;
@ -2934,7 +2935,7 @@ PointCache *BKE_ptcache_add(ListBase *ptcaches)
{
PointCache *cache;
cache = MEM_callocN<PointCache>("PointCache");
cache = MEM_new_for_free<PointCache>("PointCache");
cache->startframe = 1;
cache->endframe = 250;
cache->step = 1;

View file

@ -11,7 +11,6 @@
#include "BLI_function_ref.hh"
#include "MEM_guardedalloc.h"
#include "DNA_defaults.h"
#include "DNA_material_types.h"
#include "DNA_object_types.h"
#include "DNA_pointcloud_types.h"
@ -60,9 +59,7 @@ constexpr StringRef ATTR_POSITION = "position";
static void pointcloud_init_data(ID *id)
{
PointCloud *pointcloud = (PointCloud *)id;
BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(pointcloud, id));
MEMCPY_STRUCT_AFTER(pointcloud, DNA_struct_default_get(PointCloud), id);
INIT_DEFAULT_STRUCT_AFTER(pointcloud, id);
new (&pointcloud->attribute_storage.wrap()) blender::bke::AttributeStorage();
pointcloud->runtime = new blender::bke::PointCloudRuntime();

View file

@ -78,7 +78,7 @@ static void pose_backup_create(const Object *ob,
return;
}
PoseChannelBackup *chan_bak = MEM_callocN<PoseChannelBackup>("PoseChannelBackup");
PoseChannelBackup *chan_bak = MEM_new_for_free<PoseChannelBackup>("PoseChannelBackup");
chan_bak->pchan = pchan;
chan_bak->olddata = blender::dna::shallow_copy(*chan_bak->pchan);
chan_bak->owner = ob;

View file

@ -25,7 +25,6 @@
#include "BLO_read_write.hh"
#include "DNA_defaults.h"
#include "DNA_userdef_types.h"
#define U BLI_STATIC_ASSERT(false, "Global 'U' not allowed, only use arguments passed in!")
@ -60,7 +59,7 @@ bUserAssetLibrary *BKE_preferences_asset_library_add(UserDef *userdef,
const char *name,
const char *dirpath)
{
bUserAssetLibrary *library = DNA_struct_default_alloc(bUserAssetLibrary);
bUserAssetLibrary *library = MEM_new_for_free<bUserAssetLibrary>(__func__);
BLI_addtail(&userdef->asset_libraries, library);
if (userdef->experimental.no_data_block_packing) {
@ -184,7 +183,7 @@ bUserExtensionRepo *BKE_preferences_extension_repo_add(UserDef *userdef,
const char *module,
const char *custom_dirpath)
{
bUserExtensionRepo *repo = DNA_struct_default_alloc(bUserExtensionRepo);
bUserExtensionRepo *repo = MEM_new_for_free<bUserExtensionRepo>(__func__);
BLI_addtail(&userdef->extension_repos, repo);
/* Set the unique ID-name. */
@ -557,7 +556,7 @@ void BKE_preferences_extension_repo_write_data(BlendWriter *writer, const bUserE
static bUserAssetShelfSettings *asset_shelf_settings_new(UserDef *userdef,
const char *shelf_idname)
{
bUserAssetShelfSettings *settings = DNA_struct_default_alloc(bUserAssetShelfSettings);
bUserAssetShelfSettings *settings = MEM_new_for_free<bUserAssetShelfSettings>(__func__);
BLI_addtail(&userdef->asset_shelves_settings, settings);
STRNCPY(settings->shelf_idname, shelf_idname);
BLI_assert(BLI_listbase_is_empty(&settings->enabled_catalog_paths));

View file

@ -77,7 +77,7 @@ static PreviewImage *previewimg_deferred_create(const char *filepath, ThumbSourc
PreviewImage *BKE_previewimg_create()
{
PreviewImage *prv = MEM_callocN<PreviewImage>(__func__);
PreviewImage *prv = MEM_new_for_free<PreviewImage>(__func__);
for (int i = 0; i < NUM_ICON_SIZES; i++) {
prv->flag[i] |= PRV_CHANGED;
@ -142,7 +142,7 @@ PreviewImage *BKE_previewimg_copy(const PreviewImage *prv)
return nullptr;
}
PreviewImage *prv_img = MEM_mallocN<PreviewImage>(__func__);
PreviewImage *prv_img = MEM_new_for_free<PreviewImage>(__func__);
*prv_img = blender::dna::shallow_copy(*prv);
prv_img->runtime = MEM_new<blender::bke::PreviewImageRuntime>(__func__, *prv->runtime);

View file

@ -165,7 +165,7 @@ void BKE_report(ReportList *reports, eReportType type, const char *_message)
std::scoped_lock lock(*reports->lock);
char *message_alloc;
report = MEM_callocN<Report>("Report");
report = MEM_new_for_free<Report>("Report");
report->type = type;
report->typestr = BKE_report_type_str(type);
@ -196,7 +196,7 @@ void BKE_reportf(ReportList *reports, eReportType type, const char *_format, ...
if (reports && (reports->flag & RPT_STORE) && (type >= reports->storelevel)) {
std::scoped_lock lock(*reports->lock);
report = MEM_callocN<Report>("Report");
report = MEM_new_for_free<Report>("Report");
va_start(args, _format);
report->message = BLI_vsprintfN(format, args);

View file

@ -1138,8 +1138,8 @@ RigidBodyWorld *BKE_rigidbody_create_world(Scene *scene)
}
/* create a new sim world */
rbw = MEM_callocN<RigidBodyWorld>("RigidBodyWorld");
rbw->shared = MEM_callocN<RigidBodyWorld_Shared>("RigidBodyWorld_Shared");
rbw = MEM_new_for_free<RigidBodyWorld>("RigidBodyWorld");
rbw->shared = MEM_new_for_free<RigidBodyWorld_Shared>("RigidBodyWorld_Shared");
/* set default settings */
rbw->effector_weights = BKE_effector_add_weights(nullptr);
@ -1180,7 +1180,7 @@ RigidBodyWorld *BKE_rigidbody_world_copy(RigidBodyWorld *rbw, const int flag)
if ((flag & LIB_ID_COPY_SET_COPIED_ON_WRITE) == 0) {
/* This is a regular copy, and not an evaluated copy for depsgraph evaluation. */
rbw_copy->shared = MEM_callocN<RigidBodyWorld_Shared>("RigidBodyWorld_Shared");
rbw_copy->shared = MEM_new_for_free<RigidBodyWorld_Shared>("RigidBodyWorld_Shared");
BKE_ptcache_copy_list(&rbw_copy->shared->ptcaches, &rbw->shared->ptcaches, LIB_ID_COPY_CACHES);
rbw_copy->shared->pointcache = static_cast<PointCache *>(rbw_copy->shared->ptcaches.first);
BKE_rigidbody_world_init_runtime(rbw_copy);
@ -1218,8 +1218,8 @@ RigidBodyOb *BKE_rigidbody_create_object(Scene *scene, Object *ob, short type)
}
/* create new settings data, and link it up */
rbo = MEM_callocN<RigidBodyOb>("RigidBodyOb");
rbo->shared = MEM_callocN<RigidBodyOb_Shared>("RigidBodyOb_Shared");
rbo = MEM_new_for_free<RigidBodyOb>("RigidBodyOb");
rbo->shared = MEM_new_for_free<RigidBodyOb_Shared>("RigidBodyOb_Shared");
/* set default settings */
rbo->type = type;
@ -1277,7 +1277,7 @@ RigidBodyCon *BKE_rigidbody_create_constraint(Scene *scene, Object *ob, short ty
}
/* create new settings data, and link it up */
rbc = MEM_callocN<RigidBodyCon>("RigidBodyCon");
rbc = MEM_new_for_free<RigidBodyCon>("RigidBodyCon");
/* set default settings */
rbc->type = type;
@ -2434,7 +2434,7 @@ static RigidBodyOb *rigidbody_copy_object(const Object *ob, const int flag)
if (is_orig) {
/* This is a regular copy, and not an evaluated copy for depsgraph evaluation */
rboN->shared = MEM_callocN<RigidBodyOb_Shared>("RigidBodyOb_Shared");
rboN->shared = MEM_new_for_free<RigidBodyOb_Shared>("RigidBodyOb_Shared");
}
/* tag object as needing to be verified */

View file

@ -20,7 +20,6 @@
#include "DNA_brush_types.h"
#include "DNA_collection_types.h"
#include "DNA_curveprofile_types.h"
#include "DNA_defaults.h"
#include "DNA_gpencil_legacy_types.h"
#include "DNA_lightprobe_types.h"
#include "DNA_linestyle_types.h"
@ -162,9 +161,7 @@ static void scene_init_data(ID *id)
SceneRenderView *srv;
CurveMapping *mblur_shutter_curve;
BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(scene, id));
MEMCPY_STRUCT_AFTER(scene, DNA_struct_default_get(Scene), id);
INIT_DEFAULT_STRUCT_AFTER(scene, id);
STRNCPY(scene->r.bake.filepath, U.renderdir);
@ -176,7 +173,7 @@ static void scene_init_data(ID *id)
CURVE_PRESET_MAX,
CurveMapSlopeType::PositiveNegative);
scene->toolsettings = DNA_struct_default_alloc(ToolSettings);
scene->toolsettings = MEM_new_for_free<ToolSettings>(__func__);
scene->toolsettings->autokey_mode = uchar(U.autokey_mode);
@ -334,7 +331,7 @@ static void scene_copy_data(Main *bmain,
/* Copy sequencer, this is local data! */
if (scene_src->ed) {
scene_dst->ed = MEM_callocN<Editing>(__func__);
scene_dst->ed = MEM_new_for_free<Editing>(__func__);
scene_dst->ed->cache_flag = scene_src->ed->cache_flag;
scene_dst->ed->show_missing_media_flag = scene_src->ed->show_missing_media_flag;
scene_dst->ed->proxy_storage = scene_src->ed->proxy_storage;
@ -1847,7 +1844,7 @@ void BKE_toolsettings_free(ToolSettings *toolsettings)
void BKE_scene_copy_data_eevee(Scene *sce_dst, const Scene *sce_src)
{
/* Copy eevee data between scenes. */
sce_dst->eevee = sce_src->eevee;
sce_dst->eevee = blender::dna::shallow_copy(sce_src->eevee);
}
Scene *BKE_scene_duplicate(Main *bmain,
@ -1867,7 +1864,7 @@ Scene *BKE_scene_duplicate(Main *bmain,
rv = sce_copy->r.views;
BKE_curvemapping_free_data(&sce_copy->r.mblur_shutter_curve);
sce_copy->r = sce->r;
sce_copy->r = blender::dna::shallow_copy(sce->r);
sce_copy->r.views = rv;
sce_copy->unit = sce->unit;
sce_copy->physics_settings = sce->physics_settings;
@ -2818,7 +2815,7 @@ SceneRenderView *BKE_scene_add_render_view(Scene *sce, const char *name)
name = DATA_("RenderView");
}
SceneRenderView *srv = MEM_callocN<SceneRenderView>(__func__);
SceneRenderView *srv = MEM_new_for_free<SceneRenderView>(__func__);
STRNCPY_UTF8(srv->name, name);
BLI_uniquename(&sce->r.views,
srv,

View file

@ -12,6 +12,7 @@
#include "BLO_userdef_default.h"
#include "DNA_defs.h"
#include "IMB_imbuf.hh"
#include "DNA_action_types.h"
@ -67,7 +68,7 @@ class SceneTest : public ::testing::Test {
IMB_init();
BKE_idtype_init();
/* #BKE_scene_duplicate() uses #U::dupflag. */
U = blender::dna::shallow_copy(U_default);
U = dna::shallow_copy(UserDef());
}
static void TearDownTestSuite()

View file

@ -21,7 +21,6 @@
#include "MEM_guardedalloc.h"
#include "DNA_defaults.h"
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
#include "DNA_space_types.h"
@ -477,7 +476,7 @@ ARegion *BKE_area_region_copy(const SpaceType *st, const ARegion *region)
ARegion *BKE_area_region_new()
{
ARegion *region = MEM_callocN<ARegion>(__func__);
ARegion *region = MEM_new_for_free<ARegion>(__func__);
region->runtime = MEM_new<blender::bke::ARegionRuntime>(__func__);
return region;
}
@ -626,7 +625,7 @@ LayoutPanelState *BKE_panel_layout_panel_state_ensure(Panel *panel,
return state;
}
}
LayoutPanelState *state = MEM_callocN<LayoutPanelState>(__func__);
LayoutPanelState *state = MEM_new_for_free<LayoutPanelState>(__func__);
state->idname = BLI_strdupn(idname.data(), idname.size());
SET_FLAG_FROM_TEST(state->flag, !default_closed, LAYOUT_PANEL_STATE_FLAG_OPEN);
state->last_used = logical_time;
@ -636,7 +635,7 @@ LayoutPanelState *BKE_panel_layout_panel_state_ensure(Panel *panel,
Panel *BKE_panel_new(PanelType *panel_type)
{
Panel *panel = MEM_callocN<Panel>(__func__);
Panel *panel = MEM_new_for_free<Panel>(__func__);
panel->runtime = MEM_new<Panel_Runtime>(__func__);
panel->type = panel_type;
if (panel_type) {
@ -1153,8 +1152,7 @@ void BKE_screen_view3d_scene_sync(bScreen *screen, Scene *scene)
void BKE_screen_view3d_shading_init(View3DShading *shading)
{
const View3DShading *shading_default = DNA_struct_default_get(View3DShading);
memcpy(shading, shading_default, sizeof(*shading));
*shading = View3DShading();
}
ARegion *BKE_screen_find_main_region_at_xy(const bScreen *screen,
@ -1437,7 +1435,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_callocN<RegionView3D>("region view3d");
region->regiondata = MEM_new_for_free<RegionView3D>("region view3d");
}
RegionView3D *rv3d = static_cast<RegionView3D *>(region->regiondata);
@ -1469,7 +1467,7 @@ void BKE_screen_view3d_do_versions_250(View3D *v3d, ListBase *regions)
if (region->regiontype == RGN_TYPE_WINDOW && region->regiondata == nullptr) {
RegionView3D *rv3d;
rv3d = MEM_callocN<RegionView3D>("region v3d patch");
rv3d = MEM_new_for_free<RegionView3D>("region v3d patch");
rv3d->persp = char(v3d->persp);
rv3d->view = char(v3d->view);
rv3d->dist = v3d->dist;
@ -1520,7 +1518,7 @@ static void direct_link_area(BlendDataReader *reader, ScrArea *area)
/* accident can happen when read/save new file with older version */
/* 2.50: we now always add spacedata for info */
if (area->spacedata.first == nullptr) {
SpaceInfo *sinfo = MEM_callocN<SpaceInfo>("spaceinfo");
SpaceInfo *sinfo = MEM_new_for_free<SpaceInfo>("spaceinfo");
area->spacetype = sinfo->spacetype = SPACE_INFO;
BLI_addtail(&area->spacedata, sinfo);
}

View file

@ -3057,7 +3057,7 @@ SoftBody *sbNew()
{
SoftBody *sb;
sb = MEM_callocN<SoftBody>("softbody");
sb = MEM_new_for_free<SoftBody>("softbody");
sb->mediafrict = 0.5f;
sb->nodemass = 1.0f;
@ -3093,7 +3093,7 @@ SoftBody *sbNew()
sb->shearstiff = 1.0f;
sb->solverflags |= SBSO_OLDERR;
sb->shared = MEM_callocN<SoftBody_Shared>("SoftBody_Shared");
sb->shared = MEM_new_for_free<SoftBody_Shared>("SoftBody_Shared");
sb->shared->pointcache = BKE_ptcache_add(&sb->shared->ptcaches);
if (!sb->effector_weights) {

Some files were not shown because too many files have changed in this diff Show more