IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 38500


Ignore:
Timestamp:
Jun 19, 2015, 3:10:04 PM (11 years ago)
Author:
eugene
Message:

do a better job of freeing memory; load GSC regions with modest allocations

Location:
branches/eam_branches/ipp-20150616/Ohana/src/libdvo
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20150616/Ohana/src/libdvo/include/dvo.h

    r38472 r38500  
    259259typedef struct {
    260260  off_t Nregions;
     261  off_t Nalloc;
    261262  char **filename;
    262263  SkyRegion *regions;
     
    920921PhotCodeData *GetPhotcodeTable (void);
    921922void SetPhotcodeTable (PhotCodeData *);
     923void FreePhotcodeData (PhotCodeData *myPhotcodes);
     924void FreePhotcodeTable (void);
    922925
    923926int *GetSecFiltMap(PhotCodeData *ouput, PhotCodeData* input);
  • branches/eam_branches/ipp-20150616/Ohana/src/libdvo/src/LoadPhotcodesFITS.c

    r38441 r38500  
    5151    }                                                                   \
    5252    photcode = PhotCode_##FORMAT##_To_Internal (photcode_input, Ncode); \
    53     free (photcode_input);                                              \
    5453  }
    5554
     
    6564  CONVERT_FORMAT("DVO_PHOTCODE_PS1_V4",    PS1_V4);
    6665  CONVERT_FORMAT("DVO_PHOTCODE_PS1_V5",    PS1_V5);
     66
     67  gfits_db_free (&db);
    6768
    6869  table = GetPhotcodeTable ();
  • branches/eam_branches/ipp-20150616/Ohana/src/libdvo/src/SavePhotcodesFITS.c

    r38441 r38500  
    3737  if (!gfits_db_save (&db)) return (FALSE);
    3838  if (!gfits_db_close (&db)) return (FALSE);
     39  if (!gfits_db_free (&db)) return (FALSE);
    3940
    4041  free (photcode_output);
  • branches/eam_branches/ipp-20150616/Ohana/src/libdvo/src/dvo_convert.c

    r38441 r38500  
    10351035  Nimage = theader[0].Naxis[1];
    10361036
    1037 # define FORMAT_CASE(FORMAT, TYPE) \
    1038     case DVO_FORMAT_##FORMAT: { \
    1039       Image_##TYPE *tmpImage; \
     1037# define FORMAT_CASE(FORMAT, TYPE)              \
     1038  case DVO_FORMAT_##FORMAT: {                   \
     1039    Image_##TYPE *tmpImage;                                             \
    10401040      tmpImage = ImageInternalTo_##TYPE ((Image *) ftable[0].buffer, Nimage); \
    1041       free (ftable[0].buffer); \
    1042       gfits_table_set_Image_##TYPE (ftable, tmpImage, Nimage, TRUE); \
    1043       free (tmpImage); \
    1044       break; }
     1041        free (ftable[0].buffer);                                        \
     1042        gfits_free_header (ftable->header);                             \
     1043        gfits_table_set_Image_##TYPE (ftable, tmpImage, Nimage, TRUE);  \
     1044          free (tmpImage);                                              \
     1045          break; }
    10451046
    10461047  /* convert from the internal format */
  • branches/eam_branches/ipp-20150616/Ohana/src/libdvo/src/dvo_photcode_ops.c

    r38153 r38500  
    4343}
    4444
    45 // set the photcode table. This is used to switch between serveral previously
     45// free a specified photcode set
     46void FreePhotcodeData (PhotCodeData *myPhotcodes) {
     47  if (!myPhotcodes) return;
     48  FREE(myPhotcodes->code);
     49  FREE(myPhotcodes);
     50}
     51
     52// free the internal table
     53void FreePhotcodeTable (void) {
     54  FreePhotcodeData (photcodes);
     55  FREE(genericCodeMag);
     56  FREE(genericCodeFlux);
     57}
     58
     59// set the photcode table. This is used to switch between several previously
    4660// allocated tables
    4761void SetPhotcodeTable (PhotCodeData *new) {
  • branches/eam_branches/ipp-20150616/Ohana/src/libdvo/src/skyregion_gsc.c

    r37807 r38500  
    4646  FTable ftable;
    4747  SkyTable *skytable;
    48   SkyTable *band;
    4948  SkyTable L0, L1, L2, L3, L4;
    5049  SkyRegionZone *zones;
     
    7978/* L0 : full sky */
    8079  L0.Nregions = 1;
    81   ALLOCATE (L0.regions, SkyRegion, L0.Nregions);
     80  L0.Nalloc = 1;
     81  ALLOCATE (L0.regions, SkyRegion, L0.Nalloc);
    8282  L0.regions[0].Rmin    =   0;
    8383  L0.regions[0].Rmax    = 360;
     
    9999  /* allocate space for all levels */
    100100  L1.Nregions = L2.Nregions = L3.Nregions = L4.Nregions = 0;
    101   ALLOCATE (L1.regions, SkyRegion, 1);
    102   ALLOCATE (L2.regions, SkyRegion, 1);
    103   ALLOCATE (L3.regions, SkyRegion, 1);
    104   ALLOCATE (L4.regions, SkyRegion, 1);
     101  L1.Nalloc = NDECBANDS;         ALLOCATE (L1.regions, SkyRegion, L1.Nalloc);
     102  L2.Nalloc = NDECBANDS*0x10;    ALLOCATE (L2.regions, SkyRegion, L2.Nalloc);
     103  L3.Nalloc = NDECBANDS*0x100;   ALLOCATE (L3.regions, SkyRegion, L3.Nalloc);
     104  L4.Nalloc = NDECBANDS*0x1000;  ALLOCATE (L4.regions, SkyRegion, L4.Nalloc);
    105105
    106106  // skipLines = 0;
     
    130130
    131131    /* load all GSC Regions in this band */
    132     band = SkyRegionForDecBand (&ftable.buffer[skipLines*48], DecLines[i], DecNames[i], L1.regions[i].Dmin, L1.regions[i].Dmax);
     132    SkyTable *band = SkyRegionForDecBand (&ftable.buffer[skipLines*48], DecLines[i], DecNames[i], L1.regions[i].Dmin, L1.regions[i].Dmax);
    133133    skipLines += DecLines[i];
    134134
     
    151151
    152152    L1.Nregions ++;
    153     REALLOCATE (L1.regions, SkyRegion, L1.Nregions + 1);
     153    myAssert (L1.Nregions <= NDECBANDS, "too many L1 regions");
    154154  }
    155155
     
    231231  band[0].regions = regions;
    232232  band[0].Nregions = Nregions;
     233  band[0].Nalloc   = Nregions;
    233234  return (band);
    234235}
     
    277278  Nregions = band[0].Nregions;
    278279
    279   NZ = 10;
     280  NZ = 100;
    280281  ALLOCATE (zones, SkyRegionZone, NZ);
    281282 
     
    312313      /* go to the next zone */
    313314      Nz++;
    314       CHECK_REALLOCATE (zones, SkyRegionZone, NZ, Nz, 10);
     315      CHECK_REALLOCATE (zones, SkyRegionZone, NZ, Nz, 100);
    315316
    316317      /* start info for the new zone */
     
    401402void SkyTableL2fromZone (SkyTable *L2, SkyTable *L3, SkyTable *L4, SkyTable *band, SkyRegionZone *zone, int parent) {
    402403
    403   int i, Nr, Ns, Ne;
     404  int i, Ns, Ne;
    404405  char *p, name[80];
    405406
    406   Nr = L2[0].Nregions;
    407   REALLOCATE (L2[0].regions, SkyRegion, Nr + 1);
     407  int Nr = L2[0].Nregions;
     408  CHECK_REALLOCATE (L2[0].regions, SkyRegion, L2[0].Nalloc, L2[0].Nregions, 100);
    408409 
    409410  /* divide this zone into L2 regions with Nset L3 regions each (fewer on ends) */
     
    444445
    445446    Nr++;
    446     REALLOCATE (L2[0].regions, SkyRegion, Nr + 1);
     447    CHECK_REALLOCATE (L2[0].regions, SkyRegion, L2[0].Nalloc, Nr, 100);
    447448  }
    448449  L2[0].Nregions = Nr;
     
    456457  Nr = L3[0].Nregions;
    457458  L3[0].Nregions += Ne - Ns;
    458   REALLOCATE (L3[0].regions, SkyRegion, L3[0].Nregions);
     459  CHECK_REALLOCATE (L3[0].regions, SkyRegion, L3[0].Nalloc, L3[0].Nregions, 0.5*L3[0].Nalloc);
    459460
    460461  L2[0].child  = TRUE;
     
    498499  Nr = L4[0].Nregions;
    499500  L4[0].Nregions += NDIV*NDIV;
    500   REALLOCATE (L4[0].regions, SkyRegion, L4[0].Nregions);
     501  CHECK_REALLOCATE (L4[0].regions, SkyRegion, L4[0].Nalloc, L4[0].Nregions, 0.5*L4[0].Nalloc);
    501502
    502503  L3[0].child  = TRUE;
  • branches/eam_branches/ipp-20150616/Ohana/src/libdvo/src/skyregion_io.c

    r38441 r38500  
    113113  fclose (f);
    114114
     115  gfits_free_header  (&header);
     116  gfits_free_matrix  (&matrix);
     117  gfits_free_header  (&theader);
     118  gfits_free_table   (&ftable);
     119
    115120  return (TRUE);
    116121}
     
    131136    exit (1);
    132137  }
     138  free (filename);
    133139  return (sky);
    134140
  • branches/eam_branches/ipp-20150616/Ohana/src/libdvo/src/skyregion_ops.c

    r37807 r38500  
    550550    }
    551551    free (list[0].regions);
     552    free (list[0].filename);
    552553  }
    553554  free (list);
Note: See TracChangeset for help on using the changeset viewer.