ReactOS  0.4.14-dev-552-g2fad488
tif_close.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 1988-1997 Sam Leffler
3  * Copyright (c) 1991-1997 Silicon Graphics, Inc.
4  *
5  * Permission to use, copy, modify, distribute, and sell this software and
6  * its documentation for any purpose is hereby granted without fee, provided
7  * that (i) the above copyright notices and this permission notice appear in
8  * all copies of the software and related documentation, and (ii) the names of
9  * Sam Leffler and Silicon Graphics may not be used in any advertising or
10  * publicity relating to the software without the specific, prior written
11  * permission of Sam Leffler and Silicon Graphics.
12  *
13  * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
14  * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
15  * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
16  *
17  * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
18  * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
19  * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
20  * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
21  * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
22  * OF THIS SOFTWARE.
23  */
24 
25 /*
26  * TIFF Library.
27  */
28 
29 #include <precomp.h>
30 //#include <string.h>
31 
32 /************************************************************************/
33 /* TIFFCleanup() */
34 /************************************************************************/
35 
45 void
47 {
48  /*
49  * Flush buffered data and directory (if dirty).
50  */
51  if (tif->tif_mode != O_RDONLY)
52  TIFFFlush(tif);
53  (*tif->tif_cleanup)(tif);
54  TIFFFreeDirectory(tif);
55 
56  if (tif->tif_dirlist)
57  _TIFFfree(tif->tif_dirlist);
58 
59  /*
60  * Clean up client info links.
61  */
62  while( tif->tif_clientinfo )
63  {
64  TIFFClientInfoLink *psLink = tif->tif_clientinfo;
65 
66  tif->tif_clientinfo = psLink->next;
67  _TIFFfree( psLink->name );
68  _TIFFfree( psLink );
69  }
70 
71  if (tif->tif_rawdata && (tif->tif_flags&TIFF_MYBUFFER))
72  _TIFFfree(tif->tif_rawdata);
73  if (isMapped(tif))
75 
76  /*
77  * Clean up custom fields.
78  */
79  if (tif->tif_fields && tif->tif_nfields > 0) {
80  uint32 i;
81 
82  for (i = 0; i < tif->tif_nfields; i++) {
83  TIFFField *fld = tif->tif_fields[i];
84  if (fld->field_bit == FIELD_CUSTOM &&
85  strncmp("Tag ", fld->field_name, 4) == 0) {
86  _TIFFfree(fld->field_name);
87  _TIFFfree(fld);
88  }
89  }
90 
91  _TIFFfree(tif->tif_fields);
92  }
93 
94  if (tif->tif_nfieldscompat > 0) {
95  uint32 i;
96 
97  for (i = 0; i < tif->tif_nfieldscompat; i++) {
100  }
102  }
103 
104  _TIFFfree(tif);
105 }
106 
107 /************************************************************************/
108 /* TIFFClose() */
109 /************************************************************************/
110 
121 void
123 {
124  TIFFCloseProc closeproc = tif->tif_closeproc;
125  thandle_t fd = tif->tif_clientdata;
126 
127  TIFFCleanup(tif);
128  (void) (*closeproc)(fd);
129 }
130 
131 /* vim: set ts=8 sts=8 sw=8 noet: */
132 
133 /*
134  * Local Variables:
135  * mode: c
136  * c-basic-offset: 8
137  * fill-column: 78
138  * End:
139  */
#define FIELD_CUSTOM
Definition: tiffio.h:317
int(* TIFFCloseProc)(thandle_t)
Definition: tiffio.h:280
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
uint8 * tif_base
Definition: tiffiop.h:186
unsigned int uint32
Definition: types.h:32
uint64 toff_t
Definition: tiffio.h:66
TIFFClientInfoLink * tif_clientinfo
Definition: tiffiop.h:204
static int fd
Definition: io.c:51
uint8 * tif_rawdata
Definition: tiffiop.h:179
#define TIFFUnmapFileContents(tif, addr, size)
Definition: tiffiop.h:229
thandle_t tif_clientdata
Definition: tiffiop.h:191
Definition: tiffiop.h:102
void TIFFCleanup(TIFF *tif)
Definition: tif_close.c:46
unsigned short field_bit
Definition: tif_dir.h:286
void TIFFClose(TIFF *tif)
Definition: tif_close.c:122
char * name
Definition: tiffiop.h:83
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
char * field_name
Definition: tif_dir.h:289
int tif_mode
Definition: tiffiop.h:105
uint32 tif_flags
Definition: tiffiop.h:106
size_t tif_nfields
Definition: tiffiop.h:201
TIFFFieldArray * tif_fieldscompat
Definition: tiffiop.h:207
#define isMapped(tif)
Definition: tiffiop.h:214
uint32 allocated_size
Definition: tif_dir.h:273
void TIFFFreeDirectory(TIFF *tif)
Definition: tif_dir.c:1251
TIFFField * fields
Definition: tif_dir.h:275
struct client_info * next
Definition: tiffiop.h:81
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
Definition: utclib.c:534
uint64 * tif_dirlist
Definition: tiffiop.h:132
tmsize_t tif_size
Definition: tiffiop.h:187
TIFFVoidMethod tif_cleanup
Definition: tiffiop.h:172
TIFFCloseProc tif_closeproc
Definition: tiffiop.h:195
TIFFField ** tif_fields
Definition: tiffiop.h:200
int TIFFFlush(TIFF *tif)
Definition: tif_flush.c:32
size_t tif_nfieldscompat
Definition: tiffiop.h:208
void _TIFFfree(void *p)
Definition: tif_unix.c:326
#define TIFF_MYBUFFER
Definition: tiffiop.h:115
#define O_RDONLY
Definition: acwin.h:108