diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2017-06-23 12:45:16 +0300 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2017-06-23 12:45:16 +0300 |
commit | 5ea4224acd6effc77359d42436de4804b86f1112 (patch) | |
tree | 9d4936e21342b71fd43de7cac311822677caad98 /awk.h | |
parent | 231cb5df34699fd98001e2e124d73da5d2f795f9 (diff) | |
parent | 44e29458a6355ad64e8d89676a441b224ce76cbc (diff) | |
download | egawk-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.h | 20 |
1 files changed, 20 insertions, 0 deletions
@@ -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 * |