]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Cache-Control headers refactoring: c++-ize constuctors
authorFrancesco Chemolli <kinkie@squid-cache.org>
Mon, 12 Sep 2011 12:02:55 +0000 (14:02 +0200)
committerFrancesco Chemolli <kinkie@squid-cache.org>
Mon, 12 Sep 2011 12:02:55 +0000 (14:02 +0200)
src/HttpHeaderCacheControl.cc
src/http.cc
src/mime.cc
src/protos.h

index 1bcaca4bd1555914b2a683a91de85c0cb5bf62d3..16bc7f7ec0f54cebb732390f3279b4e28406bf5d 100644 (file)
@@ -48,7 +48,7 @@ typedef struct {
     HttpHeaderFieldStat stat;
 } HttpHeaderCcFields;
 
-/* order must match that of enum http_hdr_cc_type */
+/* order must match that of enum http_hdr_cc_type. The constraint is verified at initialization time */
 static HttpHeaderCcFields CcAttrs[CC_ENUM_END] = {
         {"public", CC_PUBLIC},
         {"private", CC_PRIVATE},
@@ -66,9 +66,11 @@ static HttpHeaderCcFields CcAttrs[CC_ENUM_END] = {
         {"Other,", CC_OTHER} /* ',' will protect from matches */
 };
 
+/// Map an header name to its type, to expedite parsing
 typedef std::map<String,http_hdr_cc_type> HdrCcNameToIdMap_t;
 static HdrCcNameToIdMap_t HdrCcNameToIdMap;
 
+// iterate over a table of http_header_cc_type structs
 http_hdr_cc_type &operator++ (http_hdr_cc_type &aHeader)
 {
     int tmp = (int)aHeader;
@@ -100,22 +102,14 @@ httpHdrCcCleanModule(void)
     // HdrCcNameToIdMap is self-cleaning
 }
 
-/* implementation */
-
-HttpHdrCc *
-httpHdrCcCreate(void)
-{
-    return new HttpHdrCc();
-}
-
 /* creates an cc object from a 0-terminating string */
 HttpHdrCc *
 httpHdrCcParseCreate(const String * str)
 {
-    HttpHdrCc *cc = httpHdrCcCreate();
+    HttpHdrCc *cc = new HttpHdrCc();
 
     if (!httpHdrCcParseInit(cc, str)) {
-        httpHdrCcDestroy(cc);
+        delete cc;
         cc = NULL;
     }
 
index 96b90574c8aedc57fb27baec540e7cb8172356fe..6acb0e6e3747688a6dcf22276c13c92186bd2421 100644 (file)
@@ -1758,7 +1758,7 @@ HttpStateData::httpBuildRequestHeader(HttpRequest * request,
         HttpHdrCc *cc = hdr_in->getCc();
 
         if (!cc)
-            cc = httpHdrCcCreate();
+            cc = new HttpHdrCc();
 
 #if 0 /* see bug 2330 */
         /* Set no-cache if determined needed but not found */
index a55801022bbb30e4949e7fbe78507036ca619b1a..aaf5827a18e1d21e0899d3a390ab64e10a0c59ef 100644 (file)
@@ -462,7 +462,7 @@ MimeIcon::created (StoreEntry *newEntry)
 
     reply->setHeaders(HTTP_OK, NULL, mimeGetContentType(icon), sb.st_size, sb.st_mtime, -1);
 
-    reply->cache_control = httpHdrCcCreate();
+    reply->cache_control = new HttpHdrCc();
 
     httpHdrCcSetMaxAge(reply->cache_control, 86400);
 
index 858b42acbc33ae4b80823b074ffdf2cc4076f959..7c1bd6e3820b66ce52f3aed0f142e9fed3d63d19 100644 (file)
@@ -237,7 +237,6 @@ SQUIDCEXTERN void httpBodyPackInto(const HttpBody * body, Packer * p);
 /* Http Cache Control Header Field */
 SQUIDCEXTERN void httpHdrCcInitModule(void);
 SQUIDCEXTERN void httpHdrCcCleanModule(void);
-SQUIDCEXTERN HttpHdrCc *httpHdrCcCreate(void);
 SQUIDCEXTERN HttpHdrCc *httpHdrCcParseCreate(const String * str);
 SQUIDCEXTERN void httpHdrCcDestroy(HttpHdrCc * cc);
 SQUIDCEXTERN HttpHdrCc *httpHdrCcDup(const HttpHdrCc * cc);