diff options
author | George Hazan <ghazan@miranda.im> | 2019-07-24 14:30:13 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2019-07-24 14:30:13 +0300 |
commit | 103de9c164934b2393dfcba7011625f90c8a2097 (patch) | |
tree | f7a4a09afe29398f3b7605d7d0db264638a18150 /protocols/Twitter/src | |
parent | 541eab20530165d10592a9fda590f435c6a8b4be (diff) |
NLHR_PTR - smart pointers make better code
Diffstat (limited to 'protocols/Twitter/src')
-rw-r--r-- | protocols/Twitter/src/utility.cpp | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/protocols/Twitter/src/utility.cpp b/protocols/Twitter/src/utility.cpp index 134ef2b1f9..3001173ee1 100644 --- a/protocols/Twitter/src/utility.cpp +++ b/protocols/Twitter/src/utility.cpp @@ -110,16 +110,12 @@ http::response mir_twitter::slurp(const std::string &url, http::method meth, OAu req.flags = NLHRF_HTTP11 | NLHRF_PERSISTENT | NLHRF_REDIRECT;
req.nlc = httpPOST_;
http::response resp_data;
- ppro_->debugLogA("**SLURP - just before calling HTTPTRANSACTION");
- NETLIBHTTPREQUEST *resp = Netlib_HttpTransaction(handle_, &req);
- ppro_->debugLogA("**SLURP - HTTPTRANSACTION complete.");
+ NLHR_PTR resp(Netlib_HttpTransaction(handle_, &req));
if (resp) {
ppro_->debugLogA("**SLURP - the server has responded!");
httpPOST_ = resp->nlc;
resp_data.code = resp->resultCode;
resp_data.data = resp->pData ? resp->pData : "";
-
- Netlib_FreeHttpRequest(resp);
}
else {
httpPOST_ = nullptr;
@@ -136,7 +132,7 @@ bool save_url(HNETLIBUSER hNetlib, const std::string &url, const std::wstring &f req.flags = NLHRF_HTTP11 | NLHRF_REDIRECT;
req.szUrl = const_cast<char*>(url.c_str());
- NETLIBHTTPREQUEST *resp = Netlib_HttpTransaction(hNetlib, &req);
+ NLHR_PTR resp(Netlib_HttpTransaction(hNetlib, &req));
if (resp) {
bool success = (resp->resultCode == 200);
if (success) {
@@ -150,8 +146,6 @@ bool save_url(HNETLIBUSER hNetlib, const std::string &url, const std::wstring &f fwrite(resp->pData, 1, resp->dataLength, f);
fclose(f);
}
-
- Netlib_FreeHttpRequest(resp);
return success;
}
|