Replaced a bunch of malloc() calls with proper MEM_mallocN()

(and free() and calloc() of course)

Remainder malloc() calls need to be there for realloc().
This commit is contained in:
Ton Roosendaal 2005-04-17 18:00:33 +00:00
parent 425f295604
commit d34acbfe44
6 changed files with 16 additions and 16 deletions

@ -2296,11 +2296,11 @@ void swapdata(void *adr1, void *adr2, int len)
else {
char *adr;
adr= (char *)malloc(len);
adr= (char *)MEM_mallocN(len, "curve swap");
memcpy(adr, adr1, len);
memcpy(adr1, adr2, len);
memcpy(adr2, adr, len);
free(adr);
MEM_freeN(adr);
}
}

@ -373,7 +373,7 @@ static void read_stl_mesh_ascii(char *str)
* i.e. 30000 verts, i.e., 90000 floats.
*/
numtenthousand = 1;
vertdata = malloc(numtenthousand*3*30000*sizeof(float));
vertdata = malloc(numtenthousand*3*30000*sizeof(float)); // uses realloc!
if (!vertdata) STLALLOCERROR;
linenum = 1;

@ -1820,14 +1820,14 @@ static void editing_panel_armature_bones(Object *ob, bArmature *arm)
uiDefBut(block, LABEL, 0, "child of", bx+107,by,73,18, NULL, 0.0, 0.0, 0.0, 0.0, "");
boneString = malloc((BLI_countlist(&G.edbo) * 64)+64);
boneString = MEM_mallocN((BLI_countlist(&G.edbo) * 64)+64, "Bone str");
build_bonestring (boneString, curBone);
curBone->parNr = editbone_to_parnr(curBone->parent);
but = uiDefButI(block, MENU,REDRAWVIEW3D, boneString, bx+180,by,120,18, &curBone->parNr, 0.0, 0.0, 0.0, 0.0, "Parent");
uiButSetFunc(but, parnr_to_editbone_cb, curBone, NULL);
free(boneString);
MEM_freeN(boneString);
/* IK to parent flag */
if (curBone->parent){

@ -249,7 +249,7 @@ static void build_pict_list(char * first)
while(IMB_ispic(name)){
file = open(name, O_BINARY|O_RDONLY, 0);
if (file < 0) return;
picture = (struct pict*)calloc(1, sizeof(struct pict));
picture = (struct pict*)MEM_callocN(sizeof(struct pict), "picture");
if (picture == 0){
printf("Not enough memory for pict struct \n");
close(file);
@ -260,19 +260,19 @@ static void build_pict_list(char * first)
picture->IB_flags = IB_rect;
if (fromdisk == FALSE) {
mem=(char *)malloc(size);
mem=(char *)MEM_mallocN(size, "build pic list");
if (mem==0){
printf("Couldn't get memory\n");
close(file);
free(picture);
MEM_freeN(picture);
return;
}
if (read(file,mem,size) != size){
printf("Error while reading %s\n",name);
close(file);
free(picture);
free(mem);
MEM_freeN(picture);
MEM_freeN(mem);
return;
}
} else mem = 0;

@ -69,7 +69,7 @@ static void copy_back_to_front(void)
winlay_get_winsize(&winx, &winy);
if (actually_swap) {
data= malloc(4*winx*winy);
data= MEM_mallocN(4*winx*winy, "swap");
glReadPixels(0, 0, winx, winy, GL_RGBA, GL_UNSIGNED_BYTE, data);
}
@ -85,7 +85,7 @@ static void copy_back_to_front(void)
glRasterPos2f(-0.5,-0.5);
glDrawPixels(winx, winy, GL_RGBA, GL_UNSIGNED_BYTE, data);
glFlush();
free(data);
MEM_freeN(data);
}
}
#endif

@ -564,12 +564,12 @@ static void acd_to_opts(AviCodecData *acd)
opts.cbParms = acd->cbParms;
if (acd->lpFormat && acd->cbFormat) {
opts.lpFormat = malloc(opts.cbFormat);
opts.lpFormat = MEM_mallocN(opts.cbFormat, "opts lpFormat");
memcpy(opts.lpFormat, acd->lpFormat, opts.cbFormat);
}
if (acd->lpParms && acd->cbParms) {
opts.lpParms = malloc(opts.cbParms);
opts.lpParms = MEM_mallocN(opts.cbParms, "opts.cbParms");
memcpy(opts.lpParms, acd->lpParms, opts.cbParms);
}
}
@ -578,11 +578,11 @@ static void acd_to_opts(AviCodecData *acd)
static void free_opts_data()
{
if (opts.lpFormat) {
free(opts.lpFormat);
MEM_freeN(opts.lpFormat);
opts.lpFormat = NULL;
}
if (opts.lpParms) {
free(opts.lpParms);
MEM_freeN(opts.lpParms);
opts.lpParms = NULL;
}
}