[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gawk-diffs] [SCM] gawk branch, gawk-4.1-stable, updated. gawk-4.1.0-524
From: |
Arnold Robbins |
Subject: |
[gawk-diffs] [SCM] gawk branch, gawk-4.1-stable, updated. gawk-4.1.0-524-g838f650 |
Date: |
Sat, 22 Nov 2014 18:39:00 +0000 |
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, gawk-4.1-stable has been updated
via 838f65088cda84edc2df609d3e388acb3c8eb13d (commit)
from 1fc15398cbd381b83e20bca3913c12ee7aa34bd4 (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=838f65088cda84edc2df609d3e388acb3c8eb13d
commit 838f65088cda84edc2df609d3e388acb3c8eb13d
Author: Arnold D. Robbins <address@hidden>
Date: Sat Nov 22 20:38:31 2014 +0200
Dork around with xmalloc for z/OS.
diff --git a/ChangeLog b/ChangeLog
index bf73f3d..c24ecd3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2014-11-22 Arnold D. Robbins <address@hidden>
+
+ * awk.h (emalloc, realloc): Redefine in terms of ...
+ (emalloc_real, eralloc_real): New static inline functions.
+ (fatal): Move definition up.
+ * gawkmisc.c (xmalloc): If count is zero, make it one for older
+ mallocs that require size > 0 (such as z/OS).
+
2014-11-21 Arnold D. Robbins <address@hidden>
* main.c: Remove a debugging // comment.
diff --git a/awk.h b/awk.h
index 9b72a53..84c8ca0 100644
--- a/awk.h
+++ b/awk.h
@@ -1245,13 +1245,42 @@ DEREF(NODE *r)
#define cant_happen() r_fatal("internal error line %d, file: %s", \
__LINE__, __FILE__)
-#define emalloc(var,ty,x,str) (void)((var=(ty)malloc((size_t)(x))) ||\
- (fatal(_("%s: %s: can't allocate %ld bytes of
memory (%s)"),\
- (str), #var, (long) (x),
strerror(errno)),0))
-#define erealloc(var,ty,x,str) (void)((var = (ty)realloc((char *)var,
(size_t)(x))) \
- ||\
- (fatal(_("%s: %s: can't allocate %ld bytes of
memory (%s)"),\
- (str), #var, (long) (x),
strerror(errno)),0))
+#define fatal set_loc(__FILE__, __LINE__), r_fatal
+
+static inline void *
+emalloc_real(size_t count, const char *where, const char *var, const char
*file, int line)
+{
+ void *ret;
+
+ if (count == 0)
+ fatal("%s:%d: emalloc called with zero bytes", file, line);
+
+ ret = (void *) malloc(count);
+ if (ret == NULL)
+ fatal(_("%s:%d:%s: %s: can't allocate %ld bytes of memory
(%s)"),
+ file, line, where, var, (long) count, strerror(errno));
+
+ return ret;
+}
+
+static inline void *
+erealloc_real(void *ptr, size_t count, const char *where, const char *var,
const char *file, int line)
+{
+ void *ret;
+
+ if (count == 0)
+ fatal("%s:%d: erealloc called with zero bytes", file, line);
+
+ ret = (void *) realloc(ptr, count);
+ if (ret == NULL)
+ fatal(_("%s:%d:%s: %s: can't reallocate %ld bytes of memory
(%s)"),
+ file, line, where, var, (long) count, strerror(errno));
+
+ return ret;
+}
+
+#define emalloc(var,ty,x,str) (void) (var = (ty)
emalloc_real((size_t)(x), str, #var, __FILE__, __LINE__))
+#define erealloc(var,ty,x,str) (void) (var = (ty) erealloc_real((void
*) var, (size_t)(x), str, #var, __FILE__, __LINE__))
#define efree(p) free(p)
@@ -1285,8 +1314,6 @@ force_number(NODE *n)
#endif /* GAWKDEBUG */
-#define fatal set_loc(__FILE__, __LINE__), r_fatal
-
extern jmp_buf fatal_tag;
extern bool fatal_tag_valid;
diff --git a/gawkmisc.c b/gawkmisc.c
index a729d88..0172a81 100644
--- a/gawkmisc.c
+++ b/gawkmisc.c
@@ -52,6 +52,8 @@ pointer
xmalloc(size_t bytes)
{
pointer p;
+ if (bytes == 0)
+ bytes = 1; /* avoid dfa.c mishegos */
emalloc(p, pointer, bytes, "xmalloc");
return p;
}
-----------------------------------------------------------------------
Summary of changes:
ChangeLog | 8 ++++++++
awk.h | 45 ++++++++++++++++++++++++++++++++++++---------
gawkmisc.c | 2 ++
3 files changed, 46 insertions(+), 9 deletions(-)
hooks/post-receive
--
gawk
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gawk-diffs] [SCM] gawk branch, gawk-4.1-stable, updated. gawk-4.1.0-524-g838f650,
Arnold Robbins <=