[Bf-blender-cvs] [6e0cf86e73f] master: Cleanup: use new c++ guarded allocator API

Aaron Carlisle noreply at git.blender.org
Sat Dec 25 04:19:13 CET 2021


Commit: 6e0cf86e73fedebb1615dde664fbac4859a72b60
Author: Aaron Carlisle
Date:   Fri Dec 24 22:17:49 2021 -0500
Branches: master
https://developer.blender.org/rB6e0cf86e73fedebb1615dde664fbac4859a72b60

Cleanup: use new c++ guarded allocator API

API added in rBa3ad5abf2fe85d623f9e78fefc34e27bdc14632e

===================================================================

M	intern/opencolorio/fallback_impl.cc
M	source/blender/blenkernel/intern/bvhutils.cc
M	source/blender/blenkernel/intern/cryptomatte.cc
M	source/blender/blenkernel/intern/curve.cc
M	source/blender/blenkernel/intern/displist.cc
M	source/blender/blenkernel/intern/gpencil_geom.cc
M	source/blender/blenkernel/intern/image_gpu.cc
M	source/blender/blenkernel/intern/mesh_convert.cc
M	source/blender/blenkernel/intern/node.cc
M	source/blender/blenkernel/intern/node_tree_update.cc
M	source/blender/blenkernel/intern/object.cc
M	source/blender/blenkernel/intern/object_dupli.cc
M	source/blender/blenkernel/intern/volume.cc
M	source/blender/blenlib/tests/BLI_task_test.cc
M	source/blender/compositor/operations/COM_KeyingScreenOperation.cc
M	source/blender/editors/interface/interface_region_search.cc
M	source/blender/editors/object/object_remesh.cc
M	source/blender/editors/space_node/node_add.cc
M	source/blender/editors/space_node/node_edit.cc
M	source/blender/editors/space_node/node_relationships.cc
M	source/blender/editors/space_node/node_templates.cc
M	source/blender/editors/space_node/node_view.cc
M	source/blender/editors/space_node/space_node.cc
M	source/blender/editors/space_spreadsheet/space_spreadsheet.cc
M	source/blender/editors/space_spreadsheet/spreadsheet_column.cc
M	source/blender/editors/space_spreadsheet/spreadsheet_context.cc
M	source/blender/editors/space_spreadsheet/spreadsheet_panels.cc
M	source/blender/editors/space_spreadsheet/spreadsheet_row_filter.cc
M	source/blender/editors/space_spreadsheet/spreadsheet_row_filter_ui.cc
M	source/blender/gpu/intern/gpu_framebuffer.cc
M	source/blender/ikplugin/intern/itasc_plugin.cpp
M	source/blender/imbuf/intern/openexr/openexr_api.cpp
M	source/blender/io/collada/AnimationImporter.cpp
M	source/blender/io/gpencil/intern/gpencil_io_export_pdf.cc
M	source/blender/io/gpencil/intern/gpencil_io_export_svg.cc
M	source/blender/nodes/intern/node_common.cc
M	source/blender/nodes/intern/node_exec.cc
M	source/blender/nodes/intern/node_socket.cc
M	source/blender/simulation/intern/SIM_mass_spring.cpp
M	source/blender/simulation/intern/hair_volume.cpp

===================================================================

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>(
+      "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<BVHCache>(__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<CryptomatteEntry>(__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<CryptomatteEntry>(__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<BevList>(__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<BevList>(__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<BevList>(__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<DispList>(__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<DispList>(__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<DispList>(__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<DispList>(__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<DispList>(__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<DispList>(__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<CurveCache>(__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<DispList>(__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<DispList>(__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<DispList>(__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<DispList>("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<DispList>(__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 = nullp

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list