libcurl 版本变化 curl_easy_setopt 使用问题

0,项目要迁移到新的开发环境下, 编译环境的改变以及系统库版本的变化,给开发带来不少问题。 如之前gcc从4.1.2 升到 4.4.4 就出现缺少<stdio.h> <string.h> <limits.h> 等头文件的问题。 这次libcurl也有问题了。

 

1,libcurl 官网http://blog.chinaunix.net/link.php?url=http://curl.haxx.se%2Flibcurl%2Fc%2Fcurl_easy_setopt.html 有说明:

“Strings passed to libcurl as 'char *' arguments, are copied by the library; thus the string storage associated to the pointer argument may be overwritten after curl_easy_setopt() returns. Exceptions to this rule are described in the option details below.

Before version 7.17.0, strings were not copied. Instead the user was forced keep them available until libcurl no longer needed them. ”

 

再来看看之前版本如何说的:感谢http://blog.chinaunix.net/space.php?uid=46552&do=blog&cuid=264498 这个链接作者的摘抄(版本不知, 发帖时间是07年:))

CURLOPT_URL

The actual URL to deal with. The parameter should be a char * to a zero terminated string. The string must remain present until curl no longer needs it, as it doesn't copy the string.

 

2,之前版本6.18, 于是只需 curl_easy_setopt(curl, CURLOPT_URL, url); 一次, 然后每次更新url即可。

再新版本7.22下,就需要每次访问不同url是都要 curl_easy_setopt 下。

 

posted on 2011-10-09 10:46  foreveryl  阅读(503)  评论(0编辑  收藏  举报