Subject: Re: bug#18410: Use SAFE_ALLOCA etc. to avoid unbounded stack allocation.

From: Stefan Monnier <[email-masked]>
Date: Fri, 05 Sep 2014 11:44:25 -0400

> USE_SAFE_ALLOCA;                                                    |-
> ptrdiff_t count = SPECPDL_INDEX ();                    |-           |
> ...                                                    | inner bind | outer bind
> Lisp_Object result = unbind_to (count, Fsome_func ()); |-           |
> SAFE_FREE ();                                                       |-
> return result;
>
> looks suboptimal because it calls unbind_to twice.

Only if the object is "too large" and requires heap allocation.

BTW, AFAIK

   Lisp_Object result = unbind_to (count, Fsome_func ());

can always be written

   Lisp_Object result = Fsome_func ();
   unbind_to (count, Qnil);

which I find more readable (if it were me, unbind_to would take
a single arg and return void).

        Stefan