cURL / Mailing Lists / curl-library / Single Mail


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

From: Daniel Stenberg <>
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
> 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 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 to also use

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.


List admin:
Received on 2013-03-09