emacs-devel
[Top][All Lists]
Advanced

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

Re: Strange code in emacs.c


From: Noam Postavsky
Subject: Re: Strange code in emacs.c
Date: Wed, 3 Oct 2018 18:12:45 -0400

On Wed, 3 Oct 2018 at 11:15, Eli Zaretskii <address@hidden> wrote:
>
> We have this in 'main':
>
>       emacs_re_safe_alloca = max
>         (min (lim - extra, SIZE_MAX) * (min_ratio / ratio),
>          MAX_ALLOCA);
>
> This always yields MAX_ALLOCA because 'ratio' is always greater than
> 'min_ratio':
>
>       int min_ratio = 20 * sizeof (char *);
>       int ratio = min_ratio + min_ratio / 3;

Yes, it seems I forgot how integer math works when I wrote that. I
guess that I meant to write it without the parens around the division
(which is approximately the same as your 2 statement suggestion):

      emacs_re_safe_alloca = max
        (min (lim - extra, SIZE_MAX) * min_ratio / ratio,
         MAX_ALLOCA);

Also, I forgot the word "use" in the comment just above:

      /* If the stack is big enough, let regex.c more of it before
                                                ^
                                                use
         falling back to heap allocation.  */



reply via email to

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