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

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

[debbugs-tracker] bug#23717: closed ([PATCH 6/6] grep: do pagesize initi


From: GNU bug Tracking System
Subject: [debbugs-tracker] bug#23717: closed ([PATCH 6/6] grep: do pagesize initialization and buffer allocation earlier)
Date: Mon, 22 Aug 2016 06:29:01 +0000

Your message dated Sun, 21 Aug 2016 23:28:08 -0700
with message-id <address@hidden>
and subject line Re: bug#23717: [PATCH 6/6] grep: do pagesize initialization 
and buffer allocation earlier
has caused the debbugs.gnu.org bug report #23717,
regarding [PATCH 6/6] grep: do pagesize initialization and buffer allocation 
earlier
to be marked as done.

(If you believe you have received this mail in error, please contact
address@hidden)


-- 
23717: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=23717
GNU Bug Tracking System
Contact address@hidden with problems
--- Begin Message --- Subject: [PATCH 6/6] grep: do pagesize initialization and buffer allocation earlier Date: Tue, 7 Jun 2016 01:37:43 -0500
* src/grep.c (reset, main): We're going to need pagesize and buffer
initialized anyway, so we might as well do so unconditionally early on
rather than checking on every call to reset().
---
 src/grep.c | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/src/grep.c b/src/grep.c
index d01bc4f..302e4d7 100644
--- a/src/grep.c
+++ b/src/grep.c
@@ -769,16 +769,6 @@ all_zeros (char const *buf, size_t size)
 static bool
 reset (int fd, struct stat const *st)
 {
-  if (! pagesize)
-    {
-      pagesize = getpagesize ();
-      if (pagesize == 0 || 2 * pagesize + 1 <= pagesize)
-        abort ();
-      bufalloc = (ALIGN_TO (INITIAL_BUFSIZE, pagesize)
-                  + pagesize + sizeof (uword));
-      buffer = xmalloc (bufalloc);
-    }
-
   bufbeg = buflim = ALIGN_TO (buffer + 1, pagesize);
   bufbeg[-1] = eolbyte;
   bufdesc = fd;
@@ -2252,6 +2242,12 @@ main (int argc, char **argv)
   set_program_name (argv[0]);
   program_name = argv[0];
 
+  pagesize = getpagesize ();
+  if (pagesize == 0 || 2 * pagesize + 1 <= pagesize)
+    abort ();
+  bufalloc = (ALIGN_TO (INITIAL_BUFSIZE, pagesize) + pagesize + sizeof 
(uword));
+  buffer = xmalloc (bufalloc);
+
   keys = NULL;
   keycc = 0;
   with_filenames = false;
-- 
2.8.0.rc3




--- End Message ---
--- Begin Message --- Subject: Re: bug#23717: [PATCH 6/6] grep: do pagesize initialization and buffer allocation earlier Date: Sun, 21 Aug 2016 23:28:08 -0700 User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0
Thanks, I see this one was also installed in June and so am closing the bug 
report.

I noticed that the old code and the new both have some glitches with respect to large page sizes, so I installed the attached further patch to fix them. I've never used grep on a machine with 2 GiB pages, but such beasts exist nowadays and we might as well make grep safe for them.

Attachment: 0001-grep-minor-tweaks-of-initial-buffer-alloc.patch
Description: Text Data


--- End Message ---

reply via email to

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