initialize memory pools etc.
Static constructors is dangerous in that you don't know for sure
in which order they will be called. The recent String pool change
where the object size is dynamically calculated on startup is and
example, where the requested pool size had not yet been calculated
before the pools was created.
/*
- * $Id: gopher.cc,v 1.205 2007/05/18 06:41:24 amosjeffries Exp $
+ * $Id: gopher.cc,v 1.206 2007/05/23 20:59:14 hno Exp $
*
* DEBUG: section 10 Gopher
* AUTHOR: Harvest Derived
if (request) {
xstrncpy(request, path + 1, MAX_URL);
/* convert %xx to char */
- url_convert_hex(request, 0);
+ rfc1738_unescape(request);
}
}
/*
- * $Id: protos.h,v 1.543 2007/05/18 06:41:25 amosjeffries Exp $
+ * $Id: protos.h,v 1.544 2007/05/23 20:59:14 hno Exp $
*
*
* SQUID Web Proxy Cache http://www.squid-cache.org/
SQUIDCEXTERN void unlinkdUnlink(const char *);
#endif
-SQUIDCEXTERN char *url_convert_hex(char *org_url, int allocate);
-SQUIDCEXTERN char *url_escape(const char *url);
SQUIDCEXTERN protocol_t urlParseProtocol(const char *, const char *e = NULL);
SQUIDCEXTERN void urlInitialize(void);
SQUIDCEXTERN HttpRequest *urlParse(method_t, char *, HttpRequest *request = NULL);
/* init memory pools */
-struct Initer
+void testCacheManager::setUp()
{
- Initer() {Mem::Init();}
-};
-
-static Initer ensure_mempools;
+ Mem::Init();
+}
/*
* Test creating a CacheManager
CPPUNIT_TEST_SUITE_END();
public:
+ void setUp();
protected:
void testCreate();
CPPUNIT_TEST_SUITE_REGISTRATION( testDiskIO );
-struct Initer {
- Initer() {
+void
+testDiskIO::setUp()
+{
Mem::Init();
DiskIOModule::SetupAllModules();
- };
-};
-
-Initer ensure_inited;
+}
void
testDiskIO::testFindDefault()
CPPUNIT_TEST_SUITE_END();
public:
+ void setUp();
protected:
void testFindDefault();
/* init legacy static-initialized modules */
-struct Initer
+void
+testEvent::setUp()
{
- Initer()
- {
- Mem::Init();
- statInit();
- }
-};
-
-static Initer ensure_mempools;
+ Mem::Init();
+ statInit();
+}
/*
* Test creating a EventDispatcher and Scheduler
CPPUNIT_TEST_SUITE_END();
public:
+ void setUp();
protected:
void testCreate();
/* init legacy static-initialized modules */
-struct Initer
+void
+testEventLoop::setUp()
{
- Initer()
- {
- Mem::Init();
- statInit();
- }
-};
-
-static Initer ensure_mempools;
+ Mem::Init();
+ statInit();
+}
/*
* Test creating a EventLoop
CPPUNIT_TEST_SUITE_END();
public:
+ void setUp();
protected:
void testCreate();
/* init memory pools */
-struct Initer
+void
+testHttpRequest::setUp()
{
- Initer() {Mem::Init();}
-};
-
-static Initer ensure_mempools;
+ Mem::Init();
+}
/*
* Test creating an HttpRequest object from a Url and method
CPPUNIT_TEST_SUITE_END();
public:
+ void setUp();
protected:
void testCreateFromUrlAndMethod();
/* init memory pools */
-struct Initer
+void testStoreEntryStream::setUp()
{
- Initer() {Mem::Init();}
-};
-
-static Initer ensure_mempools;
+ Mem::Init();
+}
void
testStoreEntryStream::testGetStream()
CPPUNIT_TEST_SUITE_END();
public:
+ void setUp();
protected:
void testGetStream();
/* init memory pools */
-struct Initer
+void
+testString::setUp()
{
- Initer() {Mem::Init();}
-};
-
-static Initer ensure_mempools;
+ Mem::Init();
+}
void
testString::testDefaults()
CPPUNIT_TEST_SUITE_END();
public:
+ void setUp();
protected:
/* init memory pools */
-struct Initer
+void
+testURL::setUp()
{
- Initer() {Mem::Init();}
-};
-
-static Initer ensure_mempools;
+ Mem::Init();
+}
/*
* we can construct a URL with a URLScheme.
CPPUNIT_TEST_SUITE_END();
public:
+ void setUp();
protected:
/*
- * $Id: url.cc,v 1.158 2007/05/18 06:41:25 amosjeffries Exp $
+ * $Id: url.cc,v 1.159 2007/05/23 20:59:14 hno Exp $
*
* DEBUG: section 23 URL Parsing
* AUTHOR: Duane Wessels
"0123456789-."
;
-/* convert %xx in url string to a character
- * Allocate a new string and return a pointer to converted string */
-
-char *
-url_convert_hex(char *org_url, int allocate)
-{
- static char code[] = "00";
- char *url = NULL;
- char *s = NULL;
- char *t = NULL;
- url = allocate ? (char *) xstrdup(org_url) : org_url;
-
- if ((int) strlen(url) < 3 || !strchr(url, '%'))
- return url;
-
- for (s = t = url; *s; s++) {
- if (*s == '%' && *(s + 1) && *(s + 2)) {
- code[0] = *(++s);
- code[1] = *(++s);
- *t++ = (char) strtol(code, NULL, 16);
- } else {
- *t++ = *s;
- }
- }
-
- do {
- *t++ = *s;
- } while (*s++);
-
- return url;
-}
-
void
urlInitialize(void)
{