summaryrefslogtreecommitdiffstats
path: root/tksao/frame
diff options
context:
space:
mode:
authorWilliam Joye <wjoye@cfa.harvard.edu>2017-10-04 17:07:35 (GMT)
committerWilliam Joye <wjoye@cfa.harvard.edu>2017-10-04 17:07:35 (GMT)
commit3802d3df703ae75262c86187cad4d3bae745a9ca (patch)
tree8c77eac67f2decca132e559e51038024a98ed5a9 /tksao/frame
parenta18d63abab08e41fe439e13da46e1e686933e9c0 (diff)
downloadblt-3802d3df703ae75262c86187cad4d3bae745a9ca.zip
blt-3802d3df703ae75262c86187cad4d3bae745a9ca.tar.gz
blt-3802d3df703ae75262c86187cad4d3bae745a9ca.tar.bz2
track down memory leaks with getString
Diffstat (limited to 'tksao/frame')
-rw-r--r--tksao/frame/fitscompress.C2
-rw-r--r--tksao/frame/fitshealpix.C4
-rw-r--r--tksao/frame/fitsimage.C44
-rw-r--r--tksao/frame/frsave.C26
4 files changed, 38 insertions, 38 deletions
diff --git a/tksao/frame/fitscompress.C b/tksao/frame/fitscompress.C
index d04c32f..e472490 100644
--- a/tksao/frame/fitscompress.C
+++ b/tksao/frame/fitscompress.C
@@ -12,7 +12,7 @@
void FitsImage::initCompress()
{
int bitpix = fits_->getInteger("ZBITPIX",0);
- char* type = fits_->getString("ZCMPTYPE");
+ char* type = fits_->getStringCopy("ZCMPTYPE");
if (!bitpix || !type) {
if (type)
delete [] type;
diff --git a/tksao/frame/fitshealpix.C b/tksao/frame/fitshealpix.C
index de8738e..4d0992b 100644
--- a/tksao/frame/fitshealpix.C
+++ b/tksao/frame/fitshealpix.C
@@ -25,7 +25,7 @@ void FitsImage::initHPX()
if (fits_->pHPXSystem() >= 0)
coord = (FitsHPX::CoordSys)fits_->pHPXSystem();
else {
- char* str = head->getString("COORDSYS");
+ char* str = head->getStringCopy("COORDSYS");
if (str) {
if (str[0] == 'G')
coord = FitsHPX::GAL;
@@ -45,7 +45,7 @@ void FitsImage::initHPX()
if (fits_->pHPXOrder() >=0)
order = (FitsHPX::Order)fits_->pHPXOrder();
else {
- char* str = head->getString("ORDERING");
+ char* str = head->getStringCopy("ORDERING");
if (str) {
if (str[0] == 'N')
order = FitsHPX::NESTED;
diff --git a/tksao/frame/fitsimage.C b/tksao/frame/fitsimage.C
index a51e208..65a14be 100644
--- a/tksao/frame/fitsimage.C
+++ b/tksao/frame/fitsimage.C
@@ -898,7 +898,7 @@ void FitsImage::altWCS(istream& str)
// Process OBJECT keyword
if (objectKeyword_)
delete [] objectKeyword_;
- objectKeyword_ = hh->getString("OBJECT");
+ objectKeyword_ = hh->getStringCopy("OBJECT");
// Process WCS keywords
if (altHeader_)
@@ -913,7 +913,7 @@ void FitsImage::appendWCS(istream& str)
FitsHead* hh = parseWCS(str);
// process OBJECT keyword
- char* obj = hh->getString("OBJECT");
+ char* obj = hh->getStringCopy("OBJECT");
if (obj) {
if (objectKeyword_)
delete [] objectKeyword_;
@@ -1173,7 +1173,7 @@ void FitsImage::initWCS()
#ifndef NEWWCS
// WCSDEP
if (hd->find("WCSDEP")) {
- char* str = hd->getString("WCSDEP");
+ char* str = hd->getStringCopy("WCSDEP");
if (str) {
for (int ii=1; ii<MULTWCS; ii++) {
if (wcs_[ii]) {
@@ -1870,7 +1870,7 @@ void FitsImage::process(const char* fn, int id)
load();
}
// HEALPIX
- else if ((fits_->find("PIXTYPE") && (!strncmp(fits_->getString("PIXTYPE"),"HEALPIX",4))) || fits_->find("NSIDE")) {
+ else if ((fits_->find("PIXTYPE") && (!strncmp(fits_->getStringCopy("PIXTYPE"),"HEALPIX",4))) || fits_->find("NSIDE")) {
initHPX();
if (!hpx_ || !hpx_->isValid()) {
reset();
@@ -1997,11 +1997,11 @@ void FitsImage::processKeywordsPhysical()
/*
// Radio data?
- char* bunit = image_->getString("BUNIT");
+ char* bunit = image_->getStringCopy("BUNIT");
double cdelt1 = fabs(image_->getReal("CDELT1",0));
- char* cunit1 = image_->getString("CUNIT1");
+ char* cunit1 = image_->getStringCopy("CUNIT1");
double cdelt2 = fabs(image_->getReal("CDELT2",0));
- char* cunit2 = image_->getString("CUNIT2");
+ char* cunit2 = image_->getStringCopy("CUNIT2");
double bmaj = image_->getReal("BMAJ",0);
double bmin = image_->getReal("BMIN",0);
@@ -2031,7 +2031,7 @@ void FitsImage::processKeywordsParams()
iparams.set(0, 0, width(), height());
{
- char* datstr = image_->getString("DATASEC");
+ char* datstr = image_->getStringCopy("DATASEC");
// default
Vector v1(1,1);
Vector v2(size());
@@ -2113,7 +2113,7 @@ int FitsImage::processKeywordsIRAF(FitsImage* fits)
// DETSEC
Coord::Orientation orientation = Coord::NORMAL;
- char* detstr = image_->getString("DETSEC");
+ char* detstr = image_->getStringCopy("DETSEC");
Vector dv1,dv2;
if (!(detstr && *detstr && parseSection(detstr,&dv1,&dv2))) {
if (detstr)
@@ -2136,7 +2136,7 @@ int FitsImage::processKeywordsIRAF(FitsImage* fits)
orientation = Coord::YY;
// DETSIZE
- char* sizestr = image_->getString("DETSIZE");
+ char* sizestr = image_->getStringCopy("DETSIZE");
Vector sv1(1,1);
Vector sv2(10000,10000);
if (sizestr && *sizestr) {
@@ -2151,7 +2151,7 @@ int FitsImage::processKeywordsIRAF(FitsImage* fits)
// CCDSUM
Vector ccdsum(1,1);
- char* ccdstr = image_->getString("CCDSUM");
+ char* ccdstr = image_->getStringCopy("CCDSUM");
if (ccdstr && *ccdstr) {
double Ns, Np, Ns1, Np1;
string x(ccdstr);
@@ -2242,7 +2242,7 @@ void FitsImage::replaceWCS(istream& str)
// Process OBJECT keyword
if (objectKeyword_)
delete [] objectKeyword_;
- objectKeyword_ = hh->getString("OBJECT");
+ objectKeyword_ = hh->getStringCopy("OBJECT");
// Process WCS keywords
if (wcsHeader_)
@@ -2302,7 +2302,7 @@ void FitsImage::resetWCS()
// Process OBJECT keyword
if (objectKeyword_)
delete [] objectKeyword_;
- objectKeyword_ = image_->getString("OBJECT");
+ objectKeyword_ = image_->getStringCopy("OBJECT");
// Process WCS keywords
if (wcsHeader_)
@@ -3124,7 +3124,7 @@ const char* FitsImage::getWCSName(Coord::CoordSystem sys)
return NULL;
if (fits_->find("WCSNAME"))
- return fits_->getString("WCSNAME");
+ return fits_->getStringCopy("WCSNAME");
else
return NULL;
}
@@ -3864,8 +3864,8 @@ void FitsImage::header2ast(int ii, FitsHead* hd, void* chan)
if (!hd->find(key1) && !hd->find(key2))
return;
- char* ctype1 = hd->getString(key1);
- char* ctype2 = hd->getString(key2);
+ char* ctype1 = hd->getStringCopy(key1);
+ char* ctype2 = hd->getStringCopy(key2);
if (ctype1 && !strncmp(ctype1,"GLON",4)) {
if (!ctype2 || strncmp(ctype2,"GLAT",4)) {
@@ -4144,19 +4144,19 @@ void FitsImage::wcs2ast(int ww, FitsHead* hd, FitsHead* prim, void* chan)
radesys << "RADESYS" << alt << ends;
if (hd->find(radesys.str().c_str())) {
// if RADESYS present, use it
- putFitsCard(chan, "RADESYS", hd->getString(radesys.str().c_str()));
+ putFitsCard(chan, "RADESYS", hd->getStringCopy(radesys.str().c_str()));
}
else if (prim && prim->find(radesys.str().c_str())) {
// if RADESYS present, use it
- putFitsCard(chan, "RADESYS", prim->getString(radesys.str().c_str()));
+ putFitsCard(chan, "RADESYS", prim->getStringCopy(radesys.str().c_str()));
}
else if (hd->find("RADECSYS")) {
// look for old RADECSYS
- putFitsCard(chan, "RADESYS", hd->getString("RADECSYS"));
+ putFitsCard(chan, "RADESYS", hd->getStringCopy("RADECSYS"));
}
else if (prim && prim->find("RADECSYS")) {
// look for old RADECSYS
- putFitsCard(chan, "RADESYS", prim->getString("RADECSYS"));
+ putFitsCard(chan, "RADESYS", prim->getStringCopy("RADECSYS"));
}
else {
// fall back on wcssubs
@@ -4232,14 +4232,14 @@ void FitsImage::wcs2ast(int ww, FitsHead* hd, FitsHead* prim, void* chan)
ostringstream str;
str << "WAT" << jj << "_00" << ii << ends;
if (hd->find(str.str().c_str())) {
- char* val = hd->getString(str.str().c_str());
+ char* val = hd->getStringCopy(str.str().c_str());
if (val) {
putFitsCard(chan, str.str().c_str(), val);
delete [] val;
}
}
else if (prim && prim->find(str.str().c_str())) {
- char* val = prim->getString(str.str().c_str());
+ char* val = prim->getStringCopy(str.str().c_str());
if (val) {
putFitsCard(chan, str.str().c_str(), val);
delete [] val;
diff --git a/tksao/frame/frsave.C b/tksao/frame/frsave.C
index 21406a5..332043b 100644
--- a/tksao/frame/frsave.C
+++ b/tksao/frame/frsave.C
@@ -377,34 +377,34 @@ void FrameBase::saveFitsResampleKeyword(OutFitsStream& str, FitsHead& dst)
Vector center = Vector(options->width, options->height)/2.;
// OBJECT
- char* object = src->getString("OBJECT");
+ char* object = src->getStringCopy("OBJECT");
if (object) {
dst.appendString("OBJECT", object, NULL);
delete [] object;
}
// DATE-OBS
- char* date = src->getString("DATE");
+ char* date = src->getStringCopy("DATE");
if (date) {
dst.appendString("DATE", date, NULL);
delete [] date;
}
- char* dateobs = src->getString("DATE-OBS");
+ char* dateobs = src->getStringCopy("DATE-OBS");
if (dateobs) {
dst.appendString("DATE-OBS", dateobs, NULL);
delete [] dateobs;
}
- char* timeobs = src->getString("TIME-OBS");
+ char* timeobs = src->getStringCopy("TIME-OBS");
if (timeobs) {
dst.appendString("TIME-OBS", timeobs, NULL);
delete [] timeobs;
}
- char* dateend = src->getString("DATE-END");
+ char* dateend = src->getStringCopy("DATE-END");
if (dateend) {
dst.appendString("DATE-END", dateend, NULL);
delete [] dateend;
}
- char* timeend = src->getString("TIME-END");
+ char* timeend = src->getStringCopy("TIME-END");
if (timeend) {
dst.appendString("TIME-END", timeend, NULL);
delete [] timeend;
@@ -463,13 +463,13 @@ void FrameBase::saveFitsResampleKeyword(OutFitsStream& str, FitsHead& dst)
dst.appendReal("CRVAL1", wcs->crval[0], 9, NULL);
dst.appendReal("CRVAL2", wcs->crval[1], 9, NULL);
- char* cunit1 = src->getString("CUNIT1");
+ char* cunit1 = src->getStringCopy("CUNIT1");
if (cunit1) {
dst.appendString("CUNIT1", cunit1, NULL);
delete [] cunit1;
}
- char* cunit2 = src->getString("CUNIT2");
+ char* cunit2 = src->getStringCopy("CUNIT2");
if (cunit2) {
dst.appendString("CUNIT2", cunit2, NULL);
delete [] cunit2;
@@ -507,21 +507,21 @@ void FrameBase::saveFitsResampleKeyword(OutFitsStream& str, FitsHead& dst)
#else
if (src->find("RADESYS"))
- dst.appendString("RADESYS", src->getString("RADESYS"), NULL);
+ dst.appendString("RADESYS", src->getStringCopy("RADESYS"), NULL);
if (src->find("EQUINOX"))
dst.appendReal("EQUINOX", src->getReal("EQUINOX",2000), 9, NULL);
if (src->find("CTYPE1"))
- dst.appendString("CTYPE1", src->getString("CTYPE1"), NULL);
+ dst.appendString("CTYPE1", src->getStringCopy("CTYPE1"), NULL);
if (src->find("CTYPE2"))
- dst.appendString("CTYPE2", src->getString("CTYPE2"), NULL);
+ dst.appendString("CTYPE2", src->getStringCopy("CTYPE2"), NULL);
if (src->find("CRVAL1"))
dst.appendReal("CRVAL1", src->getReal("CRVAL1",1), 9, NULL);
if (src->find("CRVAL2"))
dst.appendReal("CRVAL2", src->getReal("CRVAL2",1), 9, NULL);
if (src->find("CUNIT1"))
- dst.appendString("CUNIT1", src->getString("CUNIT1"), NULL);
+ dst.appendString("CUNIT1", src->getStringCopy("CUNIT1"), NULL);
if (src->find("CUNIT2"))
- dst.appendString("CUNIT2", src->getString("CUNIT2"), NULL);
+ dst.appendString("CUNIT2", src->getStringCopy("CUNIT2"), NULL);
#endif
}