Make pointers returned via TIFFGetField const
According to http://bugzilla.maptools.org/show_bug.cgi?id=2125#c6 callers are not allowed to modify pointer or array values returned from TIFFGetField or the like. So, make this explicit in the documentation by specifying these things as const. Note that this is not an ABI change, since C does not encode const in libraries. Also, this is not really an API change, since the varargs call strips away all the types anyway. So it really is more of a documentation change. fixes #11
This commit is contained in:
parent
e95584d3b8
commit
63c666344f
@ -270,7 +270,7 @@ TIFFVGetFieldDefaulted(TIFF* tif, uint32 tag, va_list ap)
|
||||
return (1);
|
||||
case TIFFTAG_EXTRASAMPLES:
|
||||
*va_arg(ap, uint16 *) = td->td_extrasamples;
|
||||
*va_arg(ap, uint16 **) = td->td_sampleinfo;
|
||||
*va_arg(ap, const uint16 **) = td->td_sampleinfo;
|
||||
return (1);
|
||||
case TIFFTAG_MATTEING:
|
||||
*va_arg(ap, uint16 *) =
|
||||
@ -293,7 +293,7 @@ TIFFVGetFieldDefaulted(TIFF* tif, uint32 tag, va_list ap)
|
||||
{
|
||||
/* defaults are from CCIR Recommendation 601-1 */
|
||||
static float ycbcrcoeffs[] = { 0.299f, 0.587f, 0.114f };
|
||||
*va_arg(ap, float **) = ycbcrcoeffs;
|
||||
*va_arg(ap, const float **) = ycbcrcoeffs;
|
||||
return 1;
|
||||
}
|
||||
case TIFFTAG_YCBCRSUBSAMPLING:
|
||||
@ -306,13 +306,12 @@ TIFFVGetFieldDefaulted(TIFF* tif, uint32 tag, va_list ap)
|
||||
case TIFFTAG_WHITEPOINT:
|
||||
{
|
||||
static float whitepoint[2];
|
||||
|
||||
/* TIFF 6.0 specification tells that it is no default
|
||||
value for the WhitePoint, but AdobePhotoshop TIFF
|
||||
Technical Note tells that it should be CIE D50. */
|
||||
whitepoint[0] = D50_X0 / (D50_X0 + D50_Y0 + D50_Z0);
|
||||
whitepoint[1] = D50_Y0 / (D50_X0 + D50_Y0 + D50_Z0);
|
||||
*va_arg(ap, float **) = whitepoint;
|
||||
*va_arg(ap, const float **) = whitepoint;
|
||||
return 1;
|
||||
}
|
||||
case TIFFTAG_TRANSFERFUNCTION:
|
||||
@ -321,16 +320,16 @@ TIFFVGetFieldDefaulted(TIFF* tif, uint32 tag, va_list ap)
|
||||
TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "No space for \"TransferFunction\" tag");
|
||||
return (0);
|
||||
}
|
||||
*va_arg(ap, uint16 **) = td->td_transferfunction[0];
|
||||
*va_arg(ap, const uint16 **) = td->td_transferfunction[0];
|
||||
if (td->td_samplesperpixel - td->td_extrasamples > 1) {
|
||||
*va_arg(ap, uint16 **) = td->td_transferfunction[1];
|
||||
*va_arg(ap, uint16 **) = td->td_transferfunction[2];
|
||||
*va_arg(ap, const uint16 **) = td->td_transferfunction[1];
|
||||
*va_arg(ap, const uint16 **) = td->td_transferfunction[2];
|
||||
}
|
||||
return (1);
|
||||
case TIFFTAG_REFERENCEBLACKWHITE:
|
||||
if (!td->td_refblackwhite && !TIFFDefaultRefBlackWhite(td))
|
||||
return (0);
|
||||
*va_arg(ap, float **) = td->td_refblackwhite;
|
||||
*va_arg(ap, const float **) = td->td_refblackwhite;
|
||||
return (1);
|
||||
}
|
||||
return 0;
|
||||
|
@ -1033,19 +1033,19 @@ _TIFFVGetField(TIFF* tif, uint32 tag, va_list ap)
|
||||
*va_arg(ap, uint16*) = td->td_halftonehints[1];
|
||||
break;
|
||||
case TIFFTAG_COLORMAP:
|
||||
*va_arg(ap, uint16**) = td->td_colormap[0];
|
||||
*va_arg(ap, uint16**) = td->td_colormap[1];
|
||||
*va_arg(ap, uint16**) = td->td_colormap[2];
|
||||
*va_arg(ap, const uint16**) = td->td_colormap[0];
|
||||
*va_arg(ap, const uint16**) = td->td_colormap[1];
|
||||
*va_arg(ap, const uint16**) = td->td_colormap[2];
|
||||
break;
|
||||
case TIFFTAG_STRIPOFFSETS:
|
||||
case TIFFTAG_TILEOFFSETS:
|
||||
_TIFFFillStriles( tif );
|
||||
*va_arg(ap, uint64**) = td->td_stripoffset_p;
|
||||
*va_arg(ap, const uint64**) = td->td_stripoffset_p;
|
||||
break;
|
||||
case TIFFTAG_STRIPBYTECOUNTS:
|
||||
case TIFFTAG_TILEBYTECOUNTS:
|
||||
_TIFFFillStriles( tif );
|
||||
*va_arg(ap, uint64**) = td->td_stripbytecount_p;
|
||||
*va_arg(ap, const uint64**) = td->td_stripbytecount_p;
|
||||
break;
|
||||
case TIFFTAG_MATTEING:
|
||||
*va_arg(ap, uint16*) =
|
||||
@ -1054,7 +1054,7 @@ _TIFFVGetField(TIFF* tif, uint32 tag, va_list ap)
|
||||
break;
|
||||
case TIFFTAG_EXTRASAMPLES:
|
||||
*va_arg(ap, uint16*) = td->td_extrasamples;
|
||||
*va_arg(ap, uint16**) = td->td_sampleinfo;
|
||||
*va_arg(ap, const uint16**) = td->td_sampleinfo;
|
||||
break;
|
||||
case TIFFTAG_TILEWIDTH:
|
||||
*va_arg(ap, uint32*) = td->td_tilewidth;
|
||||
@ -1089,7 +1089,7 @@ _TIFFVGetField(TIFF* tif, uint32 tag, va_list ap)
|
||||
break;
|
||||
case TIFFTAG_SUBIFD:
|
||||
*va_arg(ap, uint16*) = td->td_nsubifd;
|
||||
*va_arg(ap, uint64**) = td->td_subifd;
|
||||
*va_arg(ap, const uint64**) = td->td_subifd;
|
||||
break;
|
||||
case TIFFTAG_YCBCRPOSITIONING:
|
||||
*va_arg(ap, uint16*) = td->td_ycbcrpositioning;
|
||||
@ -1099,20 +1099,20 @@ _TIFFVGetField(TIFF* tif, uint32 tag, va_list ap)
|
||||
*va_arg(ap, uint16*) = td->td_ycbcrsubsampling[1];
|
||||
break;
|
||||
case TIFFTAG_TRANSFERFUNCTION:
|
||||
*va_arg(ap, uint16**) = td->td_transferfunction[0];
|
||||
*va_arg(ap, const uint16**) = td->td_transferfunction[0];
|
||||
if (td->td_samplesperpixel - td->td_extrasamples > 1) {
|
||||
*va_arg(ap, uint16**) = td->td_transferfunction[1];
|
||||
*va_arg(ap, uint16**) = td->td_transferfunction[2];
|
||||
*va_arg(ap, const uint16**) = td->td_transferfunction[1];
|
||||
*va_arg(ap, const uint16**) = td->td_transferfunction[2];
|
||||
} else {
|
||||
*va_arg(ap, uint16**) = NULL;
|
||||
*va_arg(ap, uint16**) = NULL;
|
||||
*va_arg(ap, const uint16**) = NULL;
|
||||
*va_arg(ap, const uint16**) = NULL;
|
||||
}
|
||||
break;
|
||||
case TIFFTAG_REFERENCEBLACKWHITE:
|
||||
*va_arg(ap, float**) = td->td_refblackwhite;
|
||||
*va_arg(ap, const float**) = td->td_refblackwhite;
|
||||
break;
|
||||
case TIFFTAG_INKNAMES:
|
||||
*va_arg(ap, char**) = td->td_inknames;
|
||||
*va_arg(ap, const char**) = td->td_inknames;
|
||||
break;
|
||||
default:
|
||||
{
|
||||
@ -1154,7 +1154,7 @@ _TIFFVGetField(TIFF* tif, uint32 tag, va_list ap)
|
||||
*va_arg(ap, uint32*) = (uint32)tv->count;
|
||||
else /* Assume TIFF_VARIABLE */
|
||||
*va_arg(ap, uint16*) = (uint16)tv->count;
|
||||
*va_arg(ap, void **) = tv->value;
|
||||
*va_arg(ap, const void **) = tv->value;
|
||||
ret_val = 1;
|
||||
} else if (fip->field_tag == TIFFTAG_DOTRANGE
|
||||
&& strcmp(fip->field_name,"DotRange") == 0) {
|
||||
|
@ -2344,7 +2344,7 @@ JPEGVGetField(TIFF* tif, uint32 tag, va_list ap)
|
||||
switch (tag) {
|
||||
case TIFFTAG_JPEGTABLES:
|
||||
*va_arg(ap, uint32*) = sp->jpegtables_length;
|
||||
*va_arg(ap, void**) = sp->jpegtables;
|
||||
*va_arg(ap, const void**) = sp->jpegtables;
|
||||
break;
|
||||
case TIFFTAG_JPEGQUALITY:
|
||||
*va_arg(ap, int*) = sp->jpegquality;
|
||||
|
@ -498,15 +498,15 @@ OJPEGVGetField(TIFF* tif, uint32 tag, va_list ap)
|
||||
break;
|
||||
case TIFFTAG_JPEGQTABLES:
|
||||
*va_arg(ap,uint32*)=(uint32)sp->qtable_offset_count;
|
||||
*va_arg(ap,void**)=(void*)sp->qtable_offset;
|
||||
*va_arg(ap,const void**)=(const void*)sp->qtable_offset;
|
||||
break;
|
||||
case TIFFTAG_JPEGDCTABLES:
|
||||
*va_arg(ap,uint32*)=(uint32)sp->dctable_offset_count;
|
||||
*va_arg(ap,void**)=(void*)sp->dctable_offset;
|
||||
*va_arg(ap,const void**)=(const void*)sp->dctable_offset;
|
||||
break;
|
||||
case TIFFTAG_JPEGACTABLES:
|
||||
*va_arg(ap,uint32*)=(uint32)sp->actable_offset_count;
|
||||
*va_arg(ap,void**)=(void*)sp->actable_offset;
|
||||
*va_arg(ap,const void**)=(const void*)sp->actable_offset;
|
||||
break;
|
||||
case TIFFTAG_JPEGPROC:
|
||||
*va_arg(ap,uint16*)=(uint16)sp->jpeg_proc;
|
||||
|
@ -102,77 +102,77 @@ meaning of each tag and their possible values.
|
||||
.ta \w'TIFFTAG_CONSECUTIVEBADFAXLINES'u+2n +\w'Count'u+2n +\w'TIFFFaxFillFunc*'u+2n
|
||||
\fITag Name\fP \fICount\fP \fITypes\fP \fINotes\fP
|
||||
.sp 5p
|
||||
TIFFTAG_ARTIST 1 char**
|
||||
TIFFTAG_ARTIST 1 const char**
|
||||
TIFFTAG_BADFAXLINES 1 uint32*
|
||||
TIFFTAG_BITSPERSAMPLE 1 uint16*
|
||||
TIFFTAG_CLEANFAXDATA 1 uint16*
|
||||
TIFFTAG_COLORMAP 3 uint16** 1<<BitsPerSample arrays
|
||||
TIFFTAG_COLORMAP 3 const uint16** 1<<BitsPerSample arrays
|
||||
TIFFTAG_COMPRESSION 1 uint16*
|
||||
TIFFTAG_CONSECUTIVEBADFAXLINES 1 uint32*
|
||||
TIFFTAG_COPYRIGHT 1 char**
|
||||
TIFFTAG_COPYRIGHT 1 const char**
|
||||
TIFFTAG_DATATYPE 1 uint16*
|
||||
TIFFTAG_DATETIME 1 char**
|
||||
TIFFTAG_DOCUMENTNAME 1 char**
|
||||
TIFFTAG_DATETIME 1 const char**
|
||||
TIFFTAG_DOCUMENTNAME 1 const char**
|
||||
TIFFTAG_DOTRANGE 2 uint16*
|
||||
TIFFTAG_EXTRASAMPLES 2 uint16*,uint16** count & types array
|
||||
TIFFTAG_EXTRASAMPLES 2 uint16*,const uint16** count & types array
|
||||
TIFFTAG_FAXFILLFUNC 1 TIFFFaxFillFunc* G3/G4 compression pseudo-tag
|
||||
TIFFTAG_FAXMODE 1 int* G3/G4 compression pseudo-tag
|
||||
TIFFTAG_FILLORDER 1 uint16*
|
||||
TIFFTAG_GROUP3OPTIONS 1 uint32*
|
||||
TIFFTAG_GROUP4OPTIONS 1 uint32*
|
||||
TIFFTAG_HALFTONEHINTS 2 uint16*
|
||||
TIFFTAG_HOSTCOMPUTER 1 char**
|
||||
TIFFTAG_ICCPROFILE 2 uint32*,void** count, profile data
|
||||
TIFFTAG_HOSTCOMPUTER 1 const char**
|
||||
TIFFTAG_ICCPROFILE 2 const uint32*,const void** count, profile data
|
||||
TIFFTAG_IMAGEDEPTH 1 uint32*
|
||||
TIFFTAG_IMAGEDESCRIPTION 1 char**
|
||||
TIFFTAG_IMAGEDESCRIPTION 1 const char**
|
||||
TIFFTAG_IMAGELENGTH 1 uint32*
|
||||
TIFFTAG_IMAGEWIDTH 1 uint32*
|
||||
TIFFTAG_INKNAMES 1 char**
|
||||
TIFFTAG_INKNAMES 1 const char**
|
||||
TIFFTAG_INKSET 1 uint16*
|
||||
TIFFTAG_JPEGCOLORMODE 1 int* JPEG pseudo-tag
|
||||
TIFFTAG_JPEGQUALITY 1 int* JPEG pseudo-tag
|
||||
TIFFTAG_JPEGTABLES 2 uint32*,void** count & tables
|
||||
TIFFTAG_JPEGTABLES 2 uint32*,const void** count & tables
|
||||
TIFFTAG_JPEGTABLESMODE 1 int* JPEG pseudo-tag
|
||||
TIFFTAG_MAKE 1 char**
|
||||
TIFFTAG_MAKE 1 const char**
|
||||
TIFFTAG_MATTEING 1 uint16*
|
||||
TIFFTAG_MAXSAMPLEVALUE 1 uint16*
|
||||
TIFFTAG_MINSAMPLEVALUE 1 uint16*
|
||||
TIFFTAG_MODEL 1 char**
|
||||
TIFFTAG_MODEL 1 const char**
|
||||
TIFFTAG_ORIENTATION 1 uint16*
|
||||
TIFFTAG_PAGENAME 1 char**
|
||||
TIFFTAG_PAGENAME 1 const char**
|
||||
TIFFTAG_PAGENUMBER 2 uint16*
|
||||
TIFFTAG_PHOTOMETRIC 1 uint16*
|
||||
TIFFTAG_PHOTOSHOP 2 uint32*,void** count, data
|
||||
TIFFTAG_PHOTOSHOP 2 uint32*,const void** count, data
|
||||
TIFFTAG_PLANARCONFIG 1 uint16*
|
||||
TIFFTAG_PREDICTOR 1 uint16*
|
||||
TIFFTAG_PRIMARYCHROMATICITIES 1 float** 6-entry array
|
||||
TIFFTAG_REFERENCEBLACKWHITE 1 float** 6-entry array
|
||||
TIFFTAG_PRIMARYCHROMATICITIES 1 const float** 6-entry array
|
||||
TIFFTAG_REFERENCEBLACKWHITE 1 const float** 6-entry array
|
||||
TIFFTAG_RESOLUTIONUNIT 1 uint16*
|
||||
TIFFTAG_RICHTIFFIPTC 2 uint32*,void** count, data
|
||||
TIFFTAG_RICHTIFFIPTC 2 uint32*,const void** count, data
|
||||
TIFFTAG_ROWSPERSTRIP 1 uint32*
|
||||
TIFFTAG_SAMPLEFORMAT 1 uint16*
|
||||
TIFFTAG_SAMPLESPERPIXEL 1 uint16*
|
||||
TIFFTAG_SMAXSAMPLEVALUE 1 double*
|
||||
TIFFTAG_SMINSAMPLEVALUE 1 double*
|
||||
TIFFTAG_SOFTWARE 1 char**
|
||||
TIFFTAG_STONITS 1 double**
|
||||
TIFFTAG_STRIPBYTECOUNTS 1 uint32**
|
||||
TIFFTAG_STRIPOFFSETS 1 uint32**
|
||||
TIFFTAG_SOFTWARE 1 const char**
|
||||
TIFFTAG_STONITS 1 const double**
|
||||
TIFFTAG_STRIPBYTECOUNTS 1 const uint32**
|
||||
TIFFTAG_STRIPOFFSETS 1 const uint32**
|
||||
TIFFTAG_SUBFILETYPE 1 uint32*
|
||||
TIFFTAG_SUBIFD 2 uint16*,uint64** count & offsets array
|
||||
TIFFTAG_TARGETPRINTER 1 char**
|
||||
TIFFTAG_SUBIFD 2 uint16*,const uint64** count & offsets array
|
||||
TIFFTAG_TARGETPRINTER 1 const char**
|
||||
TIFFTAG_THRESHHOLDING 1 uint16*
|
||||
TIFFTAG_TILEBYTECOUNTS 1 uint32**
|
||||
TIFFTAG_TILEBYTECOUNTS 1 const uint32**
|
||||
TIFFTAG_TILEDEPTH 1 uint32*
|
||||
TIFFTAG_TILELENGTH 1 uint32*
|
||||
TIFFTAG_TILEOFFSETS 1 uint32**
|
||||
TIFFTAG_TILEOFFSETS 1 const uint32**
|
||||
TIFFTAG_TILEWIDTH 1 uint32*
|
||||
TIFFTAG_TRANSFERFUNCTION 1 or 3\(dg uint16**1<<BitsPerSample entry arrays
|
||||
TIFFTAG_WHITEPOINT 1 float** 2-entry array
|
||||
TIFFTAG_XMLPACKET 2 uint32*,void** count, data
|
||||
TIFFTAG_TRANSFERFUNCTION 1 or 3\(dg const uint16**1<<BitsPerSample entry arrays
|
||||
TIFFTAG_WHITEPOINT 1 const float** 2-entry array
|
||||
TIFFTAG_XMLPACKET 2 uint32*,const void** count, data
|
||||
TIFFTAG_XPOSITION 1 float*
|
||||
TIFFTAG_XRESOLUTION 1 float*
|
||||
TIFFTAG_YCBCRCOEFFICIENTS 1 float** 3-entry array
|
||||
TIFFTAG_YCBCRCOEFFICIENTS 1 const float** 3-entry array
|
||||
TIFFTAG_YCBCRPOSITIONING 1 uint16*
|
||||
TIFFTAG_YCBCRSUBSAMPLING 2 uint16*
|
||||
TIFFTAG_YPOSITION 1 float*
|
||||
|
Loading…
Reference in New Issue
Block a user