From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Noam Postavsky Newsgroups: gmane.emacs.devel Subject: Re: Strange code in emacs.c Date: Wed, 3 Oct 2018 18:12:45 -0400 Message-ID: References: <83h8i32ha8.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" X-Trace: blaine.gmane.org 1538605073 29959 195.159.176.226 (3 Oct 2018 22:17:53 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 3 Oct 2018 22:17:53 +0000 (UTC) Cc: Emacs developers To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Oct 04 00:17:49 2018 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1g7pSl-0007eN-TH for ged-emacs-devel@m.gmane.org; Thu, 04 Oct 2018 00:17:48 +0200 Original-Received: from localhost ([::1]:53388 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g7pUs-0003aV-G6 for ged-emacs-devel@m.gmane.org; Wed, 03 Oct 2018 18:19:58 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:39647) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g7pTm-0003Xg-8O for emacs-devel@gnu.org; Wed, 03 Oct 2018 18:18:50 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g7pOC-0007qa-35 for emacs-devel@gnu.org; Wed, 03 Oct 2018 18:13:04 -0400 Original-Received: from mail-oi1-x233.google.com ([2607:f8b0:4864:20::233]:44497) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g7pOA-0007oe-E7; Wed, 03 Oct 2018 18:13:02 -0400 Original-Received: by mail-oi1-x233.google.com with SMTP id u74-v6so5849126oia.11; Wed, 03 Oct 2018 15:13:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=m0OPKhS7hd8Qz1RJo4dwzlogPu/TSvaYyFlRqTvZ2VM=; b=gzqZdTPg2XTRIrJrjvj9Xok3sdlqRA9EbJtT8FUCXgZFsmp+QgMoq9WUWfXMScbZBz 2bpPpwZ9Vkc4rQJsHBUEc/URWkYb4LxtkLUAz34ybdEZPUXdhfEn3BfHGwgG6QgYyqiV IJpEmMQb1hwnwcErmrWbjQrurW1HeiXvuxRmzzQZNOkgtUGGMZY6pGAoHNEnPvTf77Dh wacNJnv6FXtbZwObhLuviYebJelwanHMGaWs1jDLCaAHGw4nshWLPdP3wDFrUhWD2ZaG JQ+yApcnvGuyYZ44L3emrmwb242r7pLcENteulm4LiH+YM2csxQ34hVmiBVN0KjDV8kj 18zA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=m0OPKhS7hd8Qz1RJo4dwzlogPu/TSvaYyFlRqTvZ2VM=; b=j+zjHpk7pDluGnFF50MQasvLJA/2UYQN21VQKtsCEvh8JtgW0X8+Zbk5qnj8H+jYXj 9srv7RQxGXLVYK6ng8J+akDHzJm/oAucVKccWeZ4G9B2oKiEIv7cZBq7SaX+WuHyjrcC HjNOLSHlLOpA/ZyQkKz2nuEG0uWIwai1cA+4j7AGSnasxLYoNhFK9LvqTU37phaQxGG4 QjxvZiy5YYS43Vo5yZYXr7kCdVQFjECrsvOeheD6tA6GopN4ubNYoh2rXalsQT+K/7rW 6pBIQKG32AwknqH8HsodK9d4cXIePxwcxRisUc/e9blllW5Xt2M5lO5tbBMfHwym5scq Cv9g== X-Gm-Message-State: ABuFfoiQ8jfOifa7U/sOLAOMuLgS0RtmGMq1xwlJ5di5ZOeE3aA4i8Vt FYbFmOJlbu4gBpRsSq7Mk28QnvSRkyMNdr58g03b13JE X-Google-Smtp-Source: ACcGV62A4NjgvNmxU8ENnfzBnc+oqWOmptPYTzds9WGgzk8/Xyo+0M1cir1e82xhNZsvHAJEhZXlJUv56C5EZuAuJPE= X-Received: by 2002:aca:ac4:: with SMTP id k65-v6mr1834502oiy.265.1538604780930; Wed, 03 Oct 2018 15:13:00 -0700 (PDT) In-Reply-To: <83h8i32ha8.fsf@gnu.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::233 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:230211 Archived-At: On Wed, 3 Oct 2018 at 11:15, Eli Zaretskii 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. */