Cleanup: use new c++ guarded allocator API

API added in rBa3ad5abf2fe85d623f9e78fefc34e27bdc14632e
This commit is contained in:
Aaron Carlisle 2021-12-24 22:17:49 -05:00
parent 79012c6784
commit 6e0cf86e73
40 changed files with 143 additions and 161 deletions

@ -485,8 +485,8 @@ OCIO_PackedImageDesc *FallbackImpl::createOCIO_PackedImageDesc(float *data,
long xStrideBytes, long xStrideBytes,
long yStrideBytes) long yStrideBytes)
{ {
OCIO_PackedImageDescription *desc = (OCIO_PackedImageDescription *)MEM_callocN( OCIO_PackedImageDescription *desc = MEM_cnew<OCIO_PackedImageDescription>(
sizeof(OCIO_PackedImageDescription), "OCIO_PackedImageDescription"); "OCIO_PackedImageDescription");
desc->data = data; desc->data = data;
desc->width = width; desc->width = width;
desc->height = height; desc->height = height;

@ -127,7 +127,7 @@ bool bvhcache_has_tree(const BVHCache *bvh_cache, const BVHTree *tree)
BVHCache *bvhcache_init() BVHCache *bvhcache_init()
{ {
BVHCache *cache = (BVHCache *)MEM_callocN(sizeof(BVHCache), __func__); BVHCache *cache = MEM_cnew<BVHCache>(__func__);
BLI_mutex_init(&cache->mutex); BLI_mutex_init(&cache->mutex);
return cache; return cache;
} }

@ -278,13 +278,13 @@ void BKE_cryptomatte_matte_id_to_entries(NodeCryptomatte *node_storage, const ch
token = token.substr(first, (last - first + 1)); token = token.substr(first, (last - first + 1));
if (*token.begin() == '<' && *(--token.end()) == '>') { if (*token.begin() == '<' && *(--token.end()) == '>') {
float encoded_hash = atof(token.substr(1, token.length() - 2).c_str()); float encoded_hash = atof(token.substr(1, token.length() - 2).c_str());
entry = (CryptomatteEntry *)MEM_callocN(sizeof(CryptomatteEntry), __func__); entry = MEM_cnew<CryptomatteEntry>(__func__);
entry->encoded_hash = encoded_hash; entry->encoded_hash = encoded_hash;
} }
else { else {
const char *name = token.c_str(); const char *name = token.c_str();
int name_len = token.length(); int name_len = token.length();
entry = (CryptomatteEntry *)MEM_callocN(sizeof(CryptomatteEntry), __func__); entry = MEM_cnew<CryptomatteEntry>(__func__);
STRNCPY(entry->name, name); STRNCPY(entry->name, name);
uint32_t hash = BKE_cryptomatte_hash(name, name_len); uint32_t hash = BKE_cryptomatte_hash(name, name_len);
entry->encoded_hash = BKE_cryptomatte_hash_to_float(hash); entry->encoded_hash = BKE_cryptomatte_hash_to_float(hash);

@ -2694,7 +2694,7 @@ void BKE_curve_bevelList_make(Object *ob, const ListBase *nurbs, const bool for_
if (nu->type == CU_POLY) { if (nu->type == CU_POLY) {
len = nu->pntsu; len = nu->pntsu;
BevList *bl = (BevList *)MEM_callocN(sizeof(BevList), __func__); BevList *bl = MEM_cnew<BevList>(__func__);
bl->bevpoints = (BevPoint *)MEM_calloc_arrayN(len, sizeof(BevPoint), __func__); bl->bevpoints = (BevPoint *)MEM_calloc_arrayN(len, sizeof(BevPoint), __func__);
if (need_seglen && (nu->flagu & CU_NURB_CYCLIC) == 0) { if (need_seglen && (nu->flagu & CU_NURB_CYCLIC) == 0) {
bl->seglen = (float *)MEM_malloc_arrayN(segcount, sizeof(float), __func__); bl->seglen = (float *)MEM_malloc_arrayN(segcount, sizeof(float), __func__);
@ -2744,7 +2744,7 @@ void BKE_curve_bevelList_make(Object *ob, const ListBase *nurbs, const bool for_
/* in case last point is not cyclic */ /* in case last point is not cyclic */
len = segcount * resolu + 1; len = segcount * resolu + 1;
BevList *bl = (BevList *)MEM_callocN(sizeof(BevList), __func__); BevList *bl = MEM_cnew<BevList>(__func__);
bl->bevpoints = (BevPoint *)MEM_calloc_arrayN(len, sizeof(BevPoint), __func__); bl->bevpoints = (BevPoint *)MEM_calloc_arrayN(len, sizeof(BevPoint), __func__);
if (need_seglen && (nu->flagu & CU_NURB_CYCLIC) == 0) { if (need_seglen && (nu->flagu & CU_NURB_CYCLIC) == 0) {
bl->seglen = (float *)MEM_malloc_arrayN(segcount, sizeof(float), __func__); bl->seglen = (float *)MEM_malloc_arrayN(segcount, sizeof(float), __func__);
@ -2880,7 +2880,7 @@ void BKE_curve_bevelList_make(Object *ob, const ListBase *nurbs, const bool for_
if (nu->pntsv == 1) { if (nu->pntsv == 1) {
len = (resolu * segcount); len = (resolu * segcount);
BevList *bl = (BevList *)MEM_callocN(sizeof(BevList), __func__); BevList *bl = MEM_cnew<BevList>(__func__);
bl->bevpoints = (BevPoint *)MEM_calloc_arrayN(len, sizeof(BevPoint), __func__); bl->bevpoints = (BevPoint *)MEM_calloc_arrayN(len, sizeof(BevPoint), __func__);
if (need_seglen && (nu->flagu & CU_NURB_CYCLIC) == 0) { if (need_seglen && (nu->flagu & CU_NURB_CYCLIC) == 0) {
bl->seglen = (float *)MEM_malloc_arrayN(segcount, sizeof(float), __func__); bl->seglen = (float *)MEM_malloc_arrayN(segcount, sizeof(float), __func__);

@ -316,7 +316,7 @@ static void curve_to_displist(const Curve *cu,
* and resolution > 1. */ * and resolution > 1. */
const bool use_cyclic_sample = is_cyclic && (samples_len != 2); const bool use_cyclic_sample = is_cyclic && (samples_len != 2);
DispList *dl = (DispList *)MEM_callocN(sizeof(DispList), __func__); DispList *dl = MEM_cnew<DispList>(__func__);
/* Add one to the length because of 'BKE_curve_forward_diff_bezier'. */ /* Add one to the length because of 'BKE_curve_forward_diff_bezier'. */
dl->verts = (float *)MEM_mallocN(sizeof(float[3]) * (samples_len + 1), __func__); dl->verts = (float *)MEM_mallocN(sizeof(float[3]) * (samples_len + 1), __func__);
BLI_addtail(r_dispbase, dl); BLI_addtail(r_dispbase, dl);
@ -371,7 +371,7 @@ static void curve_to_displist(const Curve *cu,
} }
else if (nu->type == CU_NURBS) { else if (nu->type == CU_NURBS) {
const int len = (resolution * SEGMENTSU(nu)); const int len = (resolution * SEGMENTSU(nu));
DispList *dl = (DispList *)MEM_callocN(sizeof(DispList), __func__); DispList *dl = MEM_cnew<DispList>(__func__);
dl->verts = (float *)MEM_mallocN(len * sizeof(float[3]), __func__); dl->verts = (float *)MEM_mallocN(len * sizeof(float[3]), __func__);
BLI_addtail(r_dispbase, dl); BLI_addtail(r_dispbase, dl);
dl->parts = 1; dl->parts = 1;
@ -384,7 +384,7 @@ static void curve_to_displist(const Curve *cu,
} }
else if (nu->type == CU_POLY) { else if (nu->type == CU_POLY) {
const int len = nu->pntsu; const int len = nu->pntsu;
DispList *dl = (DispList *)MEM_callocN(sizeof(DispList), __func__); DispList *dl = MEM_cnew<DispList>(__func__);
dl->verts = (float *)MEM_mallocN(len * sizeof(float[3]), __func__); dl->verts = (float *)MEM_mallocN(len * sizeof(float[3]), __func__);
BLI_addtail(r_dispbase, dl); BLI_addtail(r_dispbase, dl);
dl->parts = 1; dl->parts = 1;
@ -475,7 +475,7 @@ void BKE_displist_fill(const ListBase *dispbase,
const int triangles_len = BLI_scanfill_calc_ex(&sf_ctx, scanfill_flag, normal_proj); const int triangles_len = BLI_scanfill_calc_ex(&sf_ctx, scanfill_flag, normal_proj);
if (totvert != 0 && triangles_len != 0) { if (totvert != 0 && triangles_len != 0) {
DispList *dlnew = (DispList *)MEM_callocN(sizeof(DispList), __func__); DispList *dlnew = MEM_cnew<DispList>(__func__);
dlnew->type = DL_INDEX3; dlnew->type = DL_INDEX3;
dlnew->flag = (dl_flag_accum & (DL_BACK_CURVE | DL_FRONT_CURVE)); dlnew->flag = (dl_flag_accum & (DL_BACK_CURVE | DL_FRONT_CURVE));
dlnew->rt = (dl_rt_accum & CU_SMOOTH); dlnew->rt = (dl_rt_accum & CU_SMOOTH);
@ -530,7 +530,7 @@ static void bevels_to_filledpoly(const Curve *cu, ListBase *dispbase)
if (dl->type == DL_SURF) { if (dl->type == DL_SURF) {
if ((dl->flag & DL_CYCL_V) && (dl->flag & DL_CYCL_U) == 0) { if ((dl->flag & DL_CYCL_V) && (dl->flag & DL_CYCL_U) == 0) {
if ((cu->flag & CU_BACK) && (dl->flag & DL_BACK_CURVE)) { if ((cu->flag & CU_BACK) && (dl->flag & DL_BACK_CURVE)) {
DispList *dlnew = (DispList *)MEM_callocN(sizeof(DispList), __func__); DispList *dlnew = MEM_cnew<DispList>(__func__);
BLI_addtail(&front, dlnew); BLI_addtail(&front, dlnew);
dlnew->verts = (float *)MEM_mallocN(sizeof(float[3]) * dl->parts, __func__); dlnew->verts = (float *)MEM_mallocN(sizeof(float[3]) * dl->parts, __func__);
dlnew->nr = dl->parts; dlnew->nr = dl->parts;
@ -549,7 +549,7 @@ static void bevels_to_filledpoly(const Curve *cu, ListBase *dispbase)
} }
} }
if ((cu->flag & CU_FRONT) && (dl->flag & DL_FRONT_CURVE)) { if ((cu->flag & CU_FRONT) && (dl->flag & DL_FRONT_CURVE)) {
DispList *dlnew = (DispList *)MEM_callocN(sizeof(DispList), __func__); DispList *dlnew = MEM_cnew<DispList>(__func__);
BLI_addtail(&back, dlnew); BLI_addtail(&back, dlnew);
dlnew->verts = (float *)MEM_mallocN(sizeof(float[3]) * dl->parts, __func__); dlnew->verts = (float *)MEM_mallocN(sizeof(float[3]) * dl->parts, __func__);
dlnew->nr = dl->parts; dlnew->nr = dl->parts;
@ -665,7 +665,7 @@ void BKE_displist_make_mball(Depsgraph *depsgraph, Scene *scene, Object *ob)
BKE_displist_free(&(ob->runtime.curve_cache->disp)); BKE_displist_free(&(ob->runtime.curve_cache->disp));
} }
else { else {
ob->runtime.curve_cache = (CurveCache *)MEM_callocN(sizeof(CurveCache), __func__); ob->runtime.curve_cache = MEM_cnew<CurveCache>(__func__);
} }
BKE_mball_polygonize(depsgraph, scene, ob, &ob->runtime.curve_cache->disp); BKE_mball_polygonize(depsgraph, scene, ob, &ob->runtime.curve_cache->disp);
@ -996,7 +996,7 @@ static void evaluate_surface_object(Depsgraph *depsgraph,
if (nu->pntsv == 1) { if (nu->pntsv == 1) {
const int len = SEGMENTSU(nu) * resolu; const int len = SEGMENTSU(nu) * resolu;
DispList *dl = (DispList *)MEM_callocN(sizeof(DispList), __func__); DispList *dl = MEM_cnew<DispList>(__func__);
dl->verts = (float *)MEM_mallocN(len * sizeof(float[3]), __func__); dl->verts = (float *)MEM_mallocN(len * sizeof(float[3]), __func__);
BLI_addtail(r_dispbase, dl); BLI_addtail(r_dispbase, dl);
@ -1019,7 +1019,7 @@ static void evaluate_surface_object(Depsgraph *depsgraph,
else { else {
const int len = (nu->pntsu * resolu) * (nu->pntsv * resolv); const int len = (nu->pntsu * resolu) * (nu->pntsv * resolv);
DispList *dl = (DispList *)MEM_callocN(sizeof(DispList), __func__); DispList *dl = MEM_cnew<DispList>(__func__);
dl->verts = (float *)MEM_mallocN(len * sizeof(float[3]), __func__); dl->verts = (float *)MEM_mallocN(len * sizeof(float[3]), __func__);
BLI_addtail(r_dispbase, dl); BLI_addtail(r_dispbase, dl);
@ -1122,7 +1122,7 @@ static void fillBevelCap(const Nurb *nu,
const float *prev_fp, const float *prev_fp,
ListBase *dispbase) ListBase *dispbase)
{ {
DispList *dl = (DispList *)MEM_callocN(sizeof(DispList), __func__); DispList *dl = MEM_cnew<DispList>(__func__);
dl->verts = (float *)MEM_mallocN(sizeof(float[3]) * dlb->nr, __func__); dl->verts = (float *)MEM_mallocN(sizeof(float[3]) * dlb->nr, __func__);
memcpy(dl->verts, prev_fp, sizeof(float[3]) * dlb->nr); memcpy(dl->verts, prev_fp, sizeof(float[3]) * dlb->nr);
@ -1321,7 +1321,7 @@ static GeometrySet evaluate_curve_type_object(Depsgraph *depsgraph,
/* exception handling; curve without bevel or extrude, with width correction */ /* exception handling; curve without bevel or extrude, with width correction */
if (BLI_listbase_is_empty(&dlbev)) { if (BLI_listbase_is_empty(&dlbev)) {
DispList *dl = (DispList *)MEM_callocN(sizeof(DispList), "makeDispListbev"); DispList *dl = MEM_cnew<DispList>("makeDispListbev");
dl->verts = (float *)MEM_mallocN(sizeof(float[3]) * bl->nr, "dlverts"); dl->verts = (float *)MEM_mallocN(sizeof(float[3]) * bl->nr, "dlverts");
BLI_addtail(r_dispbase, dl); BLI_addtail(r_dispbase, dl);
@ -1371,7 +1371,7 @@ static GeometrySet evaluate_curve_type_object(Depsgraph *depsgraph,
LISTBASE_FOREACH (DispList *, dlb, &dlbev) { LISTBASE_FOREACH (DispList *, dlb, &dlbev) {
/* for each part of the bevel use a separate displblock */ /* for each part of the bevel use a separate displblock */
DispList *dl = (DispList *)MEM_callocN(sizeof(DispList), __func__); DispList *dl = MEM_cnew<DispList>(__func__);
dl->verts = data = (float *)MEM_mallocN(sizeof(float[3]) * dlb->nr * steps, __func__); dl->verts = data = (float *)MEM_mallocN(sizeof(float[3]) * dlb->nr * steps, __func__);
BLI_addtail(r_dispbase, dl); BLI_addtail(r_dispbase, dl);
@ -1495,7 +1495,7 @@ void BKE_displist_make_curveTypes(Depsgraph *depsgraph,
BKE_object_free_derived_caches(ob); BKE_object_free_derived_caches(ob);
cow_curve.curve_eval = nullptr; cow_curve.curve_eval = nullptr;
ob->runtime.curve_cache = (CurveCache *)MEM_callocN(sizeof(CurveCache), __func__); ob->runtime.curve_cache = MEM_cnew<CurveCache>(__func__);
ListBase *dispbase = &ob->runtime.curve_cache->disp; ListBase *dispbase = &ob->runtime.curve_cache->disp;
if (ob->type == OB_SURF) { if (ob->type == OB_SURF) {

@ -145,7 +145,7 @@ void BKE_gpencil_stroke_boundingbox_calc(bGPDstroke *gps)
static void boundbox_gpencil(Object *ob) static void boundbox_gpencil(Object *ob)
{ {
if (ob->runtime.bb == nullptr) { if (ob->runtime.bb == nullptr) {
ob->runtime.bb = (BoundBox *)MEM_callocN(sizeof(BoundBox), "GPencil boundbox"); ob->runtime.bb = MEM_cnew<BoundBox>("GPencil boundbox");
} }
BoundBox *bb = ob->runtime.bb; BoundBox *bb = ob->runtime.bb;
@ -182,7 +182,7 @@ BoundBox *BKE_gpencil_boundbox_get(Object *ob)
* to keep both values synchronized. */ * to keep both values synchronized. */
if (!ELEM(ob_orig, nullptr, ob)) { if (!ELEM(ob_orig, nullptr, ob)) {
if (ob_orig->runtime.bb == nullptr) { if (ob_orig->runtime.bb == nullptr) {
ob_orig->runtime.bb = (BoundBox *)MEM_callocN(sizeof(BoundBox), "GPencil boundbox"); ob_orig->runtime.bb = MEM_cnew<BoundBox>("GPencil boundbox");
} }
for (int i = 0; i < 8; i++) { for (int i = 0; i < 8; i++) {
copy_v3_v3(ob_orig->runtime.bb->vec[i], ob->runtime.bb->vec[i]); copy_v3_v3(ob_orig->runtime.bb->vec[i], ob->runtime.bb->vec[i]);
@ -364,7 +364,7 @@ static void stroke_defvert_create_nr_list(MDeformVert *dv_list,
} }
} }
if (!found) { if (!found) {
ld = (LinkData *)MEM_callocN(sizeof(LinkData), "def_nr_item"); ld = MEM_cnew<LinkData>("def_nr_item");
ld->data = POINTER_FROM_INT(dw->def_nr); ld->data = POINTER_FROM_INT(dw->def_nr);
BLI_addtail(result, ld); BLI_addtail(result, ld);
tw++; tw++;
@ -3482,7 +3482,7 @@ struct tSampleEdge {
/* Helper: creates a tSamplePoint from a bGPDspoint and (optionally) a MDeformVert. */ /* Helper: creates a tSamplePoint from a bGPDspoint and (optionally) a MDeformVert. */
static tSamplePoint *new_sample_point_from_gp_point(const bGPDspoint *pt, const MDeformVert *dvert) static tSamplePoint *new_sample_point_from_gp_point(const bGPDspoint *pt, const MDeformVert *dvert)
{ {
tSamplePoint *new_pt = (tSamplePoint *)MEM_callocN(sizeof(tSamplePoint), __func__); tSamplePoint *new_pt = MEM_cnew<tSamplePoint>(__func__);
copy_v3_v3(&new_pt->x, &pt->x); copy_v3_v3(&new_pt->x, &pt->x);
new_pt->pressure = pt->pressure; new_pt->pressure = pt->pressure;
new_pt->strength = pt->strength; new_pt->strength = pt->strength;
@ -3505,7 +3505,7 @@ static tSamplePoint *new_sample_point_from_gp_point(const bGPDspoint *pt, const
* the edge. */ * the edge. */
static tSampleEdge *new_sample_edge_from_sample_points(tSamplePoint *from, tSamplePoint *to) static tSampleEdge *new_sample_edge_from_sample_points(tSamplePoint *from, tSamplePoint *to)
{ {
tSampleEdge *new_edge = (tSampleEdge *)MEM_callocN(sizeof(tSampleEdge), __func__); tSampleEdge *new_edge = MEM_cnew<tSampleEdge>(__func__);
new_edge->from = from; new_edge->from = from;
new_edge->to = to; new_edge->to = to;
new_edge->length_sq = len_squared_v3v3(&from->x, &to->x); new_edge->length_sq = len_squared_v3v3(&from->x, &to->x);
@ -3561,7 +3561,7 @@ void BKE_gpencil_stroke_uniform_subdivide(bGPdata *gpd,
tSamplePoint *sp_next = se->to; tSamplePoint *sp_next = se->to;
/* Subdivide the edge. */ /* Subdivide the edge. */
tSamplePoint *new_sp = (tSamplePoint *)MEM_callocN(sizeof(tSamplePoint), __func__); tSamplePoint *new_sp = MEM_cnew<tSamplePoint>(__func__);
interp_v3_v3v3(&new_sp->x, &sp->x, &sp_next->x, 0.5f); interp_v3_v3v3(&new_sp->x, &sp->x, &sp_next->x, 0.5f);
new_sp->pressure = interpf(sp->pressure, sp_next->pressure, 0.5f); new_sp->pressure = interpf(sp->pressure, sp_next->pressure, 0.5f);
new_sp->strength = interpf(sp->strength, sp_next->strength, 0.5f); new_sp->strength = interpf(sp->strength, sp_next->strength, 0.5f);
@ -3687,7 +3687,7 @@ struct tPerimeterPoint {
static tPerimeterPoint *new_perimeter_point(const float pt[3]) static tPerimeterPoint *new_perimeter_point(const float pt[3])
{ {
tPerimeterPoint *new_pt = (tPerimeterPoint *)MEM_callocN(sizeof(tPerimeterPoint), __func__); tPerimeterPoint *new_pt = MEM_cnew<tPerimeterPoint>(__func__);
copy_v3_v3(&new_pt->x, pt); copy_v3_v3(&new_pt->x, pt);
return new_pt; return new_pt;
} }
@ -3856,8 +3856,8 @@ static ListBase *gpencil_stroke_perimeter_ex(const bGPdata *gpd,
float defaultpixsize = 1000.0f / gpd->pixfactor; float defaultpixsize = 1000.0f / gpd->pixfactor;
float stroke_radius = ((gps->thickness + gpl->line_change) / defaultpixsize) / 2.0f; float stroke_radius = ((gps->thickness + gpl->line_change) / defaultpixsize) / 2.0f;
ListBase *perimeter_right_side = (ListBase *)MEM_callocN(sizeof(ListBase), __func__); ListBase *perimeter_right_side = MEM_cnew<ListBase>(__func__);
ListBase *perimeter_left_side = (ListBase *)MEM_callocN(sizeof(ListBase), __func__); ListBase *perimeter_left_side = MEM_cnew<ListBase>(__func__);
int num_perimeter_points = 0; int num_perimeter_points = 0;
bGPDspoint *first = &gps->points[0]; bGPDspoint *first = &gps->points[0];

@ -172,7 +172,7 @@ static GPUTexture *gpu_texture_create_tile_array(Image *ima,
ImBuf *ibuf = BKE_image_acquire_ibuf(ima, &iuser, nullptr); ImBuf *ibuf = BKE_image_acquire_ibuf(ima, &iuser, nullptr);
if (ibuf) { if (ibuf) {
PackTile *packtile = (PackTile *)MEM_callocN(sizeof(PackTile), __func__); PackTile *packtile = MEM_cnew<PackTile>(__func__);
packtile->tile = tile; packtile->tile = tile;
packtile->boxpack.w = ibuf->x; packtile->boxpack.w = ibuf->x;
packtile->boxpack.h = ibuf->y; packtile->boxpack.h = ibuf->y;

@ -589,14 +589,14 @@ struct VertLink {
static void prependPolyLineVert(ListBase *lb, uint index) static void prependPolyLineVert(ListBase *lb, uint index)
{ {
VertLink *vl = (VertLink *)MEM_callocN(sizeof(VertLink), "VertLink"); VertLink *vl = MEM_cnew<VertLink>("VertLink");
vl->index = index; vl->index = index;
BLI_addhead(lb, vl); BLI_addhead(lb, vl);
} }
static void appendPolyLineVert(ListBase *lb, uint index) static void appendPolyLineVert(ListBase *lb, uint index)
{ {
VertLink *vl = (VertLink *)MEM_callocN(sizeof(VertLink), "VertLink"); VertLink *vl = MEM_cnew<VertLink>("VertLink");
vl->index = index; vl->index = index;
BLI_addtail(lb, vl); BLI_addtail(lb, vl);
} }
@ -632,7 +632,7 @@ void BKE_mesh_to_curve_nurblist(const Mesh *me, ListBase *nurblist, const int ed
med = medge; med = medge;
for (i = 0; i < medge_len; i++, med++) { for (i = 0; i < medge_len; i++, med++) {
if (edge_users[i] == edge_users_test) { if (edge_users[i] == edge_users_test) {
EdgeLink *edl = (EdgeLink *)MEM_callocN(sizeof(EdgeLink), "EdgeLink"); EdgeLink *edl = MEM_cnew<EdgeLink>("EdgeLink");
edl->edge = med; edl->edge = med;
BLI_addtail(&edges, edl); BLI_addtail(&edges, edl);
@ -719,7 +719,7 @@ void BKE_mesh_to_curve_nurblist(const Mesh *me, ListBase *nurblist, const int ed
VertLink *vl; VertLink *vl;
/* create new 'nurb' within the curve */ /* create new 'nurb' within the curve */
nu = (Nurb *)MEM_callocN(sizeof(Nurb), "MeshNurb"); nu = MEM_cnew<Nurb>("MeshNurb");
nu->pntsu = totpoly; nu->pntsu = totpoly;
nu->pntsv = 1; nu->pntsv = 1;

@ -1529,7 +1529,7 @@ static bNodeSocket *make_socket(bNodeTree *ntree,
BLI_uniquename_cb( BLI_uniquename_cb(
unique_identifier_check, lb, "socket", '_', auto_identifier, sizeof(auto_identifier)); unique_identifier_check, lb, "socket", '_', auto_identifier, sizeof(auto_identifier));
bNodeSocket *sock = (bNodeSocket *)MEM_callocN(sizeof(bNodeSocket), "sock"); bNodeSocket *sock = MEM_cnew<bNodeSocket>("sock");
sock->in_out = in_out; sock->in_out = in_out;
BLI_strncpy(sock->identifier, auto_identifier, NODE_MAXSTR); BLI_strncpy(sock->identifier, auto_identifier, NODE_MAXSTR);
@ -2160,7 +2160,7 @@ void nodeUniqueName(bNodeTree *ntree, bNode *node)
bNode *nodeAddNode(const struct bContext *C, bNodeTree *ntree, const char *idname) bNode *nodeAddNode(const struct bContext *C, bNodeTree *ntree, const char *idname)
{ {
bNode *node = (bNode *)MEM_callocN(sizeof(bNode), "new node"); bNode *node = MEM_cnew<bNode>("new node");
BLI_addtail(&ntree->nodes, node); BLI_addtail(&ntree->nodes, node);
BLI_strncpy(node->idname, idname, sizeof(node->idname)); BLI_strncpy(node->idname, idname, sizeof(node->idname));
@ -2329,7 +2329,7 @@ bNodeLink *nodeAddLink(
BLI_assert(tonode); BLI_assert(tonode);
if (fromsock->in_out == SOCK_OUT && tosock->in_out == SOCK_IN) { if (fromsock->in_out == SOCK_OUT && tosock->in_out == SOCK_IN) {
link = (bNodeLink *)MEM_callocN(sizeof(bNodeLink), "link"); link = MEM_cnew<bNodeLink>("link");
if (ntree) { if (ntree) {
BLI_addtail(&ntree->links, link); BLI_addtail(&ntree->links, link);
} }
@ -2340,7 +2340,7 @@ bNodeLink *nodeAddLink(
} }
else if (fromsock->in_out == SOCK_IN && tosock->in_out == SOCK_OUT) { else if (fromsock->in_out == SOCK_IN && tosock->in_out == SOCK_OUT) {
/* OK but flip */ /* OK but flip */
link = (bNodeLink *)MEM_callocN(sizeof(bNodeLink), "link"); link = MEM_cnew<bNodeLink>("link");
if (ntree) { if (ntree) {
BLI_addtail(&ntree->links, link); BLI_addtail(&ntree->links, link);
} }
@ -2752,7 +2752,7 @@ bNodePreview *BKE_node_preview_verify(bNodeInstanceHash *previews,
bNodePreview *preview = (bNodePreview *)BKE_node_instance_hash_lookup(previews, key); bNodePreview *preview = (bNodePreview *)BKE_node_instance_hash_lookup(previews, key);
if (!preview) { if (!preview) {
if (create) { if (create) {
preview = (bNodePreview *)MEM_callocN(sizeof(bNodePreview), "node preview"); preview = MEM_cnew<bNodePreview>("node preview");
BKE_node_instance_hash_insert(previews, key, preview); BKE_node_instance_hash_insert(previews, key, preview);
} }
else { else {
@ -3374,7 +3374,7 @@ static bNodeSocket *make_socket_interface(bNodeTree *ntree,
return nullptr; return nullptr;
} }
bNodeSocket *sock = (bNodeSocket *)MEM_callocN(sizeof(bNodeSocket), "socket template"); bNodeSocket *sock = MEM_cnew<bNodeSocket>("socket template");
BLI_strncpy(sock->idname, stype->idname, sizeof(sock->idname)); BLI_strncpy(sock->idname, stype->idname, sizeof(sock->idname));
node_socket_set_typeinfo(ntree, sock, stype); node_socket_set_typeinfo(ntree, sock, stype);
sock->in_out = in_out; sock->in_out = in_out;

@ -1219,7 +1219,7 @@ class NodeTreeMainUpdater {
for (const auto &item : links) { for (const auto &item : links) {
bNodeSocket *from_socket = item.first; bNodeSocket *from_socket = item.first;
bNodeSocket *to_socket = item.second; bNodeSocket *to_socket = item.second;
bNodeLink *link = (bNodeLink *)MEM_callocN(sizeof(bNodeLink), __func__); bNodeLink *link = MEM_cnew<bNodeLink>(__func__);
link->fromnode = &node; link->fromnode = &node;
link->fromsock = from_socket; link->fromsock = from_socket;
link->tonode = &node; link->tonode = &node;

@ -3793,7 +3793,7 @@ BoundBox *BKE_boundbox_alloc_unit()
{ {
const float min[3] = {-1.0f, -1.0f, -1.0f}, max[3] = {1.0f, 1.0f, 1.0f}; const float min[3] = {-1.0f, -1.0f, -1.0f}, max[3] = {1.0f, 1.0f, 1.0f};
BoundBox *bb = (BoundBox *)MEM_callocN(sizeof(BoundBox), "OB-BoundBox"); BoundBox *bb = MEM_cnew<BoundBox>("OB-BoundBox");
BKE_boundbox_init_from_minmax(bb, min, max); BKE_boundbox_init_from_minmax(bb, min, max);
return bb; return bb;
@ -3903,7 +3903,7 @@ void BKE_object_boundbox_calc_from_mesh(Object *ob, const Mesh *me_eval)
} }
if (ob->runtime.bb == nullptr) { if (ob->runtime.bb == nullptr) {
ob->runtime.bb = (BoundBox *)MEM_callocN(sizeof(BoundBox), "DM-BoundBox"); ob->runtime.bb = MEM_cnew<BoundBox>("DM-BoundBox");
} }
BKE_boundbox_init_from_minmax(ob->runtime.bb, min, max); BKE_boundbox_init_from_minmax(ob->runtime.bb, min, max);
@ -3932,7 +3932,7 @@ bool BKE_object_boundbox_calc_from_evaluated_geometry(Object *ob)
} }
if (ob->runtime.bb == nullptr) { if (ob->runtime.bb == nullptr) {
ob->runtime.bb = (BoundBox *)MEM_callocN(sizeof(BoundBox), __func__); ob->runtime.bb = MEM_cnew<BoundBox>(__func__);
} }
BKE_boundbox_init_from_minmax(ob->runtime.bb, min, max); BKE_boundbox_init_from_minmax(ob->runtime.bb, min, max);
@ -4108,7 +4108,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->type == OB_EMPTY && ob->empty_drawtype == OB_EMPTY_IMAGE) {
if (!ob->iuser) { if (!ob->iuser) {
ob->iuser = (ImageUser *)MEM_callocN(sizeof(ImageUser), "image user"); ob->iuser = MEM_cnew<ImageUser>("image user");
ob->iuser->flag |= IMA_ANIM_ALWAYS; ob->iuser->flag |= IMA_ANIM_ALWAYS;
ob->iuser->frames = 100; ob->iuser->frames = 100;
ob->iuser->sfra = 1; ob->iuser->sfra = 1;
@ -4447,7 +4447,7 @@ void BKE_object_handle_update(Depsgraph *depsgraph, Scene *scene, Object *ob)
void BKE_object_sculpt_data_create(Object *ob) void BKE_object_sculpt_data_create(Object *ob)
{ {
BLI_assert((ob->sculpt == nullptr) && (ob->mode & OB_MODE_ALL_SCULPT)); BLI_assert((ob->sculpt == nullptr) && (ob->mode & OB_MODE_ALL_SCULPT));
ob->sculpt = (SculptSession *)MEM_callocN(sizeof(SculptSession), __func__); ob->sculpt = MEM_cnew<SculptSession>(__func__);
ob->sculpt->mode_type = (eObjectMode)ob->mode; ob->sculpt->mode_type = (eObjectMode)ob->mode;
} }
@ -4621,7 +4621,7 @@ int BKE_object_insert_ptcache(Object *ob)
} }
} }
link = (LinkData *)MEM_callocN(sizeof(LinkData), "PCLink"); link = MEM_cnew<LinkData>("PCLink");
link->data = POINTER_FROM_INT(i); link->data = POINTER_FROM_INT(i);
BLI_addtail(&ob->pc_ids, link); BLI_addtail(&ob->pc_ids, link);

@ -190,7 +190,7 @@ static DupliObject *make_dupli(const DupliContext *ctx,
/* Add a #DupliObject instance to the result container. */ /* Add a #DupliObject instance to the result container. */
if (ctx->duplilist) { if (ctx->duplilist) {
dob = (DupliObject *)MEM_callocN(sizeof(DupliObject), "dupli object"); dob = MEM_cnew<DupliObject>("dupli object");
BLI_addtail(ctx->duplilist, dob); BLI_addtail(ctx->duplilist, dob);
} }
else { else {
@ -1690,7 +1690,7 @@ static const DupliGenerator *get_dupli_generator(const DupliContext *ctx)
ListBase *object_duplilist(Depsgraph *depsgraph, Scene *sce, Object *ob) ListBase *object_duplilist(Depsgraph *depsgraph, Scene *sce, Object *ob)
{ {
ListBase *duplilist = (ListBase *)MEM_callocN(sizeof(ListBase), "duplilist"); ListBase *duplilist = MEM_cnew<ListBase>("duplilist");
DupliContext ctx; DupliContext ctx;
Vector<Object *> instance_stack; Vector<Object *> instance_stack;
instance_stack.append(ob); instance_stack.append(ob);

@ -955,7 +955,7 @@ BoundBox *BKE_volume_boundbox_get(Object *ob)
} }
if (ob->runtime.bb == nullptr) { if (ob->runtime.bb == nullptr) {
ob->runtime.bb = (BoundBox *)MEM_callocN(sizeof(BoundBox), __func__); ob->runtime.bb = MEM_cnew<BoundBox>(__func__);
} }
const Volume *volume = (Volume *)ob->data; const Volume *volume = (Volume *)ob->data;

@ -154,7 +154,7 @@ static void task_mempool_iter_tls_func(void *UNUSED(userdata),
EXPECT_TRUE(data != nullptr); EXPECT_TRUE(data != nullptr);
if (task_data->accumulate_items == nullptr) { if (task_data->accumulate_items == nullptr) {
task_data->accumulate_items = (ListBase *)MEM_callocN(sizeof(ListBase), __func__); task_data->accumulate_items = MEM_cnew<ListBase>(__func__);
} }
/* Flip to prove this has been touched. */ /* Flip to prove this has been touched. */
@ -172,7 +172,7 @@ static void task_mempool_iter_tls_reduce(const void *__restrict UNUSED(userdata)
if (data_chunk->accumulate_items != nullptr) { if (data_chunk->accumulate_items != nullptr) {
if (join_chunk->accumulate_items == nullptr) { if (join_chunk->accumulate_items == nullptr) {
join_chunk->accumulate_items = (ListBase *)MEM_callocN(sizeof(ListBase), __func__); join_chunk->accumulate_items = MEM_cnew<ListBase>(__func__);
} }
BLI_movelisttolist(join_chunk->accumulate_items, data_chunk->accumulate_items); BLI_movelisttolist(join_chunk->accumulate_items, data_chunk->accumulate_items);
} }

@ -132,8 +132,7 @@ KeyingScreenOperation::TriangulationData *KeyingScreenOperation::build_voronoi_t
return nullptr; return nullptr;
} }
triangulation = (TriangulationData *)MEM_callocN(sizeof(TriangulationData), triangulation = MEM_cnew<TriangulationData>("keying screen triangulation data");
"keying screen triangulation data");
sites = (VoronoiSite *)MEM_callocN(sizeof(VoronoiSite) * sites_total, sites = (VoronoiSite *)MEM_callocN(sizeof(VoronoiSite) * sites_total,
"keyingscreen voronoi sites"); "keyingscreen voronoi sites");
@ -243,7 +242,7 @@ KeyingScreenOperation::TileData *KeyingScreenOperation::triangulate(const rcti *
return nullptr; return nullptr;
} }
tile_data = (TileData *)MEM_callocN(sizeof(TileData), "keying screen tile data"); tile_data = MEM_cnew<TileData>("keying screen tile data");
for (i = 0; i < triangulation->triangles_total; i++) { for (i = 0; i < triangulation->triangles_total; i++) {
if (BLI_rcti_isect(rect, &triangulation->triangles_AABB[i], nullptr)) { if (BLI_rcti_isect(rect, &triangulation->triangles_AABB[i], nullptr)) {

@ -725,7 +725,7 @@ static ARegion *ui_searchbox_create_generic_ex(bContext *C,
region->type = &type; region->type = &type;
/* create searchbox data */ /* create searchbox data */
uiSearchboxData *data = (uiSearchboxData *)MEM_callocN(sizeof(uiSearchboxData), __func__); uiSearchboxData *data = MEM_cnew<uiSearchboxData>(__func__);
/* set font, get bb */ /* set font, get bb */
data->fstyle = style->widget; /* copy struct */ data->fstyle = style->widget; /* copy struct */
@ -1021,7 +1021,7 @@ void ui_but_search_refresh(uiButSearch *search_but)
return; return;
} }
uiSearchItems *items = (uiSearchItems *)MEM_callocN(sizeof(uiSearchItems), __func__); uiSearchItems *items = MEM_cnew<uiSearchItems>(__func__);
/* setup search struct */ /* setup search struct */
items->maxitem = 10; items->maxitem = 10;

@ -463,8 +463,8 @@ static int voxel_size_edit_invoke(bContext *C, wmOperator *op, const wmEvent *ev
Object *active_object = CTX_data_active_object(C); Object *active_object = CTX_data_active_object(C);
Mesh *mesh = (Mesh *)active_object->data; Mesh *mesh = (Mesh *)active_object->data;
VoxelSizeEditCustomData *cd = (VoxelSizeEditCustomData *)MEM_callocN( VoxelSizeEditCustomData *cd = MEM_cnew<VoxelSizeEditCustomData>(
sizeof(VoxelSizeEditCustomData), "Voxel Size Edit OP Custom Data"); "Voxel Size Edit OP Custom Data");
/* Initial operator Custom Data setup. */ /* Initial operator Custom Data setup. */
cd->draw_handle = ED_region_draw_cb_activate( cd->draw_handle = ED_region_draw_cb_activate(

@ -130,7 +130,7 @@ static bNodeSocketLink *add_reroute_insert_socket_link(ListBase *lb,
{ {
bNodeSocketLink *socklink, *prev; bNodeSocketLink *socklink, *prev;
socklink = (bNodeSocketLink *)MEM_callocN(sizeof(bNodeSocketLink), "socket link"); socklink = MEM_cnew<bNodeSocketLink>("socket link");
socklink->sock = sock; socklink->sock = sock;
socklink->link = link; socklink->link = link;
copy_v2_v2(socklink->point, point); copy_v2_v2(socklink->point, point);

@ -344,7 +344,7 @@ void ED_node_composite_job(const bContext *C, struct bNodeTree *nodetree, Scene
"Compositing", "Compositing",
WM_JOB_EXCL_RENDER | WM_JOB_PROGRESS, WM_JOB_EXCL_RENDER | WM_JOB_PROGRESS,
WM_JOB_TYPE_COMPOSITE); WM_JOB_TYPE_COMPOSITE);
CompoJob *cj = (CompoJob *)MEM_callocN(sizeof(CompoJob), "compo job"); CompoJob *cj = MEM_cnew<CompoJob>("compo job");
/* customdata for preview thread */ /* customdata for preview thread */
cj->bmain = bmain; cj->bmain = bmain;
@ -908,7 +908,7 @@ static void node_resize_init(bContext *C,
{ {
SpaceNode *snode = CTX_wm_space_node(C); SpaceNode *snode = CTX_wm_space_node(C);
NodeSizeWidget *nsw = (NodeSizeWidget *)MEM_callocN(sizeof(NodeSizeWidget), __func__); NodeSizeWidget *nsw = MEM_cnew<NodeSizeWidget>(__func__);
op->customdata = nsw; op->customdata = nsw;
nsw->mxstart = snode->runtime->cursor[0] * UI_DPI_FAC; nsw->mxstart = snode->runtime->cursor[0] * UI_DPI_FAC;
@ -1308,7 +1308,7 @@ static int node_duplicate_exec(bContext *C, wmOperator *op)
*/ */
if (link->tonode && (link->tonode->flag & NODE_SELECT) && if (link->tonode && (link->tonode->flag & NODE_SELECT) &&
(keep_inputs || (link->fromnode && (link->fromnode->flag & NODE_SELECT)))) { (keep_inputs || (link->fromnode && (link->fromnode->flag & NODE_SELECT)))) {
bNodeLink *newlink = (bNodeLink *)MEM_callocN(sizeof(bNodeLink), "bNodeLink"); bNodeLink *newlink = MEM_cnew<bNodeLink>("bNodeLink");
newlink->flag = link->flag; newlink->flag = link->flag;
newlink->tonode = node_map.lookup(link->tonode); newlink->tonode = node_map.lookup(link->tonode);
newlink->tosock = socket_map.lookup(link->tosock); newlink->tosock = socket_map.lookup(link->tosock);
@ -2138,7 +2138,7 @@ static int node_clipboard_copy_exec(bContext *C, wmOperator *UNUSED(op))
BLI_assert(link->tonode); BLI_assert(link->tonode);
BLI_assert(link->fromnode); BLI_assert(link->fromnode);
if (link->tonode->flag & NODE_SELECT && link->fromnode->flag & NODE_SELECT) { if (link->tonode->flag & NODE_SELECT && link->fromnode->flag & NODE_SELECT) {
bNodeLink *newlink = (bNodeLink *)MEM_callocN(sizeof(bNodeLink), __func__); bNodeLink *newlink = MEM_cnew<bNodeLink>(__func__);
newlink->flag = link->flag; newlink->flag = link->flag;
newlink->tonode = node_map.lookup(link->tonode); newlink->tonode = node_map.lookup(link->tonode);
newlink->tosock = socket_map.lookup(link->tosock); newlink->tosock = socket_map.lookup(link->tosock);

@ -102,7 +102,7 @@ static void clear_picking_highlight(ListBase *links)
static bNodeLink *create_drag_link(bNode &node, bNodeSocket &sock) static bNodeLink *create_drag_link(bNode &node, bNodeSocket &sock)
{ {
bNodeLink *oplink = (bNodeLink *)MEM_callocN(sizeof(bNodeLink), __func__); bNodeLink *oplink = MEM_cnew<bNodeLink>(__func__);
if (sock.in_out == SOCK_OUT) { if (sock.in_out == SOCK_OUT) {
oplink->fromnode = &node; oplink->fromnode = &node;
oplink->fromsock = &sock; oplink->fromsock = &sock;
@ -1123,7 +1123,7 @@ static std::unique_ptr<bNodeLinkDrag> node_link_init(SpaceNode &snode,
/* detach current links and store them in the operator data */ /* detach current links and store them in the operator data */
LISTBASE_FOREACH_MUTABLE (bNodeLink *, link, &snode.edittree->links) { LISTBASE_FOREACH_MUTABLE (bNodeLink *, link, &snode.edittree->links) {
if (link->fromsock == sock) { if (link->fromsock == sock) {
bNodeLink *oplink = (bNodeLink *)MEM_callocN(sizeof(bNodeLink), "drag link op link"); bNodeLink *oplink = MEM_cnew<bNodeLink>("drag link op link");
*oplink = *link; *oplink = *link;
oplink->next = oplink->prev = nullptr; oplink->next = oplink->prev = nullptr;
oplink->flag |= NODE_LINK_VALID; oplink->flag |= NODE_LINK_VALID;
@ -1166,7 +1166,7 @@ static std::unique_ptr<bNodeLinkDrag> node_link_init(SpaceNode &snode,
} }
if (link_to_pick != nullptr && !nldrag->from_multi_input_socket) { if (link_to_pick != nullptr && !nldrag->from_multi_input_socket) {
bNodeLink *oplink = (bNodeLink *)MEM_callocN(sizeof(bNodeLink), "drag link op link"); bNodeLink *oplink = MEM_cnew<bNodeLink>("drag link op link");
*oplink = *link_to_pick; *oplink = *link_to_pick;
oplink->next = oplink->prev = nullptr; oplink->next = oplink->prev = nullptr;
oplink->flag |= NODE_LINK_VALID; oplink->flag |= NODE_LINK_VALID;
@ -2465,8 +2465,7 @@ void ED_node_link_insert(Main *bmain, ScrArea *area)
/* set up insert offset data, it needs stuff from here */ /* set up insert offset data, it needs stuff from here */
if ((snode->flag & SNODE_SKIP_INSOFFSET) == 0) { if ((snode->flag & SNODE_SKIP_INSOFFSET) == 0) {
NodeInsertOfsData *iofsd = (NodeInsertOfsData *)MEM_callocN(sizeof(NodeInsertOfsData), NodeInsertOfsData *iofsd = MEM_cnew<NodeInsertOfsData>(__func__);
__func__);
iofsd->insert = select; iofsd->insert = select;
iofsd->prev = link->fromnode; iofsd->prev = link->fromnode;

@ -699,7 +699,7 @@ void uiTemplateNodeLink(
uiBut *but; uiBut *but;
float socket_col[4]; float socket_col[4];
arg = (NodeLinkArg *)MEM_callocN(sizeof(NodeLinkArg), "NodeLinkArg"); arg = MEM_new<NodeLinkArg>("NodeLinkArg");
arg->ntree = ntree; arg->ntree = ntree;
arg->node = node; arg->node = node;
arg->sock = input; arg->sock = input;

@ -255,7 +255,7 @@ static int snode_bg_viewmove_invoke(bContext *C, wmOperator *op, const wmEvent *
return OPERATOR_CANCELLED; return OPERATOR_CANCELLED;
} }
nvm = (NodeViewMove *)MEM_callocN(sizeof(NodeViewMove), "NodeViewMove struct"); nvm = MEM_cnew<NodeViewMove>("NodeViewMove struct");
op->customdata = nvm; op->customdata = nvm;
nvm->mvalo[0] = event->mval[0]; nvm->mvalo[0] = event->mval[0];
nvm->mvalo[1] = event->mval[1]; nvm->mvalo[1] = event->mval[1];
@ -643,7 +643,7 @@ static int sample_invoke(bContext *C, wmOperator *op, const wmEvent *event)
return OPERATOR_CANCELLED; return OPERATOR_CANCELLED;
} }
info = (ImageSampleInfo *)MEM_callocN(sizeof(ImageSampleInfo), "ImageSampleInfo"); info = MEM_cnew<ImageSampleInfo>("ImageSampleInfo");
info->art = region->type; info->art = region->type;
info->draw_handle = ED_region_draw_cb_activate( info->draw_handle = ED_region_draw_cb_activate(
region->type, sample_draw, info, REGION_DRAW_POST_PIXEL); region->type, sample_draw, info, REGION_DRAW_POST_PIXEL);

@ -63,7 +63,7 @@ void ED_node_tree_start(SpaceNode *snode, bNodeTree *ntree, ID *id, ID *from)
BLI_listbase_clear(&snode->treepath); BLI_listbase_clear(&snode->treepath);
if (ntree) { if (ntree) {
bNodeTreePath *path = (bNodeTreePath *)MEM_callocN(sizeof(bNodeTreePath), "node tree path"); bNodeTreePath *path = MEM_cnew<bNodeTreePath>("node tree path");
path->nodetree = ntree; path->nodetree = ntree;
path->parent_key = NODE_INSTANCE_KEY_BASE; path->parent_key = NODE_INSTANCE_KEY_BASE;
@ -96,7 +96,7 @@ void ED_node_tree_start(SpaceNode *snode, bNodeTree *ntree, ID *id, ID *from)
void ED_node_tree_push(SpaceNode *snode, bNodeTree *ntree, bNode *gnode) void ED_node_tree_push(SpaceNode *snode, bNodeTree *ntree, bNode *gnode)
{ {
bNodeTreePath *path = (bNodeTreePath *)MEM_callocN(sizeof(bNodeTreePath), "node tree path"); bNodeTreePath *path = MEM_cnew<bNodeTreePath>("node tree path");
bNodeTreePath *prev_path = (bNodeTreePath *)snode->treepath.last; bNodeTreePath *prev_path = (bNodeTreePath *)snode->treepath.last;
path->nodetree = ntree; path->nodetree = ntree;
if (gnode) { if (gnode) {
@ -220,7 +220,7 @@ float2 space_node_group_offset(const SpaceNode &snode)
static SpaceLink *node_create(const ScrArea *UNUSED(area), const Scene *UNUSED(scene)) static SpaceLink *node_create(const ScrArea *UNUSED(area), const Scene *UNUSED(scene))
{ {
SpaceNode *snode = (SpaceNode *)MEM_callocN(sizeof(SpaceNode), "initnode"); SpaceNode *snode = MEM_cnew<SpaceNode>("initnode");
snode->spacetype = SPACE_NODE; snode->spacetype = SPACE_NODE;
snode->flag = SNODE_SHOW_GPENCIL | SNODE_USE_ALPHA; snode->flag = SNODE_SHOW_GPENCIL | SNODE_USE_ALPHA;
@ -238,21 +238,21 @@ static SpaceLink *node_create(const ScrArea *UNUSED(area), const Scene *UNUSED(s
NODE_TREE_TYPES_END; NODE_TREE_TYPES_END;
/* header */ /* header */
ARegion *region = (ARegion *)MEM_callocN(sizeof(ARegion), "header for node"); ARegion *region = MEM_cnew<ARegion>("header for node");
BLI_addtail(&snode->regionbase, region); BLI_addtail(&snode->regionbase, region);
region->regiontype = RGN_TYPE_HEADER; region->regiontype = RGN_TYPE_HEADER;
region->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_BOTTOM : RGN_ALIGN_TOP; region->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_BOTTOM : RGN_ALIGN_TOP;
/* buttons/list view */ /* buttons/list view */
region = (ARegion *)MEM_callocN(sizeof(ARegion), "buttons for node"); region = MEM_cnew<ARegion>("buttons for node");
BLI_addtail(&snode->regionbase, region); BLI_addtail(&snode->regionbase, region);
region->regiontype = RGN_TYPE_UI; region->regiontype = RGN_TYPE_UI;
region->alignment = RGN_ALIGN_RIGHT; region->alignment = RGN_ALIGN_RIGHT;
/* toolbar */ /* toolbar */
region = (ARegion *)MEM_callocN(sizeof(ARegion), "node tools"); region = MEM_cnew<ARegion>("node tools");
BLI_addtail(&snode->regionbase, region); BLI_addtail(&snode->regionbase, region);
region->regiontype = RGN_TYPE_TOOLS; region->regiontype = RGN_TYPE_TOOLS;
@ -261,7 +261,7 @@ static SpaceLink *node_create(const ScrArea *UNUSED(area), const Scene *UNUSED(s
region->flag = RGN_FLAG_HIDDEN; region->flag = RGN_FLAG_HIDDEN;
/* main region */ /* main region */
region = (ARegion *)MEM_callocN(sizeof(ARegion), "main region for node"); region = MEM_cnew<ARegion>("main region for node");
BLI_addtail(&snode->regionbase, region); BLI_addtail(&snode->regionbase, region);
region->regiontype = RGN_TYPE_WINDOW; region->regiontype = RGN_TYPE_WINDOW;
@ -309,7 +309,7 @@ static void node_init(struct wmWindowManager *UNUSED(wm), ScrArea *area)
SpaceNode *snode = (SpaceNode *)area->spacedata.first; SpaceNode *snode = (SpaceNode *)area->spacedata.first;
if (snode->runtime == nullptr) { if (snode->runtime == nullptr) {
snode->runtime = (SpaceNode_Runtime *)MEM_callocN(sizeof(SpaceNode_Runtime), __func__); snode->runtime = MEM_new<SpaceNode_Runtime>(__func__);
} }
} }
@ -983,7 +983,7 @@ static void node_space_subtype_item_extend(bContext *C, EnumPropertyItem **item,
void ED_spacetype_node() void ED_spacetype_node()
{ {
SpaceType *st = (SpaceType *)MEM_callocN(sizeof(SpaceType), "spacetype node"); SpaceType *st = MEM_cnew<SpaceType>("spacetype node");
ARegionType *art; ARegionType *art;
st->spaceid = SPACE_NODE; st->spaceid = SPACE_NODE;
@ -1006,7 +1006,7 @@ void ED_spacetype_node()
st->space_subtype_set = node_space_subtype_set; st->space_subtype_set = node_space_subtype_set;
/* regions: main window */ /* regions: main window */
art = (ARegionType *)MEM_callocN(sizeof(ARegionType), "spacetype node region"); art = MEM_cnew<ARegionType>("spacetype node region");
art->regionid = RGN_TYPE_WINDOW; art->regionid = RGN_TYPE_WINDOW;
art->init = node_main_region_init; art->init = node_main_region_init;
art->draw = node_main_region_draw; art->draw = node_main_region_draw;
@ -1020,7 +1020,7 @@ void ED_spacetype_node()
BLI_addhead(&st->regiontypes, art); BLI_addhead(&st->regiontypes, art);
/* regions: header */ /* regions: header */
art = (ARegionType *)MEM_callocN(sizeof(ARegionType), "spacetype node region"); art = MEM_cnew<ARegionType>("spacetype node region");
art->regionid = RGN_TYPE_HEADER; art->regionid = RGN_TYPE_HEADER;
art->prefsizey = HEADERY; art->prefsizey = HEADERY;
art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_HEADER; art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_HEADER;
@ -1031,7 +1031,7 @@ void ED_spacetype_node()
BLI_addhead(&st->regiontypes, art); BLI_addhead(&st->regiontypes, art);
/* regions: listview/buttons */ /* regions: listview/buttons */
art = (ARegionType *)MEM_callocN(sizeof(ARegionType), "spacetype node region"); art = MEM_cnew<ARegionType>("spacetype node region");
art->regionid = RGN_TYPE_UI; art->regionid = RGN_TYPE_UI;
art->prefsizex = UI_SIDEBAR_PANEL_WIDTH; art->prefsizex = UI_SIDEBAR_PANEL_WIDTH;
art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_FRAMES; art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_FRAMES;
@ -1042,7 +1042,7 @@ void ED_spacetype_node()
BLI_addhead(&st->regiontypes, art); BLI_addhead(&st->regiontypes, art);
/* regions: toolbar */ /* regions: toolbar */
art = (ARegionType *)MEM_callocN(sizeof(ARegionType), "spacetype view3d tools region"); art = MEM_cnew<ARegionType>("spacetype view3d tools region");
art->regionid = RGN_TYPE_TOOLS; art->regionid = RGN_TYPE_TOOLS;
art->prefsizex = 58; /* XXX */ art->prefsizex = 58; /* XXX */
art->prefsizey = 50; /* XXX */ art->prefsizey = 50; /* XXX */

@ -60,15 +60,14 @@ using namespace blender::ed::spreadsheet;
static SpaceLink *spreadsheet_create(const ScrArea *UNUSED(area), const Scene *UNUSED(scene)) static SpaceLink *spreadsheet_create(const ScrArea *UNUSED(area), const Scene *UNUSED(scene))
{ {
SpaceSpreadsheet *spreadsheet_space = (SpaceSpreadsheet *)MEM_callocN(sizeof(SpaceSpreadsheet), SpaceSpreadsheet *spreadsheet_space = MEM_cnew<SpaceSpreadsheet>("spreadsheet space");
"spreadsheet space");
spreadsheet_space->spacetype = SPACE_SPREADSHEET; spreadsheet_space->spacetype = SPACE_SPREADSHEET;
spreadsheet_space->filter_flag = SPREADSHEET_FILTER_ENABLE; spreadsheet_space->filter_flag = SPREADSHEET_FILTER_ENABLE;
{ {
/* Header. */ /* Header. */
ARegion *region = (ARegion *)MEM_callocN(sizeof(ARegion), "spreadsheet header"); ARegion *region = MEM_cnew<ARegion>("spreadsheet header");
BLI_addtail(&spreadsheet_space->regionbase, region); BLI_addtail(&spreadsheet_space->regionbase, region);
region->regiontype = RGN_TYPE_HEADER; region->regiontype = RGN_TYPE_HEADER;
region->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_BOTTOM : RGN_ALIGN_TOP; region->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_BOTTOM : RGN_ALIGN_TOP;
@ -76,7 +75,7 @@ static SpaceLink *spreadsheet_create(const ScrArea *UNUSED(area), const Scene *U
{ {
/* Footer. */ /* Footer. */
ARegion *region = (ARegion *)MEM_callocN(sizeof(ARegion), "spreadsheet footer region"); ARegion *region = MEM_cnew<ARegion>("spreadsheet footer region");
BLI_addtail(&spreadsheet_space->regionbase, region); BLI_addtail(&spreadsheet_space->regionbase, region);
region->regiontype = RGN_TYPE_FOOTER; region->regiontype = RGN_TYPE_FOOTER;
region->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_TOP : RGN_ALIGN_BOTTOM; region->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_TOP : RGN_ALIGN_BOTTOM;
@ -84,7 +83,7 @@ static SpaceLink *spreadsheet_create(const ScrArea *UNUSED(area), const Scene *U
{ {
/* Dataset Region */ /* Dataset Region */
ARegion *region = (ARegion *)MEM_callocN(sizeof(ARegion), "spreadsheet dataset region"); ARegion *region = MEM_cnew<ARegion>("spreadsheet dataset region");
BLI_addtail(&spreadsheet_space->regionbase, region); BLI_addtail(&spreadsheet_space->regionbase, region);
region->regiontype = RGN_TYPE_CHANNELS; region->regiontype = RGN_TYPE_CHANNELS;
region->alignment = RGN_ALIGN_LEFT; region->alignment = RGN_ALIGN_LEFT;
@ -93,7 +92,7 @@ static SpaceLink *spreadsheet_create(const ScrArea *UNUSED(area), const Scene *U
{ {
/* Properties region. */ /* Properties region. */
ARegion *region = (ARegion *)MEM_callocN(sizeof(ARegion), "spreadsheet right region"); ARegion *region = MEM_cnew<ARegion>("spreadsheet right region");
BLI_addtail(&spreadsheet_space->regionbase, region); BLI_addtail(&spreadsheet_space->regionbase, region);
region->regiontype = RGN_TYPE_UI; region->regiontype = RGN_TYPE_UI;
region->alignment = RGN_ALIGN_RIGHT; region->alignment = RGN_ALIGN_RIGHT;
@ -102,7 +101,7 @@ static SpaceLink *spreadsheet_create(const ScrArea *UNUSED(area), const Scene *U
{ {
/* Main window. */ /* Main window. */
ARegion *region = (ARegion *)MEM_callocN(sizeof(ARegion), "spreadsheet main region"); ARegion *region = MEM_cnew<ARegion>("spreadsheet main region");
BLI_addtail(&spreadsheet_space->regionbase, region); BLI_addtail(&spreadsheet_space->regionbase, region);
region->regiontype = RGN_TYPE_WINDOW; region->regiontype = RGN_TYPE_WINDOW;
} }
@ -622,7 +621,7 @@ static void spreadsheet_right_region_listener(const wmRegionListenerParams *UNUS
void ED_spacetype_spreadsheet() void ED_spacetype_spreadsheet()
{ {
SpaceType *st = (SpaceType *)MEM_callocN(sizeof(SpaceType), "spacetype spreadsheet"); SpaceType *st = MEM_cnew<SpaceType>("spacetype spreadsheet");
ARegionType *art; ARegionType *art;
st->spaceid = SPACE_SPREADSHEET; st->spaceid = SPACE_SPREADSHEET;
@ -637,7 +636,7 @@ void ED_spacetype_spreadsheet()
st->id_remap = spreadsheet_id_remap; st->id_remap = spreadsheet_id_remap;
/* regions: main window */ /* regions: main window */
art = (ARegionType *)MEM_callocN(sizeof(ARegionType), "spacetype spreadsheet region"); art = MEM_cnew<ARegionType>("spacetype spreadsheet region");
art->regionid = RGN_TYPE_WINDOW; art->regionid = RGN_TYPE_WINDOW;
art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D; art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D;
@ -647,7 +646,7 @@ void ED_spacetype_spreadsheet()
BLI_addhead(&st->regiontypes, art); BLI_addhead(&st->regiontypes, art);
/* regions: header */ /* regions: header */
art = (ARegionType *)MEM_callocN(sizeof(ARegionType), "spacetype spreadsheet header region"); art = MEM_cnew<ARegionType>("spacetype spreadsheet header region");
art->regionid = RGN_TYPE_HEADER; art->regionid = RGN_TYPE_HEADER;
art->prefsizey = HEADERY; art->prefsizey = HEADERY;
art->keymapflag = 0; art->keymapflag = 0;
@ -660,7 +659,7 @@ void ED_spacetype_spreadsheet()
BLI_addhead(&st->regiontypes, art); BLI_addhead(&st->regiontypes, art);
/* regions: footer */ /* regions: footer */
art = (ARegionType *)MEM_callocN(sizeof(ARegionType), "spacetype spreadsheet footer region"); art = MEM_cnew<ARegionType>("spacetype spreadsheet footer region");
art->regionid = RGN_TYPE_FOOTER; art->regionid = RGN_TYPE_FOOTER;
art->prefsizey = HEADERY; art->prefsizey = HEADERY;
art->keymapflag = 0; art->keymapflag = 0;
@ -673,7 +672,7 @@ void ED_spacetype_spreadsheet()
BLI_addhead(&st->regiontypes, art); BLI_addhead(&st->regiontypes, art);
/* regions: right panel buttons */ /* regions: right panel buttons */
art = (ARegionType *)MEM_callocN(sizeof(ARegionType), "spacetype spreadsheet right region"); art = MEM_cnew<ARegionType>("spacetype spreadsheet right region");
art->regionid = RGN_TYPE_UI; art->regionid = RGN_TYPE_UI;
art->prefsizex = UI_SIDEBAR_PANEL_WIDTH; art->prefsizex = UI_SIDEBAR_PANEL_WIDTH;
art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_FRAMES; art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_FRAMES;
@ -688,7 +687,7 @@ void ED_spacetype_spreadsheet()
register_row_filter_panels(*art); register_row_filter_panels(*art);
/* regions: channels */ /* regions: channels */
art = (ARegionType *)MEM_callocN(sizeof(ARegionType), "spreadsheet dataset region"); art = MEM_cnew<ARegionType>("spreadsheet dataset region");
art->regionid = RGN_TYPE_CHANNELS; art->regionid = RGN_TYPE_CHANNELS;
art->prefsizex = 150 + V2D_SCROLL_WIDTH; art->prefsizex = 150 + V2D_SCROLL_WIDTH;
art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D; art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D;

@ -66,8 +66,7 @@ eSpreadsheetColumnValueType cpp_type_to_column_type(const fn::CPPType &type)
SpreadsheetColumnID *spreadsheet_column_id_new() SpreadsheetColumnID *spreadsheet_column_id_new()
{ {
SpreadsheetColumnID *column_id = (SpreadsheetColumnID *)MEM_callocN(sizeof(SpreadsheetColumnID), SpreadsheetColumnID *column_id = MEM_cnew<SpreadsheetColumnID>(__func__);
__func__);
return column_id; return column_id;
} }
@ -88,8 +87,7 @@ void spreadsheet_column_id_free(SpreadsheetColumnID *column_id)
SpreadsheetColumn *spreadsheet_column_new(SpreadsheetColumnID *column_id) SpreadsheetColumn *spreadsheet_column_new(SpreadsheetColumnID *column_id)
{ {
SpreadsheetColumn *column = (SpreadsheetColumn *)MEM_callocN(sizeof(SpreadsheetColumn), SpreadsheetColumn *column = MEM_cnew<SpreadsheetColumn>(__func__);
__func__);
column->id = column_id; column->id = column_id;
return column; return column;
} }

@ -50,8 +50,7 @@ namespace blender::ed::spreadsheet {
static SpreadsheetContextObject *spreadsheet_context_object_new() static SpreadsheetContextObject *spreadsheet_context_object_new()
{ {
SpreadsheetContextObject *context = (SpreadsheetContextObject *)MEM_callocN( SpreadsheetContextObject *context = MEM_cnew<SpreadsheetContextObject>(__func__);
sizeof(SpreadsheetContextObject), __func__);
context->base.type = SPREADSHEET_CONTEXT_OBJECT; context->base.type = SPREADSHEET_CONTEXT_OBJECT;
return context; return context;
} }
@ -77,8 +76,7 @@ static void spreadsheet_context_object_free(SpreadsheetContextObject *context)
static SpreadsheetContextModifier *spreadsheet_context_modifier_new() static SpreadsheetContextModifier *spreadsheet_context_modifier_new()
{ {
SpreadsheetContextModifier *context = (SpreadsheetContextModifier *)MEM_callocN( SpreadsheetContextModifier *context = MEM_cnew<SpreadsheetContextModifier>(__func__);
sizeof(SpreadsheetContextModifier), __func__);
context->base.type = SPREADSHEET_CONTEXT_MODIFIER; context->base.type = SPREADSHEET_CONTEXT_MODIFIER;
return context; return context;
} }
@ -111,8 +109,7 @@ static void spreadsheet_context_modifier_free(SpreadsheetContextModifier *contex
static SpreadsheetContextNode *spreadsheet_context_node_new() static SpreadsheetContextNode *spreadsheet_context_node_new()
{ {
SpreadsheetContextNode *context = (SpreadsheetContextNode *)MEM_callocN( SpreadsheetContextNode *context = MEM_cnew<SpreadsheetContextNode>(__func__);
sizeof(SpreadsheetContextNode), __func__);
context->base.type = SPREADSHEET_CONTEXT_NODE; context->base.type = SPREADSHEET_CONTEXT_NODE;
return context; return context;
} }

@ -25,7 +25,7 @@ namespace blender::ed::spreadsheet {
void spreadsheet_data_set_region_panels_register(ARegionType &region_type) void spreadsheet_data_set_region_panels_register(ARegionType &region_type)
{ {
PanelType *panel_type = (PanelType *)MEM_callocN(sizeof(PanelType), __func__); PanelType *panel_type = MEM_cnew<PanelType>(__func__);
strcpy(panel_type->idname, "SPREADSHEET_PT_data_set"); strcpy(panel_type->idname, "SPREADSHEET_PT_data_set");
strcpy(panel_type->label, N_("Data Set")); strcpy(panel_type->label, N_("Data Set"));
strcpy(panel_type->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA); strcpy(panel_type->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA);

@ -311,8 +311,7 @@ IndexMask spreadsheet_filter_rows(const SpaceSpreadsheet &sspreadsheet,
SpreadsheetRowFilter *spreadsheet_row_filter_new() SpreadsheetRowFilter *spreadsheet_row_filter_new()
{ {
SpreadsheetRowFilter *row_filter = (SpreadsheetRowFilter *)MEM_callocN( SpreadsheetRowFilter *row_filter = MEM_cnew<SpreadsheetRowFilter>(__func__);
sizeof(SpreadsheetRowFilter), __func__);
row_filter->flag = (SPREADSHEET_ROW_FILTER_UI_EXPAND | SPREADSHEET_ROW_FILTER_ENABLED); row_filter->flag = (SPREADSHEET_ROW_FILTER_UI_EXPAND | SPREADSHEET_ROW_FILTER_ENABLED);
row_filter->operation = SPREADSHEET_ROW_FILTER_LESS; row_filter->operation = SPREADSHEET_ROW_FILTER_LESS;
row_filter->threshold = 0.01f; row_filter->threshold = 0.01f;

@ -331,7 +331,7 @@ static void set_filter_expand_flag(const bContext *UNUSED(C), Panel *panel, shor
void register_row_filter_panels(ARegionType &region_type) void register_row_filter_panels(ARegionType &region_type)
{ {
{ {
PanelType *panel_type = (PanelType *)MEM_callocN(sizeof(PanelType), __func__); PanelType *panel_type = MEM_cnew<PanelType>(__func__);
strcpy(panel_type->idname, "SPREADSHEET_PT_row_filters"); strcpy(panel_type->idname, "SPREADSHEET_PT_row_filters");
strcpy(panel_type->label, N_("Filters")); strcpy(panel_type->label, N_("Filters"));
strcpy(panel_type->category, "Filters"); strcpy(panel_type->category, "Filters");
@ -342,7 +342,7 @@ void register_row_filter_panels(ARegionType &region_type)
} }
{ {
PanelType *panel_type = (PanelType *)MEM_callocN(sizeof(PanelType), __func__); PanelType *panel_type = MEM_cnew<PanelType>(__func__);
strcpy(panel_type->idname, "SPREADSHEET_PT_filter"); strcpy(panel_type->idname, "SPREADSHEET_PT_filter");
strcpy(panel_type->label, ""); strcpy(panel_type->label, "");
strcpy(panel_type->category, "Filters"); strcpy(panel_type->category, "Filters");

@ -563,7 +563,7 @@ static GPUFrameBuffer *gpu_offscreen_fb_get(GPUOffScreen *ofs)
GPUOffScreen *GPU_offscreen_create( GPUOffScreen *GPU_offscreen_create(
int width, int height, bool depth, eGPUTextureFormat format, char err_out[256]) int width, int height, bool depth, eGPUTextureFormat format, char err_out[256])
{ {
GPUOffScreen *ofs = (GPUOffScreen *)MEM_callocN(sizeof(GPUOffScreen), __func__); GPUOffScreen *ofs = MEM_cnew<GPUOffScreen>(__func__);
/* Sometimes areas can have 0 height or width and this will /* Sometimes areas can have 0 height or width and this will
* create a 1D texture which we don't want. */ * create a 1D texture which we don't want. */

@ -284,7 +284,7 @@ static int initialize_chain(Object *ob, bPoseChannel *pchan_tip, bConstraint *co
/* setup the chain data */ /* setup the chain data */
/* create a target */ /* create a target */
target = (PoseTarget *)MEM_callocN(sizeof(PoseTarget), "posetarget"); target = MEM_cnew<PoseTarget>("posetarget");
target->con = con; target->con = con;
/* by construction there can be only one tree per channel /* by construction there can be only one tree per channel
* and each channel can be part of at most one tree. */ * and each channel can be part of at most one tree. */
@ -292,7 +292,7 @@ static int initialize_chain(Object *ob, bPoseChannel *pchan_tip, bConstraint *co
if (tree == nullptr) { if (tree == nullptr) {
/* make new tree */ /* make new tree */
tree = (PoseTree *)MEM_callocN(sizeof(PoseTree), "posetree"); tree = MEM_cnew<PoseTree>("posetree");
tree->iterations = data->iterations; tree->iterations = data->iterations;
tree->totchannel = segcount; tree->totchannel = segcount;

@ -683,7 +683,7 @@ static bool imb_exr_multilayer_parse_channels_from_file(ExrHandle *data);
void *IMB_exr_get_handle(void) void *IMB_exr_get_handle(void)
{ {
ExrHandle *data = (ExrHandle *)MEM_callocN(sizeof(ExrHandle), "exr handle"); ExrHandle *data = MEM_cnew<ExrHandle>("exr handle");
data->multiView = new StringVector(); data->multiView = new StringVector();
BLI_addtail(&exrhandles, data); BLI_addtail(&exrhandles, data);
@ -789,7 +789,7 @@ void IMB_exr_add_channel(void *handle,
ExrHandle *data = (ExrHandle *)handle; ExrHandle *data = (ExrHandle *)handle;
ExrChannel *echan; ExrChannel *echan;
echan = (ExrChannel *)MEM_callocN(sizeof(ExrChannel), "exr channel"); echan = MEM_cnew<ExrChannel>("exr channel");
echan->m = new MultiViewChannelName(); echan->m = new MultiViewChannelName();
if (layname && layname[0] != '\0') { if (layname && layname[0] != '\0') {
@ -1496,7 +1496,7 @@ static ExrLayer *imb_exr_get_layer(ListBase *lb, char *layname)
ExrLayer *lay = (ExrLayer *)BLI_findstring(lb, layname, offsetof(ExrLayer, name)); ExrLayer *lay = (ExrLayer *)BLI_findstring(lb, layname, offsetof(ExrLayer, name));
if (lay == nullptr) { if (lay == nullptr) {
lay = (ExrLayer *)MEM_callocN(sizeof(ExrLayer), "exr layer"); lay = MEM_cnew<ExrLayer>("exr layer");
BLI_addtail(lb, lay); BLI_addtail(lb, lay);
BLI_strncpy(lay->name, layname, EXR_LAY_MAXNAME); BLI_strncpy(lay->name, layname, EXR_LAY_MAXNAME);
} }
@ -1509,7 +1509,7 @@ static ExrPass *imb_exr_get_pass(ListBase *lb, char *passname)
ExrPass *pass = (ExrPass *)BLI_findstring(lb, passname, offsetof(ExrPass, name)); ExrPass *pass = (ExrPass *)BLI_findstring(lb, passname, offsetof(ExrPass, name));
if (pass == nullptr) { if (pass == nullptr) {
pass = (ExrPass *)MEM_callocN(sizeof(ExrPass), "exr pass"); pass = MEM_cnew<ExrPass>("exr pass");
if (STREQ(passname, "Combined")) { if (STREQ(passname, "Combined")) {
BLI_addhead(lb, pass); BLI_addhead(lb, pass);

@ -237,7 +237,7 @@ void AnimationImporter::add_fcurves_to_object(Main *bmain,
/* no matching groups, so add one */ /* no matching groups, so add one */
if (grp == nullptr) { if (grp == nullptr) {
/* Add a new group, and make it active */ /* Add a new group, and make it active */
grp = (bActionGroup *)MEM_callocN(sizeof(bActionGroup), "bActionGroup"); grp = MEM_cnew<bActionGroup>("bActionGroup");
grp->flag = AGRP_SELECTED; grp->flag = AGRP_SELECTED;
BLI_strncpy(grp->name, bone_name, sizeof(grp->name)); BLI_strncpy(grp->name, bone_name, sizeof(grp->name));
@ -2177,7 +2177,7 @@ void AnimationImporter::add_bone_fcurve(Object *ob, COLLADAFW::Node *node, FCurv
/* no matching groups, so add one */ /* no matching groups, so add one */
if (grp == nullptr) { if (grp == nullptr) {
/* Add a new group, and make it active */ /* Add a new group, and make it active */
grp = (bActionGroup *)MEM_callocN(sizeof(bActionGroup), "bActionGroup"); grp = MEM_cnew<bActionGroup>("bActionGroup");
grp->flag = AGRP_SELECTED; grp->flag = AGRP_SELECTED;
BLI_strncpy(grp->name, bone_name, sizeof(grp->name)); BLI_strncpy(grp->name, bone_name, sizeof(grp->name));

@ -238,7 +238,7 @@ void GpencilExporterPDF::export_stroke_to_polyline(bGPDlayer *gpl,
/* Get the thickness in pixels using a simple 1 point stroke. */ /* Get the thickness in pixels using a simple 1 point stroke. */
bGPDstroke *gps_temp = BKE_gpencil_stroke_duplicate(gps, false, false); bGPDstroke *gps_temp = BKE_gpencil_stroke_duplicate(gps, false, false);
gps_temp->totpoints = 1; gps_temp->totpoints = 1;
gps_temp->points = (bGPDspoint *)MEM_callocN(sizeof(bGPDspoint), "gp_stroke_points"); gps_temp->points = MEM_cnew<bGPDspoint>("gp_stroke_points");
const bGPDspoint *pt_src = &gps->points[0]; const bGPDspoint *pt_src = &gps->points[0];
bGPDspoint *pt_dst = &gps_temp->points[0]; bGPDspoint *pt_dst = &gps_temp->points[0];
copy_v3_v3(&pt_dst->x, &pt_src->x); copy_v3_v3(&pt_dst->x, &pt_src->x);

@ -308,7 +308,7 @@ void GpencilExporterSVG::export_stroke_to_polyline(bGPDlayer *gpl,
/* Get the thickness in pixels using a simple 1 point stroke. */ /* Get the thickness in pixels using a simple 1 point stroke. */
bGPDstroke *gps_temp = BKE_gpencil_stroke_duplicate(gps, false, false); bGPDstroke *gps_temp = BKE_gpencil_stroke_duplicate(gps, false, false);
gps_temp->totpoints = 1; gps_temp->totpoints = 1;
gps_temp->points = (bGPDspoint *)MEM_callocN(sizeof(bGPDspoint), "gp_stroke_points"); gps_temp->points = MEM_cnew<bGPDspoint>("gp_stroke_points");
bGPDspoint *pt_src = &gps->points[0]; bGPDspoint *pt_src = &gps->points[0];
bGPDspoint *pt_dst = &gps_temp->points[0]; bGPDspoint *pt_dst = &gps_temp->points[0];
copy_v3_v3(&pt_dst->x, &pt_src->x); copy_v3_v3(&pt_dst->x, &pt_src->x);

@ -224,7 +224,7 @@ void node_group_update(struct bNodeTree *ntree, struct bNode *node)
static void node_frame_init(bNodeTree *UNUSED(ntree), bNode *node) static void node_frame_init(bNodeTree *UNUSED(ntree), bNode *node)
{ {
NodeFrame *data = (NodeFrame *)MEM_callocN(sizeof(NodeFrame), "frame node storage"); NodeFrame *data = MEM_cnew<NodeFrame>("frame node storage");
node->storage = data; node->storage = data;
data->flag |= NODE_FRAME_SHRINK; data->flag |= NODE_FRAME_SHRINK;
@ -235,7 +235,7 @@ static void node_frame_init(bNodeTree *UNUSED(ntree), bNode *node)
void register_node_type_frame(void) void register_node_type_frame(void)
{ {
/* frame type is used for all tree types, needs dynamic allocation */ /* frame type is used for all tree types, needs dynamic allocation */
bNodeType *ntype = (bNodeType *)MEM_callocN(sizeof(bNodeType), "frame node type"); bNodeType *ntype = MEM_cnew<bNodeType>("frame node type");
ntype->free_self = (void (*)(bNodeType *))MEM_freeN; ntype->free_self = (void (*)(bNodeType *))MEM_freeN;
node_type_base(ntype, NODE_FRAME, "Frame", NODE_CLASS_LAYOUT, NODE_BACKGROUND); node_type_base(ntype, NODE_FRAME, "Frame", NODE_CLASS_LAYOUT, NODE_BACKGROUND);
@ -264,7 +264,7 @@ static void node_reroute_init(bNodeTree *ntree, bNode *node)
void register_node_type_reroute(void) void register_node_type_reroute(void)
{ {
/* frame type is used for all tree types, needs dynamic allocation */ /* frame type is used for all tree types, needs dynamic allocation */
bNodeType *ntype = (bNodeType *)MEM_callocN(sizeof(bNodeType), "frame node type"); bNodeType *ntype = MEM_cnew<bNodeType>("frame node type");
ntype->free_self = (void (*)(bNodeType *))MEM_freeN; ntype->free_self = (void (*)(bNodeType *))MEM_freeN;
node_type_base(ntype, NODE_REROUTE, "Reroute", NODE_CLASS_LAYOUT, 0); node_type_base(ntype, NODE_REROUTE, "Reroute", NODE_CLASS_LAYOUT, 0);
@ -454,7 +454,7 @@ void node_group_input_update(bNodeTree *ntree, bNode *node)
} }
if (link->fromsock == extsock) { if (link->fromsock == extsock) {
bNodeLink *tlink = (bNodeLink *)MEM_callocN(sizeof(bNodeLink), "temporary link"); bNodeLink *tlink = MEM_cnew<bNodeLink>("temporary link");
*tlink = *link; *tlink = *link;
BLI_addtail(&tmplinks, tlink); BLI_addtail(&tmplinks, tlink);
@ -505,7 +505,7 @@ void node_group_input_update(bNodeTree *ntree, bNode *node)
void register_node_type_group_input(void) void register_node_type_group_input(void)
{ {
/* used for all tree types, needs dynamic allocation */ /* used for all tree types, needs dynamic allocation */
bNodeType *ntype = (bNodeType *)MEM_callocN(sizeof(bNodeType), "node type"); bNodeType *ntype = MEM_cnew<bNodeType>("node type");
ntype->free_self = (void (*)(bNodeType *))MEM_freeN; ntype->free_self = (void (*)(bNodeType *))MEM_freeN;
node_type_base(ntype, NODE_GROUP_INPUT, "Group Input", NODE_CLASS_INTERFACE, 0); node_type_base(ntype, NODE_GROUP_INPUT, "Group Input", NODE_CLASS_INTERFACE, 0);
@ -551,7 +551,7 @@ void node_group_output_update(bNodeTree *ntree, bNode *node)
} }
if (link->tosock == extsock) { if (link->tosock == extsock) {
bNodeLink *tlink = (bNodeLink *)MEM_callocN(sizeof(bNodeLink), "temporary link"); bNodeLink *tlink = MEM_cnew<bNodeLink>("temporary link");
*tlink = *link; *tlink = *link;
BLI_addtail(&tmplinks, tlink); BLI_addtail(&tmplinks, tlink);
@ -603,7 +603,7 @@ void node_group_output_update(bNodeTree *ntree, bNode *node)
void register_node_type_group_output(void) void register_node_type_group_output(void)
{ {
/* used for all tree types, needs dynamic allocation */ /* used for all tree types, needs dynamic allocation */
bNodeType *ntype = (bNodeType *)MEM_callocN(sizeof(bNodeType), "node type"); bNodeType *ntype = MEM_cnew<bNodeType>("node type");
ntype->free_self = (void (*)(bNodeType *))MEM_freeN; ntype->free_self = (void (*)(bNodeType *))MEM_freeN;
node_type_base(ntype, NODE_GROUP_OUTPUT, "Group Output", NODE_CLASS_INTERFACE, 0); node_type_base(ntype, NODE_GROUP_OUTPUT, "Group Output", NODE_CLASS_INTERFACE, 0);

@ -177,7 +177,7 @@ bNodeTreeExec *ntree_exec_begin(bNodeExecContext *context,
ntreeGetDependencyList(ntree, &nodelist, &totnodes); ntreeGetDependencyList(ntree, &nodelist, &totnodes);
/* XXX could let callbacks do this for specialized data */ /* XXX could let callbacks do this for specialized data */
exec = (bNodeTreeExec *)MEM_callocN(sizeof(bNodeTreeExec), "node tree execution data"); exec = MEM_cnew<bNodeTreeExec>("node tree execution data");
/* backpointer to node tree */ /* backpointer to node tree */
exec->nodetree = ntree; exec->nodetree = ntree;
@ -292,7 +292,7 @@ bNodeThreadStack *ntreeGetThreadStack(bNodeTreeExec *exec, int thread)
} }
if (!nts) { if (!nts) {
nts = (bNodeThreadStack *)MEM_callocN(sizeof(bNodeThreadStack), "bNodeThreadStack"); nts = MEM_cnew<bNodeThreadStack>("bNodeThreadStack");
nts->stack = (bNodeStack *)MEM_dupallocN(exec->stack); nts->stack = (bNodeStack *)MEM_dupallocN(exec->stack);
nts->used = true; nts->used = true;
BLI_addtail(lb, nts); BLI_addtail(lb, nts);

@ -309,8 +309,7 @@ void node_socket_init_default_value(bNodeSocket *sock)
switch (type) { switch (type) {
case SOCK_FLOAT: { case SOCK_FLOAT: {
bNodeSocketValueFloat *dval = (bNodeSocketValueFloat *)MEM_callocN( bNodeSocketValueFloat *dval = MEM_cnew<bNodeSocketValueFloat>("node socket value float");
sizeof(bNodeSocketValueFloat), "node socket value float");
dval->subtype = subtype; dval->subtype = subtype;
dval->value = 0.0f; dval->value = 0.0f;
dval->min = -FLT_MAX; dval->min = -FLT_MAX;
@ -320,8 +319,7 @@ void node_socket_init_default_value(bNodeSocket *sock)
break; break;
} }
case SOCK_INT: { case SOCK_INT: {
bNodeSocketValueInt *dval = (bNodeSocketValueInt *)MEM_callocN(sizeof(bNodeSocketValueInt), bNodeSocketValueInt *dval = MEM_cnew<bNodeSocketValueInt>("node socket value int");
"node socket value int");
dval->subtype = subtype; dval->subtype = subtype;
dval->value = 0; dval->value = 0;
dval->min = INT_MIN; dval->min = INT_MIN;
@ -331,8 +329,7 @@ void node_socket_init_default_value(bNodeSocket *sock)
break; break;
} }
case SOCK_BOOLEAN: { case SOCK_BOOLEAN: {
bNodeSocketValueBoolean *dval = (bNodeSocketValueBoolean *)MEM_callocN( bNodeSocketValueBoolean *dval = MEM_cnew<bNodeSocketValueBoolean>("node socket value bool");
sizeof(bNodeSocketValueBoolean), "node socket value bool");
dval->value = false; dval->value = false;
sock->default_value = dval; sock->default_value = dval;
@ -340,8 +337,7 @@ void node_socket_init_default_value(bNodeSocket *sock)
} }
case SOCK_VECTOR: { case SOCK_VECTOR: {
static float default_value[] = {0.0f, 0.0f, 0.0f}; static float default_value[] = {0.0f, 0.0f, 0.0f};
bNodeSocketValueVector *dval = (bNodeSocketValueVector *)MEM_callocN( bNodeSocketValueVector *dval = MEM_cnew<bNodeSocketValueVector>("node socket value vector");
sizeof(bNodeSocketValueVector), "node socket value vector");
dval->subtype = subtype; dval->subtype = subtype;
copy_v3_v3(dval->value, default_value); copy_v3_v3(dval->value, default_value);
dval->min = -FLT_MAX; dval->min = -FLT_MAX;
@ -352,16 +348,14 @@ void node_socket_init_default_value(bNodeSocket *sock)
} }
case SOCK_RGBA: { case SOCK_RGBA: {
static float default_value[] = {0.0f, 0.0f, 0.0f, 1.0f}; static float default_value[] = {0.0f, 0.0f, 0.0f, 1.0f};
bNodeSocketValueRGBA *dval = (bNodeSocketValueRGBA *)MEM_callocN( bNodeSocketValueRGBA *dval = MEM_cnew<bNodeSocketValueRGBA>("node socket value color");
sizeof(bNodeSocketValueRGBA), "node socket value color");
copy_v4_v4(dval->value, default_value); copy_v4_v4(dval->value, default_value);
sock->default_value = dval; sock->default_value = dval;
break; break;
} }
case SOCK_STRING: { case SOCK_STRING: {
bNodeSocketValueString *dval = (bNodeSocketValueString *)MEM_callocN( bNodeSocketValueString *dval = MEM_cnew<bNodeSocketValueString>("node socket value string");
sizeof(bNodeSocketValueString), "node socket value string");
dval->subtype = subtype; dval->subtype = subtype;
dval->value[0] = '\0'; dval->value[0] = '\0';
@ -369,40 +363,38 @@ void node_socket_init_default_value(bNodeSocket *sock)
break; break;
} }
case SOCK_OBJECT: { case SOCK_OBJECT: {
bNodeSocketValueObject *dval = (bNodeSocketValueObject *)MEM_callocN( bNodeSocketValueObject *dval = MEM_cnew<bNodeSocketValueObject>("node socket value object");
sizeof(bNodeSocketValueObject), "node socket value object");
dval->value = nullptr; dval->value = nullptr;
sock->default_value = dval; sock->default_value = dval;
break; break;
} }
case SOCK_IMAGE: { case SOCK_IMAGE: {
bNodeSocketValueImage *dval = (bNodeSocketValueImage *)MEM_callocN( bNodeSocketValueImage *dval = MEM_cnew<bNodeSocketValueImage>("node socket value image");
sizeof(bNodeSocketValueImage), "node socket value image");
dval->value = nullptr; dval->value = nullptr;
sock->default_value = dval; sock->default_value = dval;
break; break;
} }
case SOCK_COLLECTION: { case SOCK_COLLECTION: {
bNodeSocketValueCollection *dval = (bNodeSocketValueCollection *)MEM_callocN( bNodeSocketValueCollection *dval = MEM_cnew<bNodeSocketValueCollection>(
sizeof(bNodeSocketValueCollection), "node socket value object"); "node socket value object");
dval->value = nullptr; dval->value = nullptr;
sock->default_value = dval; sock->default_value = dval;
break; break;
} }
case SOCK_TEXTURE: { case SOCK_TEXTURE: {
bNodeSocketValueTexture *dval = (bNodeSocketValueTexture *)MEM_callocN( bNodeSocketValueTexture *dval = MEM_cnew<bNodeSocketValueTexture>(
sizeof(bNodeSocketValueTexture), "node socket value texture"); "node socket value texture");
dval->value = nullptr; dval->value = nullptr;
sock->default_value = dval; sock->default_value = dval;
break; break;
} }
case SOCK_MATERIAL: { case SOCK_MATERIAL: {
bNodeSocketValueMaterial *dval = (bNodeSocketValueMaterial *)MEM_callocN( bNodeSocketValueMaterial *dval = MEM_cnew<bNodeSocketValueMaterial>(
sizeof(bNodeSocketValueMaterial), "node socket value material"); "node socket value material");
dval->value = nullptr; dval->value = nullptr;
sock->default_value = dval; sock->default_value = dval;
@ -637,7 +629,7 @@ static bNodeSocketType *make_standard_socket_type(int type, int subtype)
bNodeSocketType *stype; bNodeSocketType *stype;
StructRNA *srna; StructRNA *srna;
stype = (bNodeSocketType *)MEM_callocN(sizeof(bNodeSocketType), "node socket C type"); stype = MEM_cnew<bNodeSocketType>("node socket C type");
stype->free_self = (void (*)(bNodeSocketType * stype)) MEM_freeN; stype->free_self = (void (*)(bNodeSocketType * stype)) MEM_freeN;
BLI_strncpy(stype->idname, socket_idname, sizeof(stype->idname)); BLI_strncpy(stype->idname, socket_idname, sizeof(stype->idname));
BLI_strncpy(stype->label, socket_label, sizeof(stype->label)); BLI_strncpy(stype->label, socket_label, sizeof(stype->label));
@ -681,7 +673,7 @@ static bNodeSocketType *make_socket_type_virtual()
bNodeSocketType *stype; bNodeSocketType *stype;
StructRNA *srna; StructRNA *srna;
stype = (bNodeSocketType *)MEM_callocN(sizeof(bNodeSocketType), "node socket C type"); stype = MEM_cnew<bNodeSocketType>("node socket C type");
stype->free_self = (void (*)(bNodeSocketType * stype)) MEM_freeN; stype->free_self = (void (*)(bNodeSocketType * stype)) MEM_freeN;
BLI_strncpy(stype->idname, socket_idname, sizeof(stype->idname)); BLI_strncpy(stype->idname, socket_idname, sizeof(stype->idname));

@ -1295,8 +1295,7 @@ int SIM_cloth_solve(
BKE_sim_debug_data_clear_category("collision"); BKE_sim_debug_data_clear_category("collision");
if (!clmd->solver_result) { if (!clmd->solver_result) {
clmd->solver_result = (ClothSolverResult *)MEM_callocN(sizeof(ClothSolverResult), clmd->solver_result = MEM_cnew<ClothSolverResult>("cloth solver result");
"cloth solver result");
} }
cloth_clear_result(clmd); cloth_clear_result(clmd);

@ -1160,7 +1160,7 @@ HairGrid *SIM_hair_volume_create_vertex_grid(float cellsize,
} }
size = hair_grid_size(res); size = hair_grid_size(res);
grid = (HairGrid *)MEM_callocN(sizeof(HairGrid), "hair grid"); grid = MEM_cnew<HairGrid>("hair grid");
grid->res[0] = res[0]; grid->res[0] = res[0];
grid->res[1] = res[1]; grid->res[1] = res[1];
grid->res[2] = res[2]; grid->res[2] = res[2];