diff --git a/src/FDM/YASim/FGFDM.cpp b/src/FDM/YASim/FGFDM.cpp index 63fb20b95..f191fc316 100644 --- a/src/FDM/YASim/FGFDM.cpp +++ b/src/FDM/YASim/FGFDM.cpp @@ -47,14 +47,12 @@ FGFDM::~FGFDM() { for(int i=0; i<_thrusters.size(); i++) { EngRec* er = (EngRec*)_thrusters.get(i); - delete[] er->prefix; delete er->eng; delete er; } for(int i=0; i<_weights.size(); i++) { WeightRec* wr = (WeightRec*)_weights.get(i); - delete[] wr->prop; delete wr; } @@ -365,7 +363,7 @@ void FGFDM::getExternalInput(float dt) if(t->getPropEngine()) { PropEngine* p = t->getPropEngine(); - sprintf(buf, "%s/rpm", er->prefix); + sprintf(buf, "%s/rpm", er->prefix.c_str()); p->setOmega(fgGetFloat(buf, 500) * RPM2RAD); } } @@ -373,7 +371,7 @@ void FGFDM::getExternalInput(float dt) // Linearly "seeks" a property by the specified fraction of the way to // the target value. Used to emulate "slowly changing" output values. -static void moveprop(SGPropertyNode* node, const char* prop, +static void moveprop(SGPropertyNode* node, const std::string& prop, float target, float frac) { float val = node->getFloatValue(prop); @@ -1135,7 +1133,7 @@ void FGFDM::parseWeight(const XMLAttributes* a) float v[3]; attrf_xyz(a, v); - wr->prop = strdup(a->getValue("mass-prop")); + wr->prop = std::string{a->getValue("mass-prop")}; wr->size = attrf(a, "size", 0); wr->handle = _airplane.addWeight(v, wr->size); _weights.add(wr); diff --git a/src/FDM/YASim/FGFDM.hpp b/src/FDM/YASim/FGFDM.hpp index 17ea3d8a9..30663721a 100644 --- a/src/FDM/YASim/FGFDM.hpp +++ b/src/FDM/YASim/FGFDM.hpp @@ -32,11 +32,11 @@ public: private: struct EngRec { - char* prefix {nullptr}; + std::string prefix; Thruster* eng {nullptr}; }; struct WeightRec { - char* prop {nullptr}; + std::string prop; float size {0}; int handle {0}; };