Code cleanup: no need to use calloc when memory is initialized after
authorCampbell Barton <ideasman42@gmail.com>
Fri, 4 Apr 2014 03:26:01 +0000 (14:26 +1100)
committerCampbell Barton <ideasman42@gmail.com>
Fri, 4 Apr 2014 03:26:01 +0000 (14:26 +1100)
also replace AT with __func__ since AT expands the full pathname

source/blender/blenkernel/intern/DerivedMesh.c
source/blender/blenkernel/intern/cdderivedmesh.c
source/blender/blenkernel/intern/multires.c
source/blender/blenkernel/intern/navmesh_conversion.c
source/blender/blenkernel/intern/particle_system.c
source/blender/blenkernel/intern/pbvh_bmesh.c
source/blender/bmesh/intern/bmesh_log.c
source/blender/editors/sculpt_paint/sculpt_undo.c
source/blender/makesrna/intern/rna_access.c
source/blender/modifiers/intern/MOD_meshdeform.c
source/blender/modifiers/intern/MOD_uvproject.c

index 4e9df194f4050d9b378681240e123ffb7b9b0be3..1a9ca234f8d056feca65dfc4703026b1f29bd19b 100644 (file)
@@ -970,7 +970,7 @@ static void add_orco_dm(Object *ob, BMEditMesh *em, DerivedMesh *dm,
        totvert = dm->getNumVerts(dm);
 
        if (orcodm) {
-               orco = MEM_callocN(sizeof(float) * 3 * totvert, "dm orco");
+               orco = MEM_callocN(sizeof(float[3]) * totvert, "dm orco");
                free = 1;
 
                if (orcodm->getNumVerts(orcodm) == totvert)
index b38e0e0527afd3d922d4811a21d9fd35c2144101..32a008c3d3378ba2618706f3f7871d2b8592570b 100644 (file)
@@ -301,7 +301,7 @@ static PBVH *cdDM_getPBVH(Object *ob, DerivedMesh *dm)
                        int totvert;
 
                        totvert = deformdm->getNumVerts(deformdm);
-                       vertCos = MEM_callocN(3 * totvert * sizeof(float), "cdDM_getPBVH vertCos");
+                       vertCos = MEM_mallocN(totvert * sizeof(float[3]), "cdDM_getPBVH vertCos");
                        deformdm->getVertCos(deformdm, vertCos);
                        BKE_pbvh_apply_vertCos(cddm->pbvh, vertCos);
                        MEM_freeN(vertCos);
index b6c87f286f0e9ac68577a2db99afd5c8a2c99555..3d8e35699a98ae937d5788fc6c815fad03907dee 100644 (file)
@@ -439,7 +439,7 @@ int multiresModifier_reshapeFromDeformMod(Scene *scene, MultiresModifierData *mm
        /* Create DerivedMesh for deformation modifier */
        dm = get_multires_dm(scene, mmd, ob);
        numVerts = dm->getNumVerts(dm);
-       deformedVerts = MEM_callocN(sizeof(float) * numVerts * 3, "multiresReshape_deformVerts");
+       deformedVerts = MEM_mallocN(sizeof(float[3]) * numVerts, "multiresReshape_deformVerts");
 
        dm->getVertCos(dm, deformedVerts);
        mti->deformVerts(md, ob, dm, deformedVerts, numVerts, 0);
index 28ef1180f53486fc5e3b4ea4442cb62ae2db3c6f..64d59b165e1b7bc7f5e88fc0eaca7739f312f8a2 100644 (file)
@@ -123,7 +123,7 @@ int buildRawVertIndicesData(DerivedMesh *dm, int *nverts_r, float **verts_r,
                printf("Converting navmesh: Error! Too many vertices. Max number of vertices %d\n", 0xffff);
                return 0;
        }
-       verts = MEM_callocN(sizeof(float) * 3 * nverts, "buildRawVertIndicesData verts");
+       verts = MEM_mallocN(sizeof(float[3]) * nverts, "buildRawVertIndicesData verts");
        dm->getVertCos(dm, (float(*)[3])verts);
 
        /* flip coordinates */
index c991cdd90fd2c96af6aa96985b5925ca6ac10d8e..846ab10412ed894508093c41ec2c5203d60abe8e 100644 (file)
@@ -4086,7 +4086,7 @@ static void do_hair_dynamics(ParticleSimulationData *sim)
        psys->clmd->point_cache = psys->pointcache;
        psys->clmd->sim_parms->effector_weights = psys->part->effector_weights;
 
-       deformedVerts = MEM_callocN(sizeof(*deformedVerts)*dm->getNumVerts(dm), "do_hair_dynamics vertexCos");
+       deformedVerts = MEM_mallocN(sizeof(*deformedVerts) * dm->getNumVerts(dm), "do_hair_dynamics vertexCos");
        psys->hair_out_dm = CDDM_copy(dm);
        psys->hair_out_dm->getVertCos(psys->hair_out_dm, deformedVerts);
 
index 1c265392523a67d3e3b094d4830d72d36ba66357..026cec31a4e425ffe59d7217271408a328be4f22 100644 (file)
@@ -1247,8 +1247,8 @@ void BKE_pbvh_bmesh_node_save_orig(PBVHNode *node)
 
        tottri = BLI_ghash_size(node->bm_faces);
 
-       node->bm_orco = MEM_mallocN(sizeof(*node->bm_orco) * totvert, AT);
-       node->bm_ortri = MEM_mallocN(sizeof(*node->bm_ortri) * tottri, AT);
+       node->bm_orco = MEM_mallocN(sizeof(*node->bm_orco) * totvert, __func__);
+       node->bm_ortri = MEM_mallocN(sizeof(*node->bm_ortri) * tottri, __func__);
 
        /* Copy out the vertices and assign a temporary index */
        i = 0;
index 10912506692be8b279113d7d57317ad3d7c60dd0..dc8e85bc606747d7360adeef4c14bcf76f088ffe 100644 (file)
@@ -365,13 +365,13 @@ static void bm_log_assign_ids(BMesh *bm, BMLog *log)
 /* Allocate an empty log entry */
 static BMLogEntry *bm_log_entry_create(void)
 {
-       BMLogEntry *entry = MEM_callocN(sizeof(BMLogEntry), AT);
+       BMLogEntry *entry = MEM_callocN(sizeof(BMLogEntry), __func__);
 
-       entry->deleted_verts = BLI_ghash_ptr_new(AT);
-       entry->deleted_faces = BLI_ghash_ptr_new(AT);
-       entry->added_verts = BLI_ghash_ptr_new(AT);
-       entry->added_faces = BLI_ghash_ptr_new(AT);
-       entry->modified_verts = BLI_ghash_ptr_new(AT);
+       entry->deleted_verts = BLI_ghash_ptr_new(__func__);
+       entry->deleted_faces = BLI_ghash_ptr_new(__func__);
+       entry->added_verts = BLI_ghash_ptr_new(__func__);
+       entry->added_faces = BLI_ghash_ptr_new(__func__);
+       entry->modified_verts = BLI_ghash_ptr_new(__func__);
 
        entry->pool_verts = BLI_mempool_create(sizeof(BMLogVert), 1, 64, 0);
        entry->pool_faces = BLI_mempool_create(sizeof(BMLogFace), 1, 64, 0);
@@ -425,7 +425,7 @@ static int uint_compare(const void *a_v, const void *b_v)
  */
 static GHash *bm_log_compress_ids_to_indices(unsigned int *ids, unsigned int totid)
 {
-       GHash *map = BLI_ghash_int_new_ex(AT, totid);
+       GHash *map = BLI_ghash_int_new_ex(__func__, totid);
        unsigned int i;
 
        qsort(ids, totid, sizeof(*ids), uint_compare);
@@ -456,11 +456,11 @@ static void bm_log_id_ghash_release(BMLog *log, GHash *id_ghash)
 /* Allocate, initialize, and assign a new BMLog */
 BMLog *BM_log_create(BMesh *bm)
 {
-       BMLog *log = MEM_callocN(sizeof(*log), AT);
+       BMLog *log = MEM_callocN(sizeof(*log), __func__);
 
        log->unused_ids = range_tree_uint_alloc(0, (unsigned)-1);
-       log->id_to_elem = BLI_ghash_ptr_new_ex(AT, (unsigned int)(bm->totvert + bm->totface));
-       log->elem_to_id = BLI_ghash_ptr_new_ex(AT, (unsigned int)(bm->totvert + bm->totface));
+       log->id_to_elem = BLI_ghash_ptr_new_ex(__func__, (unsigned int)(bm->totvert + bm->totface));
+       log->elem_to_id = BLI_ghash_ptr_new_ex(__func__, (unsigned int)(bm->totvert + bm->totface));
 
        /* Assign IDs to all existing vertices and faces */
        bm_log_assign_ids(bm, log);
@@ -558,14 +558,14 @@ void BM_log_mesh_elems_reorder(BMesh *bm, BMLog *log)
 
        /* Put all vertex IDs into an array */
        i = 0;
-       varr = MEM_mallocN(sizeof(int) * (size_t)bm->totvert, AT);
+       varr = MEM_mallocN(sizeof(int) * (size_t)bm->totvert, __func__);
        BM_ITER_MESH (v, &bm_iter, bm, BM_VERTS_OF_MESH) {
                ((unsigned int *)varr)[i++] = bm_log_vert_id_get(log, v);
        }
 
        /* Put all face IDs into an array */
        i = 0;
-       farr = MEM_mallocN(sizeof(int) * (size_t)bm->totface, AT);
+       farr = MEM_mallocN(sizeof(int) * (size_t)bm->totface, __func__);
        BM_ITER_MESH (f, &bm_iter, bm, BM_FACES_OF_MESH) {
                ((unsigned int *)farr)[i++] = bm_log_face_id_get(log, f);
        }
index 724e3ff1849872987f850a7f4bbfb0fc55997bb8..b086bff1ba787315af4eae89b7706b9d23e8118e 100644 (file)
@@ -712,7 +712,7 @@ static SculptUndoNode *sculpt_undo_bmesh_push(Object *ob,
        PBVHVertexIter vd;
 
        if (!lb->first) {
-               unode = MEM_callocN(sizeof(*unode), AT);
+               unode = MEM_callocN(sizeof(*unode), __func__);
 
                BLI_strncpy(unode->idname, ob->id.name, sizeof(unode->idname));
                unode->type = type;
index ae8280e9ec45e732db8a1232542579742ff5cc88..5e0ed7cd08b209fe06f33706702cb9ada25783fe 100644 (file)
@@ -5733,7 +5733,7 @@ void RNA_parameter_set(ParameterList *parms, PropertyRNA *parm, const void *valu
                        size *= data_alloc->array_tot;
                        if (data_alloc->array)
                                MEM_freeN(data_alloc->array);
-                       data_alloc->array = MEM_mallocN(size, AT);
+                       data_alloc->array = MEM_mallocN(size, __func__);
                        memcpy(data_alloc->array, value, size);
                }
                else {
index e8eb9c5675d3cc68d76964576e6ff0e77112c1ec..63e60d4b89840167bc332c38c89ac44603570253 100644 (file)
@@ -262,7 +262,7 @@ static void meshdeformModifier_do(
                return;
        }
 
-       cagecos = MEM_callocN(sizeof(*cagecos) * totcagevert, "meshdeformModifier vertCos");
+       cagecos = MEM_mallocN(sizeof(*cagecos) * totcagevert, "meshdeformModifier vertCos");
 
        /* setup deformation data */
        cagedm->getVertCos(cagedm, cagecos);
index 8ded9847c2a24cd62fb9f5b47396b2e48d77e869..a9c0ac9b93dfbc12590eafa8342b615280b96782 100644 (file)
@@ -232,7 +232,7 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd,
 
        numVerts = dm->getNumVerts(dm);
 
-       coords = MEM_callocN(sizeof(*coords) * numVerts,
+       coords = MEM_mallocN(sizeof(*coords) * numVerts,
                             "uvprojectModifier_do coords");
        dm->getVertCos(dm, coords);