aboutsummaryrefslogtreecommitdiffstats
path: root/awk.h
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2017-06-23 12:45:16 +0300
committerArnold D. Robbins <arnold@skeeve.com>2017-06-23 12:45:16 +0300
commit5ea4224acd6effc77359d42436de4804b86f1112 (patch)
tree9d4936e21342b71fd43de7cac311822677caad98 /awk.h
parent231cb5df34699fd98001e2e124d73da5d2f795f9 (diff)
parent44e29458a6355ad64e8d89676a441b224ce76cbc (diff)
downloadegawk-5ea4224acd6effc77359d42436de4804b86f1112.tar.gz
egawk-5ea4224acd6effc77359d42436de4804b86f1112.tar.bz2
egawk-5ea4224acd6effc77359d42436de4804b86f1112.zip
Merge branch 'master' into feature/fix-comments
Diffstat (limited to 'awk.h')
-rw-r--r--awk.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/awk.h b/awk.h
index ab84c58b..1ed5a4ef 100644
--- a/awk.h
+++ b/awk.h
@@ -736,6 +736,7 @@ typedef enum opcodeval {
Op_K_else,
Op_K_function,
Op_cond_exp,
+ Op_parens,
Op_final /* sentry value, not legal */
} OPCODE;
@@ -1331,6 +1332,7 @@ DEREF(NODE *r)
__LINE__, __FILE__)
#define emalloc(var,ty,x,str) (void) (var = (ty) emalloc_real((size_t)(x), str, #var, __FILE__, __LINE__))
+#define ezalloc(var,ty,x,str) (void) (var = (ty) ezalloc_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)
@@ -1950,6 +1952,24 @@ emalloc_real(size_t count, const char *where, const char *var, const char *file,
return ret;
}
+/* ezalloc_real --- malloc zero-filled bytes with error checking */
+
+static inline void *
+ezalloc_real(size_t count, const char *where, const char *var, const char *file, int line)
+{
+ void *ret;
+
+ if (count == 0)
+ fatal("%s:%d: ezalloc called with zero bytes", file, line);
+
+ ret = (void *) calloc(1, 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;
+}
+
/* erealloc_real --- realloc with error checking */
static inline void *