cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: [PATCH] examples/getinmemory.c: abort the transfer if not enough memory

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Sat, 9 Mar 2013 16:41:36 +0100 (CET)

On Sun, 24 Feb 2013, Cédric Deltheil wrote:

> So far the getinmemory.c example terminates the process with an EXIT_FAILURE
> status code if the in-memory growing buffer cannot be reallocated.
>
> Since the write function includes the ability to signal an error to libcurl
> [1], and let it abort the transfer with a CURLE_WRITE_ERROR, I thought it
> would be better to use it as a best practice within this example.
>
> Please find attached a (small) patch that avoids using exit(3). In addition
> there is a 2nd patch that sets the CURLOPT_FOLLOWLOCATION option since
> example.com includes redirections.

Thanks! I merged the return code fix, as I think that really helps making a
better example.

I didn't merge the CURLOPT_FOLLOWLOCATION change, even though I'm aware
http://www.example.com/ has started to redirect visitors. I just don't think
we should assume that users will use the literal URL in there, and I don't
want to "pollute" all examples using example.org to also use
CURLOPT_FOLLOWLOCATION.

We did modify simple.c for this and we have three more example codes showing
how CURLOPT_FOLLOWLOCATION is used so I think that is good enough.

-- 
  / daniel.haxx.se

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2013-03-09