Use const for direntry strings

This commit is contained in:
Campbell Barton 2015-07-12 05:50:07 +10:00
parent 8c67b8ffe9
commit 5c8fc8e505
4 changed files with 8 additions and 7 deletions

@ -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;

@ -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);
}

@ -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;

@ -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 */