curl-library
Re: return value check needed for curl_easy_setopt and curl_slist_append
Date: Sat, 21 Mar 2009 17:01:22 +0100 (CET)
On Sat, 21 Mar 2009, Shivanand wrote:
> Libcurl documentation specifies that curl_easy_setopt APIs returns CURLE_OK
> if it is successful else returns a non zero value.
>
> I would like to know if really this API can fail? Under what circumstances
> it can fail?
Yes it can fail and the circumstances vary from option to option. For the
exact function I suggest you read the code!
> Is the return value needs to be checked for these APIs. SInce my code has
> 20-30 set-opts and the code becomes lengthy.
Well, that's how C works...
> Same problem is with curl_slist_append. Do i need to check the pointer
> returned by this API?
Yes, if you want to survive when it returns error. That might of course be
rare, but it can still return NULL - like when out of memory.
-- / daniel.haxx.seReceived on 2009-03-21