[Bf-blender-cvs] [5c8fc8e] master: Use const for direntry strings

Campbell Barton noreply at git.blender.org
Sat Jul 11 21:55:55 CEST 2015


Commit: 5c8fc8e505fdfcd82e24dae75e7454b6f7d61530
Author: Campbell Barton
Date:   Sun Jul 12 05:50:07 2015 +1000
Branches: master
https://developer.blender.org/rB5c8fc8e505fdfcd82e24dae75e7454b6f7d61530

Use const for direntry strings

===================================================================

M	source/blender/blenlib/BLI_fileops_types.h
M	source/blender/blenlib/intern/BLI_filelist.c
M	source/blender/editors/space_file/file_draw.c
M	source/blender/editors/space_file/filelist.c

===================================================================

diff --git a/source/blender/blenlib/BLI_fileops_types.h b/source/blender/blenlib/BLI_fileops_types.h
index 0e6eab6..5a1126b 100644
--- a/source/blender/blenlib/BLI_fileops_types.h
+++ b/source/blender/blenlib/BLI_fileops_types.h
@@ -43,8 +43,8 @@ struct ImBuf;
 
 struct direntry {
 	mode_t  type;
-	char   *relname;
-	char   *path;
+	const char   *relname;
+	const char   *path;
 #ifdef WIN32 /* keep in sync with the definition of BLI_stat_t in BLI_fileops.h */
 #  if defined(_MSC_VER) || defined(__MINGW64__)
 	struct _stat64 s;
diff --git a/source/blender/blenlib/intern/BLI_filelist.c b/source/blender/blenlib/intern/BLI_filelist.c
index 786eaa7..38a6781 100644
--- a/source/blender/blenlib/intern/BLI_filelist.c
+++ b/source/blender/blenlib/intern/BLI_filelist.c
@@ -379,9 +379,9 @@ void BLI_filelist_free(struct direntry *filelist, unsigned int nrentries, void (
 			IMB_freeImBuf(entry->image);
 		}
 		if (entry->relname)
-			MEM_freeN(entry->relname);
+			MEM_freeN((void *)entry->relname);
 		if (entry->path)
-			MEM_freeN(entry->path);
+			MEM_freeN((void *)entry->path);
 		if (entry->poin && free_poin)
 			free_poin(entry->poin);
 	}
diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c
index 9a5ec19..be602e7 100644
--- a/source/blender/editors/space_file/file_draw.c
+++ b/source/blender/editors/space_file/file_draw.c
@@ -282,7 +282,7 @@ static int get_file_icon(struct direntry *file)
 		return ICON_FILE_BLANK;
 }
 
-static void file_draw_icon(uiBlock *block, char *path, int sx, int sy, int icon, int width, int height, bool drag)
+static void file_draw_icon(uiBlock *block, const char *path, int sx, int sy, int icon, int width, int height, bool drag)
 {
 	uiBut *but;
 	int x, y;
diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c
index 4048c9f..3358812 100644
--- a/source/blender/editors/space_file/filelist.c
+++ b/source/blender/editors/space_file/filelist.c
@@ -1252,8 +1252,9 @@ static void filelist_from_main(struct FileList *filelist)
 						files->relname = BLI_strdup(id->name + 2);
 					}
 					else {
-						files->relname = MEM_mallocN(sizeof(*files->relname) * (FILE_MAX + (MAX_ID_NAME - 2)), __func__);
-						BLI_snprintf(files->relname, FILE_MAX + (MAX_ID_NAME - 2) + 3, "%s | %s", id->lib->name, id->name + 2);
+						char relname[FILE_MAX + (MAX_ID_NAME - 2) + 3];
+						BLI_snprintf(relname, sizeof(relname), "%s | %s", id->lib->name, id->name + 2);
+						files->relname = BLI_strdup(relname);
 					}
 					files->type |= S_IFREG;
 #if 0               /* XXXXX TODO show the selection status of the objects */




More information about the Bf-blender-cvs mailing list