aboutsummaryrefslogtreecommitdiffstats
path: root/regex.c
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2010-07-16 12:27:41 +0300
committerArnold D. Robbins <arnold@skeeve.com>2010-07-16 12:27:41 +0300
commit61bb57af53ebe916d2db6e3585d4fc7ac1d99b92 (patch)
tree2bfc4e5b127618d286f57a87d416702131b1b01d /regex.c
parent0a9ae0c89481db540e1b817a63cc6c793a62c90d (diff)
downloadegawk-61bb57af53ebe916d2db6e3585d4fc7ac1d99b92.tar.gz
egawk-61bb57af53ebe916d2db6e3585d4fc7ac1d99b92.tar.bz2
egawk-61bb57af53ebe916d2db6e3585d4fc7ac1d99b92.zip
Move to gawk-2.15.3.
Diffstat (limited to 'regex.c')
-rw-r--r--regex.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/regex.c b/regex.c
index f4dd4c2c..85001608 100644
--- a/regex.c
+++ b/regex.c
@@ -334,16 +334,28 @@ long obscure_syntax = 0;
*b++ = (char) (ch); \
}
-/* Extend the buffer by twice its current size via reallociation and
+/* Extend the buffer by twice its current size via reallocation and
reset the pointers that pointed into the old allocation to point to
the correct places in the new allocation. If extending the buffer
- results in it being larger than 1 << 16, then flag memory exhausted. */
+ results in it being larger than EXTEND_BUFFER_MAX, then flag memory
+ exhausted. */
+#ifdef _MSC_VER
+/* Microsoft C 16-bit versions limit malloc to approx 65512 bytes.
+ The REALLOC define eliminates a flurry of conversion warnings,
+ but is not required. */
+#define EXTEND_BUFFER_MAX 65500L
+#define REALLOC(p,s) realloc(p, (size_t) (s))
+#else
+#define EXTEND_BUFFER_MAX (1L << 16)
+#define REALLOC realloc
+#endif
#define EXTEND_BUFFER \
{ char *old_buffer = bufp->buffer; \
- if (bufp->allocated == (1L<<16)) goto too_big; \
+ if (bufp->allocated == EXTEND_BUFFER_MAX) goto too_big; \
bufp->allocated *= 2; \
- if (bufp->allocated > (1L<<16)) bufp->allocated = (1L<<16); \
- bufp->buffer = (char *) realloc (bufp->buffer, bufp->allocated); \
+ if (bufp->allocated > EXTEND_BUFFER_MAX) \
+ bufp->allocated = EXTEND_BUFFER_MAX; \
+ bufp->buffer = (char *) REALLOC (bufp->buffer, bufp->allocated); \
if (bufp->buffer == 0) \
goto memory_exhausted; \
b = (b - old_buffer) + bufp->buffer; \