Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2020-11-11 07:05:30 +0300
committerCampbell Barton <ideasman42@gmail.com>2020-11-11 07:05:30 +0300
commit11bf3b7035fadedebd6a12214c2f38322ca294bb (patch)
tree7a23d9c51d7e9a36dde8dd0adb7fe8483c6fb7c0 /source/blender/imbuf
parent75c18b989c566d24c76f9f7a44271654bc07a02c (diff)
Cleanup: use define for targa header size
Diffstat (limited to 'source/blender/imbuf')
-rw-r--r--source/blender/imbuf/intern/targa.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/source/blender/imbuf/intern/targa.c b/source/blender/imbuf/intern/targa.c
index cb549fb43f2..0efc8dee2db 100644
--- a/source/blender/imbuf/intern/targa.c
+++ b/source/blender/imbuf/intern/targa.c
@@ -60,6 +60,14 @@ typedef struct TARGA {
unsigned char imgdes;
} TARGA;
+/**
+ * On-disk header size.
+ *
+ * \note In theory it's possible padding would make the struct and on-disk size differ,
+ * so use a constant instead of `sizeof(TARGA)`.
+ */
+#define TARGA_HEADER_SIZE 18
+
/***/
static int tga_out1(unsigned int data, FILE *file)
@@ -286,14 +294,12 @@ static bool dumptarga(struct ImBuf *ibuf, FILE *file)
return 1;
}
-int imb_savetarga(struct ImBuf *ibuf, const char *filepath, int flags)
+int imb_savetarga(struct ImBuf *ibuf, const char *filepath, int UNUSED(flags))
{
- char buf[18] = {0};
+ char buf[TARGA_HEADER_SIZE] = {0};
FILE *fildes;
bool ok = false;
- (void)flags; /* unused */
-
buf[16] = (ibuf->planes + 0x7) & ~0x7;
if (ibuf->planes > 8) {
buf[2] = 10;
@@ -326,7 +332,7 @@ int imb_savetarga(struct ImBuf *ibuf, const char *filepath, int flags)
return 0;
}
- if (fwrite(buf, 1, 18, fildes) != 18) {
+ if (fwrite(buf, 1, TARGA_HEADER_SIZE, fildes) != TARGA_HEADER_SIZE) {
fclose(fildes);
return 0;
}
@@ -647,7 +653,7 @@ ImBuf *imb_loadtarga(const unsigned char *mem,
if (tga.imgtyp < 4) {
ibuf->foptions.flag |= RAWTGA;
}
- mem = mem + 18 + tga.numid;
+ mem = mem + TARGA_HEADER_SIZE + tga.numid;
cp[0] = 0xff;
cp[1] = cp[2] = 0;