ReactOS 0.4.16-dev-2617-g01a0906
tif_close.c File Reference
#include "tiffiop.h"
#include <string.h>
Include dependency graph for tif_close.c:

Go to the source code of this file.

Functions

void TIFFCleanup (TIFF *tif)
 
void _TIFFCleanupIFDOffsetAndNumberMaps (TIFF *tif)
 
void TIFFClose (TIFF *tif)
 

Function Documentation

◆ _TIFFCleanupIFDOffsetAndNumberMaps()

void _TIFFCleanupIFDOffsetAndNumberMaps ( TIFF tif)

Definition at line 127 of file tif_close.c.

128{
130 {
133 }
135 {
138 }
139}
#define NULL
Definition: types.h:112
TIFFHashSet * tif_map_dir_number_to_offset
Definition: tiffiop.h:154
TIFFHashSet * tif_map_dir_offset_to_number
Definition: tiffiop.h:153
void TIFFHashSetDestroy(TIFFHashSet *set)
Definition: tif_hash_set.c:285

Referenced by TIFFCleanup(), TIFFCreateCustomDirectory(), TIFFSetDirectory(), TIFFSetSubDirectory(), and TIFFUnlinkDirectory().

◆ TIFFCleanup()

void TIFFCleanup ( TIFF tif)

Auxiliary function to free the TIFF structure. Given structure will be completely freed, so you should save opened file handle and pointer to the close procedure in external variables before calling _TIFFCleanup(), if you will need these ones to close the file.

Parameters
tifA TIFF pointer.

Definition at line 44 of file tif_close.c.

45{
46 /*
47 * Flush buffered data and directory (if dirty).
48 */
49 if (tif->tif_mode != O_RDONLY)
50 TIFFFlush(tif);
52
54
55 /*
56 * Clean up client info links.
57 */
58 while (tif->tif_clientinfo)
59 {
61
62 tif->tif_clientinfo = psLink->next;
63 _TIFFfreeExt(tif, psLink->name);
64 _TIFFfreeExt(tif, psLink);
65 }
66
67 if (tif->tif_rawdata && (tif->tif_flags & TIFF_MYBUFFER))
68 _TIFFfreeExt(tif, tif->tif_rawdata);
69 if (isMapped(tif))
71
72 /*
73 * Clean up custom fields.
74 */
75 if (tif->tif_fields && tif->tif_nfields > 0)
76 {
77 uint32_t i;
78
79 for (i = 0; i < tif->tif_nfields; i++)
80 {
81 TIFFField *fld = tif->tif_fields[i];
82 if (fld->field_name != NULL)
83 {
84 if (fld->field_bit == FIELD_CUSTOM &&
85 /* caution: tif_fields[i] must not be the beginning of a
86 * fields-array. Otherwise the following tags are also freed
87 * with the first free().
88 */
90 {
91 _TIFFfreeExt(tif, fld->field_name);
92 _TIFFfreeExt(tif, fld);
93 }
94 }
95 }
96
97 _TIFFfreeExt(tif, tif->tif_fields);
98 }
99
100 if (tif->tif_nfieldscompat > 0)
101 {
102 uint32_t i;
103
104 for (i = 0; i < tif->tif_nfieldscompat; i++)
105 {
108 }
110 }
111
112 if (tif->tif_cur_cumulated_mem_alloc != 0)
113 {
114 TIFFErrorExtR(tif, "TIFFCleanup",
115 "tif_cur_cumulated_mem_alloc = %" PRIu64 " whereas it "
116 "should be 0",
118 }
119
120 _TIFFfreeExt(NULL, tif);
121}
UINT32 uint32_t
Definition: types.h:75
UINT64 uint64_t
Definition: types.h:77
#define O_RDONLY
Definition: fcntl.h:34
#define PRIu64
Definition: inttypes.h:28
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
uint32_t allocated_size
Definition: tif_dir.h:324
TIFFField * fields
Definition: tif_dir.h:327
char * field_name
Definition: tif_dir.h:343
unsigned short field_bit
Definition: tif_dir.h:340
struct client_info * next
Definition: tiffiop.h:76
char * name
Definition: tiffiop.h:78
size_t tif_nfields
Definition: tiffiop.h:242
TIFFClientInfoLink * tif_clientinfo
Definition: tiffiop.h:245
TIFFField ** tif_fields
Definition: tiffiop.h:241
tmsize_t tif_size
Definition: tiffiop.h:228
tmsize_t tif_cur_cumulated_mem_alloc
Definition: tiffiop.h:257
uint8_t * tif_rawdata
Definition: tiffiop.h:220
uint32_t tif_flags
Definition: tiffiop.h:117
size_t tif_nfieldscompat
Definition: tiffiop.h:249
int tif_mode
Definition: tiffiop.h:116
TIFFFieldArray * tif_fieldscompat
Definition: tiffiop.h:248
uint8_t * tif_base
Definition: tiffiop.h:227
void _TIFFCleanupIFDOffsetAndNumberMaps(TIFF *tif)
Definition: tif_close.c:127
void TIFFFreeDirectory(TIFF *tif)
Definition: tif_dir.c:1619
int TIFFFieldIsAnonymous(const TIFFField *fip)
Definition: tif_dirinfo.c:879
void TIFFErrorExtR(TIFF *tif, const char *module, const char *fmt,...)
Definition: tif_error.c:107
int TIFFFlush(TIFF *tif)
Definition: tif_flush.c:30
void _TIFFfreeExt(TIFF *tif, void *p)
Definition: tif_open.c:275
#define FIELD_CUSTOM
Definition: tiffio.h:346
uint64_t toff_t
Definition: tiffio.h:70
#define TIFF_MYBUFFER
Definition: tiffiop.h:126
#define TIFFUnmapFileContents(tif, addr, size)
Definition: tiffiop.h:288
#define isMapped(tif)
Definition: tiffiop.h:275

Referenced by TIFFClientOpenExt(), and TIFFClose().

◆ TIFFClose()

void TIFFClose ( TIFF tif)

Close a previously opened TIFF file.

TIFFClose closes a file that was previously opened with TIFFOpen(). Any buffered data are flushed to the file, including the contents of the current directory (if modified); and all resources are reclaimed.

Parameters
tifA TIFF pointer.

Definition at line 155 of file tif_close.c.

156{
157 if (tif != NULL)
158 {
159 TIFFCloseProc closeproc = tif->tif_closeproc;
161
162 TIFFCleanup(tif);
163 (void)(*closeproc)(fd);
164 }
165}
static int fd
Definition: io.c:51
TIFFCloseProc tif_closeproc
Definition: tiffiop.h:236
thandle_t tif_clientdata
Definition: tiffiop.h:232
void TIFFCleanup(TIFF *tif)
Definition: tif_close.c:44
int(* TIFFCloseProc)(thandle_t)
Definition: tiffio.h:308

Referenced by tiff_decoder_destroy(), tiff_decoder_initialize(), tiff_encoder_commit_file(), and tiff_encoder_destroy().