From: Noam Postavsky <npostavs@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: Emacs developers <emacs-devel@gnu.org>
Subject: Re: Strange code in emacs.c
Date: Wed, 3 Oct 2018 18:12:45 -0400 [thread overview]
Message-ID: <CAM-tV-9oZV8CVo5UatuhVUjGFs4qp+hHnQdR6oNih0Z5VQVrrg@mail.gmail.com> (raw)
In-Reply-To: <83h8i32ha8.fsf@gnu.org>
On Wed, 3 Oct 2018 at 11:15, Eli Zaretskii <eliz@gnu.org> 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. */
next prev parent reply other threads:[~2018-10-03 22:12 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-03 15:15 Strange code in emacs.c Eli Zaretskii
2018-10-03 17:36 ` Paul Eggert
2018-10-03 17:42 ` Eli Zaretskii
2018-10-03 18:29 ` Paul Eggert
2018-10-03 22:12 ` Noam Postavsky [this message]
2018-10-03 22:59 ` Paul Eggert
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAM-tV-9oZV8CVo5UatuhVUjGFs4qp+hHnQdR6oNih0Z5VQVrrg@mail.gmail.com \
--to=npostavs@gmail.com \
--cc=eliz@gnu.org \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.