Hello,
when building Wt with -DHAVE_GNU_REGEX there is a memory leak.
While it is not accumulating, it is still clobbering the output
from valgrind et al.
Perhaps the following patch is acceptable...
Goetz
--
Goetz Babin-Ebell <[email protected]>
4G Systems GmbH & Co KG
Index: src/web/CgiParser.C
===================================================================
RCS file: /opt/cvs/wt/src/web/CgiParser.C,v
retrieving revision 1.26
diff -u -r1.26 CgiParser.C
--- src/web/CgiParser.C 12 Nov 2008 10:16:09 -0000 1.26
+++ src/web/CgiParser.C 15 Dec 2008 13:28:42 -0000
@@ -118,6 +118,41 @@
return regexec(&e, text.c_str(), 1, pmatch, 0) == 0;
}
+ class RegInitializer {
+ protected:
+ static bool regInitialized_;
+ public:
+ RegInitializer()
+ {}
+ ~RegInitializer() {
+ cleanup();
+ }
+ static void setup() {
+ if (!regInitialized_) {
+ regcomp(&boundary_e, boundary_ep, REG_ICASE | REG_EXTENDED);
+ regcomp(&name_e, name_ep, REG_ICASE | REG_EXTENDED);
+ regcomp(&filename_e, filename_ep, REG_ICASE | REG_EXTENDED);
+ regcomp(&content_e, content_ep, REG_ICASE | REG_EXTENDED);
+ regcomp(&content_disposition_e, content_disposition_ep,
+ REG_ICASE | REG_EXTENDED);
+ regcomp(&content_type_e, content_type_ep, REG_ICASE | REG_EXTENDED);
+ regInitialized_ = true;
+ }
+ }
+ static void cleanup() {
+ if (regInitialized_) {
+ regfree(&boundary_e);
+ regfree(&name_e);
+ regfree(&filename_e);
+ regfree(&content_e);
+ regfree(&content_disposition_e);
+ regfree(&content_type_e);
+ regInitialized_ = false;
+ }
+ }
+ };
+ bool RegInitializer::regInitialized_ = false;
+ static RegInitializer regInitializer;
#endif
}
@@ -126,13 +161,7 @@
void CgiParser::init()
{
#ifdef HAVE_GNU_REGEX
- regcomp(&boundary_e, boundary_ep, REG_ICASE | REG_EXTENDED);
- regcomp(&name_e, name_ep, REG_ICASE | REG_EXTENDED);
- regcomp(&filename_e, filename_ep, REG_ICASE | REG_EXTENDED);
- regcomp(&content_e, content_ep, REG_ICASE | REG_EXTENDED);
- regcomp(&content_disposition_e, content_disposition_ep,
- REG_ICASE | REG_EXTENDED);
- regcomp(&content_type_e, content_type_ep, REG_ICASE | REG_EXTENDED);
+ RegInitializer::setup();
#endif
}
------------------------------------------------------------------------------
SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
The future of the web can't happen without you. Join us at MIX09 to help
pave the way to the Next Web now. Learn more and register at
http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/
_______________________________________________
witty-interest mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/witty-interest