@@ -180,6 +180,7 @@ SunMoonCalc::Result SunMoonCalc::calculateSunAndMoonData(){
180180 } else {
181181 // Update Sun's maximum elevation
182182 setUTDate (sun.transitJd );
183+ delete[] out;
183184 out = doCalc (getSunPosition ());
184185 sun.transitElevation = out[5 ];
185186 }
@@ -191,6 +192,7 @@ SunMoonCalc::Result SunMoonCalc::calculateSunAndMoonData(){
191192
192193 const PositionalData moonPosition = getMoonPosition ();
193194 double moonLat = moonPosition.latitude , moonLon = moonPosition.longitude ;
195+ delete[] out;
194196 out = doCalc (moonPosition);
195197
196198 moon.azimuth = out[0 ];
@@ -216,18 +218,21 @@ SunMoonCalc::Result SunMoonCalc::calculateSunAndMoonData(){
216218 // Update Moon's maximum elevation
217219 setUTDate (moon.transitJd );
218220 getSunPosition ();
221+ delete[] out;
219222 out = doCalc (getMoonPosition ());
220223 moon.transitElevation = out[5 ];
221224 }
222225 setUTDate (jd);
223226 this ->sanomaly = sa;
224227 this ->slongitude = sl;
225228 this ->moonAge = ma;
226-
229+
230+ delete[] out;
227231 out = getMoonDiskOrientationAngles (lst, sunRA, sunDec, radians (moonLon),radians (moonLat), moonRA, moonDec);
228232 moon.axisPositionAngle = out[2 ];
229233 moon.brightLimbAngle = out[3 ];
230234 moon.paralacticAngle = out[4 ];
235+ delete[] out;
231236 moon.age = ma;
232237 moon.phase = calculateMoonPhase (moon.age );
233238
@@ -372,7 +377,7 @@ SunMoonCalc::PositionalData SunMoonCalc::getMoonPosition() {
372377 * - lst
373378 */
374379double *SunMoonCalc::doCalc (PositionalData position) {
375- auto arr = new double [10 ];
380+ double * arr = new double [10 ];
376381
377382 // Ecliptic to equatorial coordinates
378383 double t2 = this ->t / 100.0 ;
@@ -584,6 +589,7 @@ double SunMoonCalc::obtainAccurateRiseSetTransit(double riseSetJd, const int ind
584589 }
585590 step = fabs (riseSetJd - out[index]);
586591 riseSetJd = out[index];
592+ delete[] out;
587593 }
588594 if (step > 1.0 / SECONDS_PER_DAY) return -1 ; // did not converge => without rise/set/transit in this date
589595 return riseSetJd;
@@ -600,8 +606,8 @@ double SunMoonCalc::obtainAccurateRiseSetTransit(double riseSetJd, const int ind
600606double *SunMoonCalc::getMoonDiskOrientationAngles (double lst, double sunRA, double sunDec, double moonLon,
601607 double moonLat, double moonRA, double moonDec) {
602608
603- auto arr = new double [5 ];
604-
609+ double * arr = new double [5 ];
610+
605611 // Moon's argument of latitude
606612 double F = radians (93.2720993 + 483202.0175273 * this ->t - 0.0034029 * this ->t * this ->t -
607613 this ->t * this ->t * this ->t / 3526000.0 + this ->t * this ->t * this ->t * this ->t / 863310000.0 );
0 commit comments