From 59aefd51a5c526b5d5e88cdc19cd6bf4b05995f4 Mon Sep 17 00:00:00 2001 From: William Joye Date: Wed, 4 Oct 2017 13:23:08 -0400 Subject: track down memory leaks with getString --- tksao/fitsy++/file.C | 14 ++++++++++++++ tksao/fitsy++/file.h | 1 + tksao/fitsy++/head.C | 11 +++++++++++ tksao/fitsy++/head.h | 1 + 4 files changed, 27 insertions(+) diff --git a/tksao/fitsy++/file.C b/tksao/fitsy++/file.C index b871601..059854d 100644 --- a/tksao/fitsy++/file.C +++ b/tksao/fitsy++/file.C @@ -471,6 +471,20 @@ void FitsFile::getComplex(const char* name, double* real, double* img, *img = idef; } +char* FitsFile::getString(const char* name) +{ + if (head_) { + char* r = head_->getString(name); + if (r) + return r; + else + if (primary_ && inherit_) + return primary_->getString(name); + } + + return NULL; +} + char* FitsFile::getStringCopy(const char* name) { if (head_) { diff --git a/tksao/fitsy++/file.h b/tksao/fitsy++/file.h index f3e9c9d..a665fee 100644 --- a/tksao/fitsy++/file.h +++ b/tksao/fitsy++/file.h @@ -212,6 +212,7 @@ public: double getReal(const char* name, double def); void getComplex(const char* name, double* real, double* img, double rdef, double idef); + char* getString(const char* name); char* getStringCopy(const char* name); char* getComment(const char* name); char* getKeyword(const char* name); diff --git a/tksao/fitsy++/head.C b/tksao/fitsy++/head.C index 133abda..75f5749 100644 --- a/tksao/fitsy++/head.C +++ b/tksao/fitsy++/head.C @@ -326,6 +326,17 @@ void FitsHead::getComplex(const char* name, double* real, double* img, } } +char* FitsHead::getString(const char* name) +{ + char* card = find(name); + if (card) { + FitsCard c(card); + return c.getString(); + } + else + return NULL; +} + char* FitsHead::getStringCopy(const char* name) { char* card = find(name); diff --git a/tksao/fitsy++/head.h b/tksao/fitsy++/head.h index cbc4b9d..6c91323 100644 --- a/tksao/fitsy++/head.h +++ b/tksao/fitsy++/head.h @@ -121,6 +121,7 @@ public: double getReal(const char* name, double def); void getComplex(const char* name, double* real, double* img, double rdef, double idef); + char* getString(const char* name); char* getStringCopy(const char* name); char* getComment(const char* name); -- cgit v0.12