Use std::string instead of manual character buffers where applicable.

This commit is contained in:
Michael Hansen
2019-10-02 16:01:54 -07:00
parent 8d3752b4f0
commit f88869fb17
5 changed files with 45 additions and 78 deletions

View File

@@ -47,35 +47,31 @@ private:
class PycFloat : public PycObject {
public:
PycFloat(int type = TYPE_FLOAT)
: PycObject(type), m_value(0) { }
~PycFloat() { delete[] m_value; }
: PycObject(type) { }
bool isEqual(PycRef<PycObject> obj) const override;
void load(class PycData* stream, class PycModule* mod) override;
const char* value() const { return m_value; }
const char* value() const { return m_value.c_str(); }
private:
char* m_value; // Floats are stored as strings
std::string m_value; // Floats are stored as strings
};
class PycComplex : public PycFloat {
public:
PycComplex(int type = TYPE_COMPLEX)
: PycFloat(type), m_imag(0) { }
~PycComplex() { delete[] m_imag; }
: PycFloat(type) { }
bool isEqual(PycRef<PycObject> obj) const override;
void load(class PycData* stream, class PycModule* mod) override;
const char* imag() const { return m_imag; }
const char* imag() const { return m_imag.c_str(); }
private:
char* m_imag;
std::string m_imag;
};
class PycCFloat : public PycObject {