File: geo_free.c

package info (click to toggle)
libgeotiff 1.5.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 3,300 kB
  • sloc: ansic: 8,080; sh: 3,977; makefile: 166
file content (68 lines) | stat: -rw-r--r-- 1,845 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/**********************************************************************
 *
 *  geo_free.c  -- Public routines for GEOTIFF GeoKey access.
 *
 *    Written By: Niles D. Ritter.
 *
 *  copyright (c) 1995   Niles D. Ritter
 *
 *  Permission granted to use this software, so long as this copyright
 *  notice accompanies any products derived therefrom.
 *
 **********************************************************************/

#include "geotiff.h"   /* public interface        */
#include "geo_tiffp.h" /* external TIFF interface */
#include "geo_keyp.h"  /* private interface       */

#include "proj.h"

/**********************************************************************
 *
 *                        Public Routines
 *
 **********************************************************************/

/**

This function deallocates an existing GeoTIFF access handle previously
created with GTIFNew().  If the handle was
used to write GeoTIFF keys to the TIFF file, the
GTIFWriteKeys() function should be used
to flush results to the file before calling GTIFFree().  GTIFFree()
should be called before XTIFFClose() is
called on the corresponding TIFF file handle.<p>

*/

void GTIFFree(GTIF* gtif)
{
    int     i;

    if (!gtif) return;

    /* Free parameter arrays */
    if (gtif->gt_double) _GTIFFree (gtif->gt_double);
    if (gtif->gt_short) _GTIFFree (gtif->gt_short);

    /* Free GeoKey arrays */
    if (gtif->gt_keys)
    {
        for (i = 0; i < MAX_KEYS; i++)
        {
            if (gtif->gt_keys[i].gk_type == TYPE_ASCII)
            {
                _GTIFFree (gtif->gt_keys[i].gk_data);
            }
        }
        _GTIFFree (gtif->gt_keys);
    }
    if (gtif->gt_keyindex) _GTIFFree (gtif->gt_keyindex);

    if (gtif->own_pj_context)
    {
        proj_context_destroy(gtif->pj_context);
    }

    _GTIFFree (gtif);
}