LCOV - code coverage report
Current view: top level - frmts/gtiff/libgeotiff - geo_free.c (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 12 13 92.3 %
Date: 2024-05-04 12:52:34 Functions: 1 1 100.0 %

          Line data    Source code
       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       21206 : void GTIFFree(GTIF* gtif)
      39             : {
      40       21206 :     if (!gtif) return;
      41             : 
      42             :     /* Free parameter arrays */
      43       21206 :     if (gtif->gt_double) _GTIFFree (gtif->gt_double);
      44       21206 :     if (gtif->gt_short) _GTIFFree (gtif->gt_short);
      45             : 
      46             :     /* Free GeoKey arrays */
      47       21206 :     if (gtif->gt_keys)
      48             :     {
      49     2141810 :         for (int i = 0; i < MAX_KEYS; i++)
      50             :         {
      51     2120600 :             if (gtif->gt_keys[i].gk_type == TYPE_ASCII)
      52             :             {
      53       17417 :                 _GTIFFree (gtif->gt_keys[i].gk_data);
      54             :             }
      55             :         }
      56       21206 :         _GTIFFree (gtif->gt_keys);
      57             :     }
      58       21206 :     if (gtif->gt_keyindex) _GTIFFree (gtif->gt_keyindex);
      59             : 
      60       21206 :     if (gtif->own_pj_context)
      61             :     {
      62           0 :         proj_context_destroy(gtif->pj_context);
      63             :     }
      64             : 
      65       21206 :     _GTIFFree (gtif);
      66             : }

Generated by: LCOV version 1.14