summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoris Van Damme <joris.at.lebbeke@skynet.be>2007-07-11 15:52:48 +0000
committerJoris Van Damme <joris.at.lebbeke@skynet.be>2007-07-11 15:52:48 +0000
commitc4bddab560793471683b19d9fd440844e95f1bf9 (patch)
tree79c506c135ddad443aa1a319be389b1d25dce267
parentd83d6100fd2f0f0ddf2f063eb3caf07f13a1ba54 (diff)
downloadlibtiff-git-c4bddab560793471683b19d9fd440844e95f1bf9.tar.gz
BigTIFF upgrade: restoration of mapping functions protocol
-rw-r--r--libtiff/tif_close.c4
-rw-r--r--libtiff/tif_open.c20
-rw-r--r--libtiff/tif_unix.c10
-rw-r--r--libtiff/tif_win32.c12
-rw-r--r--libtiff/tiffio.h6
-rw-r--r--libtiff/tiffiop.h4
6 files changed, 32 insertions, 24 deletions
diff --git a/libtiff/tif_close.c b/libtiff/tif_close.c
index 6275c355..324423b0 100644
--- a/libtiff/tif_close.c
+++ b/libtiff/tif_close.c
@@ -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)
diff --git a/libtiff/tif_open.c b/libtiff/tif_open.c
index 4c4b861b..d9dd7f6c 100644
--- a/libtiff/tif_open.c
+++ b/libtiff/tif_open.c
@@ -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))
- tif->tif_flags &= ~TIFF_MAPPED;
+ 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;
diff --git a/libtiff/tif_unix.c b/libtiff/tif_unix.c
index 14984018..2aa52940 100644
--- a/libtiff/tif_unix.c
+++ b/libtiff/tif_unix.c
@@ -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;
}
diff --git a/libtiff/tif_win32.c b/libtiff/tif_win32.c
index ab5489de..94bccea6 100644
--- a/libtiff/tif_win32.c
+++ b/libtiff/tif_win32.c
@@ -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;
diff --git a/libtiff/tiffio.h b/libtiff/tiffio.h
index b0e10bd9..9aa776b8 100644
--- a/libtiff/tiffio.h
+++ b/libtiff/tiffio.h
@@ -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);
diff --git a/libtiff/tiffiop.h b/libtiff/tiffiop.h
index 9e1a8b52..ab77b208 100644
--- a/libtiff/tiffiop.h
+++ b/libtiff/tiffiop.h
@@ -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 */