From 16558276c068d4363334d20f8ffa83b007632d51 Mon Sep 17 00:00:00 2001 From: Wescoeur Date: Tue, 20 Feb 2018 01:06:26 +0100 Subject: [PATCH] fix(Content): use move function on headers (copy constructor) --- src/content/content-p.h | 5 +---- src/content/content.cpp | 20 +++++++++++--------- src/content/content.h | 6 +++--- 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/src/content/content-p.h b/src/content/content-p.h index 65bdfc439..bb4daced3 100644 --- a/src/content/content-p.h +++ b/src/content/content-p.h @@ -20,9 +20,6 @@ #ifndef _L_CONTENT_P_H_ #define _L_CONTENT_P_H_ -#include -#include - #include "content-type.h" #include "content.h" #include "object/clonable-object-p.h" @@ -36,7 +33,7 @@ private: std::vector body; ContentType contentType; std::string contentDisposition; - std::list> headers; + std::list> headers; L_DECLARE_PUBLIC(Content); }; diff --git a/src/content/content.cpp b/src/content/content.cpp index bfbbe0511..ffabea95a 100644 --- a/src/content/content.cpp +++ b/src/content/content.cpp @@ -46,10 +46,11 @@ Content::Content (const Content &other) : ClonableObject(*new ContentPrivate), A Content::Content (Content &&other) : ClonableObject(*new ContentPrivate), AppDataContainer(move(other)) { L_D(); - d->body = move(other.getPrivate()->body); - d->contentType = move(other.getPrivate()->contentType); - d->contentDisposition = move(other.getPrivate()->contentDisposition); - d->headers = other.getHeaders(); + ContentPrivate *dOther = other.getPrivate(); + d->body = move(dOther->body); + d->contentType = move(dOther->contentType); + d->contentDisposition = move(dOther->contentDisposition); + d->headers = move(dOther->headers); } Content::Content (ContentPrivate &p) : ClonableObject(p) {} @@ -66,10 +67,10 @@ Content::~Content () { Content &Content::operator= (const Content &other) { L_D(); if (this != &other) { + AppDataContainer::operator=(other); d->body = other.getBody(); d->contentType = other.getContentType(); d->contentDisposition = other.getContentDisposition(); - AppDataContainer::operator=(other); d->headers = other.getHeaders(); } return *this; @@ -77,11 +78,12 @@ Content &Content::operator= (const Content &other) { Content &Content::operator= (Content &&other) { L_D(); - d->body = move(other.getPrivate()->body); - d->contentType = move(other.getPrivate()->contentType); - d->contentDisposition = move(other.getPrivate()->contentDisposition); - d->headers = other.getHeaders(); AppDataContainer::operator=(move(other)); + ContentPrivate *dOther = other.getPrivate(); + d->body = move(dOther->body); + d->contentType = move(dOther->contentType); + d->contentDisposition = move(dOther->contentDisposition); + d->headers = move(dOther->headers); return *this; } diff --git a/src/content/content.h b/src/content/content.h index 582589f00..03fddd7f2 100644 --- a/src/content/content.h +++ b/src/content/content.h @@ -20,8 +20,8 @@ #ifndef _L_CONTENT_H_ #define _L_CONTENT_H_ -#include #include +#include #include "object/app-data-container.h" #include "object/clonable-object.h" @@ -72,10 +72,10 @@ public: virtual bool isFile () const; + const std::list> &getHeaders () const; void addHeader (const std::string &headerName, const std::string &headerValue); - const std::list> &getHeaders () const; void removeHeader (const std::string &headerName); - std::list>::const_iterator findHeader (const std::string &headerName); + std::list>::const_iterator findHeader (const std::string &headerName); // TODO: Remove me later. virtual LinphoneContent *toLinphoneContent () const;