GNU bug report logs - #18410
Use SAFE_ALLOCA etc. to avoid unbounded stack allocation.

Previous Next

Package: emacs;

Reported by: Paul Eggert <eggert <at> cs.ucla.edu>

Date: Fri, 5 Sep 2014 06:10:02 UTC

Severity: wishlist

Tags: patch

Done: Paul Eggert <eggert <at> cs.ucla.edu>

Bug is archived. No further changes may be made.

Full log


Message #20 received at 18410 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Dmitry Antipov <dmantipov <at> yandex.ru>
Cc: Paul Eggert <eggert <at> cs.ucla.edu>, 18410 <at> debbugs.gnu.org
Subject: Re: bug#18410: Use SAFE_ALLOCA etc. to avoid unbounded stack
 allocation.
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




This bug report was last modified 10 years and 258 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.