Network Kit: Coverity scan review and fixes

CID 1108353, 1108335: memory leak.
CID 610473: unused variable.
CID 1108446, 1108433, 1108432, 1108419, 1108400, 991710, 991713, 991712,
	610098, 610097, 610096, 610095: uninitialized field
CID 1108421: unused field

Change the ownership of the result for Url/HttpRequests. The request now
owns its result and you either access it by reference while the request
is live, or copy it to keep it after the request destruction. To help
with that, get BUrlResult copy constructor and assignment operator to
work.

Performance issue: copying the BUrlResult also copies the underlying
BMallocIO data. This should be shared between the BUrlResult objects to
make the copy lighter. The case of BUrlSynchronousRequest is now
particularly inefficient, with at least 2 copies needed to get at the
result.
This commit is contained in:
Adrien Destugues
2013-10-21 09:21:00 +02:00
parent 72eb88f5c8
commit b3d13a000c
12 changed files with 30 additions and 25 deletions
+1 -1
View File
@@ -23,7 +23,7 @@ class BAbstractSocket;
class BHttpRequest : public BUrlRequest {
public:
BHttpRequest(const BUrl& url,
BUrlResult& result, bool ssl = false,
bool ssl = false,
const char *protocolName = "HTTP",
BUrlProtocolListener* listener = NULL,
BUrlContext* context = NULL);
-2
View File
@@ -118,8 +118,6 @@ private:
mutable bool fAuthorityValid : 1;
mutable bool fUserInfoValid : 1;
bool fBasicUri : 1;
bool fHasProtocol : 1;
bool fHasUserName : 1;
bool fHasPassword : 1;
+2 -3
View File
@@ -18,7 +18,6 @@ public:
BUrlRequest(const BUrl& url,
BUrlProtocolListener* listener,
BUrlContext* context,
BUrlResult& result,
const char* threadName,
const char* protocolName);
virtual ~BUrlRequest();
@@ -37,7 +36,7 @@ public:
// URL protocol parameters access
const BUrl& Url() const;
BUrlResult& Result() const;
const BUrlResult& Result() const;
BUrlContext* Context() const;
BUrlProtocolListener* Listener() const;
const BString& Protocol() const;
@@ -63,7 +62,7 @@ protected:
protected:
BUrl fUrl;
BUrlResult& fResult;
BUrlResult fResult;
BUrlContext* fContext;
BUrlProtocolListener* fListener;