Debian Codegraph @

frmts/gtiff/libgeotiff/geo_free.c

raw symbols SCIP
1 /**********************************************************************
2 *
3 * geo_free.c -- Public routines for GEOTIFF GeoKey access.
4 *
5 * Written By: Niles D. Ritter.
6 *
7 * copyright (c) 1995 Niles D. Ritter
8 *
9 * Permission granted to use this software, so long as this copyright
10 * notice accompanies any products derived therefrom.
11 *
12 **********************************************************************/
13
14 #include "geotiff.h" /* public interface */
15 #include "geo_tiffp.h" /* external TIFF interface */
16 #include "geo_keyp.h" /* private interface */
17
18 #include "proj.h"
19
20 /**********************************************************************
21 *
22 * Public Routines
23 *
24 **********************************************************************/
25
26 /**
27
28 This function deallocates an existing GeoTIFF access handle previously
29 created with GTIFNew(). If the handle was
30 used to write GeoTIFF keys to the TIFF file, the
31 GTIFWriteKeys() function should be used
32 to flush results to the file before calling GTIFFree(). GTIFFree()
33 should be called before XTIFFClose() is
34 called on the corresponding TIFF file handle.<p>
35
36 */
37
38 void GTIFFree(GTIF* gtif)
39 {
40 if (!gtif) return;
41
42 /* Free parameter arrays */
43 if (gtif->gt_double) _GTIFFree (gtif->gt_double);
44 if (gtif->gt_short) _GTIFFree (gtif->gt_short);
45
46 /* Free GeoKey arrays */
47 if (gtif->gt_keys)
48 {
49 for (int i = 0; i < MAX_KEYS; i++)
50 {
51 if (gtif->gt_keys[i].gk_type == TYPE_ASCII)
52 {
53 _GTIFFree (gtif->gt_keys[i].gk_data);
54 }
55 }
56 _GTIFFree (gtif->gt_keys);
57 }
58 if (gtif->gt_keyindex) _GTIFFree (gtif->gt_keyindex);
59
60 if (gtif->own_pj_context)
61 {
62 proj_context_destroy(gtif->pj_context);
63 }
64
65 _GTIFFree (gtif);
66 }