some code improvements

This commit is contained in:
2019-05-11 11:09:48 +02:00
parent a3bf259fee
commit b40b674c5c
3 changed files with 5 additions and 6 deletions

View File

@ -21,14 +21,12 @@ std::string API::request(std::string myurl) {
std::string
API::request(std::string myurl, bool post, Hashmap<std::string, std::string> &map, std::vector<std::string> &headers) {
CURL *curl;
CURLcode res;
curl = curl_easy_init();
struct curl_slist *list = nullptr;
for (int j = 0; j < headers.size(); ++j) {
list = curl_slist_append(list, headers.at(j).c_str());
list = curl_slist_append(list, headers.at((unsigned long)(j)).c_str());
}
std::string readString;
@ -73,7 +71,7 @@ API::request(std::string myurl, bool post, Hashmap<std::string, std::string> &ma
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &readString);
res = curl_easy_perform(curl);
curl_easy_perform(curl);
curl_easy_cleanup(curl);
}

View File

@ -43,7 +43,7 @@ valuetype Hashmap<keytype, valuetype>::getValue(int position) {
template<class keytype, class valuetype>
int Hashmap<keytype, valuetype>::size() {
return keys.size();
return (int)(keys.size());
}