Code cleanup: no need to use calloc when memory is initialized after
also replace AT with __func__ since AT expands the full pathname
This commit is contained in:
parent
2bba04f1b0
commit
45b02cee47
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue