From 544a2d94ae14958d413d2795c8c3e9c44145c88b Mon Sep 17 00:00:00 2001 From: JunsuChoi Date: Wed, 11 Mar 2020 21:42:55 +0900 Subject: [PATCH] vdrawable: Don't strdup for name data The name information passed in is allocated and managed by the parser. There is no need to duplicate the same data. Change-Id: I9c488e654c01bdfe7c48388c29fad350cd261deb --- src/vector/vdrawable.cpp | 1 - src/vector/vdrawable.h | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/vector/vdrawable.cpp b/src/vector/vdrawable.cpp index 2102e82..7245d5f 100644 --- a/src/vector/vdrawable.cpp +++ b/src/vector/vdrawable.cpp @@ -34,7 +34,6 @@ VDrawable::~VDrawable() delete mStrokeInfo; } } - if (mName) free(mName); } void VDrawable::setType(VDrawable::Type type) diff --git a/src/vector/vdrawable.h b/src/vector/vdrawable.h index 56aefa7..13dfdf3 100644 --- a/src/vector/vdrawable.h +++ b/src/vector/vdrawable.h @@ -57,9 +57,9 @@ public: VRle rle(); void setName(const char *name) { - if (name) mName = strdup(name); + mName = name; } - char* name() const { return mName; } + const char* name() const { return mName; } public: struct StrokeInfo { @@ -83,7 +83,7 @@ public: FillRule mFillRule{FillRule::Winding}; VDrawable::Type mType{Type::Fill}; - char *mName{nullptr}; + const char *mName{nullptr}; }; #endif // VDRAWABLE_H -- 2.34.1