gawk-diffs
[Top][All Lists]
Advanced

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

[gawk-diffs] [SCM] gawk branch, master, updated. gawk-4.1.0-2580-g0ac746


From: Andrew J. Schorr
Subject: [gawk-diffs] [SCM] gawk branch, master, updated. gawk-4.1.0-2580-g0ac746d
Date: Thu, 22 Jun 2017 11:03:01 -0400 (EDT)

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "gawk".

The branch, master has been updated
       via  0ac746db72a0879bbd44325fe15b3ae33c63ecef (commit)
      from  288b15d0793936fa14b51ed860056f6ce6200c52 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.sv.gnu.org/cgit/gawk.git/commit/?id=0ac746db72a0879bbd44325fe15b3ae33c63ecef

commit 0ac746db72a0879bbd44325fe15b3ae33c63ecef
Author: Andrew J. Schorr <address@hidden>
Date:   Thu Jun 22 11:02:08 2017 -0400

    In readfile extension, no need to zero out the buffer before overwriting it.

diff --git a/extension/ChangeLog b/extension/ChangeLog
index 378de37..9574865 100644
--- a/extension/ChangeLog
+++ b/extension/ChangeLog
@@ -1,3 +1,9 @@
+2017-06-22         Andrew J. Schorr     <address@hidden>
+
+       * readfile.c (read_file_to_buffer): Use emalloc instead of ezalloc,
+       since there's no need to initialize the memory to zero before 
+       overwriting it with the file's contents.
+
 2017-06-21         Andrew J. Schorr     <address@hidden>
 
        * filefuncs.c (do_fts): Replace emalloc+memset with ezalloc.
diff --git a/extension/readfile.c b/extension/readfile.c
index f470237..b600f27 100644
--- a/extension/readfile.c
+++ b/extension/readfile.c
@@ -73,24 +73,22 @@ int plugin_is_GPL_compatible;
 static char *
 read_file_to_buffer(int fd, const struct stat *sbuf)
 {
-       char *text = NULL;
-       int ret;
+       char *text;
 
        if ((sbuf->st_mode & S_IFMT) != S_IFREG) {
                errno = EINVAL;
                update_ERRNO_int(errno);
-               goto done;
+               return NULL;
        }
 
-       ezalloc(text, char *, sbuf->st_size + 1, "do_readfile");
+       emalloc(text, char *, sbuf->st_size + 1, "do_readfile");
 
-       if ((ret = read(fd, text, sbuf->st_size)) != sbuf->st_size) {
+       if (read(fd, text, sbuf->st_size) != sbuf->st_size) {
                update_ERRNO_int(errno);
                gawk_free(text);
-               text = NULL;
-               /* fall through to return */
+               return NULL;
        }
-done:
+       text[sbuf->st_size] = '\0';
        return text;
 }
 

-----------------------------------------------------------------------

Summary of changes:
 extension/ChangeLog  |  6 ++++++
 extension/readfile.c | 14 ++++++--------
 2 files changed, 12 insertions(+), 8 deletions(-)


hooks/post-receive
-- 
gawk



reply via email to

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