various size_t->guint64 fixes

some platforms have off_t as 32-bits breaking large file support ...
make sure we use guint64 everywhere
This commit is contained in:
John Cupitt 2011-12-09 09:42:39 +00:00
parent b9756d402a
commit b9747f5a06
6 changed files with 27 additions and 21 deletions

12
TODO
View File

@ -1,15 +1,3 @@
- make sure we have the win32 largefile fix from 7.26
header_size should be a guint64 too
various other projection funcs as well I noticed
anything else there we need?
- vipsimage should be cached too, eg.
VipsImage *a = vips_image_new_from_file( "poop.jpg" );

View File

@ -77,7 +77,7 @@ extern "C" {
*/
#define VIPS_META_RESOLUTION_UNIT "resolution-unit"
int vips_format_sizeof( VipsBandFormat format );
guint64 vips_format_sizeof( VipsBandFormat format );
int vips_image_get_width( const VipsImage *image );
int vips_image_get_height( const VipsImage *image );

View File

@ -316,8 +316,11 @@ typedef struct _VipsImage {
/* Part of mmap() read ... the sizeof() the header we skip from the
* file start. Usually VIPS_SIZEOF_HEADER, but can be something else
* for binary file read.
*
* gint64 so that we can guarantee to work even on systems with
* strange ideas about large files.
*/
int sizeof_header;
guint64 sizeof_header;
/* If this is a large disc image, don't map the whole thing, instead
* have a set of windows shared between the regions active on the
@ -372,7 +375,6 @@ typedef struct _VipsImage {
*/
gboolean delete_on_close;
char *delete_on_close_filename;
} VipsImage;
typedef struct _VipsImageClass {
@ -468,7 +470,7 @@ VipsImage *vips_image_new( void );
VipsImage *vips_image_new_mode( const char *filename, const char *mode );
VipsImage *vips_image_new_from_file( const char *filename );
VipsImage *vips_image_new_from_file_raw( const char *filename,
int xsize, int ysize, int bands, int offset );
int xsize, int ysize, int bands, guint64 offset );
VipsImage *vips_image_new_from_memory( void *buffer,
int xsize, int ysize, int bands, VipsBandFormat bandfmt );
VipsImage *vips_image_new_array( int xsize, int ysize );

View File

@ -168,6 +168,19 @@ extern int _vips__argument_id;
pspec, (FLAGS), (PRIORITY), (OFFSET) ); \
}
#define VIPS_ARG_UINT64( CLASS, NAME, PRIORITY, LONG, DESC, \
FLAGS, OFFSET, MIN, MAX, VALUE ) { \
GParamSpec *pspec; \
\
pspec = g_param_spec_uint64( (NAME), (LONG), (DESC), \
(MIN), (MAX), (VALUE), \
G_PARAM_READWRITE );\
g_object_class_install_property( G_OBJECT_CLASS( CLASS ), \
_vips__argument_id++, pspec ); \
vips_object_class_install_argument( VIPS_OBJECT_CLASS( CLASS ), \
pspec, (FLAGS), (PRIORITY), (OFFSET) ); \
}
#define VIPS_ARG_ENUM( CLASS, NAME, PRIORITY, LONG, DESC, \
FLAGS, OFFSET, TYPE, VALUE ) { \
GParamSpec *pspec; \

View File

@ -186,8 +186,11 @@ static HeaderField old_double_field[] = {
/* This is used by (eg.) VIPS_IMAGE_SIZEOF_ELEMENT() to calculate object
* size.
*
* It needs to be guint64 and not size_t since we use this as the basis for
* image address calcs and they have to be 64-bit, even on 32-bit machines.
*/
const size_t vips__image_sizeof_bandformat[] = {
const guint64 vips__image_sizeof_bandformat[] = {
sizeof( unsigned char ), /* VIPS_FORMAT_UCHAR */
sizeof( signed char ), /* VIPS_FORMAT_CHAR */
sizeof( unsigned short ), /* VIPS_FORMAT_USHORT */
@ -202,7 +205,7 @@ const size_t vips__image_sizeof_bandformat[] = {
/* Return number of bytes for a band format, or -1 on error.
*/
int
guint64
vips_format_sizeof( VipsBandFormat format )
{
return( (format < 0 || format > VIPS_FORMAT_DPCOMPLEX) ?

View File

@ -757,7 +757,7 @@ vips_image_build( VipsObject *object )
const char *mode = image->mode;
VipsFormatClass *format;
size_t sizeof_image;
guint64 sizeof_image;
VIPS_DEBUG_MSG( "vips_image_build: %p\n", image );
@ -1069,7 +1069,7 @@ vips_image_class_init( VipsImageClass *class )
G_STRUCT_OFFSET( VipsImage, dhint ),
VIPS_TYPE_DEMAND_STYLE, VIPS_DEMAND_STYLE_SMALLTILE );
VIPS_ARG_INT( class, "sizeof_header", 16,
VIPS_ARG_UINT64( class, "sizeof_header", 16,
_( "Size of header" ),
_( "Offset in bytes from start of file" ),
VIPS_ARGUMENT_SET_ONCE | VIPS_ARGUMENT_CONSTRUCT,
@ -1559,7 +1559,7 @@ vips_image_new_from_file( const char *filename )
*/
VipsImage *
vips_image_new_from_file_raw( const char *filename,
int xsize, int ysize, int bands, int offset )
int xsize, int ysize, int bands, guint64 offset )
{
VipsImage *image;