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 下。

 

转载于:https://www.cnblogs.com/foreveryl/archive/2011/10/09/2203385.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值