]> granicus.if.org Git - graphviz/commitdiff
visio plugin: manage _para member of Text as a value instead of a pointer
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Thu, 8 Apr 2021 00:34:01 +0000 (17:34 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 17 Apr 2021 23:07:40 +0000 (16:07 -0700)
This member is never set to NULL and the Para class is not involved in any
inheritance hierarchy. So there is no need to heap-allocate it or pass it around
by pointer.

plugin/visio/VisioText.cpp
plugin/visio/VisioText.h

index e235218ac2394a494812bfb25f4a0a9a08e7e999..7fc98263e3f4dc50b4bf8887a1e08b5b5f1eaa65 100644 (file)
@@ -103,7 +103,7 @@ namespace Visio
                }
                
                return new Text(
-                       new Para(
+                       Para(
                                horzAlign),
                        new Char(
                                span->font->size,
@@ -115,7 +115,7 @@ namespace Visio
                                span->str));
        }
        
-       Text::Text(Para* para, Char* chars, Run* run):
+       Text::Text(const Para &para, Char* chars, Run* run):
                _para(para),
                _chars(chars),
                _run(run)
@@ -124,8 +124,6 @@ namespace Visio
        
        Text::~Text()
        {
-               if (_para)
-                       delete _para;
                if (_chars)
                        delete _chars;
                if (_run)
@@ -139,8 +137,7 @@ namespace Visio
        
        void Text::Print(GVJ_t* job) const
        {
-               if (_para)
-                       _para->Print(job);
+               _para.Print(job);
                if (_chars)
                        _chars->Print(job);
        }
index f189b736323324fb6d9e7b0ed1707b84ff86efa3..f4b5bb8feb6b40ade2b5f96b700d94a81c14b737 100644 (file)
@@ -87,9 +87,9 @@ namespace Visio
                void PrintRun(GVJ_t* job, unsigned int index) const;
                
        private:
-               Text(Para* para, Char* chars, Run* run);
+               Text(const Para &para, Char* chars, Run* run);
                
-               Para* _para;
+               Para _para;
                Char* _chars;
                Run* _run;
        };