correct the type of the im_decode_exif() data parameter
authorTony Cook <tony@develop-help.com>
Thu, 14 Feb 2019 08:01:47 +0000 (19:01 +1100)
committerTony Cook <tony@develop-help.com>
Thu, 14 Feb 2019 08:01:47 +0000 (19:01 +1100)
const foo * and foo* have the same representation so this doesn't
break the ABI.

const unsigned char * will accept all parameter types it did previously.

The only issue is if someone makes a copy of the pointer, but I don't
support that.

imexif.c
imexif.h
imexttypes.h

index 4bdf386aa2a677bcdbef60c19a2a5cd23c8def6d..30a898961266a8bb6717b6021876706c48b9ab85 100644 (file)
--- a/imexif.c
+++ b/imexif.c
@@ -213,7 +213,7 @@ typedef struct {
 /* in memory tiff structure */
 typedef struct {
   /* the data we use as a tiff */
-  unsigned char *base;
+  const unsigned char *base;
   size_t size;
 
   /* intel or motorola byte order */
@@ -228,7 +228,7 @@ typedef struct {
   unsigned long next_ifd;
 } imtiff;
 
-static int tiff_init(imtiff *tiff, unsigned char *base, size_t length);
+static int tiff_init(imtiff *tiff, const unsigned char *base, size_t length);
 static int tiff_load_ifd(imtiff *tiff, unsigned long offset);
 static void tiff_final(imtiff *tiff);
 static void tiff_clear_ifd(imtiff *tiff);
@@ -286,7 +286,7 @@ Returns true if an EXIF header was seen.
 */
 
 int
-im_decode_exif(i_img *im, unsigned char *data, size_t length) {
+im_decode_exif(i_img *im, const unsigned char *data, size_t length) {
   imtiff tiff;
   unsigned long exif_ifd_offset = 0;
   unsigned long gps_ifd_offset = 0;
@@ -840,7 +840,7 @@ the first IFD (IFD0 in EXIF) in first_ifd_offset.
 */
 
 static int
-tiff_init(imtiff *tiff, unsigned char *data, size_t length) {
+tiff_init(imtiff *tiff, const unsigned char *data, size_t length) {
   int version;
 
   tiff->base = data;
index 2e02d1d26b62f4d2ae619de5ee250324f33b1c4b..67b674c63328145483fa96fb2865b225d0841655 100644 (file)
--- a/imexif.h
+++ b/imexif.h
@@ -5,6 +5,6 @@
 #include <stddef.h>
 #include "imdatatypes.h"
 
-extern int im_decode_exif(i_img *im, unsigned char *data, size_t length);
+extern int im_decode_exif(i_img *im, const unsigned char *data, size_t length);
 
 #endif /* ifndef IMAGER_IMEXIF_H */
index 62e325baf646cbb93279a87ce84489ea424bfdd3..0d25c5ef67016f8c1fae1c582e9cfae432b8d8c7 100644 (file)
@@ -271,7 +271,7 @@ typedef struct {
   int (*f_i_img_color_channels)(i_img *im);
 
   /* IMAGER_API_LEVEL 10 functions will be added here */
-  int (*f_im_decode_exif)(i_img *im, unsigned char *data, size_t length);
+  int (*f_im_decode_exif)(i_img *im, const unsigned char *data, size_t length);
 
   /* IMAGER_API_LEVEL 11 functions will be added here */
 } im_ext_funcs;