summaryrefslogtreecommitdiffstats
path: root/generic/regcustom.h
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2007-01-10 15:30:59 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2007-01-10 15:30:59 (GMT)
commitf299701a39e378d072a5c5d97396675ce735b414 (patch)
treea89fe1c2a582e5bc126b2ec3cf259c3c61a28a55 /generic/regcustom.h
parent0461303eb629c1a59984468e671be1d59c424aae (diff)
downloadtcl-f299701a39e378d072a5c5d97396675ce735b414.zip
tcl-f299701a39e378d072a5c5d97396675ce735b414.tar.gz
tcl-f299701a39e378d072a5c5d97396675ce735b414.tar.bz2
Arrange for RE engine workspace to be held in TSD. This is safe, less
C-stack-hungry than before, and faster than just using heap allocation.
Diffstat (limited to 'generic/regcustom.h')
-rw-r--r--generic/regcustom.h22
1 files changed, 19 insertions, 3 deletions
diff --git a/generic/regcustom.h b/generic/regcustom.h
index 6abd24c..6b6b38c 100644
--- a/generic/regcustom.h
+++ b/generic/regcustom.h
@@ -11,12 +11,12 @@
* redistributions in source form retain this entire copyright notice and
* indicate the origin and nature of any modifications.
*
- * I'd appreciate being given credit for this package in the documentation
- * of software which uses it, but that is not a requirement.
+ * I'd appreciate being given credit for this package in the documentation of
+ * software which uses it, but that is not a requirement.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* HENRY SPENCER BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
@@ -116,5 +116,21 @@ typedef int celt; /* type to hold chr, MCCE number, or NOCELT */
#define REG_DEBUG /* */
#endif
+/* method of allocating a local workspace */
+#if 1
+#define AllocVars(vPtr) \
+ static Tcl_ThreadDataKey varsKey; \
+ register struct vars *vPtr = (struct vars *) \
+ Tcl_GetThreadData(&varsKey, sizeof(struct vars))
+#else
+/* This strategy for allocating workspace is "more proper" in some sense, but
+ * quite a bit slower. Using TSD (as above) leads to code that is quite a bit
+ * faster in practice. */
+#define AllocVars(vPtr) \
+ register struct vars *vPtr = (struct vars *) MALLOC(sizeof(struct vars))
+#define FreeVars(vPtr) \
+ FREE(vPtr)
+#endif
+
/* and pick up the standard header */
#include "regex.h"