bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: Stefan Monnier
Subject: bug#18410: Use SAFE_ALLOCA etc. to avoid unbounded stack allocation.
Date: Fri, 05 Sep 2014 11:44:25 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (gnu/linux)

> 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





reply via email to

[Prev in Thread] Current Thread [Next in Thread]