cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: [PATCH 2/4] src/mkhelp: use stack allocation instead of heap for line buffer

From: Dave Reisner <d_at_falconindy.com>
Date: Mon, 6 May 2013 15:13:44 -0400

On Mon, May 06, 2013 at 08:38:18PM +0200, Dan Fandrich wrote:
> On Mon, May 06, 2013 at 02:19:49PM -0400, Dave Reisner wrote:
> > void hugehelp(void)
> > {
> > - unsigned char* buf;
> > + unsigned char buf[BUF_SIZE];
> > int status,headerlen;
> > z_stream z;
>
> IIRC, this particular code used to allocate the buffer on the stack, and was
> changed to malloc when problems arose on one of the BSDs, I think, which had a
> 64 KiB stack limit by default.

I noticed exactly this on a comment in lib/content_encoding.c where a
buffer of CURL_MAX_WRITE_SIZE is allocated (generally 16kB). In this
case it's only 10000 bytes being allocated. While this is ~40% smaller,
I understand if it's still unwanted due to stack size concerns.

>
> >>> Dan
> -------------------------------------------------------------------
> List admin: http://cool.haxx.se/list/listinfo/curl-library
> Etiquette: http://curl.haxx.se/mail/etiquette.html
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2013-05-06