summaryrefslogtreecommitdiff
path: root/libtiff/tif_close.c
diff options
context:
space:
mode:
authorAndrey Kiselev <dron@ak4719.spb.edu>2004-01-28 17:57:09 +0000
committerAndrey Kiselev <dron@ak4719.spb.edu>2004-01-28 17:57:09 +0000
commit45a3f9e55128b0d267002e26fe9db47d65d23696 (patch)
tree86427c67158c3bad27134cf32c0ff2d459c94e7a /libtiff/tif_close.c
parentd75f9c355aa453eea6bc44b7bae3bf9447d081e2 (diff)
downloadlibtiff-git-45a3f9e55128b0d267002e26fe9db47d65d23696.tar.gz
Separate TIFFCleanup() from the TIFFClose() in order to fix the bug
http://bugzilla.remotesensing.org/show_bug.cgi?id=468
Diffstat (limited to 'libtiff/tif_close.c')
-rw-r--r--libtiff/tif_close.c92
1 files changed, 52 insertions, 40 deletions
diff --git a/libtiff/tif_close.c b/libtiff/tif_close.c
index 05441068..a03c590c 100644
--- a/libtiff/tif_close.c
+++ b/libtiff/tif_close.c
@@ -1,4 +1,4 @@
-/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_close.c,v 1.5 2003-09-25 08:02:46 dron Exp $ */
+/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_close.c,v 1.6 2004-01-28 17:57:09 dron Exp $ */
/*
* Copyright (c) 1988-1997 Sam Leffler
@@ -30,51 +30,63 @@
#include "tiffiop.h"
void
-TIFFClose(TIFF* tif)
+TIFFCleanup(TIFF* tif)
{
- if (tif->tif_mode != O_RDONLY)
- /*
- * Flush buffered data and directory (if dirty).
- */
- TIFFFlush(tif);
- (*tif->tif_cleanup)(tif);
- TIFFFreeDirectory(tif);
+ if (tif->tif_mode != O_RDONLY)
+ /*
+ * Flush buffered data and directory (if dirty).
+ */
+ TIFFFlush(tif);
+ (*tif->tif_cleanup)(tif);
+ TIFFFreeDirectory(tif);
- if (tif->tif_dirlist)
- _TIFFfree(tif->tif_dirlist);
-
- /* Clean up client info links */
- while( tif->tif_clientinfo )
- {
- TIFFClientInfoLink *link = tif->tif_clientinfo;
+ if (tif->tif_dirlist)
+ _TIFFfree(tif->tif_dirlist);
+
+ /* Clean up client info links */
+ while( tif->tif_clientinfo )
+ {
+ TIFFClientInfoLink *link = tif->tif_clientinfo;
- tif->tif_clientinfo = link->next;
- _TIFFfree( link->name );
- _TIFFfree( link );
- }
+ tif->tif_clientinfo = link->next;
+ _TIFFfree( link->name );
+ _TIFFfree( link );
+ }
- if (tif->tif_rawdata && (tif->tif_flags&TIFF_MYBUFFER))
- _TIFFfree(tif->tif_rawdata);
- if (isMapped(tif))
- TIFFUnmapFileContents(tif, tif->tif_base, tif->tif_size);
- (void) TIFFCloseFile(tif);
- if (tif->tif_nfields > 0)
- {
- int i;
+ if (tif->tif_rawdata && (tif->tif_flags&TIFF_MYBUFFER))
+ _TIFFfree(tif->tif_rawdata);
+ if (isMapped(tif))
+ TIFFUnmapFileContents(tif, tif->tif_base, tif->tif_size);
- for (i = 0; i < tif->tif_nfields; i++)
+ /* Clean up custom fields */
+ if (tif->tif_nfields > 0)
{
- TIFFFieldInfo *fld = tif->tif_fieldinfo[i];
- if (fld->field_bit == FIELD_CUSTOM &&
- strncmp("Tag ", fld->field_name, 4) == 0)
+ int i;
+
+ for (i = 0; i < tif->tif_nfields; i++)
{
- _TIFFfree(fld->field_name);
- _TIFFfree(fld);
- }
- }
-
- _TIFFfree(tif->tif_fieldinfo);
- }
+ TIFFFieldInfo *fld = tif->tif_fieldinfo[i];
+ if (fld->field_bit == FIELD_CUSTOM &&
+ strncmp("Tag ", fld->field_name, 4) == 0)
+ {
+ _TIFFfree(fld->field_name);
+ _TIFFfree(fld);
+ }
+ }
+
+ _TIFFfree(tif->tif_fieldinfo);
+ }
+
+ _TIFFfree(tif);
+}
- _TIFFfree(tif);
+void
+TIFFClose(TIFF* tif)
+{
+ TIFFCloseProc closeproc = tif->tif_closeproc;
+ int fd = (int)tif->tif_clientdata;
+
+ TIFFCleanup(tif);
+ (void) (*closeproc)(fd);
}
+