diff --git a/intern/opencolorio/fallback_impl.cc b/intern/opencolorio/fallback_impl.cc index 42a2b5bf3b6..9402a12a71a 100644 --- a/intern/opencolorio/fallback_impl.cc +++ b/intern/opencolorio/fallback_impl.cc @@ -485,8 +485,8 @@ OCIO_PackedImageDesc *FallbackImpl::createOCIO_PackedImageDesc(float *data, long xStrideBytes, long yStrideBytes) { - OCIO_PackedImageDescription *desc = (OCIO_PackedImageDescription *)MEM_callocN( - sizeof(OCIO_PackedImageDescription), "OCIO_PackedImageDescription"); + OCIO_PackedImageDescription *desc = MEM_cnew( + "OCIO_PackedImageDescription"); desc->data = data; desc->width = width; desc->height = height; diff --git a/source/blender/blenkernel/intern/bvhutils.cc b/source/blender/blenkernel/intern/bvhutils.cc index a68119fbc1d..09a01d209df 100644 --- a/source/blender/blenkernel/intern/bvhutils.cc +++ b/source/blender/blenkernel/intern/bvhutils.cc @@ -127,7 +127,7 @@ bool bvhcache_has_tree(const BVHCache *bvh_cache, const BVHTree *tree) BVHCache *bvhcache_init() { - BVHCache *cache = (BVHCache *)MEM_callocN(sizeof(BVHCache), __func__); + BVHCache *cache = MEM_cnew(__func__); BLI_mutex_init(&cache->mutex); return cache; } diff --git a/source/blender/blenkernel/intern/cryptomatte.cc b/source/blender/blenkernel/intern/cryptomatte.cc index d532ed9e4b2..7481d4df351 100644 --- a/source/blender/blenkernel/intern/cryptomatte.cc +++ b/source/blender/blenkernel/intern/cryptomatte.cc @@ -278,13 +278,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 = (CryptomatteEntry *)MEM_callocN(sizeof(CryptomatteEntry), __func__); + entry = MEM_cnew(__func__); entry->encoded_hash = encoded_hash; } else { const char *name = token.c_str(); int name_len = token.length(); - entry = (CryptomatteEntry *)MEM_callocN(sizeof(CryptomatteEntry), __func__); + entry = MEM_cnew(__func__); STRNCPY(entry->name, name); uint32_t hash = BKE_cryptomatte_hash(name, name_len); entry->encoded_hash = BKE_cryptomatte_hash_to_float(hash); diff --git a/source/blender/blenkernel/intern/curve.cc b/source/blender/blenkernel/intern/curve.cc index dc2527f9b62..291927ee398 100644 --- a/source/blender/blenkernel/intern/curve.cc +++ b/source/blender/blenkernel/intern/curve.cc @@ -2694,7 +2694,7 @@ void BKE_curve_bevelList_make(Object *ob, const ListBase *nurbs, const bool for_ if (nu->type == CU_POLY) { len = nu->pntsu; - BevList *bl = (BevList *)MEM_callocN(sizeof(BevList), __func__); + BevList *bl = MEM_cnew(__func__); bl->bevpoints = (BevPoint *)MEM_calloc_arrayN(len, sizeof(BevPoint), __func__); if (need_seglen && (nu->flagu & CU_NURB_CYCLIC) == 0) { bl->seglen = (float *)MEM_malloc_arrayN(segcount, sizeof(float), __func__); @@ -2744,7 +2744,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 = (BevList *)MEM_callocN(sizeof(BevList), __func__); + BevList *bl = MEM_cnew(__func__); bl->bevpoints = (BevPoint *)MEM_calloc_arrayN(len, sizeof(BevPoint), __func__); if (need_seglen && (nu->flagu & CU_NURB_CYCLIC) == 0) { bl->seglen = (float *)MEM_malloc_arrayN(segcount, sizeof(float), __func__); @@ -2880,7 +2880,7 @@ void BKE_curve_bevelList_make(Object *ob, const ListBase *nurbs, const bool for_ if (nu->pntsv == 1) { len = (resolu * segcount); - BevList *bl = (BevList *)MEM_callocN(sizeof(BevList), __func__); + BevList *bl = MEM_cnew(__func__); bl->bevpoints = (BevPoint *)MEM_calloc_arrayN(len, sizeof(BevPoint), __func__); if (need_seglen && (nu->flagu & CU_NURB_CYCLIC) == 0) { bl->seglen = (float *)MEM_malloc_arrayN(segcount, sizeof(float), __func__); diff --git a/source/blender/blenkernel/intern/displist.cc b/source/blender/blenkernel/intern/displist.cc index edf043de63f..48bf24a0825 100644 --- a/source/blender/blenkernel/intern/displist.cc +++ b/source/blender/blenkernel/intern/displist.cc @@ -316,7 +316,7 @@ static void curve_to_displist(const Curve *cu, * and resolution > 1. */ const bool use_cyclic_sample = is_cyclic && (samples_len != 2); - DispList *dl = (DispList *)MEM_callocN(sizeof(DispList), __func__); + DispList *dl = MEM_cnew(__func__); /* Add one to the length because of 'BKE_curve_forward_diff_bezier'. */ dl->verts = (float *)MEM_mallocN(sizeof(float[3]) * (samples_len + 1), __func__); BLI_addtail(r_dispbase, dl); @@ -371,7 +371,7 @@ static void curve_to_displist(const Curve *cu, } else if (nu->type == CU_NURBS) { const int len = (resolution * SEGMENTSU(nu)); - DispList *dl = (DispList *)MEM_callocN(sizeof(DispList), __func__); + DispList *dl = MEM_cnew(__func__); dl->verts = (float *)MEM_mallocN(len * sizeof(float[3]), __func__); BLI_addtail(r_dispbase, dl); dl->parts = 1; @@ -384,7 +384,7 @@ static void curve_to_displist(const Curve *cu, } else if (nu->type == CU_POLY) { const int len = nu->pntsu; - DispList *dl = (DispList *)MEM_callocN(sizeof(DispList), __func__); + DispList *dl = MEM_cnew(__func__); dl->verts = (float *)MEM_mallocN(len * sizeof(float[3]), __func__); BLI_addtail(r_dispbase, dl); 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); if (totvert != 0 && triangles_len != 0) { - DispList *dlnew = (DispList *)MEM_callocN(sizeof(DispList), __func__); + DispList *dlnew = MEM_cnew(__func__); dlnew->type = DL_INDEX3; dlnew->flag = (dl_flag_accum & (DL_BACK_CURVE | DL_FRONT_CURVE)); 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->flag & DL_CYCL_V) && (dl->flag & DL_CYCL_U) == 0) { if ((cu->flag & CU_BACK) && (dl->flag & DL_BACK_CURVE)) { - DispList *dlnew = (DispList *)MEM_callocN(sizeof(DispList), __func__); + DispList *dlnew = MEM_cnew(__func__); BLI_addtail(&front, dlnew); dlnew->verts = (float *)MEM_mallocN(sizeof(float[3]) * dl->parts, __func__); 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)) { - DispList *dlnew = (DispList *)MEM_callocN(sizeof(DispList), __func__); + DispList *dlnew = MEM_cnew(__func__); BLI_addtail(&back, dlnew); dlnew->verts = (float *)MEM_mallocN(sizeof(float[3]) * dl->parts, __func__); 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)); } else { - ob->runtime.curve_cache = (CurveCache *)MEM_callocN(sizeof(CurveCache), __func__); + ob->runtime.curve_cache = MEM_cnew(__func__); } 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) { const int len = SEGMENTSU(nu) * resolu; - DispList *dl = (DispList *)MEM_callocN(sizeof(DispList), __func__); + DispList *dl = MEM_cnew(__func__); dl->verts = (float *)MEM_mallocN(len * sizeof(float[3]), __func__); BLI_addtail(r_dispbase, dl); @@ -1019,7 +1019,7 @@ static void evaluate_surface_object(Depsgraph *depsgraph, else { const int len = (nu->pntsu * resolu) * (nu->pntsv * resolv); - DispList *dl = (DispList *)MEM_callocN(sizeof(DispList), __func__); + DispList *dl = MEM_cnew(__func__); dl->verts = (float *)MEM_mallocN(len * sizeof(float[3]), __func__); BLI_addtail(r_dispbase, dl); @@ -1122,7 +1122,7 @@ static void fillBevelCap(const Nurb *nu, const float *prev_fp, ListBase *dispbase) { - DispList *dl = (DispList *)MEM_callocN(sizeof(DispList), __func__); + DispList *dl = MEM_cnew(__func__); dl->verts = (float *)MEM_mallocN(sizeof(float[3]) * dlb->nr, __func__); 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 */ if (BLI_listbase_is_empty(&dlbev)) { - DispList *dl = (DispList *)MEM_callocN(sizeof(DispList), "makeDispListbev"); + DispList *dl = MEM_cnew("makeDispListbev"); dl->verts = (float *)MEM_mallocN(sizeof(float[3]) * bl->nr, "dlverts"); BLI_addtail(r_dispbase, dl); @@ -1371,7 +1371,7 @@ static GeometrySet evaluate_curve_type_object(Depsgraph *depsgraph, LISTBASE_FOREACH (DispList *, dlb, &dlbev) { /* for each part of the bevel use a separate displblock */ - DispList *dl = (DispList *)MEM_callocN(sizeof(DispList), __func__); + DispList *dl = MEM_cnew(__func__); dl->verts = data = (float *)MEM_mallocN(sizeof(float[3]) * dlb->nr * steps, __func__); BLI_addtail(r_dispbase, dl); @@ -1495,7 +1495,7 @@ void BKE_displist_make_curveTypes(Depsgraph *depsgraph, BKE_object_free_derived_caches(ob); cow_curve.curve_eval = nullptr; - ob->runtime.curve_cache = (CurveCache *)MEM_callocN(sizeof(CurveCache), __func__); + ob->runtime.curve_cache = MEM_cnew(__func__); ListBase *dispbase = &ob->runtime.curve_cache->disp; if (ob->type == OB_SURF) { diff --git a/source/blender/blenkernel/intern/gpencil_geom.cc b/source/blender/blenkernel/intern/gpencil_geom.cc index b5190f598c6..f8681647a77 100644 --- a/source/blender/blenkernel/intern/gpencil_geom.cc +++ b/source/blender/blenkernel/intern/gpencil_geom.cc @@ -145,7 +145,7 @@ void BKE_gpencil_stroke_boundingbox_calc(bGPDstroke *gps) static void boundbox_gpencil(Object *ob) { if (ob->runtime.bb == nullptr) { - ob->runtime.bb = (BoundBox *)MEM_callocN(sizeof(BoundBox), "GPencil boundbox"); + ob->runtime.bb = MEM_cnew("GPencil boundbox"); } BoundBox *bb = ob->runtime.bb; @@ -182,7 +182,7 @@ BoundBox *BKE_gpencil_boundbox_get(Object *ob) * to keep both values synchronized. */ if (!ELEM(ob_orig, nullptr, ob)) { if (ob_orig->runtime.bb == nullptr) { - ob_orig->runtime.bb = (BoundBox *)MEM_callocN(sizeof(BoundBox), "GPencil boundbox"); + ob_orig->runtime.bb = MEM_cnew("GPencil boundbox"); } for (int i = 0; i < 8; 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) { - ld = (LinkData *)MEM_callocN(sizeof(LinkData), "def_nr_item"); + ld = MEM_cnew("def_nr_item"); ld->data = POINTER_FROM_INT(dw->def_nr); BLI_addtail(result, ld); tw++; @@ -3482,7 +3482,7 @@ struct tSampleEdge { /* 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) { - tSamplePoint *new_pt = (tSamplePoint *)MEM_callocN(sizeof(tSamplePoint), __func__); + tSamplePoint *new_pt = MEM_cnew(__func__); copy_v3_v3(&new_pt->x, &pt->x); new_pt->pressure = pt->pressure; new_pt->strength = pt->strength; @@ -3505,7 +3505,7 @@ static tSamplePoint *new_sample_point_from_gp_point(const bGPDspoint *pt, const * the edge. */ 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(__func__); new_edge->from = from; new_edge->to = to; 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; /* Subdivide the edge. */ - tSamplePoint *new_sp = (tSamplePoint *)MEM_callocN(sizeof(tSamplePoint), __func__); + tSamplePoint *new_sp = MEM_cnew(__func__); 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->strength = interpf(sp->strength, sp_next->strength, 0.5f); @@ -3687,7 +3687,7 @@ struct tPerimeterPoint { static tPerimeterPoint *new_perimeter_point(const float pt[3]) { - tPerimeterPoint *new_pt = (tPerimeterPoint *)MEM_callocN(sizeof(tPerimeterPoint), __func__); + tPerimeterPoint *new_pt = MEM_cnew(__func__); copy_v3_v3(&new_pt->x, pt); return new_pt; } @@ -3856,8 +3856,8 @@ static ListBase *gpencil_stroke_perimeter_ex(const bGPdata *gpd, float defaultpixsize = 1000.0f / gpd->pixfactor; float stroke_radius = ((gps->thickness + gpl->line_change) / defaultpixsize) / 2.0f; - ListBase *perimeter_right_side = (ListBase *)MEM_callocN(sizeof(ListBase), __func__); - ListBase *perimeter_left_side = (ListBase *)MEM_callocN(sizeof(ListBase), __func__); + ListBase *perimeter_right_side = MEM_cnew(__func__); + ListBase *perimeter_left_side = MEM_cnew(__func__); int num_perimeter_points = 0; bGPDspoint *first = &gps->points[0]; diff --git a/source/blender/blenkernel/intern/image_gpu.cc b/source/blender/blenkernel/intern/image_gpu.cc index 4440e4b101a..c82de02e52a 100644 --- a/source/blender/blenkernel/intern/image_gpu.cc +++ b/source/blender/blenkernel/intern/image_gpu.cc @@ -172,7 +172,7 @@ static GPUTexture *gpu_texture_create_tile_array(Image *ima, ImBuf *ibuf = BKE_image_acquire_ibuf(ima, &iuser, nullptr); if (ibuf) { - PackTile *packtile = (PackTile *)MEM_callocN(sizeof(PackTile), __func__); + PackTile *packtile = MEM_cnew(__func__); packtile->tile = tile; packtile->boxpack.w = ibuf->x; packtile->boxpack.h = ibuf->y; diff --git a/source/blender/blenkernel/intern/mesh_convert.cc b/source/blender/blenkernel/intern/mesh_convert.cc index 07c126861f0..43242e3a093 100644 --- a/source/blender/blenkernel/intern/mesh_convert.cc +++ b/source/blender/blenkernel/intern/mesh_convert.cc @@ -589,14 +589,14 @@ struct VertLink { static void prependPolyLineVert(ListBase *lb, uint index) { - VertLink *vl = (VertLink *)MEM_callocN(sizeof(VertLink), "VertLink"); + VertLink *vl = MEM_cnew("VertLink"); vl->index = index; BLI_addhead(lb, vl); } static void appendPolyLineVert(ListBase *lb, uint index) { - VertLink *vl = (VertLink *)MEM_callocN(sizeof(VertLink), "VertLink"); + VertLink *vl = MEM_cnew("VertLink"); vl->index = index; BLI_addtail(lb, vl); } @@ -632,7 +632,7 @@ void BKE_mesh_to_curve_nurblist(const Mesh *me, ListBase *nurblist, const int ed med = medge; for (i = 0; i < medge_len; i++, med++) { if (edge_users[i] == edge_users_test) { - EdgeLink *edl = (EdgeLink *)MEM_callocN(sizeof(EdgeLink), "EdgeLink"); + EdgeLink *edl = MEM_cnew("EdgeLink"); edl->edge = med; BLI_addtail(&edges, edl); @@ -719,7 +719,7 @@ void BKE_mesh_to_curve_nurblist(const Mesh *me, ListBase *nurblist, const int ed VertLink *vl; /* create new 'nurb' within the curve */ - nu = (Nurb *)MEM_callocN(sizeof(Nurb), "MeshNurb"); + nu = MEM_cnew("MeshNurb"); nu->pntsu = totpoly; nu->pntsv = 1; diff --git a/source/blender/blenkernel/intern/node.cc b/source/blender/blenkernel/intern/node.cc index e05d452ca50..9975d4022c5 100644 --- a/source/blender/blenkernel/intern/node.cc +++ b/source/blender/blenkernel/intern/node.cc @@ -1529,7 +1529,7 @@ static bNodeSocket *make_socket(bNodeTree *ntree, BLI_uniquename_cb( unique_identifier_check, lb, "socket", '_', auto_identifier, sizeof(auto_identifier)); - bNodeSocket *sock = (bNodeSocket *)MEM_callocN(sizeof(bNodeSocket), "sock"); + bNodeSocket *sock = MEM_cnew("sock"); sock->in_out = in_out; 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 *node = (bNode *)MEM_callocN(sizeof(bNode), "new node"); + bNode *node = MEM_cnew("new node"); BLI_addtail(&ntree->nodes, node); BLI_strncpy(node->idname, idname, sizeof(node->idname)); @@ -2329,7 +2329,7 @@ bNodeLink *nodeAddLink( BLI_assert(tonode); if (fromsock->in_out == SOCK_OUT && tosock->in_out == SOCK_IN) { - link = (bNodeLink *)MEM_callocN(sizeof(bNodeLink), "link"); + link = MEM_cnew("link"); if (ntree) { BLI_addtail(&ntree->links, link); } @@ -2340,7 +2340,7 @@ bNodeLink *nodeAddLink( } else if (fromsock->in_out == SOCK_IN && tosock->in_out == SOCK_OUT) { /* OK but flip */ - link = (bNodeLink *)MEM_callocN(sizeof(bNodeLink), "link"); + link = MEM_cnew("link"); if (ntree) { 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); if (!preview) { if (create) { - preview = (bNodePreview *)MEM_callocN(sizeof(bNodePreview), "node preview"); + preview = MEM_cnew("node preview"); BKE_node_instance_hash_insert(previews, key, preview); } else { @@ -3374,7 +3374,7 @@ static bNodeSocket *make_socket_interface(bNodeTree *ntree, return nullptr; } - bNodeSocket *sock = (bNodeSocket *)MEM_callocN(sizeof(bNodeSocket), "socket template"); + bNodeSocket *sock = MEM_cnew("socket template"); BLI_strncpy(sock->idname, stype->idname, sizeof(sock->idname)); node_socket_set_typeinfo(ntree, sock, stype); sock->in_out = in_out; diff --git a/source/blender/blenkernel/intern/node_tree_update.cc b/source/blender/blenkernel/intern/node_tree_update.cc index abdc2dfeabf..6bf1c883f1d 100644 --- a/source/blender/blenkernel/intern/node_tree_update.cc +++ b/source/blender/blenkernel/intern/node_tree_update.cc @@ -1219,7 +1219,7 @@ class NodeTreeMainUpdater { for (const auto &item : links) { bNodeSocket *from_socket = item.first; bNodeSocket *to_socket = item.second; - bNodeLink *link = (bNodeLink *)MEM_callocN(sizeof(bNodeLink), __func__); + bNodeLink *link = MEM_cnew(__func__); link->fromnode = &node; link->fromsock = from_socket; link->tonode = &node; diff --git a/source/blender/blenkernel/intern/object.cc b/source/blender/blenkernel/intern/object.cc index 7fec91ed65a..6cc6219b7d7 100644 --- a/source/blender/blenkernel/intern/object.cc +++ b/source/blender/blenkernel/intern/object.cc @@ -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}; - BoundBox *bb = (BoundBox *)MEM_callocN(sizeof(BoundBox), "OB-BoundBox"); + BoundBox *bb = MEM_cnew("OB-BoundBox"); BKE_boundbox_init_from_minmax(bb, min, max); return bb; @@ -3903,7 +3903,7 @@ void BKE_object_boundbox_calc_from_mesh(Object *ob, const Mesh *me_eval) } if (ob->runtime.bb == nullptr) { - ob->runtime.bb = (BoundBox *)MEM_callocN(sizeof(BoundBox), "DM-BoundBox"); + ob->runtime.bb = MEM_cnew("DM-BoundBox"); } 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) { - ob->runtime.bb = (BoundBox *)MEM_callocN(sizeof(BoundBox), __func__); + ob->runtime.bb = MEM_cnew(__func__); } 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->iuser) { - ob->iuser = (ImageUser *)MEM_callocN(sizeof(ImageUser), "image user"); + ob->iuser = MEM_cnew("image user"); ob->iuser->flag |= IMA_ANIM_ALWAYS; ob->iuser->frames = 100; 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) { BLI_assert((ob->sculpt == nullptr) && (ob->mode & OB_MODE_ALL_SCULPT)); - ob->sculpt = (SculptSession *)MEM_callocN(sizeof(SculptSession), __func__); + ob->sculpt = MEM_cnew(__func__); 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("PCLink"); link->data = POINTER_FROM_INT(i); BLI_addtail(&ob->pc_ids, link); diff --git a/source/blender/blenkernel/intern/object_dupli.cc b/source/blender/blenkernel/intern/object_dupli.cc index 9f998b746a2..e682486390c 100644 --- a/source/blender/blenkernel/intern/object_dupli.cc +++ b/source/blender/blenkernel/intern/object_dupli.cc @@ -190,7 +190,7 @@ static DupliObject *make_dupli(const DupliContext *ctx, /* Add a #DupliObject instance to the result container. */ if (ctx->duplilist) { - dob = (DupliObject *)MEM_callocN(sizeof(DupliObject), "dupli object"); + dob = MEM_cnew("dupli object"); BLI_addtail(ctx->duplilist, dob); } else { @@ -1690,7 +1690,7 @@ static const DupliGenerator *get_dupli_generator(const DupliContext *ctx) ListBase *object_duplilist(Depsgraph *depsgraph, Scene *sce, Object *ob) { - ListBase *duplilist = (ListBase *)MEM_callocN(sizeof(ListBase), "duplilist"); + ListBase *duplilist = MEM_cnew("duplilist"); DupliContext ctx; Vector instance_stack; instance_stack.append(ob); diff --git a/source/blender/blenkernel/intern/volume.cc b/source/blender/blenkernel/intern/volume.cc index 63807f90334..4b71c98339b 100644 --- a/source/blender/blenkernel/intern/volume.cc +++ b/source/blender/blenkernel/intern/volume.cc @@ -955,7 +955,7 @@ BoundBox *BKE_volume_boundbox_get(Object *ob) } if (ob->runtime.bb == nullptr) { - ob->runtime.bb = (BoundBox *)MEM_callocN(sizeof(BoundBox), __func__); + ob->runtime.bb = MEM_cnew(__func__); } const Volume *volume = (Volume *)ob->data; diff --git a/source/blender/blenlib/tests/BLI_task_test.cc b/source/blender/blenlib/tests/BLI_task_test.cc index dd4441517a9..3bb6f6f753c 100644 --- a/source/blender/blenlib/tests/BLI_task_test.cc +++ b/source/blender/blenlib/tests/BLI_task_test.cc @@ -154,7 +154,7 @@ static void task_mempool_iter_tls_func(void *UNUSED(userdata), EXPECT_TRUE(data != nullptr); if (task_data->accumulate_items == nullptr) { - task_data->accumulate_items = (ListBase *)MEM_callocN(sizeof(ListBase), __func__); + task_data->accumulate_items = MEM_cnew(__func__); } /* 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 (join_chunk->accumulate_items == nullptr) { - join_chunk->accumulate_items = (ListBase *)MEM_callocN(sizeof(ListBase), __func__); + join_chunk->accumulate_items = MEM_cnew(__func__); } BLI_movelisttolist(join_chunk->accumulate_items, data_chunk->accumulate_items); } diff --git a/source/blender/compositor/operations/COM_KeyingScreenOperation.cc b/source/blender/compositor/operations/COM_KeyingScreenOperation.cc index c34eaad87ef..aa92c5c0c2b 100644 --- a/source/blender/compositor/operations/COM_KeyingScreenOperation.cc +++ b/source/blender/compositor/operations/COM_KeyingScreenOperation.cc @@ -132,8 +132,7 @@ KeyingScreenOperation::TriangulationData *KeyingScreenOperation::build_voronoi_t return nullptr; } - triangulation = (TriangulationData *)MEM_callocN(sizeof(TriangulationData), - "keying screen triangulation data"); + triangulation = MEM_cnew("keying screen triangulation data"); sites = (VoronoiSite *)MEM_callocN(sizeof(VoronoiSite) * sites_total, "keyingscreen voronoi sites"); @@ -243,7 +242,7 @@ KeyingScreenOperation::TileData *KeyingScreenOperation::triangulate(const rcti * return nullptr; } - tile_data = (TileData *)MEM_callocN(sizeof(TileData), "keying screen tile data"); + tile_data = MEM_cnew("keying screen tile data"); for (i = 0; i < triangulation->triangles_total; i++) { if (BLI_rcti_isect(rect, &triangulation->triangles_AABB[i], nullptr)) { diff --git a/source/blender/editors/interface/interface_region_search.cc b/source/blender/editors/interface/interface_region_search.cc index f4c99fb3c16..e27dd2a7981 100644 --- a/source/blender/editors/interface/interface_region_search.cc +++ b/source/blender/editors/interface/interface_region_search.cc @@ -725,7 +725,7 @@ static ARegion *ui_searchbox_create_generic_ex(bContext *C, region->type = &type; /* create searchbox data */ - uiSearchboxData *data = (uiSearchboxData *)MEM_callocN(sizeof(uiSearchboxData), __func__); + uiSearchboxData *data = MEM_cnew(__func__); /* set font, get bb */ data->fstyle = style->widget; /* copy struct */ @@ -1021,7 +1021,7 @@ void ui_but_search_refresh(uiButSearch *search_but) return; } - uiSearchItems *items = (uiSearchItems *)MEM_callocN(sizeof(uiSearchItems), __func__); + uiSearchItems *items = MEM_cnew(__func__); /* setup search struct */ items->maxitem = 10; diff --git a/source/blender/editors/object/object_remesh.cc b/source/blender/editors/object/object_remesh.cc index 719ffd36f03..4737de4d8fa 100644 --- a/source/blender/editors/object/object_remesh.cc +++ b/source/blender/editors/object/object_remesh.cc @@ -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); Mesh *mesh = (Mesh *)active_object->data; - VoxelSizeEditCustomData *cd = (VoxelSizeEditCustomData *)MEM_callocN( - sizeof(VoxelSizeEditCustomData), "Voxel Size Edit OP Custom Data"); + VoxelSizeEditCustomData *cd = MEM_cnew( + "Voxel Size Edit OP Custom Data"); /* Initial operator Custom Data setup. */ cd->draw_handle = ED_region_draw_cb_activate( diff --git a/source/blender/editors/space_node/node_add.cc b/source/blender/editors/space_node/node_add.cc index 78683a69db3..c30e8b92d6b 100644 --- a/source/blender/editors/space_node/node_add.cc +++ b/source/blender/editors/space_node/node_add.cc @@ -130,7 +130,7 @@ static bNodeSocketLink *add_reroute_insert_socket_link(ListBase *lb, { bNodeSocketLink *socklink, *prev; - socklink = (bNodeSocketLink *)MEM_callocN(sizeof(bNodeSocketLink), "socket link"); + socklink = MEM_cnew("socket link"); socklink->sock = sock; socklink->link = link; copy_v2_v2(socklink->point, point); diff --git a/source/blender/editors/space_node/node_edit.cc b/source/blender/editors/space_node/node_edit.cc index 3b34d0b386e..e83bfb43847 100644 --- a/source/blender/editors/space_node/node_edit.cc +++ b/source/blender/editors/space_node/node_edit.cc @@ -344,7 +344,7 @@ void ED_node_composite_job(const bContext *C, struct bNodeTree *nodetree, Scene "Compositing", WM_JOB_EXCL_RENDER | WM_JOB_PROGRESS, WM_JOB_TYPE_COMPOSITE); - CompoJob *cj = (CompoJob *)MEM_callocN(sizeof(CompoJob), "compo job"); + CompoJob *cj = MEM_cnew("compo job"); /* customdata for preview thread */ cj->bmain = bmain; @@ -908,7 +908,7 @@ static void node_resize_init(bContext *C, { SpaceNode *snode = CTX_wm_space_node(C); - NodeSizeWidget *nsw = (NodeSizeWidget *)MEM_callocN(sizeof(NodeSizeWidget), __func__); + NodeSizeWidget *nsw = MEM_cnew(__func__); op->customdata = nsw; 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) && (keep_inputs || (link->fromnode && (link->fromnode->flag & NODE_SELECT)))) { - bNodeLink *newlink = (bNodeLink *)MEM_callocN(sizeof(bNodeLink), "bNodeLink"); + bNodeLink *newlink = MEM_cnew("bNodeLink"); newlink->flag = link->flag; newlink->tonode = node_map.lookup(link->tonode); 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->fromnode); if (link->tonode->flag & NODE_SELECT && link->fromnode->flag & NODE_SELECT) { - bNodeLink *newlink = (bNodeLink *)MEM_callocN(sizeof(bNodeLink), __func__); + bNodeLink *newlink = MEM_cnew(__func__); newlink->flag = link->flag; newlink->tonode = node_map.lookup(link->tonode); newlink->tosock = socket_map.lookup(link->tosock); diff --git a/source/blender/editors/space_node/node_relationships.cc b/source/blender/editors/space_node/node_relationships.cc index 663b3a4c89a..4055dfdbf9e 100644 --- a/source/blender/editors/space_node/node_relationships.cc +++ b/source/blender/editors/space_node/node_relationships.cc @@ -102,7 +102,7 @@ static void clear_picking_highlight(ListBase *links) static bNodeLink *create_drag_link(bNode &node, bNodeSocket &sock) { - bNodeLink *oplink = (bNodeLink *)MEM_callocN(sizeof(bNodeLink), __func__); + bNodeLink *oplink = MEM_cnew(__func__); if (sock.in_out == SOCK_OUT) { oplink->fromnode = &node; oplink->fromsock = &sock; @@ -1123,7 +1123,7 @@ static std::unique_ptr node_link_init(SpaceNode &snode, /* detach current links and store them in the operator data */ LISTBASE_FOREACH_MUTABLE (bNodeLink *, link, &snode.edittree->links) { if (link->fromsock == sock) { - bNodeLink *oplink = (bNodeLink *)MEM_callocN(sizeof(bNodeLink), "drag link op link"); + bNodeLink *oplink = MEM_cnew("drag link op link"); *oplink = *link; oplink->next = oplink->prev = nullptr; oplink->flag |= NODE_LINK_VALID; @@ -1166,7 +1166,7 @@ static std::unique_ptr node_link_init(SpaceNode &snode, } 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("drag link op link"); *oplink = *link_to_pick; oplink->next = oplink->prev = nullptr; 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 */ if ((snode->flag & SNODE_SKIP_INSOFFSET) == 0) { - NodeInsertOfsData *iofsd = (NodeInsertOfsData *)MEM_callocN(sizeof(NodeInsertOfsData), - __func__); + NodeInsertOfsData *iofsd = MEM_cnew(__func__); iofsd->insert = select; iofsd->prev = link->fromnode; diff --git a/source/blender/editors/space_node/node_templates.cc b/source/blender/editors/space_node/node_templates.cc index defb1e82c3e..492237477c1 100644 --- a/source/blender/editors/space_node/node_templates.cc +++ b/source/blender/editors/space_node/node_templates.cc @@ -699,7 +699,7 @@ void uiTemplateNodeLink( uiBut *but; float socket_col[4]; - arg = (NodeLinkArg *)MEM_callocN(sizeof(NodeLinkArg), "NodeLinkArg"); + arg = MEM_new("NodeLinkArg"); arg->ntree = ntree; arg->node = node; arg->sock = input; diff --git a/source/blender/editors/space_node/node_view.cc b/source/blender/editors/space_node/node_view.cc index df629a983e3..12f390c47cd 100644 --- a/source/blender/editors/space_node/node_view.cc +++ b/source/blender/editors/space_node/node_view.cc @@ -255,7 +255,7 @@ static int snode_bg_viewmove_invoke(bContext *C, wmOperator *op, const wmEvent * return OPERATOR_CANCELLED; } - nvm = (NodeViewMove *)MEM_callocN(sizeof(NodeViewMove), "NodeViewMove struct"); + nvm = MEM_cnew("NodeViewMove struct"); op->customdata = nvm; nvm->mvalo[0] = event->mval[0]; nvm->mvalo[1] = event->mval[1]; @@ -643,7 +643,7 @@ static int sample_invoke(bContext *C, wmOperator *op, const wmEvent *event) return OPERATOR_CANCELLED; } - info = (ImageSampleInfo *)MEM_callocN(sizeof(ImageSampleInfo), "ImageSampleInfo"); + info = MEM_cnew("ImageSampleInfo"); info->art = region->type; info->draw_handle = ED_region_draw_cb_activate( region->type, sample_draw, info, REGION_DRAW_POST_PIXEL); diff --git a/source/blender/editors/space_node/space_node.cc b/source/blender/editors/space_node/space_node.cc index 96c6dd89447..54a72a4b53d 100644 --- a/source/blender/editors/space_node/space_node.cc +++ b/source/blender/editors/space_node/space_node.cc @@ -63,7 +63,7 @@ void ED_node_tree_start(SpaceNode *snode, bNodeTree *ntree, ID *id, ID *from) BLI_listbase_clear(&snode->treepath); if (ntree) { - bNodeTreePath *path = (bNodeTreePath *)MEM_callocN(sizeof(bNodeTreePath), "node tree path"); + bNodeTreePath *path = MEM_cnew("node tree path"); path->nodetree = ntree; 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) { - bNodeTreePath *path = (bNodeTreePath *)MEM_callocN(sizeof(bNodeTreePath), "node tree path"); + bNodeTreePath *path = MEM_cnew("node tree path"); bNodeTreePath *prev_path = (bNodeTreePath *)snode->treepath.last; path->nodetree = ntree; 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)) { - SpaceNode *snode = (SpaceNode *)MEM_callocN(sizeof(SpaceNode), "initnode"); + SpaceNode *snode = MEM_cnew("initnode"); snode->spacetype = SPACE_NODE; 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; /* header */ - ARegion *region = (ARegion *)MEM_callocN(sizeof(ARegion), "header for node"); + ARegion *region = MEM_cnew("header for node"); BLI_addtail(&snode->regionbase, region); region->regiontype = RGN_TYPE_HEADER; region->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_BOTTOM : RGN_ALIGN_TOP; /* buttons/list view */ - region = (ARegion *)MEM_callocN(sizeof(ARegion), "buttons for node"); + region = MEM_cnew("buttons for node"); BLI_addtail(&snode->regionbase, region); region->regiontype = RGN_TYPE_UI; region->alignment = RGN_ALIGN_RIGHT; /* toolbar */ - region = (ARegion *)MEM_callocN(sizeof(ARegion), "node tools"); + region = MEM_cnew("node tools"); BLI_addtail(&snode->regionbase, region); 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; /* main region */ - region = (ARegion *)MEM_callocN(sizeof(ARegion), "main region for node"); + region = MEM_cnew("main region for node"); BLI_addtail(&snode->regionbase, region); 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; if (snode->runtime == nullptr) { - snode->runtime = (SpaceNode_Runtime *)MEM_callocN(sizeof(SpaceNode_Runtime), __func__); + snode->runtime = MEM_new(__func__); } } @@ -983,7 +983,7 @@ static void node_space_subtype_item_extend(bContext *C, EnumPropertyItem **item, void ED_spacetype_node() { - SpaceType *st = (SpaceType *)MEM_callocN(sizeof(SpaceType), "spacetype node"); + SpaceType *st = MEM_cnew("spacetype node"); ARegionType *art; st->spaceid = SPACE_NODE; @@ -1006,7 +1006,7 @@ void ED_spacetype_node() st->space_subtype_set = node_space_subtype_set; /* regions: main window */ - art = (ARegionType *)MEM_callocN(sizeof(ARegionType), "spacetype node region"); + art = MEM_cnew("spacetype node region"); art->regionid = RGN_TYPE_WINDOW; art->init = node_main_region_init; art->draw = node_main_region_draw; @@ -1020,7 +1020,7 @@ void ED_spacetype_node() BLI_addhead(&st->regiontypes, art); /* regions: header */ - art = (ARegionType *)MEM_callocN(sizeof(ARegionType), "spacetype node region"); + art = MEM_cnew("spacetype node region"); art->regionid = RGN_TYPE_HEADER; art->prefsizey = HEADERY; art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_HEADER; @@ -1031,7 +1031,7 @@ void ED_spacetype_node() BLI_addhead(&st->regiontypes, art); /* regions: listview/buttons */ - art = (ARegionType *)MEM_callocN(sizeof(ARegionType), "spacetype node region"); + art = MEM_cnew("spacetype node region"); art->regionid = RGN_TYPE_UI; art->prefsizex = UI_SIDEBAR_PANEL_WIDTH; art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_FRAMES; @@ -1042,7 +1042,7 @@ void ED_spacetype_node() BLI_addhead(&st->regiontypes, art); /* regions: toolbar */ - art = (ARegionType *)MEM_callocN(sizeof(ARegionType), "spacetype view3d tools region"); + art = MEM_cnew("spacetype view3d tools region"); art->regionid = RGN_TYPE_TOOLS; art->prefsizex = 58; /* XXX */ art->prefsizey = 50; /* XXX */ diff --git a/source/blender/editors/space_spreadsheet/space_spreadsheet.cc b/source/blender/editors/space_spreadsheet/space_spreadsheet.cc index 7526a61bf4a..908954f1815 100644 --- a/source/blender/editors/space_spreadsheet/space_spreadsheet.cc +++ b/source/blender/editors/space_spreadsheet/space_spreadsheet.cc @@ -60,15 +60,14 @@ using namespace blender::ed::spreadsheet; static SpaceLink *spreadsheet_create(const ScrArea *UNUSED(area), const Scene *UNUSED(scene)) { - SpaceSpreadsheet *spreadsheet_space = (SpaceSpreadsheet *)MEM_callocN(sizeof(SpaceSpreadsheet), - "spreadsheet space"); + SpaceSpreadsheet *spreadsheet_space = MEM_cnew("spreadsheet space"); spreadsheet_space->spacetype = SPACE_SPREADSHEET; spreadsheet_space->filter_flag = SPREADSHEET_FILTER_ENABLE; { /* Header. */ - ARegion *region = (ARegion *)MEM_callocN(sizeof(ARegion), "spreadsheet header"); + ARegion *region = MEM_cnew("spreadsheet header"); BLI_addtail(&spreadsheet_space->regionbase, region); region->regiontype = RGN_TYPE_HEADER; 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. */ - ARegion *region = (ARegion *)MEM_callocN(sizeof(ARegion), "spreadsheet footer region"); + ARegion *region = MEM_cnew("spreadsheet footer region"); BLI_addtail(&spreadsheet_space->regionbase, region); region->regiontype = RGN_TYPE_FOOTER; 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 */ - ARegion *region = (ARegion *)MEM_callocN(sizeof(ARegion), "spreadsheet dataset region"); + ARegion *region = MEM_cnew("spreadsheet dataset region"); BLI_addtail(&spreadsheet_space->regionbase, region); region->regiontype = RGN_TYPE_CHANNELS; region->alignment = RGN_ALIGN_LEFT; @@ -93,7 +92,7 @@ static SpaceLink *spreadsheet_create(const ScrArea *UNUSED(area), const Scene *U { /* Properties region. */ - ARegion *region = (ARegion *)MEM_callocN(sizeof(ARegion), "spreadsheet right region"); + ARegion *region = MEM_cnew("spreadsheet right region"); BLI_addtail(&spreadsheet_space->regionbase, region); region->regiontype = RGN_TYPE_UI; region->alignment = RGN_ALIGN_RIGHT; @@ -102,7 +101,7 @@ static SpaceLink *spreadsheet_create(const ScrArea *UNUSED(area), const Scene *U { /* Main window. */ - ARegion *region = (ARegion *)MEM_callocN(sizeof(ARegion), "spreadsheet main region"); + ARegion *region = MEM_cnew("spreadsheet main region"); BLI_addtail(&spreadsheet_space->regionbase, region); region->regiontype = RGN_TYPE_WINDOW; } @@ -622,7 +621,7 @@ static void spreadsheet_right_region_listener(const wmRegionListenerParams *UNUS void ED_spacetype_spreadsheet() { - SpaceType *st = (SpaceType *)MEM_callocN(sizeof(SpaceType), "spacetype spreadsheet"); + SpaceType *st = MEM_cnew("spacetype spreadsheet"); ARegionType *art; st->spaceid = SPACE_SPREADSHEET; @@ -637,7 +636,7 @@ void ED_spacetype_spreadsheet() st->id_remap = spreadsheet_id_remap; /* regions: main window */ - art = (ARegionType *)MEM_callocN(sizeof(ARegionType), "spacetype spreadsheet region"); + art = MEM_cnew("spacetype spreadsheet region"); art->regionid = RGN_TYPE_WINDOW; art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D; @@ -647,7 +646,7 @@ void ED_spacetype_spreadsheet() BLI_addhead(&st->regiontypes, art); /* regions: header */ - art = (ARegionType *)MEM_callocN(sizeof(ARegionType), "spacetype spreadsheet header region"); + art = MEM_cnew("spacetype spreadsheet header region"); art->regionid = RGN_TYPE_HEADER; art->prefsizey = HEADERY; art->keymapflag = 0; @@ -660,7 +659,7 @@ void ED_spacetype_spreadsheet() BLI_addhead(&st->regiontypes, art); /* regions: footer */ - art = (ARegionType *)MEM_callocN(sizeof(ARegionType), "spacetype spreadsheet footer region"); + art = MEM_cnew("spacetype spreadsheet footer region"); art->regionid = RGN_TYPE_FOOTER; art->prefsizey = HEADERY; art->keymapflag = 0; @@ -673,7 +672,7 @@ void ED_spacetype_spreadsheet() BLI_addhead(&st->regiontypes, art); /* regions: right panel buttons */ - art = (ARegionType *)MEM_callocN(sizeof(ARegionType), "spacetype spreadsheet right region"); + art = MEM_cnew("spacetype spreadsheet right region"); art->regionid = RGN_TYPE_UI; art->prefsizex = UI_SIDEBAR_PANEL_WIDTH; art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_FRAMES; @@ -688,7 +687,7 @@ void ED_spacetype_spreadsheet() register_row_filter_panels(*art); /* regions: channels */ - art = (ARegionType *)MEM_callocN(sizeof(ARegionType), "spreadsheet dataset region"); + art = MEM_cnew("spreadsheet dataset region"); art->regionid = RGN_TYPE_CHANNELS; art->prefsizex = 150 + V2D_SCROLL_WIDTH; art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D; diff --git a/source/blender/editors/space_spreadsheet/spreadsheet_column.cc b/source/blender/editors/space_spreadsheet/spreadsheet_column.cc index 7551593ef38..ee623083db7 100644 --- a/source/blender/editors/space_spreadsheet/spreadsheet_column.cc +++ b/source/blender/editors/space_spreadsheet/spreadsheet_column.cc @@ -66,8 +66,7 @@ eSpreadsheetColumnValueType cpp_type_to_column_type(const fn::CPPType &type) SpreadsheetColumnID *spreadsheet_column_id_new() { - SpreadsheetColumnID *column_id = (SpreadsheetColumnID *)MEM_callocN(sizeof(SpreadsheetColumnID), - __func__); + SpreadsheetColumnID *column_id = MEM_cnew(__func__); return column_id; } @@ -88,8 +87,7 @@ void spreadsheet_column_id_free(SpreadsheetColumnID *column_id) SpreadsheetColumn *spreadsheet_column_new(SpreadsheetColumnID *column_id) { - SpreadsheetColumn *column = (SpreadsheetColumn *)MEM_callocN(sizeof(SpreadsheetColumn), - __func__); + SpreadsheetColumn *column = MEM_cnew(__func__); column->id = column_id; return column; } diff --git a/source/blender/editors/space_spreadsheet/spreadsheet_context.cc b/source/blender/editors/space_spreadsheet/spreadsheet_context.cc index e55a7cae6a6..5cec016b727 100644 --- a/source/blender/editors/space_spreadsheet/spreadsheet_context.cc +++ b/source/blender/editors/space_spreadsheet/spreadsheet_context.cc @@ -50,8 +50,7 @@ namespace blender::ed::spreadsheet { static SpreadsheetContextObject *spreadsheet_context_object_new() { - SpreadsheetContextObject *context = (SpreadsheetContextObject *)MEM_callocN( - sizeof(SpreadsheetContextObject), __func__); + SpreadsheetContextObject *context = MEM_cnew(__func__); context->base.type = SPREADSHEET_CONTEXT_OBJECT; return context; } @@ -77,8 +76,7 @@ static void spreadsheet_context_object_free(SpreadsheetContextObject *context) static SpreadsheetContextModifier *spreadsheet_context_modifier_new() { - SpreadsheetContextModifier *context = (SpreadsheetContextModifier *)MEM_callocN( - sizeof(SpreadsheetContextModifier), __func__); + SpreadsheetContextModifier *context = MEM_cnew(__func__); context->base.type = SPREADSHEET_CONTEXT_MODIFIER; return context; } @@ -111,8 +109,7 @@ static void spreadsheet_context_modifier_free(SpreadsheetContextModifier *contex static SpreadsheetContextNode *spreadsheet_context_node_new() { - SpreadsheetContextNode *context = (SpreadsheetContextNode *)MEM_callocN( - sizeof(SpreadsheetContextNode), __func__); + SpreadsheetContextNode *context = MEM_cnew(__func__); context->base.type = SPREADSHEET_CONTEXT_NODE; return context; } diff --git a/source/blender/editors/space_spreadsheet/spreadsheet_panels.cc b/source/blender/editors/space_spreadsheet/spreadsheet_panels.cc index 854c3d4aba6..db8265a33ce 100644 --- a/source/blender/editors/space_spreadsheet/spreadsheet_panels.cc +++ b/source/blender/editors/space_spreadsheet/spreadsheet_panels.cc @@ -25,7 +25,7 @@ namespace blender::ed::spreadsheet { void spreadsheet_data_set_region_panels_register(ARegionType ®ion_type) { - PanelType *panel_type = (PanelType *)MEM_callocN(sizeof(PanelType), __func__); + PanelType *panel_type = MEM_cnew(__func__); strcpy(panel_type->idname, "SPREADSHEET_PT_data_set"); strcpy(panel_type->label, N_("Data Set")); strcpy(panel_type->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA); diff --git a/source/blender/editors/space_spreadsheet/spreadsheet_row_filter.cc b/source/blender/editors/space_spreadsheet/spreadsheet_row_filter.cc index a6a0266fcc1..36c7f1057df 100644 --- a/source/blender/editors/space_spreadsheet/spreadsheet_row_filter.cc +++ b/source/blender/editors/space_spreadsheet/spreadsheet_row_filter.cc @@ -311,8 +311,7 @@ IndexMask spreadsheet_filter_rows(const SpaceSpreadsheet &sspreadsheet, SpreadsheetRowFilter *spreadsheet_row_filter_new() { - SpreadsheetRowFilter *row_filter = (SpreadsheetRowFilter *)MEM_callocN( - sizeof(SpreadsheetRowFilter), __func__); + SpreadsheetRowFilter *row_filter = MEM_cnew(__func__); row_filter->flag = (SPREADSHEET_ROW_FILTER_UI_EXPAND | SPREADSHEET_ROW_FILTER_ENABLED); row_filter->operation = SPREADSHEET_ROW_FILTER_LESS; row_filter->threshold = 0.01f; diff --git a/source/blender/editors/space_spreadsheet/spreadsheet_row_filter_ui.cc b/source/blender/editors/space_spreadsheet/spreadsheet_row_filter_ui.cc index bcced7b5937..56722104b4f 100644 --- a/source/blender/editors/space_spreadsheet/spreadsheet_row_filter_ui.cc +++ b/source/blender/editors/space_spreadsheet/spreadsheet_row_filter_ui.cc @@ -331,7 +331,7 @@ static void set_filter_expand_flag(const bContext *UNUSED(C), Panel *panel, shor void register_row_filter_panels(ARegionType ®ion_type) { { - PanelType *panel_type = (PanelType *)MEM_callocN(sizeof(PanelType), __func__); + PanelType *panel_type = MEM_cnew(__func__); strcpy(panel_type->idname, "SPREADSHEET_PT_row_filters"); strcpy(panel_type->label, N_("Filters")); strcpy(panel_type->category, "Filters"); @@ -342,7 +342,7 @@ void register_row_filter_panels(ARegionType ®ion_type) } { - PanelType *panel_type = (PanelType *)MEM_callocN(sizeof(PanelType), __func__); + PanelType *panel_type = MEM_cnew(__func__); strcpy(panel_type->idname, "SPREADSHEET_PT_filter"); strcpy(panel_type->label, ""); strcpy(panel_type->category, "Filters"); diff --git a/source/blender/gpu/intern/gpu_framebuffer.cc b/source/blender/gpu/intern/gpu_framebuffer.cc index 3404eb67e28..5b1eac2e82f 100644 --- a/source/blender/gpu/intern/gpu_framebuffer.cc +++ b/source/blender/gpu/intern/gpu_framebuffer.cc @@ -563,7 +563,7 @@ static GPUFrameBuffer *gpu_offscreen_fb_get(GPUOffScreen *ofs) GPUOffScreen *GPU_offscreen_create( int width, int height, bool depth, eGPUTextureFormat format, char err_out[256]) { - GPUOffScreen *ofs = (GPUOffScreen *)MEM_callocN(sizeof(GPUOffScreen), __func__); + GPUOffScreen *ofs = MEM_cnew(__func__); /* Sometimes areas can have 0 height or width and this will * create a 1D texture which we don't want. */ diff --git a/source/blender/ikplugin/intern/itasc_plugin.cpp b/source/blender/ikplugin/intern/itasc_plugin.cpp index 949efb522f3..4a4e22ed884 100644 --- a/source/blender/ikplugin/intern/itasc_plugin.cpp +++ b/source/blender/ikplugin/intern/itasc_plugin.cpp @@ -284,7 +284,7 @@ static int initialize_chain(Object *ob, bPoseChannel *pchan_tip, bConstraint *co /* setup the chain data */ /* create a target */ - target = (PoseTarget *)MEM_callocN(sizeof(PoseTarget), "posetarget"); + target = MEM_cnew("posetarget"); target->con = con; /* by construction there can be only one tree per channel * and each channel can be part of at most one tree. */ @@ -292,7 +292,7 @@ static int initialize_chain(Object *ob, bPoseChannel *pchan_tip, bConstraint *co if (tree == nullptr) { /* make new tree */ - tree = (PoseTree *)MEM_callocN(sizeof(PoseTree), "posetree"); + tree = MEM_cnew("posetree"); tree->iterations = data->iterations; tree->totchannel = segcount; diff --git a/source/blender/imbuf/intern/openexr/openexr_api.cpp b/source/blender/imbuf/intern/openexr/openexr_api.cpp index e1b9853ac21..ec8cf36dd49 100644 --- a/source/blender/imbuf/intern/openexr/openexr_api.cpp +++ b/source/blender/imbuf/intern/openexr/openexr_api.cpp @@ -683,7 +683,7 @@ static bool imb_exr_multilayer_parse_channels_from_file(ExrHandle *data); void *IMB_exr_get_handle(void) { - ExrHandle *data = (ExrHandle *)MEM_callocN(sizeof(ExrHandle), "exr handle"); + ExrHandle *data = MEM_cnew("exr handle"); data->multiView = new StringVector(); BLI_addtail(&exrhandles, data); @@ -789,7 +789,7 @@ void IMB_exr_add_channel(void *handle, ExrHandle *data = (ExrHandle *)handle; ExrChannel *echan; - echan = (ExrChannel *)MEM_callocN(sizeof(ExrChannel), "exr channel"); + echan = MEM_cnew("exr channel"); echan->m = new MultiViewChannelName(); 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)); if (lay == nullptr) { - lay = (ExrLayer *)MEM_callocN(sizeof(ExrLayer), "exr layer"); + lay = MEM_cnew("exr layer"); BLI_addtail(lb, lay); 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)); if (pass == nullptr) { - pass = (ExrPass *)MEM_callocN(sizeof(ExrPass), "exr pass"); + pass = MEM_cnew("exr pass"); if (STREQ(passname, "Combined")) { BLI_addhead(lb, pass); diff --git a/source/blender/io/collada/AnimationImporter.cpp b/source/blender/io/collada/AnimationImporter.cpp index 870db4a15d3..49a4b22dbc3 100644 --- a/source/blender/io/collada/AnimationImporter.cpp +++ b/source/blender/io/collada/AnimationImporter.cpp @@ -237,7 +237,7 @@ void AnimationImporter::add_fcurves_to_object(Main *bmain, /* no matching groups, so add one */ if (grp == nullptr) { /* Add a new group, and make it active */ - grp = (bActionGroup *)MEM_callocN(sizeof(bActionGroup), "bActionGroup"); + grp = MEM_cnew("bActionGroup"); grp->flag = AGRP_SELECTED; 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 */ if (grp == nullptr) { /* Add a new group, and make it active */ - grp = (bActionGroup *)MEM_callocN(sizeof(bActionGroup), "bActionGroup"); + grp = MEM_cnew("bActionGroup"); grp->flag = AGRP_SELECTED; BLI_strncpy(grp->name, bone_name, sizeof(grp->name)); diff --git a/source/blender/io/gpencil/intern/gpencil_io_export_pdf.cc b/source/blender/io/gpencil/intern/gpencil_io_export_pdf.cc index 7539fba1343..c856e60c4b8 100644 --- a/source/blender/io/gpencil/intern/gpencil_io_export_pdf.cc +++ b/source/blender/io/gpencil/intern/gpencil_io_export_pdf.cc @@ -238,7 +238,7 @@ void GpencilExporterPDF::export_stroke_to_polyline(bGPDlayer *gpl, /* Get the thickness in pixels using a simple 1 point stroke. */ bGPDstroke *gps_temp = BKE_gpencil_stroke_duplicate(gps, false, false); gps_temp->totpoints = 1; - gps_temp->points = (bGPDspoint *)MEM_callocN(sizeof(bGPDspoint), "gp_stroke_points"); + gps_temp->points = MEM_cnew("gp_stroke_points"); const bGPDspoint *pt_src = &gps->points[0]; bGPDspoint *pt_dst = &gps_temp->points[0]; copy_v3_v3(&pt_dst->x, &pt_src->x); diff --git a/source/blender/io/gpencil/intern/gpencil_io_export_svg.cc b/source/blender/io/gpencil/intern/gpencil_io_export_svg.cc index 09eac7a2813..3ca6ed6cd45 100644 --- a/source/blender/io/gpencil/intern/gpencil_io_export_svg.cc +++ b/source/blender/io/gpencil/intern/gpencil_io_export_svg.cc @@ -308,7 +308,7 @@ void GpencilExporterSVG::export_stroke_to_polyline(bGPDlayer *gpl, /* Get the thickness in pixels using a simple 1 point stroke. */ bGPDstroke *gps_temp = BKE_gpencil_stroke_duplicate(gps, false, false); gps_temp->totpoints = 1; - gps_temp->points = (bGPDspoint *)MEM_callocN(sizeof(bGPDspoint), "gp_stroke_points"); + gps_temp->points = MEM_cnew("gp_stroke_points"); bGPDspoint *pt_src = &gps->points[0]; bGPDspoint *pt_dst = &gps_temp->points[0]; copy_v3_v3(&pt_dst->x, &pt_src->x); diff --git a/source/blender/nodes/intern/node_common.cc b/source/blender/nodes/intern/node_common.cc index a1fccc401a4..05b85ca7fdc 100644 --- a/source/blender/nodes/intern/node_common.cc +++ b/source/blender/nodes/intern/node_common.cc @@ -224,7 +224,7 @@ void node_group_update(struct bNodeTree *ntree, struct 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("frame node storage"); node->storage = data; 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) { /* 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("frame node type"); ntype->free_self = (void (*)(bNodeType *))MEM_freeN; 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) { /* 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("frame node type"); ntype->free_self = (void (*)(bNodeType *))MEM_freeN; 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) { - bNodeLink *tlink = (bNodeLink *)MEM_callocN(sizeof(bNodeLink), "temporary link"); + bNodeLink *tlink = MEM_cnew("temporary link"); *tlink = *link; BLI_addtail(&tmplinks, tlink); @@ -505,7 +505,7 @@ void node_group_input_update(bNodeTree *ntree, bNode *node) void register_node_type_group_input(void) { /* used for all tree types, needs dynamic allocation */ - bNodeType *ntype = (bNodeType *)MEM_callocN(sizeof(bNodeType), "node type"); + bNodeType *ntype = MEM_cnew("node type"); ntype->free_self = (void (*)(bNodeType *))MEM_freeN; 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) { - bNodeLink *tlink = (bNodeLink *)MEM_callocN(sizeof(bNodeLink), "temporary link"); + bNodeLink *tlink = MEM_cnew("temporary link"); *tlink = *link; BLI_addtail(&tmplinks, tlink); @@ -603,7 +603,7 @@ void node_group_output_update(bNodeTree *ntree, bNode *node) void register_node_type_group_output(void) { /* used for all tree types, needs dynamic allocation */ - bNodeType *ntype = (bNodeType *)MEM_callocN(sizeof(bNodeType), "node type"); + bNodeType *ntype = MEM_cnew("node type"); ntype->free_self = (void (*)(bNodeType *))MEM_freeN; node_type_base(ntype, NODE_GROUP_OUTPUT, "Group Output", NODE_CLASS_INTERFACE, 0); diff --git a/source/blender/nodes/intern/node_exec.cc b/source/blender/nodes/intern/node_exec.cc index f5b64f8499c..4ff662036c3 100644 --- a/source/blender/nodes/intern/node_exec.cc +++ b/source/blender/nodes/intern/node_exec.cc @@ -177,7 +177,7 @@ bNodeTreeExec *ntree_exec_begin(bNodeExecContext *context, ntreeGetDependencyList(ntree, &nodelist, &totnodes); /* XXX could let callbacks do this for specialized data */ - exec = (bNodeTreeExec *)MEM_callocN(sizeof(bNodeTreeExec), "node tree execution data"); + exec = MEM_cnew("node tree execution data"); /* backpointer to node tree */ exec->nodetree = ntree; @@ -292,7 +292,7 @@ bNodeThreadStack *ntreeGetThreadStack(bNodeTreeExec *exec, int thread) } if (!nts) { - nts = (bNodeThreadStack *)MEM_callocN(sizeof(bNodeThreadStack), "bNodeThreadStack"); + nts = MEM_cnew("bNodeThreadStack"); nts->stack = (bNodeStack *)MEM_dupallocN(exec->stack); nts->used = true; BLI_addtail(lb, nts); diff --git a/source/blender/nodes/intern/node_socket.cc b/source/blender/nodes/intern/node_socket.cc index 46cb9dcf891..8e2d7e7ebe9 100644 --- a/source/blender/nodes/intern/node_socket.cc +++ b/source/blender/nodes/intern/node_socket.cc @@ -309,8 +309,7 @@ void node_socket_init_default_value(bNodeSocket *sock) switch (type) { case SOCK_FLOAT: { - bNodeSocketValueFloat *dval = (bNodeSocketValueFloat *)MEM_callocN( - sizeof(bNodeSocketValueFloat), "node socket value float"); + bNodeSocketValueFloat *dval = MEM_cnew("node socket value float"); dval->subtype = subtype; dval->value = 0.0f; dval->min = -FLT_MAX; @@ -320,8 +319,7 @@ void node_socket_init_default_value(bNodeSocket *sock) break; } case SOCK_INT: { - bNodeSocketValueInt *dval = (bNodeSocketValueInt *)MEM_callocN(sizeof(bNodeSocketValueInt), - "node socket value int"); + bNodeSocketValueInt *dval = MEM_cnew("node socket value int"); dval->subtype = subtype; dval->value = 0; dval->min = INT_MIN; @@ -331,8 +329,7 @@ void node_socket_init_default_value(bNodeSocket *sock) break; } case SOCK_BOOLEAN: { - bNodeSocketValueBoolean *dval = (bNodeSocketValueBoolean *)MEM_callocN( - sizeof(bNodeSocketValueBoolean), "node socket value bool"); + bNodeSocketValueBoolean *dval = MEM_cnew("node socket value bool"); dval->value = false; sock->default_value = dval; @@ -340,8 +337,7 @@ void node_socket_init_default_value(bNodeSocket *sock) } case SOCK_VECTOR: { static float default_value[] = {0.0f, 0.0f, 0.0f}; - bNodeSocketValueVector *dval = (bNodeSocketValueVector *)MEM_callocN( - sizeof(bNodeSocketValueVector), "node socket value vector"); + bNodeSocketValueVector *dval = MEM_cnew("node socket value vector"); dval->subtype = subtype; copy_v3_v3(dval->value, default_value); dval->min = -FLT_MAX; @@ -352,16 +348,14 @@ void node_socket_init_default_value(bNodeSocket *sock) } case SOCK_RGBA: { static float default_value[] = {0.0f, 0.0f, 0.0f, 1.0f}; - bNodeSocketValueRGBA *dval = (bNodeSocketValueRGBA *)MEM_callocN( - sizeof(bNodeSocketValueRGBA), "node socket value color"); + bNodeSocketValueRGBA *dval = MEM_cnew("node socket value color"); copy_v4_v4(dval->value, default_value); sock->default_value = dval; break; } case SOCK_STRING: { - bNodeSocketValueString *dval = (bNodeSocketValueString *)MEM_callocN( - sizeof(bNodeSocketValueString), "node socket value string"); + bNodeSocketValueString *dval = MEM_cnew("node socket value string"); dval->subtype = subtype; dval->value[0] = '\0'; @@ -369,40 +363,38 @@ void node_socket_init_default_value(bNodeSocket *sock) break; } case SOCK_OBJECT: { - bNodeSocketValueObject *dval = (bNodeSocketValueObject *)MEM_callocN( - sizeof(bNodeSocketValueObject), "node socket value object"); + bNodeSocketValueObject *dval = MEM_cnew("node socket value object"); dval->value = nullptr; sock->default_value = dval; break; } case SOCK_IMAGE: { - bNodeSocketValueImage *dval = (bNodeSocketValueImage *)MEM_callocN( - sizeof(bNodeSocketValueImage), "node socket value image"); + bNodeSocketValueImage *dval = MEM_cnew("node socket value image"); dval->value = nullptr; sock->default_value = dval; break; } case SOCK_COLLECTION: { - bNodeSocketValueCollection *dval = (bNodeSocketValueCollection *)MEM_callocN( - sizeof(bNodeSocketValueCollection), "node socket value object"); + bNodeSocketValueCollection *dval = MEM_cnew( + "node socket value object"); dval->value = nullptr; sock->default_value = dval; break; } case SOCK_TEXTURE: { - bNodeSocketValueTexture *dval = (bNodeSocketValueTexture *)MEM_callocN( - sizeof(bNodeSocketValueTexture), "node socket value texture"); + bNodeSocketValueTexture *dval = MEM_cnew( + "node socket value texture"); dval->value = nullptr; sock->default_value = dval; break; } case SOCK_MATERIAL: { - bNodeSocketValueMaterial *dval = (bNodeSocketValueMaterial *)MEM_callocN( - sizeof(bNodeSocketValueMaterial), "node socket value material"); + bNodeSocketValueMaterial *dval = MEM_cnew( + "node socket value material"); dval->value = nullptr; sock->default_value = dval; @@ -637,7 +629,7 @@ static bNodeSocketType *make_standard_socket_type(int type, int subtype) bNodeSocketType *stype; StructRNA *srna; - stype = (bNodeSocketType *)MEM_callocN(sizeof(bNodeSocketType), "node socket C type"); + stype = MEM_cnew("node socket C type"); stype->free_self = (void (*)(bNodeSocketType * stype)) MEM_freeN; BLI_strncpy(stype->idname, socket_idname, sizeof(stype->idname)); BLI_strncpy(stype->label, socket_label, sizeof(stype->label)); @@ -681,7 +673,7 @@ static bNodeSocketType *make_socket_type_virtual() bNodeSocketType *stype; StructRNA *srna; - stype = (bNodeSocketType *)MEM_callocN(sizeof(bNodeSocketType), "node socket C type"); + stype = MEM_cnew("node socket C type"); stype->free_self = (void (*)(bNodeSocketType * stype)) MEM_freeN; BLI_strncpy(stype->idname, socket_idname, sizeof(stype->idname)); diff --git a/source/blender/simulation/intern/SIM_mass_spring.cpp b/source/blender/simulation/intern/SIM_mass_spring.cpp index f9a22276363..36513690584 100644 --- a/source/blender/simulation/intern/SIM_mass_spring.cpp +++ b/source/blender/simulation/intern/SIM_mass_spring.cpp @@ -1295,8 +1295,7 @@ int SIM_cloth_solve( BKE_sim_debug_data_clear_category("collision"); if (!clmd->solver_result) { - clmd->solver_result = (ClothSolverResult *)MEM_callocN(sizeof(ClothSolverResult), - "cloth solver result"); + clmd->solver_result = MEM_cnew("cloth solver result"); } cloth_clear_result(clmd); diff --git a/source/blender/simulation/intern/hair_volume.cpp b/source/blender/simulation/intern/hair_volume.cpp index e47593eda05..d4550eec5d6 100644 --- a/source/blender/simulation/intern/hair_volume.cpp +++ b/source/blender/simulation/intern/hair_volume.cpp @@ -1160,7 +1160,7 @@ HairGrid *SIM_hair_volume_create_vertex_grid(float cellsize, } size = hair_grid_size(res); - grid = (HairGrid *)MEM_callocN(sizeof(HairGrid), "hair grid"); + grid = MEM_cnew("hair grid"); grid->res[0] = res[0]; grid->res[1] = res[1]; grid->res[2] = res[2];