Cleanup: replace unnecessary MEM_callocN calls
Use MEM_mallocN when memory is immediately copied over.
This commit is contained in:
parent
a5c4a44df6
commit
a297a6c444
|
@ -3031,7 +3031,7 @@ void BKE_curve_bevelList_make(Object *ob, ListBase *nurbs, bool for_render)
|
||||||
blnext = bl->next;
|
blnext = bl->next;
|
||||||
if (bl->nr && bl->dupe_nr) {
|
if (bl->nr && bl->dupe_nr) {
|
||||||
nr = bl->nr - bl->dupe_nr + 1; /* +1 because vectorbezier sets flag too */
|
nr = bl->nr - bl->dupe_nr + 1; /* +1 because vectorbezier sets flag too */
|
||||||
blnew = MEM_callocN(sizeof(BevList), "makeBevelList4");
|
blnew = MEM_mallocN(sizeof(BevList), "makeBevelList4");
|
||||||
memcpy(blnew, bl, sizeof(BevList));
|
memcpy(blnew, bl, sizeof(BevList));
|
||||||
blnew->bevpoints = MEM_calloc_arrayN(nr, sizeof(BevPoint), "makeBevelPoints4");
|
blnew->bevpoints = MEM_calloc_arrayN(nr, sizeof(BevPoint), "makeBevelPoints4");
|
||||||
if (!blnew->bevpoints) {
|
if (!blnew->bevpoints) {
|
||||||
|
|
|
@ -121,7 +121,7 @@ void BKE_report(ReportList *reports, ReportType type, const char *_message)
|
||||||
report->typestr = BKE_report_type_str(type);
|
report->typestr = BKE_report_type_str(type);
|
||||||
|
|
||||||
len = strlen(message);
|
len = strlen(message);
|
||||||
message_alloc = MEM_callocN(sizeof(char) * (len + 1), "ReportMessage");
|
message_alloc = MEM_mallocN(sizeof(char) * (len + 1), "ReportMessage");
|
||||||
memcpy(message_alloc, message, sizeof(char) * (len + 1));
|
memcpy(message_alloc, message, sizeof(char) * (len + 1));
|
||||||
report->message = message_alloc;
|
report->message = message_alloc;
|
||||||
report->len = len;
|
report->len = len;
|
||||||
|
|
|
@ -899,7 +899,7 @@ void BKE_tracking_tracks_join(MovieTracking *tracking,
|
||||||
|
|
||||||
MEM_freeN(dst_track->markers);
|
MEM_freeN(dst_track->markers);
|
||||||
|
|
||||||
dst_track->markers = MEM_callocN(i * sizeof(MovieTrackingMarker), "tracking joined tracks");
|
dst_track->markers = MEM_mallocN(i * sizeof(MovieTrackingMarker), "tracking joined tracks");
|
||||||
memcpy(dst_track->markers, markers, i * sizeof(MovieTrackingMarker));
|
memcpy(dst_track->markers, markers, i * sizeof(MovieTrackingMarker));
|
||||||
|
|
||||||
dst_track->markersnr = i;
|
dst_track->markersnr = i;
|
||||||
|
|
|
@ -243,7 +243,7 @@ static bool reconstruct_retrieve_libmv_tracks(MovieReconstructContext *context,
|
||||||
|
|
||||||
if (reconstruction->camnr) {
|
if (reconstruction->camnr) {
|
||||||
int size = reconstruction->camnr * sizeof(MovieReconstructedCamera);
|
int size = reconstruction->camnr * sizeof(MovieReconstructedCamera);
|
||||||
reconstruction->cameras = MEM_callocN(size, "reconstructed camera");
|
reconstruction->cameras = MEM_mallocN(size, "reconstructed camera");
|
||||||
memcpy(reconstruction->cameras, reconstructed, size);
|
memcpy(reconstruction->cameras, reconstructed, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -677,12 +677,12 @@ static void gp_duplicate_points(const bGPDstroke *gps,
|
||||||
gpsd->tot_triangles = 0;
|
gpsd->tot_triangles = 0;
|
||||||
|
|
||||||
/* now, make a new points array, and copy of the relevant parts */
|
/* now, make a new points array, and copy of the relevant parts */
|
||||||
gpsd->points = MEM_callocN(sizeof(bGPDspoint) * len, "gps stroke points copy");
|
gpsd->points = MEM_mallocN(sizeof(bGPDspoint) * len, "gps stroke points copy");
|
||||||
memcpy(gpsd->points, gps->points + start_idx, sizeof(bGPDspoint) * len);
|
memcpy(gpsd->points, gps->points + start_idx, sizeof(bGPDspoint) * len);
|
||||||
gpsd->totpoints = len;
|
gpsd->totpoints = len;
|
||||||
|
|
||||||
if (gps->dvert != NULL) {
|
if (gps->dvert != NULL) {
|
||||||
gpsd->dvert = MEM_callocN(sizeof(MDeformVert) * len, "gps stroke weights copy");
|
gpsd->dvert = MEM_mallocN(sizeof(MDeformVert) * len, "gps stroke weights copy");
|
||||||
memcpy(gpsd->dvert, gps->dvert + start_idx, sizeof(MDeformVert) * len);
|
memcpy(gpsd->dvert, gps->dvert + start_idx, sizeof(MDeformVert) * len);
|
||||||
|
|
||||||
/* Copy weights */
|
/* Copy weights */
|
||||||
|
|
|
@ -430,7 +430,7 @@ int join_mesh_exec(bContext *C, wmOperator *op)
|
||||||
for (dg = ob_iter->defbase.first; dg; dg = dg->next) {
|
for (dg = ob_iter->defbase.first; dg; dg = dg->next) {
|
||||||
/* See if this group exists in the object (if it doesn't, add it to the end) */
|
/* See if this group exists in the object (if it doesn't, add it to the end) */
|
||||||
if (!defgroup_find_name(ob, dg->name)) {
|
if (!defgroup_find_name(ob, dg->name)) {
|
||||||
odg = MEM_callocN(sizeof(bDeformGroup), "join deformGroup");
|
odg = MEM_mallocN(sizeof(bDeformGroup), "join deformGroup");
|
||||||
memcpy(odg, dg, sizeof(bDeformGroup));
|
memcpy(odg, dg, sizeof(bDeformGroup));
|
||||||
BLI_addtail(&ob->defbase, odg);
|
BLI_addtail(&ob->defbase, odg);
|
||||||
}
|
}
|
||||||
|
@ -443,7 +443,7 @@ int join_mesh_exec(bContext *C, wmOperator *op)
|
||||||
for (bFaceMap *fmap = ob_iter->fmaps.first; fmap; fmap = fmap->next) {
|
for (bFaceMap *fmap = ob_iter->fmaps.first; fmap; fmap = fmap->next) {
|
||||||
/* See if this group exists in the object (if it doesn't, add it to the end) */
|
/* See if this group exists in the object (if it doesn't, add it to the end) */
|
||||||
if (BKE_object_facemap_find_name(ob, fmap->name) == NULL) {
|
if (BKE_object_facemap_find_name(ob, fmap->name) == NULL) {
|
||||||
bFaceMap *fmap_new = MEM_callocN(sizeof(bFaceMap), "join faceMap");
|
bFaceMap *fmap_new = MEM_mallocN(sizeof(bFaceMap), "join faceMap");
|
||||||
memcpy(fmap_new, fmap, sizeof(bFaceMap));
|
memcpy(fmap_new, fmap, sizeof(bFaceMap));
|
||||||
BLI_addtail(&ob->fmaps, fmap_new);
|
BLI_addtail(&ob->fmaps, fmap_new);
|
||||||
}
|
}
|
||||||
|
|
|
@ -332,7 +332,7 @@ static StructRNA *rna_KeyingSetInfo_register(Main *bmain,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* create a new KeyingSetInfo type */
|
/* create a new KeyingSetInfo type */
|
||||||
ksi = MEM_callocN(sizeof(KeyingSetInfo), "python keying set info");
|
ksi = MEM_mallocN(sizeof(KeyingSetInfo), "python keying set info");
|
||||||
memcpy(ksi, &dummyksi, sizeof(KeyingSetInfo));
|
memcpy(ksi, &dummyksi, sizeof(KeyingSetInfo));
|
||||||
|
|
||||||
/* set RNA-extensions info */
|
/* set RNA-extensions info */
|
||||||
|
|
|
@ -816,7 +816,7 @@ static StructRNA *rna_NodeTree_register(Main *bmain,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* create a new node tree type */
|
/* create a new node tree type */
|
||||||
nt = MEM_callocN(sizeof(bNodeTreeType), "node tree type");
|
nt = MEM_mallocN(sizeof(bNodeTreeType), "node tree type");
|
||||||
memcpy(nt, &dummynt, sizeof(dummynt));
|
memcpy(nt, &dummynt, sizeof(dummynt));
|
||||||
|
|
||||||
nt->type = NTREE_CUSTOM;
|
nt->type = NTREE_CUSTOM;
|
||||||
|
@ -1650,7 +1650,7 @@ static bNodeType *rna_Node_register_base(Main *bmain,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* create a new node type */
|
/* create a new node type */
|
||||||
nt = MEM_callocN(sizeof(bNodeType), "node type");
|
nt = MEM_mallocN(sizeof(bNodeType), "node type");
|
||||||
memcpy(nt, &dummynt, sizeof(dummynt));
|
memcpy(nt, &dummynt, sizeof(dummynt));
|
||||||
nt->free_self = (void (*)(bNodeType *))MEM_freeN;
|
nt->free_self = (void (*)(bNodeType *))MEM_freeN;
|
||||||
|
|
||||||
|
@ -2178,7 +2178,7 @@ static StructRNA *rna_NodeSocket_register(Main *UNUSED(bmain),
|
||||||
st = nodeSocketTypeFind(dummyst.idname);
|
st = nodeSocketTypeFind(dummyst.idname);
|
||||||
if (!st) {
|
if (!st) {
|
||||||
/* create a new node socket type */
|
/* create a new node socket type */
|
||||||
st = MEM_callocN(sizeof(bNodeSocketType), "node socket type");
|
st = MEM_mallocN(sizeof(bNodeSocketType), "node socket type");
|
||||||
memcpy(st, &dummyst, sizeof(dummyst));
|
memcpy(st, &dummyst, sizeof(dummyst));
|
||||||
|
|
||||||
nodeRegisterSocketType(st);
|
nodeRegisterSocketType(st);
|
||||||
|
@ -2494,7 +2494,7 @@ static StructRNA *rna_NodeSocketInterface_register(Main *UNUSED(bmain),
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* create a new node socket type */
|
/* create a new node socket type */
|
||||||
st = MEM_callocN(sizeof(bNodeSocketType), "node socket type");
|
st = MEM_mallocN(sizeof(bNodeSocketType), "node socket type");
|
||||||
memcpy(st, &dummyst, sizeof(dummyst));
|
memcpy(st, &dummyst, sizeof(dummyst));
|
||||||
|
|
||||||
nodeRegisterSocketType(st);
|
nodeRegisterSocketType(st);
|
||||||
|
|
|
@ -351,7 +351,7 @@ static StructRNA *rna_RenderEngine_register(Main *bmain,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* create a new engine type */
|
/* create a new engine type */
|
||||||
et = MEM_callocN(sizeof(RenderEngineType), "python render engine");
|
et = MEM_mallocN(sizeof(RenderEngineType), "python render engine");
|
||||||
memcpy(et, &dummyet, sizeof(dummyet));
|
memcpy(et, &dummyet, sizeof(dummyet));
|
||||||
|
|
||||||
et->ext.srna = RNA_def_struct_ptr(&BLENDER_RNA, et->idname, &RNA_RenderEngine);
|
et->ext.srna = RNA_def_struct_ptr(&BLENDER_RNA, et->idname, &RNA_RenderEngine);
|
||||||
|
|
|
@ -341,7 +341,7 @@ static StructRNA *rna_Panel_register(Main *bmain,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* create a new panel type */
|
/* create a new panel type */
|
||||||
pt = MEM_callocN(sizeof(PanelType), "python buttons panel");
|
pt = MEM_mallocN(sizeof(PanelType), "python buttons panel");
|
||||||
memcpy(pt, &dummypt, sizeof(dummypt));
|
memcpy(pt, &dummypt, sizeof(dummypt));
|
||||||
|
|
||||||
pt->ext.srna = RNA_def_struct_ptr(&BLENDER_RNA, pt->idname, &RNA_Panel);
|
pt->ext.srna = RNA_def_struct_ptr(&BLENDER_RNA, pt->idname, &RNA_Panel);
|
||||||
|
@ -775,7 +775,7 @@ static StructRNA *rna_Header_register(Main *bmain,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* create a new header type */
|
/* create a new header type */
|
||||||
ht = MEM_callocN(sizeof(HeaderType), "python buttons header");
|
ht = MEM_mallocN(sizeof(HeaderType), "python buttons header");
|
||||||
memcpy(ht, &dummyht, sizeof(dummyht));
|
memcpy(ht, &dummyht, sizeof(dummyht));
|
||||||
|
|
||||||
ht->ext.srna = RNA_def_struct_ptr(&BLENDER_RNA, ht->idname, &RNA_Header);
|
ht->ext.srna = RNA_def_struct_ptr(&BLENDER_RNA, ht->idname, &RNA_Header);
|
||||||
|
|
Loading…
Reference in New Issue