qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From acon...@apache.org
Subject [44/48] qpid-proton git commit: NO-JIRA: cpp: fix clang c++11 compile error in url::impl
Date Fri, 25 Nov 2016 21:01:40 GMT
NO-JIRA: cpp: fix clang c++11 compile error in url::impl

url::impl had explict dtor (delete[] raw C char array) but no explict copy ctor.
Replaced raw char* with vector<char> and removed the explicit dtor.


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/8c306f29
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/8c306f29
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/8c306f29

Branch: refs/heads/go1
Commit: 8c306f2964a5f19898b258729393814646d3acb6
Parents: 6af49b8
Author: Alan Conway <aconway@redhat.com>
Authored: Wed Nov 23 11:24:11 2016 -0500
Committer: Alan Conway <aconway@redhat.com>
Committed: Wed Nov 23 11:24:11 2016 -0500

----------------------------------------------------------------------
 proton-c/bindings/cpp/src/url.cpp | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8c306f29/proton-c/bindings/cpp/src/url.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/url.cpp b/proton-c/bindings/cpp/src/url.cpp
index 1aa01e1..867f605 100644
--- a/proton-c/bindings/cpp/src/url.cpp
+++ b/proton-c/bindings/cpp/src/url.cpp
@@ -29,6 +29,7 @@
 #include <cstring>
 #include <iomanip>
 #include <sstream>
+#include <vector>
 
 namespace {
 
@@ -156,20 +157,15 @@ struct url::impl {
     const char* host;
     const char* port;
     const char* path;
-    char* cstr;
+    std::vector<char> cstr;
     mutable std::string str;
 
     impl(const std::string& s) :
-      scheme(0), username(0), password(0), host(0), port(0), path(0),
-      cstr(new char[s.size()+1])
+        scheme(0), username(0), password(0), host(0), port(0), path(0),
+        cstr(s.size()+1, '\0')
     {
-        std::strncpy(cstr, s.c_str(), s.size());
-        cstr[s.size()] = 0;
-        parse_url(cstr, &scheme, &username, &password, &host, &port,
&path);
-    }
-
-    ~impl() {
-        delete [] cstr;
+        std::copy(s.begin(), s.end(), cstr.begin());
+        parse_url(&cstr[0], &scheme, &username, &password, &host, &port,
&path);
     }
 
     void defaults() {


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message