From 1e6cd1b1a531914fc20ee7e1fe27e8bdbdc5a324 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Thu, 18 Sep 2014 10:19:24 +0100 Subject: [PATCH] clean up length return read file to mem was using uint for length for historical reasons --- libvips/colour/colour.c | 2 +- libvips/foreign/analyze2vips.c | 2 +- libvips/foreign/vips2jpeg.c | 2 +- libvips/foreign/vips2tiff.c | 2 +- libvips/foreign/vipspng.c | 12 +++++------- libvips/include/vips/util.h | 4 ++-- libvips/iofuncs/util.c | 4 ++-- tools/vipsedit.c | 2 +- 8 files changed, 14 insertions(+), 16 deletions(-) diff --git a/libvips/colour/colour.c b/libvips/colour/colour.c index 0ea7e6ee..229696d5 100644 --- a/libvips/colour/colour.c +++ b/libvips/colour/colour.c @@ -277,7 +277,7 @@ static int vips_colour_attach_profile( VipsImage *im, const char *filename ) { char *data; - unsigned int data_length; + size_t data_length; if( !(data = vips__file_read_name( filename, VIPS_ICC_DIR, &data_length )) ) diff --git a/libvips/foreign/analyze2vips.c b/libvips/foreign/analyze2vips.c index f73f3372..d92f295c 100644 --- a/libvips/foreign/analyze2vips.c +++ b/libvips/foreign/analyze2vips.c @@ -299,7 +299,7 @@ static struct dsr * read_header( const char *header ) { struct dsr *d; - unsigned int len; + size_t len; if( !(d = (struct dsr *) vips__file_read_name( header, NULL, &len )) ) return( NULL ); diff --git a/libvips/foreign/vips2jpeg.c b/libvips/foreign/vips2jpeg.c index e36ab91f..e2172cf3 100644 --- a/libvips/foreign/vips2jpeg.c +++ b/libvips/foreign/vips2jpeg.c @@ -181,7 +181,7 @@ typedef struct { ErrorManager eman; JSAMPROW *row_pointer; char *profile_bytes; - unsigned int profile_length; + size_t profile_length; VipsImage *inverted; } Write; diff --git a/libvips/foreign/vips2tiff.c b/libvips/foreign/vips2tiff.c index 0fba3dd6..ff69144f 100644 --- a/libvips/foreign/vips2tiff.c +++ b/libvips/foreign/vips2tiff.c @@ -402,7 +402,7 @@ static int embed_profile_file( TIFF *tif, const char *profile ) { char *buffer; - unsigned int length; + size_t length; if( !(buffer = vips__file_read_name( profile, VIPS_ICC_DIR, &length )) ) return( -1 ); diff --git a/libvips/foreign/vipspng.c b/libvips/foreign/vipspng.c index 88af61ae..c639c9fa 100644 --- a/libvips/foreign/vipspng.c +++ b/libvips/foreign/vipspng.c @@ -857,22 +857,20 @@ write_vips( Write *write, int compress, int interlace, const char *profile ) if( profile ) { if( strcmp( profile, "none" ) != 0 ) { void *data; - unsigned int length; + size_t length; - if( !(data = - vips__file_read_name( profile, VIPS_ICC_DIR, - &length )) ) + if( !(data = vips__file_read_name( profile, + VIPS_ICC_DIR, &length )) ) return( -1 ); #ifdef DEBUG printf( "write_vips: " - "attaching %d bytes of ICC profile\n", + "attaching %zd bytes of ICC profile\n", length ); #endif /*DEBUG*/ png_set_iCCP( write->pPng, write->pInfo, "icc", - PNG_COMPRESSION_TYPE_BASE, - data, length ); + PNG_COMPRESSION_TYPE_BASE, data, length ); } } else if( vips_image_get_typeof( in, VIPS_META_ICC_NAME ) ) { diff --git a/libvips/include/vips/util.h b/libvips/include/vips/util.h index 1fb2c60c..4043dd10 100644 --- a/libvips/include/vips/util.h +++ b/libvips/include/vips/util.h @@ -201,9 +201,9 @@ FILE *vips__file_open_read( const char *filename, const char *fallback_dir, gboolean text_mode ); FILE *vips__file_open_write( const char *filename, gboolean text_mode ); -char *vips__file_read( FILE *fp, const char *name, unsigned int *length_out ); +char *vips__file_read( FILE *fp, const char *name, size_t *length_out ); char *vips__file_read_name( const char *name, const char *fallback_dir, - unsigned int *length_out ); + size_t *length_out ); int vips__file_write( void *data, size_t size, size_t nmemb, FILE *stream ); int vips__get_bytes( const char *filename, unsigned char buf[], int len ); diff --git a/libvips/iofuncs/util.c b/libvips/iofuncs/util.c index 4c9da487..aab2e106 100644 --- a/libvips/iofuncs/util.c +++ b/libvips/iofuncs/util.c @@ -620,7 +620,7 @@ vips__file_open_write( const char *filename, gboolean text_mode ) /* Load up a file as a string. */ char * -vips__file_read( FILE *fp, const char *filename, unsigned int *length_out ) +vips__file_read( FILE *fp, const char *filename, size_t *length_out ) { gint64 len; size_t read; @@ -697,7 +697,7 @@ vips__file_read( FILE *fp, const char *filename, unsigned int *length_out ) */ char * vips__file_read_name( const char *filename, const char *fallback_dir, - unsigned int *length_out ) + size_t *length_out ) { FILE *fp; char *buffer; diff --git a/tools/vipsedit.c b/tools/vipsedit.c index a1eeca49..89987d26 100644 --- a/tools/vipsedit.c +++ b/tools/vipsedit.c @@ -216,7 +216,7 @@ main( int argc, char **argv ) if( setext ) { char *xml; - unsigned int size; + size_t size; if( !(xml = im__file_read( stdin, "stdin", &size )) ) error_exit( "%s", _( "could not get ext data" ) );