Coverage Report

Created: 2025-06-13 06:29

/src/gdal/frmts/gtiff/libgeotiff/geo_free.c
Line
Count
Source (jump to first uncovered line)
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
0
{
40
0
    if (!gtif) return;
41
42
    /* Free parameter arrays */
43
0
    if (gtif->gt_double) _GTIFFree (gtif->gt_double);
44
0
    if (gtif->gt_short) _GTIFFree (gtif->gt_short);
45
46
    /* Free GeoKey arrays */
47
0
    if (gtif->gt_keys)
48
0
    {
49
0
        for (int i = 0; i < MAX_KEYS; i++)
50
0
        {
51
0
            if (gtif->gt_keys[i].gk_type == TYPE_ASCII)
52
0
            {
53
0
                _GTIFFree (gtif->gt_keys[i].gk_data);
54
0
            }
55
0
        }
56
0
        _GTIFFree (gtif->gt_keys);
57
0
    }
58
0
    if (gtif->gt_keyindex) _GTIFFree (gtif->gt_keyindex);
59
60
0
    if (gtif->own_pj_context)
61
0
    {
62
0
        proj_context_destroy(gtif->pj_context);
63
0
    }
64
65
0
    _GTIFFree (gtif);
66
0
}