comparison Resources/Orthanc/Plugins/OrthancPluginCppWrapper.cpp @ 69:07fdf388c12e

sync
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 11 Jun 2021 14:37:40 +0200
parents d88ae86b7b79
children e2b2e1d4e1bb
comparison
equal deleted inserted replaced
68:0b3ef425db31 69:07fdf388c12e
2724 { 2724 {
2725 assert(*it != NULL); 2725 assert(*it != NULL);
2726 delete *it; 2726 delete *it;
2727 } 2727 }
2728 2728
2729 size_ = 0;
2729 content_.clear(); 2730 content_.clear();
2730 } 2731 }
2731 2732
2732 void Flatten(std::string& target) const 2733 /**
2734 * Since Orthanc 1.9.3, this function also clears the content of
2735 * the ChunkedBuffer in order to mimic the behavior of the
2736 * original class "Orthanc::ChunkedBuffer". This prevents the
2737 * forgetting of calling "Clear()" in order to reduce memory
2738 * consumption.
2739 **/
2740 void Flatten(std::string& target)
2733 { 2741 {
2734 target.resize(size_); 2742 target.resize(size_);
2735 2743
2736 size_t pos = 0; 2744 size_t pos = 0;
2737 2745
2743 if (s != 0) 2751 if (s != 0)
2744 { 2752 {
2745 memcpy(&target[pos], (*it)->c_str(), s); 2753 memcpy(&target[pos], (*it)->c_str(), s);
2746 pos += s; 2754 pos += s;
2747 } 2755 }
2756
2757 delete *it;
2748 } 2758 }
2749 2759
2750 assert(size_ == 0 || 2760 assert(pos == target.size());
2751 pos == target.size()); 2761
2762 size_ = 0;
2763 content_.clear();
2752 } 2764 }
2753 2765
2754 void AddChunk(const void* data, 2766 void AddChunk(const void* data,
2755 size_t size) 2767 size_t size)
2756 { 2768 {
2777 const HttpClient::HttpHeaders& GetHeaders() const 2789 const HttpClient::HttpHeaders& GetHeaders() const
2778 { 2790 {
2779 return headers_; 2791 return headers_;
2780 } 2792 }
2781 2793
2782 const ChunkedBuffer& GetBody() const 2794 ChunkedBuffer& GetBody()
2783 { 2795 {
2784 return body_; 2796 return body_;
2785 } 2797 }
2786 2798
2787 virtual void AddHeader(const std::string& key, 2799 virtual void AddHeader(const std::string& key,