我有以下代码:
CURL *curl;
void http_init()
{
curl = curl_easy_init();
if (!curl) return -1;
}
void http_send_message(char *msg_out, char **msg_in)
{
CURLcode res;
curl_easy_setopt(curl, CURLOPT_URL, "http://192.168.1.133:8080/tawtaw");
curl_easy_setopt(curl, CURLOPT_USERNAME, "tawtaw");
curl_easy_setopt(curl, CURLOPT_PASSWORD, "tawtaw");
curl_easy_setopt(curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC|CURLAUTH_DIGEST);
.
.
.
curl_easy_reset(curl);
}
void http_exit()
{
curl_easy_cleanup(curl);
}
int main()
{
char *msgin=NULL;
http_init();
http_send_message("message number 1", &msg_in);
free(msgin);msgin=NULL;
http_send_message("message number 2", &msg_in);
free(msgin);msgin=NULL;
http_exit();
}
如果我打电话
curl_easy_setopt(curl, CURLOPT_URL, "http://192.168.1.133:8080/tawtaw");
进而
curl_easy_reset(curl)
进而
curl_easy_setopt(curl, CURLOPT_URL, "http://192.168.1.133:8080/tawtaw");
再一次,第一次分配的内存是由第二次调用还是由第二次调用curl_easy_setopt
释放的?curl_easy_reset(curl)
curl_easy_setopt
还是内存没有释放,有内存泄漏?