This member is never set to NULL and the Char class is not involved in any
inheritance hierarchy. So there is no need to heap-allocate it or pass it around
by pointer.
return new Text(
Para(
horzAlign),
- new Char(
+ Char(
span->font->size,
job->obj->pencolor.u.rgba[0],
job->obj->pencolor.u.rgba[1],
span->str));
}
- Text::Text(const Para ¶, Char* chars, Run* run):
+ Text::Text(const Para ¶, const Char &chars, Run* run):
_para(para),
_chars(chars),
_run(run)
Text::~Text()
{
- if (_chars)
- delete _chars;
if (_run)
delete _run;
}
void Text::Print(GVJ_t* job) const
{
_para.Print(job);
- if (_chars)
- _chars->Print(job);
+ _chars.Print(job);
}
void Text::PrintRun(GVJ_t* job, unsigned int index) const
void PrintRun(GVJ_t* job, unsigned int index) const;
private:
- Text(const Para ¶, Char* chars, Run* run);
+ Text(const Para ¶, const Char &chars, Run* run);
Para _para;
- Char* _chars;
+ Char _chars;
Run* _run;
};