Patch provided by Andrea Weikert (elubie):
With a few tests I have discovered that when quitting Blender the filelist in SpaceFile doesn't get free'd. storage.c: I have replaced strdup for the relname member in BLI_builddir with BLI_strdup. and malloc with MEM_mallocN for the string member in BLI_addstrings(). filesel.c: Of course also had to replace free with MEM_freeN in freefilelist(). In freespacelist (space.c) I added call to freefilelist for the SPACE_FILE space type.
This commit is contained in:
@@ -245,7 +245,7 @@ void BLI_builddir(char *dirname, char *relname)
|
||||
if (dlink){
|
||||
strcpy(buf+rellen,fname->d_name);
|
||||
|
||||
dlink->name = strdup(buf);
|
||||
dlink->name = BLI_strdup(buf);
|
||||
|
||||
if (dlink->name[0] == '.') {
|
||||
if (dlink->name[1] == 0) seen_ = 1;
|
||||
@@ -264,14 +264,14 @@ void BLI_builddir(char *dirname, char *relname)
|
||||
if (seen_ == 0) { /* Cachefs PATCH */
|
||||
dlink = (struct dirlink *)malloc(sizeof(struct dirlink));
|
||||
strcpy(buf+rellen,"./.");
|
||||
dlink->name = strdup(buf);
|
||||
dlink->name = BLI_strdup(buf);
|
||||
BLI_addhead(dirbase,dlink);
|
||||
newnum++;
|
||||
}
|
||||
if (seen__ == 0) { /* MAC PATCH */
|
||||
dlink = (struct dirlink *)malloc(sizeof(struct dirlink));
|
||||
strcpy(buf+rellen,"./..");
|
||||
dlink->name = strdup(buf);
|
||||
dlink->name = BLI_strdup(buf);
|
||||
BLI_addhead(dirbase,dlink);
|
||||
newnum++;
|
||||
}
|
||||
@@ -407,7 +407,7 @@ void BLI_adddirstrings()
|
||||
sprintf(buf,"%s %s %s %7s %s %s %10s %s", file->mode1, file->mode2, file->mode3, files[num].owner, files[num].date, files[num].time, size,
|
||||
files[num].relname);
|
||||
|
||||
files[num].string=malloc(strlen(buf)+1);
|
||||
files[num].string=MEM_mallocN(strlen(buf)+1, "filestring");
|
||||
if (files[num].string){
|
||||
strcpy(files[num].string,buf);
|
||||
}
|
||||
|
||||
@@ -681,9 +681,9 @@ void freefilelist(SpaceFile *sfile)
|
||||
if (sfile->filelist==0) return;
|
||||
|
||||
for(; num>=0; num--){
|
||||
free(sfile->filelist[num].relname);
|
||||
MEM_freeN(sfile->filelist[num].relname);
|
||||
|
||||
if (sfile->filelist[num].string) free(sfile->filelist[num].string);
|
||||
if (sfile->filelist[num].string) MEM_freeN(sfile->filelist[num].string);
|
||||
}
|
||||
free(sfile->filelist);
|
||||
sfile->filelist= 0;
|
||||
|
||||
@@ -4317,6 +4317,8 @@ void freespacelist(ListBase *lb)
|
||||
SpaceFile *sfile= (SpaceFile*) sl;
|
||||
if(sfile->libfiledata)
|
||||
BLO_blendhandle_close(sfile->libfiledata);
|
||||
if(sfile->filelist)
|
||||
freefilelist(sfile);
|
||||
}
|
||||
else if(sl->spacetype==SPACE_BUTS) {
|
||||
SpaceButs *buts= (SpaceButs*) sl;
|
||||
|
||||
Reference in New Issue
Block a user