This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Don't bind to registered ports in bindresvport


On Thu, Jun 07, 2012 at 01:10:21AM -0700, Paul Eggert wrote:
>   This use of alloca is a memory optimization.  That is, the above
>   'alloca' example is equivalent to the following:
> 
>     struct foo buffer[__MAX_ALLOCA_CUTOFF / sizeof (struct foo)];
>     bool use_auto = bufsize <= sizeof buffer;
>     struct foo *buf = use_auto ? buffer : malloc (bufsize);
>     do_work_with (buf, bufsize);
>     if (! use_auto)
>       free (buf);
> 
>   except that the 'alloca' version consumes only the stack space
>   needed, rather than always consuming approximately
>   __MAX_ALLOCA_CUTOFF bytes.

__libc_use_alloca does actually more than that, it isn't a fixed limit
comparison, but if the size is larger than PTHREAD_STACK_MIN / 4,
it limits use of alloca to current thread stack size / 4 (and
__MAX_ALLOCA_CUTOFF as a maximum).

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]