1
- /* $Id: tif_close.c,v 1.19 2010-03-10 18:56:48 bfriesen Exp $ */
1
+ /* $Id: tif_close.c,v 1.21 2016-01-23 21:20:34 erouault Exp $ */
2
2
3
3
/*
4
4
* Copyright (c) 1988-1997 Sam Leffler
5
5
* Copyright (c) 1991-1997 Silicon Graphics, Inc.
6
6
*
7
- * Permission to use, copy, modify, distribute, and sell this software and
7
+ * Permission to use, copy, modify, distribute, and sell this software and
8
8
* its documentation for any purpose is hereby granted without fee, provided
9
9
* that (i) the above copyright notices and this permission notice appear in
10
10
* all copies of the software and related documentation, and (ii) the names of
11
11
* Sam Leffler and Silicon Graphics may not be used in any advertising or
12
12
* publicity relating to the software without the specific, prior written
13
13
* permission of Sam Leffler and Silicon Graphics.
14
- *
15
- * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
16
- * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
17
- * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
18
- *
14
+ *
15
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
16
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
17
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
18
+ *
19
19
* IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
20
20
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
21
21
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
22
- * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
23
- * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
22
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
23
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
24
24
* OF THIS SOFTWARE.
25
25
*/
26
26
36
36
37
37
/**
38
38
* Auxiliary function to free the TIFF structure. Given structure will be
39
- * completetly freed, so you should save opened file handle and pointer
39
+ * completely freed, so you should save opened file handle and pointer
40
40
* to the close procedure in external variables before calling
41
41
* _TIFFCleanup(), if you will need these ones to close the file.
42
- *
42
+ *
43
43
* @param tif A TIFF pointer.
44
44
*/
45
45
46
46
void
47
47
TIFFCleanup (TIFF * tif )
48
48
{
49
- /*
49
+ /*
50
50
* Flush buffered data and directory (if dirty).
51
51
*/
52
- if (tif -> tif_mode != O_RDONLY )
53
- TIFFFlush (tif );
54
- (* tif -> tif_cleanup )(tif );
55
- TIFFFreeDirectory (tif );
52
+ if (tif -> tif_mode != O_RDONLY )
53
+ TIFFFlush (tif );
54
+ (* tif -> tif_cleanup )(tif );
55
+ TIFFFreeDirectory (tif );
56
56
57
- if (tif -> tif_dirlist )
58
- _TIFFfree (tif -> tif_dirlist );
57
+ if (tif -> tif_dirlist )
58
+ _TIFFfree (tif -> tif_dirlist );
59
59
60
- /*
60
+ /*
61
61
* Clean up client info links.
62
62
*/
63
- while ( tif -> tif_clientinfo )
64
- {
65
- TIFFClientInfoLink * link = tif -> tif_clientinfo ;
63
+ while ( tif -> tif_clientinfo )
64
+ {
65
+ TIFFClientInfoLink * psLink = tif -> tif_clientinfo ;
66
66
67
- tif -> tif_clientinfo = link -> next ;
68
- _TIFFfree ( link -> name );
69
- _TIFFfree ( link );
70
- }
67
+ tif -> tif_clientinfo = psLink -> next ;
68
+ _TIFFfree ( psLink -> name );
69
+ _TIFFfree ( psLink );
70
+ }
71
71
72
- if (tif -> tif_rawdata && (tif -> tif_flags & TIFF_MYBUFFER ))
73
- _TIFFfree (tif -> tif_rawdata );
74
- if (isMapped (tif ))
75
- TIFFUnmapFileContents (tif , tif -> tif_base , (toff_t )tif -> tif_size );
72
+ if (tif -> tif_rawdata && (tif -> tif_flags & TIFF_MYBUFFER ))
73
+ _TIFFfree (tif -> tif_rawdata );
74
+ if (isMapped (tif ))
75
+ TIFFUnmapFileContents (tif , tif -> tif_base , (toff_t )tif -> tif_size );
76
76
77
- /*
77
+ /*
78
78
* Clean up custom fields.
79
79
*/
80
- if (tif -> tif_fields && tif -> tif_nfields > 0 ) {
81
- uint32 i ;
82
-
83
- for (i = 0 ; i < tif -> tif_nfields ; i ++ ) {
84
- TIFFField * fld = tif -> tif_fields [i ];
85
- if (fld -> field_bit == FIELD_CUSTOM &&
86
- strncmp ("Tag " , fld -> field_name , 4 ) == 0 ) {
87
- _TIFFfree (fld -> field_name );
88
- _TIFFfree (fld );
89
- }
90
- }
80
+ if (tif -> tif_fields && tif -> tif_nfields > 0 ) {
81
+ uint32 i ;
82
+
83
+ for (i = 0 ; i < tif -> tif_nfields ; i ++ ) {
84
+ TIFFField * fld = tif -> tif_fields [i ];
85
+ if (fld -> field_bit == FIELD_CUSTOM &&
86
+ strncmp ("Tag " , fld -> field_name , 4 ) == 0 ) {
87
+ _TIFFfree (fld -> field_name );
88
+ _TIFFfree (fld );
89
+ }
90
+ }
91
91
92
- _TIFFfree (tif -> tif_fields );
93
- }
92
+ _TIFFfree (tif -> tif_fields );
93
+ }
94
94
95
95
if (tif -> tif_nfieldscompat > 0 ) {
96
96
uint32 i ;
@@ -102,7 +102,7 @@ TIFFCleanup(TIFF* tif)
102
102
_TIFFfree (tif -> tif_fieldscompat );
103
103
}
104
104
105
- _TIFFfree (tif );
105
+ _TIFFfree (tif );
106
106
}
107
107
108
108
/************************************************************************/
@@ -115,18 +115,18 @@ TIFFCleanup(TIFF* tif)
115
115
* TIFFClose closes a file that was previously opened with TIFFOpen().
116
116
* Any buffered data are flushed to the file, including the contents of
117
117
* the current directory (if modified); and all resources are reclaimed.
118
- *
118
+ *
119
119
* @param tif A TIFF pointer.
120
120
*/
121
121
122
122
void
123
123
TIFFClose (TIFF * tif )
124
124
{
125
- TIFFCloseProc closeproc = tif -> tif_closeproc ;
126
- thandle_t fd = tif -> tif_clientdata ;
125
+ TIFFCloseProc closeproc = tif -> tif_closeproc ;
126
+ thandle_t fd = tif -> tif_clientdata ;
127
127
128
- TIFFCleanup (tif );
129
- (void ) (* closeproc )(fd );
128
+ TIFFCleanup (tif );
129
+ (void ) (* closeproc )(fd );
130
130
}
131
131
132
132
/* vim: set ts=8 sts=8 sw=8 noet: */
0 commit comments