Fix (unreported) more invalid C-style allocation of non-trivial C++ data.

This commit is contained in:
Bastien Montagne
2025-02-14 12:23:38 +01:00
parent 13c3d95f52
commit 194e233d86
4 changed files with 8 additions and 9 deletions

View File

@@ -796,7 +796,7 @@ GPUPass *GPU_generate_pass(GPUMaterial *material,
else {
/* We still create a pass even if shader compilation
* fails to avoid trying to compile again and again. */
pass = (GPUPass *)MEM_callocN(sizeof(GPUPass), "GPUPass");
pass = MEM_new<GPUPass>("GPUPass");
pass->shader = nullptr;
pass->refcount = 1;
pass->create_info = codegen.create_info;
@@ -984,7 +984,7 @@ static void gpu_pass_free(GPUPass *pass)
GPU_shader_free(pass->shader);
}
delete pass->create_info;
MEM_freeN(pass);
MEM_delete(pass);
}
void GPU_pass_acquire(GPUPass *pass)

View File

@@ -66,7 +66,7 @@ void MOV_close(MovieReader *anim)
MOV_close_proxies(anim);
IMB_metadata_free(anim->metadata);
MEM_freeN(anim);
MEM_delete(anim);
}
void MOV_get_filename(const MovieReader *anim, char *filename, int filename_maxncpy)
@@ -106,7 +106,7 @@ MovieReader *MOV_open_file(const char *filepath,
BLI_assert(!BLI_path_is_rel(filepath));
anim = (MovieReader *)MEM_callocN(sizeof(MovieReader), "anim struct");
anim = MEM_new<MovieReader>("anim struct");
if (anim != nullptr) {
if (colorspace) {
colorspace_set_default_role(colorspace, IM_MAX_SPACE, COLOR_ROLE_DEFAULT_BYTE);

View File

@@ -1257,8 +1257,7 @@ static MovieWriter *ffmpeg_movie_open(const Scene *scene,
bool preview,
const char *suffix)
{
MovieWriter *context = static_cast<MovieWriter *>(
MEM_callocN(sizeof(MovieWriter), "new FFMPEG context"));
MovieWriter *context = MEM_new<MovieWriter>("new FFMPEG context");
context->ffmpeg_codec = AV_CODEC_ID_MPEG4;
context->ffmpeg_audio_codec = AV_CODEC_ID_NONE;
@@ -1400,7 +1399,7 @@ static void ffmpeg_movie_close(MovieWriter *context)
if (context->stamp_data) {
MEM_freeN(context->stamp_data);
}
MEM_freeN(context);
MEM_delete(context);
}
#endif /* WITH_FFMPEG */

View File

@@ -69,7 +69,7 @@ static void delete_laplacian_system(LaplacianSystem *sys)
EIG_linear_solver_delete(sys->context);
}
sys->vertexCos = nullptr;
MEM_freeN(sys);
MEM_delete(sys);
}
static void memset_laplacian_system(LaplacianSystem *sys, int val)
@@ -87,7 +87,7 @@ static void memset_laplacian_system(LaplacianSystem *sys, int val)
static LaplacianSystem *init_laplacian_system(int a_numEdges, int a_numLoops, int a_numVerts)
{
LaplacianSystem *sys;
sys = static_cast<LaplacianSystem *>(MEM_callocN(sizeof(LaplacianSystem), __func__));
sys = MEM_new<LaplacianSystem>(__func__);
sys->verts_num = a_numVerts;
sys->eweights = MEM_cnew_array<float>(a_numEdges, __func__);