X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/b47c832e5529dc6c632536b4665a005f0a85aec8..f1f5f16f780bb41aa2ea24ccbf728f14c86cc475:/src/tiff/tif_win32.c diff --git a/src/tiff/tif_win32.c b/src/tiff/tif_win32.c index eae85229c9..9ddf5fea12 100644 --- a/src/tiff/tif_win32.c +++ b/src/tiff/tif_win32.c @@ -52,23 +52,30 @@ _tiffWriteProc(thandle_t fd, tdata_t buf, tsize_t size) static toff_t _tiffSeekProc(thandle_t fd, toff_t off, int whence) { - DWORD dwMoveMethod; + DWORD dwMoveMethod, dwMoveHigh; + + /* we use this as a special code, so avoid accepting it */ + if( off == 0xFFFFFFFF ) + return 0xFFFFFFFF; + switch(whence) { - case 0: + case SEEK_SET: dwMoveMethod = FILE_BEGIN; break; - case 1: + case SEEK_CUR: dwMoveMethod = FILE_CURRENT; break; - case 2: + case SEEK_END: dwMoveMethod = FILE_END; break; default: dwMoveMethod = FILE_BEGIN; break; } - return ((toff_t)SetFilePointer(fd, off, NULL, dwMoveMethod)); + dwMoveHigh = 0; + return ((toff_t)SetFilePointer(fd, (LONG) off, (PLONG)&dwMoveHigh, + dwMoveMethod)); } static int @@ -83,6 +90,9 @@ _tiffSizeProc(thandle_t fd) return ((toff_t)GetFileSize(fd, NULL)); } +#ifdef __BORLANDC__ +#pragma argsused +#endif static int _tiffDummyMapProc(thandle_t fd, tdata_t* pbase, toff_t* psize) { @@ -106,7 +116,7 @@ _tiffMapProc(thandle_t fd, tdata_t* pbase, toff_t* psize) toff_t size; HANDLE hMapFile; - if ((size = _tiffSizeProc(fd)) == (toff_t)-1) + if ((size = _tiffSizeProc(fd)) == 0xFFFFFFFF) return (0); hMapFile = CreateFileMapping(fd, NULL, PAGE_READONLY, 0, size, NULL); if (hMapFile == NULL) @@ -119,6 +129,9 @@ _tiffMapProc(thandle_t fd, tdata_t* pbase, toff_t* psize) return(1); } +#ifdef __BORLANDC__ +#pragma argsused +#endif static void _tiffDummyUnmapProc(thandle_t fd, tdata_t base, toff_t size) { @@ -139,7 +152,7 @@ TIFF* TIFFFdOpen(int ifd, const char* name, const char* mode) { TIFF* tif; - BOOL fSuppressMap = (mode[1] == 'u' || mode[2] == 'u'); + BOOL fSuppressMap = (mode[1] == 'u' || (mode[1]!=0 && mode[2] == 'u')); tif = TIFFClientOpen(name, mode, (thandle_t)ifd, @@ -211,14 +224,23 @@ _TIFFfree(tdata_t p) tdata_t _TIFFrealloc(tdata_t p, tsize_t s) { - void* pvTmp; - if ((pvTmp = GlobalReAlloc(p, s, 0)) == NULL) { - if ((pvTmp = GlobalAlloc(GMEM_FIXED, s)) != NULL) { - CopyMemory(pvTmp, p, GlobalSize(p)); - GlobalFree(p); - } - } - return ((tdata_t)pvTmp); + void* pvTmp; + tsize_t old=GlobalSize(p); + if (old>=s) + { + if ((pvTmp = GlobalAlloc(GMEM_FIXED, s)) != NULL) { + CopyMemory(pvTmp, p, s); + GlobalFree(p); + } + } + else + { + if ((pvTmp = GlobalAlloc(GMEM_FIXED, s)) != NULL) { + CopyMemory(pvTmp, p, old); + GlobalFree(p); + } + } + return ((tdata_t)pvTmp); } void @@ -236,8 +258,8 @@ _TIFFmemcpy(void* d, const tdata_t s, tsize_t c) int _TIFFmemcmp(const tdata_t p1, const tdata_t p2, tsize_t c) { - register const BYTE *pb1 = p1; - register const BYTE *pb2 = p2; + register const BYTE *pb1 = (const BYTE *) p1; + register const BYTE *pb2 = (const BYTE *) p2; register DWORD dwTmp = c; register int iTmp; for (iTmp = 0; dwTmp-- && !iTmp; iTmp = (int)*pb1++ - (int)*pb2++)