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-2585-gc07e72


From: Andrew J. Schorr
Subject: [gawk-diffs] [SCM] gawk branch, master, updated. gawk-4.1.0-2585-gc07e725
Date: Sun, 25 Jun 2017 23:22:12 -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  c07e72504d045f8e5070668e61fa5d8a3290ab66 (commit)
      from  44e29458a6355ad64e8d89676a441b224ce76cbc (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=c07e72504d045f8e5070668e61fa5d8a3290ab66

commit c07e72504d045f8e5070668e61fa5d8a3290ab66
Author: Andrew J. Schorr <address@hidden>
Date:   Sun Jun 25 23:20:54 2017 -0400

    Remove xmalloc from gawkmisc.c, and improve dfa xalloc by using calloc 
instead of malloc+memset.

diff --git a/ChangeLog b/ChangeLog
index 2d9a5b9..9bfff32 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2017-06-25         Andrew J. Schorr     <address@hidden>
+
+       * gawkmisc.c (xmalloc): Remove function now in support/xalloc.h.
+
 2017-06-22         Arnold D. Robbins     <address@hidden>
 
        Make pretty-printing include parentheses that were explicitly
diff --git a/gawkmisc.c b/gawkmisc.c
index f165892..bef4f36 100644
--- a/gawkmisc.c
+++ b/gawkmisc.c
@@ -41,19 +41,3 @@
 #include "posix/gawkmisc.c"
 #endif /* not VMS */
 #endif /* not __DJGPP__, not __MINGW32__ */
-
-/* xmalloc --- provide this so that other GNU library routines work */
-
-typedef void *pointer;
-
-extern pointer xmalloc(size_t bytes);  /* get rid of gcc warning */
-
-pointer
-xmalloc(size_t bytes)
-{
-       pointer p;
-       if (bytes == 0)
-               bytes = 1;      /* avoid dfa.c mishegos */
-       emalloc(p, pointer, bytes, "xmalloc");
-       return p;
-}
diff --git a/helpers/ChangeLog b/helpers/ChangeLog
index ce3fd9c..bd7e548 100644
--- a/helpers/ChangeLog
+++ b/helpers/ChangeLog
@@ -1,3 +1,8 @@
+2017-06-25         Andrew J. Schorr      <address@hidden>
+
+       * testdfa.c (xcalloc): Replace xmalloc+memset with calloc.
+       (xzalloc): Replace xmalloc+memset with xcalloc.
+
 2017-04-26         Arnold D. Robbins     <address@hidden>
 
        * test-build.sh: Allow override of compiler lists. Print
diff --git a/helpers/testdfa.c b/helpers/testdfa.c
index 72b9790..f61d4e2 100644
--- a/helpers/testdfa.c
+++ b/helpers/testdfa.c
@@ -880,8 +880,13 @@ xnmalloc (size_t n, size_t s)
 void *
 xcalloc(size_t nmemb, size_t size)
 {
-  void *p = xmalloc (nmemb * size);
-  memset(p, '\0', nmemb * size);
+  void *p = calloc (nmemb, size);
+
+  if (p == NULL) {
+    fprintf(stderr, "xcalloc: calloc failed: %s\n", strerror(errno));
+    exit(EXIT_FAILURE);
+  }
+
   return p;
 }
 
@@ -1031,7 +1036,7 @@ xcharalloc (size_t n)
 void *
 xzalloc (size_t s)
 {
-  return memset (xmalloc (s), 0, s);
+  return xcalloc (1, s);
 }
 
 # endif
diff --git a/support/ChangeLog b/support/ChangeLog
index ec54675..bc535ea 100644
--- a/support/ChangeLog
+++ b/support/ChangeLog
@@ -1,3 +1,10 @@
+2017-06-25         Andrew J. Schorr      <address@hidden>
+
+       * dfa.c (dfaalloc): Replace xmalloc+memset with xzalloc.
+       * xalloc.h (xmalloc): New function moved here from gawkmisc.c.
+       (xcalloc): Replace xmalloc+memset with calloc.
+       (xzalloc): Replace xmalloc+memset with xcalloc.
+
 2017-06-22         Arnold D. Robbins     <address@hidden>
 
        * regcomp.c, regex.c, regex.h, regex_internal.c, regex_internal.h,
diff --git a/support/dfa.c b/support/dfa.c
index 18c17a5..3a675f5 100644
--- a/support/dfa.c
+++ b/support/dfa.c
@@ -4062,12 +4062,7 @@ dfamustfree (struct dfamust *dm)
 struct dfa *
 dfaalloc (void)
 {
-  void *p = xmalloc (sizeof (struct dfa));
-  if (p)
-    {
-      memset (p, 0, sizeof (struct dfa));
-    }
-  return p;
+  return xzalloc (sizeof (struct dfa));
 }
 
 /* Initialize DFA.  */
diff --git a/support/xalloc.h b/support/xalloc.h
index 0d169cf..89dbe2c 100644
--- a/support/xalloc.h
+++ b/support/xalloc.h
@@ -138,6 +138,17 @@ xnmalloc (size_t n, size_t s)
 #include <errno.h>
 extern void r_fatal(const char *msg, ...) ATTRIBUTE_NORETURN ;
 
+void *
+xmalloc(size_t bytes)
+{
+  void *p;
+  if (bytes == 0)
+    bytes = 1; /* avoid dfa.c mishegos */
+  if ((p = malloc(bytes)) == NULL)
+    xalloc_die ();
+  return p;
+}
+
 /* Allocate an array of N objects, each with S bytes of memory,
    dynamically, with error checking.  S must be nonzero.
    Clear the contents afterwards.  */
@@ -145,8 +156,12 @@ extern void r_fatal(const char *msg, ...) 
ATTRIBUTE_NORETURN ;
 void *
 xcalloc(size_t nmemb, size_t size)
 {
-  void *p = xmalloc (nmemb * size);
-  memset(p, '\0', nmemb * size);
+  void *p;
+
+  if (nmemb == 0 || size == 0)
+    nmemb = size = 1;  /* avoid dfa.c mishegos */
+  if ((p = calloc(nmemb, size)) == NULL)
+    xalloc_die ();
   return p;
 }
 
@@ -314,7 +329,7 @@ xcharalloc (size_t n)
 inline void *
 xzalloc (size_t s)
 {
-  return memset (xmalloc (s), 0, s);
+  return xcalloc(1, s);
 }
 
 # endif

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

Summary of changes:
 ChangeLog         |  4 ++++
 gawkmisc.c        | 16 ----------------
 helpers/ChangeLog |  5 +++++
 helpers/testdfa.c | 11 ++++++++---
 support/ChangeLog |  7 +++++++
 support/dfa.c     |  7 +------
 support/xalloc.h  | 21 ++++++++++++++++++---
 7 files changed, 43 insertions(+), 28 deletions(-)


hooks/post-receive
-- 
gawk



reply via email to

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