| Bsoft 1.9 Bernard's software package

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

tif_close.c
Go to the documentation of this file.
1 /* $Id: tif_close.c,v 1.10.2.1 2010-06-08 18:50:41 bfriesen Exp $ */
2
3 /*
4 * Copyright (c) 1988-1997 Sam Leffler
5 * Copyright (c) 1991-1997 Silicon Graphics, Inc.
6 *
7 * Permission to use, copy, modify, distribute, and sell this software and
8 * its documentation for any purpose is hereby granted without fee, provided
9 * that (i) the above copyright notices and this permission notice appear in
10 * all copies of the software and related documentation, and (ii) the names of
11 * Sam Leffler and Silicon Graphics may not be used in any advertising or
12 * publicity relating to the software without the specific, prior written
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 *
19 * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
20 * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
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
24 * OF THIS SOFTWARE.
25 */
26
27 /*
28 * TIFF Library.
29 */
30 #include "tiffiop.h"
31
32 /************************************************************************/
33 /* TIFFCleanup() */
34 /************************************************************************/
35
45 void
46 TIFFCleanup(TIFF* tif)
47 {
48 if (tif->tif_mode != O_RDONLY)
49 /*
50 * Flush buffered data and directory (if dirty).
51 */
52 TIFFFlush(tif);
53 (*tif->tif_cleanup)(tif);
54 TIFFFreeDirectory(tif);
55
56 if (tif->tif_dirlist)
57 _TIFFfree(tif->tif_dirlist);
58
59 /* Clean up client info links */
60 while( tif->tif_clientinfo )
61 {
62 TIFFClientInfoLink *link = tif->tif_clientinfo;
63
64 tif->tif_clientinfo = link->next;
65 _TIFFfree( link->name );
66 _TIFFfree( link );
67 }
68
69 if (tif->tif_rawdata && (tif->tif_flags&TIFF_MYBUFFER))
70 _TIFFfree(tif->tif_rawdata);
71 if (isMapped(tif))
72 TIFFUnmapFileContents(tif, tif->tif_base, tif->tif_size);
73
74 /* Clean up custom fields */
75 if (tif->tif_nfields > 0)
76 {
77 size_t i;
78
79 for (i = 0; i < tif->tif_nfields; i++)
80 {
81 TIFFFieldInfo *fld = tif->tif_fieldinfo[i];
82 if (fld->field_bit == FIELD_CUSTOM &&
83 strncmp("Tag ", fld->field_name, 4) == 0)
84 {
85 _TIFFfree(fld->field_name);
86 _TIFFfree(fld);
87 }
88 }
89
90 _TIFFfree(tif->tif_fieldinfo);
91 }
92
93 _TIFFfree(tif);
94 }
95
96 /************************************************************************/
97 /* TIFFClose() */
98 /************************************************************************/
99
110 void
111 TIFFClose(TIFF* tif)
112 {
113 TIFFCloseProc closeproc = tif->tif_closeproc;
114 thandle_t fd = tif->tif_clientdata;
115
116 TIFFCleanup(tif);
117 (void) (*closeproc)(fd);
118 }
119
120 /*
121 * Local Variables:
122 * mode: c
123 * c-basic-offset: 8
124 * fill-column: 78
125 * End:
126 */
FIELD_CUSTOM
#define FIELD_CUSTOM
Definition: tiffio.h:301
TIFFCloseProc
int(* TIFFCloseProc)(thandle_t)
Definition: tiffio.h:265
tiff::tif_clientinfo
TIFFClientInfoLink * tif_clientinfo
Definition: tiffiop.h:198
tiff::tif_rawdata
tidata_t tif_rawdata
Definition: tiffiop.h:174
client_info
Definition: tiffiop.h:81
TIFFUnmapFileContents
#define TIFFUnmapFileContents(tif, addr, size)
Definition: tiffiop.h:219
tiff::tif_clientdata
thandle_t tif_clientdata
Definition: tiffiop.h:185
tiffiop.h
tiff
Definition: tiffiop.h:102
TIFFCleanup
void TIFFCleanup(TIFF *tif)
Definition: tif_close.c:46
TIFFClose
void TIFFClose(TIFF *tif)
Definition: tif_close.c:111
client_info::name
char * name
Definition: tiffiop.h:84
tiff::tif_size
toff_t tif_size
Definition: tiffiop.h:180
tiff::tif_mode
int tif_mode
Definition: tiffiop.h:105
tiff::tif_flags
uint32 tif_flags
Definition: tiffiop.h:106
tiff::tif_nfields
size_t tif_nfields
Definition: tiffiop.h:195
tiff::tif_base
tidata_t tif_base
Definition: tiffiop.h:179
isMapped
#define isMapped(tif)
Definition: tiffiop.h:204
TIFFFreeDirectory
void TIFFFreeDirectory(TIFF *tif)
Definition: tif_dir.c:987
TIFFFieldInfo
Definition: tiffio.h:303
client_info::next
struct client_info * next
Definition: tiffiop.h:82
tiff::tif_fieldinfo
TIFFFieldInfo ** tif_fieldinfo
Definition: tiffiop.h:194
tiff::tif_dirlist
toff_t * tif_dirlist
Definition: tiffiop.h:129
tiff::tif_cleanup
TIFFVoidMethod tif_cleanup
Definition: tiffiop.h:167
tiff::tif_closeproc
TIFFCloseProc tif_closeproc
Definition: tiffiop.h:189
TIFFFlush
int TIFFFlush(TIFF *tif)
Definition: tif_flush.c:33
TIFFFieldInfo::field_name
char * field_name
Definition: tiffio.h:311
_TIFFfree
void _TIFFfree(tdata_t p)
Definition: tif_acorn.c:467
TIFFFieldInfo::field_bit
unsigned short field_bit
Definition: tiffio.h:308
thandle_t
void * thandle_t
Definition: tiffio.h:97
TIFF_MYBUFFER
#define TIFF_MYBUFFER
Definition: tiffiop.h:115