cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: realloc size is (mem->size + realsize + 1)... why + 1?

From: Kamil Dudka <kdudka_at_redhat.com>
Date: Sat, 11 Jun 2011 16:21:57 +0200

On Saturday 11 June 2011 13:31:37 Rieker Flaik wrote:
> in http://curl.haxx.se/libcurl/c/getinmemory.html :
> why is realloc called with this + 1 ?

If it was not, you would have an off-by-one error a few lines later:

mem->size += realsize;
mem->memory[mem->size] = 0;

Kamil
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2011-06-11