aboutsummaryrefslogtreecommitdiffstats
path: root/regex_internal.h
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2015-04-13 10:58:50 +0300
committerArnold D. Robbins <arnold@skeeve.com>2015-04-13 10:58:50 +0300
commit0900989f28eb43fe5744b622a1f8ae02f53f26f0 (patch)
tree0292b1d055ba5023bc9def76dab31b42dd9f21d6 /regex_internal.h
parentd047b198dca5da3577f696ac868c19feb030bc7a (diff)
parent06a351f8774409db0d9c72ac4a51652f7c855c06 (diff)
downloadegawk-0900989f28eb43fe5744b622a1f8ae02f53f26f0.tar.gz
egawk-0900989f28eb43fe5744b622a1f8ae02f53f26f0.tar.bz2
egawk-0900989f28eb43fe5744b622a1f8ae02f53f26f0.zip
Merge branch 'master' into feature/cmake
Diffstat (limited to 'regex_internal.h')
-rw-r--r--regex_internal.h30
1 files changed, 30 insertions, 0 deletions
diff --git a/regex_internal.h b/regex_internal.h
index 9aab5e52..6a870f23 100644
--- a/regex_internal.h
+++ b/regex_internal.h
@@ -467,8 +467,38 @@ static unsigned int re_string_context_at (const re_string_t *input, int idx,
# endif
#endif
+/*
+ * GAWK checks for zero-size allocations everywhere else,
+ * do it here too.
+ */
+#ifndef GAWK
#define re_malloc(t,n) ((t *) malloc ((n) * sizeof (t)))
#define re_realloc(p,t,n) ((t *) realloc (p, (n) * sizeof (t)))
+#else
+static void *
+test_malloc(size_t count, const char *file, size_t line)
+{
+ if (count == 0) {
+ fprintf(stderr, "%s:%d: allocation of zero bytes\n",
+ file, line);
+ exit(1);
+ }
+ return malloc(count);
+}
+
+static void *
+test_realloc(void *p, size_t count, const char *file, size_t line)
+{
+ if (count == 0) {
+ fprintf(stderr, "%s:%d: reallocation of zero bytes\n",
+ file, line);
+ exit(1);
+ }
+ return realloc(p, count);
+}
+#define re_malloc(t,n) ((t *) test_malloc (((n) * sizeof (t)), __FILE__, __LINE__))
+#define re_realloc(p,t,n) ((t *) test_realloc (p, (n) * sizeof (t), __FILE__, __LINE__))
+#endif
#define re_free(p) free (p)
struct bin_tree_t