BigTIFF upgrade: restoration of mapping functions protocol

This commit is contained in:
Joris Van Damme 2007-07-11 15:52:48 +00:00
parent d83d6100fd
commit c4bddab560
6 changed files with 32 additions and 24 deletions

View File

@ -1,4 +1,4 @@
/* $Id: tif_close.c,v 1.14 2007-07-10 11:52:02 dron Exp $ */
/* $Id: tif_close.c,v 1.15 2007-07-11 15:52:48 joris Exp $ */
/*
* Copyright (c) 1988-1997 Sam Leffler
@ -69,7 +69,7 @@ TIFFCleanup(TIFF* tif)
if (tif->tif_rawdata && (tif->tif_flags&TIFF_MYBUFFER))
_TIFFfree(tif->tif_rawdata);
if (isMapped(tif))
TIFFUnmapFileContents(tif, tif->tif_base, tif->tif_size);
TIFFUnmapFileContents(tif, tif->tif_base, (toff_t)tif->tif_size);
/* Clean up custom fields */
if (tif->tif_nfields > 0)

View File

@ -1,4 +1,4 @@
/* $Id: tif_open.c,v 1.41 2007-06-29 11:30:29 joris Exp $ */
/* $Id: tif_open.c,v 1.42 2007-07-11 15:52:48 joris Exp $ */
/*
* Copyright (c) 1988-1997 Sam Leffler
@ -33,14 +33,14 @@
* Dummy functions to fill the omitted client procedures.
*/
static int
_tiffDummyMapProc(thandle_t fd, void** pbase, tmsize_t* psize)
_tiffDummyMapProc(thandle_t fd, void** pbase, toff_t* psize)
{
(void) fd; (void) pbase; (void) psize;
return (0);
}
static void
_tiffDummyUnmapProc(thandle_t fd, void* base, tmsize_t size)
_tiffDummyUnmapProc(thandle_t fd, void* base, toff_t size)
{
(void) fd; (void) base; (void) size;
}
@ -450,9 +450,17 @@ TIFFClientOpen(
* has not explicitly suppressed usage with the
* 'm' flag in the open mode (see above).
*/
if ((tif->tif_flags & TIFF_MAPPED) &&
!TIFFMapFileContents(tif,(void**)(&tif->tif_base),&tif->tif_size))
if (tif->tif_flags & TIFF_MAPPED)
{
toff_t n;
if (TIFFMapFileContents(tif,(void**)(&tif->tif_base),&n))
{
tif->tif_size=(tmsize_t)n;
assert((toff_t)tif->tif_size==n);
}
else
tif->tif_flags &= ~TIFF_MAPPED;
}
if (TIFFReadDirectory(tif)) {
tif->tif_rawcc = (tmsize_t)-1;
tif->tif_flags |= TIFF_BUFFERSETUP;

View File

@ -1,4 +1,4 @@
/* $Id: tif_unix.c,v 1.19 2007-06-28 22:23:49 bfriesen Exp $ */
/* $Id: tif_unix.c,v 1.20 2007-07-11 15:52:48 joris Exp $ */
/*
* Copyright (c) 1988-1997 Sam Leffler
@ -111,7 +111,7 @@ _tiffSizeProc(thandle_t fd)
#include <sys/mman.h>
static int
_tiffMapProc(thandle_t fd, void** pbase, tmsize_t* psize)
_tiffMapProc(thandle_t fd, void** pbase, toff_t* psize)
{
uint64 size64 = _tiffSizeProc(fd);
tmsize_t sizem = (tmsize_t)size64;
@ -127,21 +127,21 @@ _tiffMapProc(thandle_t fd, void** pbase, tmsize_t* psize)
}
static void
_tiffUnmapProc(thandle_t fd, void* base, tmsize_t size)
_tiffUnmapProc(thandle_t fd, void* base, toff_t size)
{
(void) fd;
(void) munmap(base, (off_t) size);
}
#else /* !HAVE_MMAP */
static int
_tiffMapProc(thandle_t fd, void** pbase, tmsize_t* psize)
_tiffMapProc(thandle_t fd, void** pbase, toff_t* psize)
{
(void) fd; (void) pbase; (void) psize;
return (0);
}
static void
_tiffUnmapProc(thandle_t fd, void* base, tmsize_t size)
_tiffUnmapProc(thandle_t fd, void* base, toff_t size)
{
(void) fd; (void) base; (void) size;
}

View File

@ -1,4 +1,4 @@
/* $Id: tif_win32.c,v 1.30 2007-06-28 01:34:01 joris Exp $ */
/* $Id: tif_win32.c,v 1.31 2007-07-11 15:52:48 joris Exp $ */
/*
* Copyright (c) 1988-1997 Sam Leffler
@ -133,7 +133,7 @@ _tiffSizeProc(thandle_t fd)
}
static int
_tiffDummyMapProc(thandle_t fd, void** pbase, tmsize_t* psize)
_tiffDummyMapProc(thandle_t fd, void** pbase, toff_t* psize)
{
(void) fd;
(void) pbase;
@ -153,7 +153,7 @@ _tiffDummyMapProc(thandle_t fd, void** pbase, tmsize_t* psize)
* with Visual C++ 5.0
*/
static int
_tiffMapProc(thandle_t fd, void** pbase, tmsize_t* psize)
_tiffMapProc(thandle_t fd, void** pbase, toff_t* psize)
{
uint64 size;
tmsize_t sizem;
@ -170,12 +170,12 @@ _tiffMapProc(thandle_t fd, void** pbase, tmsize_t* psize)
CloseHandle(hMapFile);
if (*pbase == NULL)
return (0);
*psize = sizem;
*psize = size;
return(1);
}
static void
_tiffDummyUnmapProc(thandle_t fd, void* base, tmsize_t size)
_tiffDummyUnmapProc(thandle_t fd, void* base, toff_t size)
{
(void) fd;
(void) base;
@ -183,7 +183,7 @@ _tiffDummyUnmapProc(thandle_t fd, void* base, tmsize_t size)
}
static void
_tiffUnmapProc(thandle_t fd, void* base, tmsize_t size)
_tiffUnmapProc(thandle_t fd, void* base, toff_t size)
{
(void) fd;
(void) size;

View File

@ -1,4 +1,4 @@
/* $Id: tiffio.h,v 1.76 2007-07-09 10:15:37 dron Exp $ */
/* $Id: tiffio.h,v 1.77 2007-07-11 15:52:48 joris Exp $ */
/*
* Copyright (c) 1988-1997 Sam Leffler
@ -272,8 +272,8 @@ typedef tmsize_t (*TIFFReadWriteProc)(thandle_t, void*, tmsize_t);
typedef uint64 (*TIFFSeekProc)(thandle_t, uint64, int);
typedef int (*TIFFCloseProc)(thandle_t);
typedef uint64 (*TIFFSizeProc)(thandle_t);
typedef int (*TIFFMapFileProc)(thandle_t, void** base, tmsize_t* size);
typedef void (*TIFFUnmapFileProc)(thandle_t, void* base, tmsize_t size);
typedef int (*TIFFMapFileProc)(thandle_t, void** base, toff_t* size);
typedef void (*TIFFUnmapFileProc)(thandle_t, void* base, toff_t size);
typedef void (*TIFFExtendProc)(TIFF*);
extern const char* TIFFGetVersion(void);

View File

@ -1,4 +1,4 @@
/* $Id: tiffiop.h,v 1.65 2007-07-10 11:52:02 dron Exp $ */
/* $Id: tiffiop.h,v 1.66 2007-07-11 15:52:48 joris Exp $ */
/*
* Copyright (c) 1988-1997 Sam Leffler
@ -190,7 +190,7 @@ struct tiff {
tmsize_t tif_rawcc; /* bytes unread from raw buffer */
/* memory-mapped file support */
uint8* tif_base; /* base of mapped file */
tmsize_t tif_size; /* size of mapped file region (bytes) */
tmsize_t tif_size; /* size of mapped file region (bytes, thus tmsize_t) */
TIFFMapFileProc tif_mapproc; /* map file method */
TIFFUnmapFileProc tif_unmapproc; /* unmap file method */
/* input/output callback methods */