From 3dfce097e49b8dd443ecd364ff57d5fadc4a2c8c Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 18 May 2015 16:26:45 +1000 Subject: Cleanup: use const for Imbuf file types --- source/blender/imbuf/intern/IMB_filetype.h | 6 +++--- source/blender/imbuf/intern/colormanagement.c | 4 ++-- source/blender/imbuf/intern/filetype.c | 12 ++++++------ source/blender/imbuf/intern/readimage.c | 6 +++--- source/blender/imbuf/intern/util.c | 4 ++-- source/blender/imbuf/intern/writeimage.c | 4 ++-- 6 files changed, 18 insertions(+), 18 deletions(-) (limited to 'source') diff --git a/source/blender/imbuf/intern/IMB_filetype.h b/source/blender/imbuf/intern/IMB_filetype.h index 0e6438fb729..332878b6067 100644 --- a/source/blender/imbuf/intern/IMB_filetype.h +++ b/source/blender/imbuf/intern/IMB_filetype.h @@ -40,7 +40,7 @@ typedef struct ImFileType { int (*is_a)(unsigned char *buf); int (*is_a_filepath)(const char *name); - int (*ftype)(struct ImFileType *type, struct ImBuf *ibuf); + int (*ftype)(const struct ImFileType *type, struct ImBuf *ibuf); struct ImBuf *(*load)(unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE]); struct ImBuf *(*load_filepath)(const char *name, int flags, char colorspace[IM_MAX_SPACE]); int (*save)(struct ImBuf *ibuf, const char *name, int flags); @@ -51,8 +51,8 @@ typedef struct ImFileType { int default_save_role; } ImFileType; -extern ImFileType IMB_FILE_TYPES[]; -extern ImFileType *IMB_FILE_TYPES_LAST; +extern const ImFileType IMB_FILE_TYPES[]; +extern const ImFileType *IMB_FILE_TYPES_LAST; void imb_filetypes_init(void); void imb_filetypes_exit(void); diff --git a/source/blender/imbuf/intern/colormanagement.c b/source/blender/imbuf/intern/colormanagement.c index d6fdcad0819..a2f89ec4cbe 100644 --- a/source/blender/imbuf/intern/colormanagement.c +++ b/source/blender/imbuf/intern/colormanagement.c @@ -1948,7 +1948,7 @@ ImBuf *IMB_colormanagement_imbuf_for_write(ImBuf *ibuf, bool save_as_render, boo if (do_colormanagement) { bool make_byte = false; - ImFileType *type; + const ImFileType *type; /* for proper check whether byte buffer is required by a format or not * should be pretty safe since this image buffer is supposed to be used for @@ -2457,7 +2457,7 @@ const char *IMB_colormanagement_colorspace_get_indexed_name(int index) void IMB_colormanagment_colorspace_from_ibuf_ftype(ColorManagedColorspaceSettings *colorspace_settings, ImBuf *ibuf) { - ImFileType *type; + const ImFileType *type; for (type = IMB_FILE_TYPES; type < IMB_FILE_TYPES_LAST; type++) { if (type->save && type->ftype(type, ibuf)) { diff --git a/source/blender/imbuf/intern/filetype.c b/source/blender/imbuf/intern/filetype.c index c6e358dd3d2..e58cda07ecf 100644 --- a/source/blender/imbuf/intern/filetype.c +++ b/source/blender/imbuf/intern/filetype.c @@ -51,17 +51,17 @@ #include "quicktime_import.h" #endif -static int imb_ftype_default(ImFileType *type, ImBuf *ibuf) +static int imb_ftype_default(const ImFileType *type, ImBuf *ibuf) { return (ibuf->ftype & type->filetype); } -static int imb_ftype_iris(ImFileType *type, ImBuf *ibuf) +static int imb_ftype_iris(const ImFileType *type, ImBuf *ibuf) { (void)type; return (ibuf->ftype == IMAGIC); } -ImFileType IMB_FILE_TYPES[] = { +const ImFileType IMB_FILE_TYPES[] = { {NULL, NULL, imb_is_a_jpeg, NULL, imb_ftype_default, imb_load_jpeg, NULL, imb_savejpeg, NULL, 0, JPG, COLOR_ROLE_DEFAULT_BYTE}, {NULL, NULL, imb_is_a_png, NULL, imb_ftype_default, imb_loadpng, NULL, imb_savepng, NULL, 0, PNG, COLOR_ROLE_DEFAULT_BYTE}, {NULL, NULL, imb_is_a_bmp, NULL, imb_ftype_default, imb_bmp_decode, NULL, imb_savebmp, NULL, 0, BMP, COLOR_ROLE_DEFAULT_BYTE}, @@ -92,11 +92,11 @@ ImFileType IMB_FILE_TYPES[] = { {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 0} }; -ImFileType *IMB_FILE_TYPES_LAST = &IMB_FILE_TYPES[sizeof(IMB_FILE_TYPES) / sizeof(ImFileType) - 1]; +const ImFileType *IMB_FILE_TYPES_LAST = &IMB_FILE_TYPES[sizeof(IMB_FILE_TYPES) / sizeof(ImFileType) - 1]; void imb_filetypes_init(void) { - ImFileType *type; + const ImFileType *type; for (type = IMB_FILE_TYPES; type < IMB_FILE_TYPES_LAST; type++) if (type->init) @@ -109,7 +109,7 @@ void imb_filetypes_init(void) void imb_filetypes_exit(void) { - ImFileType *type; + const ImFileType *type; for (type = IMB_FILE_TYPES; type < IMB_FILE_TYPES_LAST; type++) if (type->exit) diff --git a/source/blender/imbuf/intern/readimage.c b/source/blender/imbuf/intern/readimage.c index bb09c57d1e5..3cf123fbc28 100644 --- a/source/blender/imbuf/intern/readimage.c +++ b/source/blender/imbuf/intern/readimage.c @@ -103,7 +103,7 @@ static void imb_handle_alpha(ImBuf *ibuf, int flags, char colorspace[IM_MAX_SPAC ImBuf *IMB_ibImageFromMemory(unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE], const char *descr) { ImBuf *ibuf; - ImFileType *type; + const ImFileType *type; char effective_colorspace[IM_MAX_SPACE] = ""; if (mem == NULL) { @@ -133,7 +133,7 @@ ImBuf *IMB_ibImageFromMemory(unsigned char *mem, size_t size, int flags, char co static ImBuf *IMB_ibImageFromFile(const char *filepath, int flags, char colorspace[IM_MAX_SPACE], const char *descr) { ImBuf *ibuf; - ImFileType *type; + const ImFileType *type; char effective_colorspace[IM_MAX_SPACE] = ""; if (colorspace) @@ -257,7 +257,7 @@ ImBuf *IMB_testiffname(const char *filepath, int flags) static void imb_loadtilefile(ImBuf *ibuf, int file, int tx, int ty, unsigned int *rect) { - ImFileType *type; + const ImFileType *type; unsigned char *mem; size_t size; diff --git a/source/blender/imbuf/intern/util.c b/source/blender/imbuf/intern/util.c index 3fee6688014..77962d43470 100644 --- a/source/blender/imbuf/intern/util.c +++ b/source/blender/imbuf/intern/util.c @@ -186,7 +186,7 @@ int IMB_ispic_type(const char *name) #define HEADER_SIZE 64 unsigned char buf[HEADER_SIZE]; - ImFileType *type; + const ImFileType *type; BLI_stat_t st; int fp; @@ -442,7 +442,7 @@ bool IMB_isanim(const char *filename) bool IMB_isfloat(ImBuf *ibuf) { - ImFileType *type; + const ImFileType *type; for (type = IMB_FILE_TYPES; type < IMB_FILE_TYPES_LAST; type++) { if (type->ftype(type, ibuf)) { diff --git a/source/blender/imbuf/intern/writeimage.c b/source/blender/imbuf/intern/writeimage.c index 5e9ccf4437e..2f688803804 100644 --- a/source/blender/imbuf/intern/writeimage.c +++ b/source/blender/imbuf/intern/writeimage.c @@ -41,14 +41,14 @@ #include "IMB_colormanagement.h" #include "IMB_colormanagement_intern.h" -static ImBuf *prepare_write_imbuf(ImFileType *type, ImBuf *ibuf) +static ImBuf *prepare_write_imbuf(const ImFileType *type, ImBuf *ibuf) { return IMB_prepare_write_ImBuf((type->flag & IM_FTYPE_FLOAT), ibuf); } short IMB_saveiff(struct ImBuf *ibuf, const char *name, int flags) { - ImFileType *type; + const ImFileType *type; if (ibuf == NULL) return (false); ibuf->flags = flags; -- cgit v1.2.3