cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Modifying the example source code

From: Tor Arntsen <tor_at_spacetec.no>
Date: Mon, 28 Feb 2011 09:34:58 +0100

On Mon, Feb 28, 2011 at 07:28, Alan Wolfe <alan.wolfe_at_gmail.com> wrote:

>
> Basically, it allocates a single byte so there's a valid memory
> address in chunk.memory so that realloc can be called on it later on.
> If it started out NULL, there would have to be an if check before the
> realloc call, so it just simplifies things a little.

Just to pre-answer a question people may ask.. realloc(NULL) works
fine on many architectures. But not on all architectures. To be
perfectly portable we use the malloc(1) trick.

-Tor
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2011-02-28