]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
unsafeBuf is no more.
authorFrancesco Chemolli <kinkie@squid-cache.org>
Thu, 12 Feb 2009 10:46:08 +0000 (11:46 +0100)
committerFrancesco Chemolli <kinkie@squid-cache.org>
Thu, 12 Feb 2009 10:46:08 +0000 (11:46 +0100)
Reverted shortening of size_type to unisgned int, due to issue with std::string::npos.

src/SquidString.h
src/String.cci
src/adaptation/Config.cc
src/peer_digest.cc
src/store.cc

index 0aac98957b229c372187d7754a6e22f19364c59e..897ce13d723e93d5727ef0307b5d5e0eb4486148 100644 (file)
@@ -92,7 +92,7 @@ public:
     String (String const &);
     ~String();
 
-    typedef unsigned int size_type; //storage size intentionally unspecified
+    typedef size_t size_type; //storage size intentionally unspecified
 
     String &operator =(char const *);
     String &operator =(String const &);
@@ -109,7 +109,6 @@ public:
     /// variant of size() suited to be used for printf-alikes.
     /// throws when size() > MAXINT
     int psize() const;
-    _SQUID_INLINE_ char const * unsafeBuf() const;
 
     /**
      * \retval true the String has some contents
index 263fd9931b01d60c35332663a0d5d55b395f66c4..adbf8916dea1b73e8f02dc10ef15e67e7225ec38 100644 (file)
@@ -58,12 +58,6 @@ String::size() const
     return len_;
 }
 
-char const *
-String::unsafeBuf() const
-{
-    return buf_;
-}
-
 bool String::defined() const
 {
     return buf_!=NULL;
index ac5f17ee23382d1260fc8e38632750740ec42a88..1ae4ee486313c38aa02abdfe39aa48a07437d782 100644 (file)
@@ -68,8 +68,11 @@ Adaptation::Config::dumpService(StoreEntry *entry, const char *name) const
     typedef Services::iterator SCI;
     for (SCI i = AllServices().begin(); i != AllServices().end(); ++i) {
         const ServiceConfig &cfg = (*i)->cfg();
-        storeAppendPrintf(entry, "%s %.*s_%s %s %d %.*s\n", name, cfg.key.size(), cfg.key.rawBuf(),
-                          cfg.methodStr(), cfg.vectPointStr(), cfg.bypass, cfg.uri.size(), cfg.uri.rawBuf());
+        storeAppendPrintf(entry, "%s " SQUIDSTRINGPH "_%s %s %d " SQUIDSTRINGPH "\n",
+            name,
+            SQUIDSTRINGPRINT(cfg.key),
+            cfg.methodStr(), cfg.vectPointStr(), cfg.bypass,
+            SQUIDSTRINGPRINT(cfg.uri));
     }
 }
 
index d8b510bb7d45bece2c329ce0116086c20737b647..4f009ec93e592296c73dadd1388a13cf9d1154c4 100644 (file)
@@ -279,7 +279,7 @@ peerDigestCheck(void *data)
     /* per-peer limit */
 
     if (req_time - pd->times.received < PeerDigestReqMinGap) {
-        debugs(72, 2, "peerDigestCheck: " << pd->host.unsafeBuf() <<
+        debugs(72, 2, "peerDigestCheck: " << pd->host <<
                ", avoiding close peer requests (" <<
                (int) (req_time - pd->times.received) << " < " <<
                (int) PeerDigestReqMinGap << " secs).");
@@ -289,7 +289,7 @@ peerDigestCheck(void *data)
 
     /* global limit */
     if (req_time - pd_last_req_time < GlobDigestReqMinGap) {
-        debugs(72, 2, "peerDigestCheck: " << pd->host.unsafeBuf() <<
+        debugs(72, 2, "peerDigestCheck: " << pd->host <<
                ", avoiding close requests (" <<
                (int) (req_time - pd_last_req_time) << " < " <<
                (int) GlobDigestReqMinGap << " secs).");
@@ -544,7 +544,7 @@ peerDigestFetchReply(void *data, char *buf, ssize_t size)
         assert(reply);
         assert (reply->sline.status != 0);
         status = reply->sline.status;
-        debugs(72, 3, "peerDigestFetchReply: " << pd->host.unsafeBuf() << " status: " << status <<
+        debugs(72, 3, "peerDigestFetchReply: " << pd->host << " status: " << status <<
                ", expires: " << (long int) reply->expires << " (" << std::showpos <<
                (int) (reply->expires - squid_curtime) << ")");
 
@@ -634,7 +634,7 @@ peerDigestSwapInHeaders(void *data, char *buf, ssize_t size)
         assert (fetch->entry->getReply()->sline.status != 0);
 
         if (fetch->entry->getReply()->sline.status != HTTP_OK) {
-            debugs(72, 1, "peerDigestSwapInHeaders: " << fetch->pd->host.unsafeBuf() <<
+            debugs(72, 1, "peerDigestSwapInHeaders: " << fetch->pd->host <<
                    " status " << fetch->entry->getReply()->sline.status <<
                    " got cached!");
 
@@ -762,7 +762,7 @@ peerDigestFetchedEnough(DigestFetchState * fetch, char *buf, ssize_t size, const
 #endif
 
         else
-            host = pd->host.unsafeBuf();
+            host = pd->host.termedBuf();
     }
 
     debugs(72, 6, step_name << ": peer " << host << ", offset: " <<
@@ -813,7 +813,7 @@ static void
 peerDigestFetchStop(DigestFetchState * fetch, char *buf, const char *reason)
 {
     assert(reason);
-    debugs(72, 2, "peerDigestFetchStop: peer " << fetch->pd->host.unsafeBuf() << ", reason: " << reason);
+    debugs(72, 2, "peerDigestFetchStop: peer " << fetch->pd->host << ", reason: " << reason);
     peerDigestReqFinish(fetch, buf, 1, 1, 1, reason, 0);
 }
 
@@ -822,7 +822,7 @@ static void
 peerDigestFetchAbort(DigestFetchState * fetch, char *buf, const char *reason)
 {
     assert(reason);
-    debugs(72, 2, "peerDigestFetchAbort: peer " << fetch->pd->host.unsafeBuf() << ", reason: " << reason);
+    debugs(72, 2, "peerDigestFetchAbort: peer " << fetch->pd->host << ", reason: " << reason);
     peerDigestReqFinish(fetch, buf, 1, 1, 1, reason, 1);
 }
 
@@ -872,7 +872,7 @@ static void
 peerDigestPDFinish(DigestFetchState * fetch, int pcb_valid, int err)
 {
     PeerDigest *pd = fetch->pd;
-    const char *host = pd->host.unsafeBuf();
+    const char *host = pd->host.termedBuf();
 
     pd->times.received = squid_curtime;
     pd->times.req_delay = fetch->resp_time;
@@ -986,7 +986,7 @@ peerDigestSetCBlock(PeerDigest * pd, const char *buf)
 {
     StoreDigestCBlock cblock;
     int freed_size = 0;
-    const char *host = pd->host.unsafeBuf();
+    const char *host = pd->host.termedBuf();
 
     xmemcpy(&cblock, buf, sizeof(cblock));
     /* network -> host conversions */
@@ -1080,7 +1080,7 @@ peerDigestUseful(const PeerDigest * pd)
     const int bit_util = cacheDigestBitUtil(pd->cd);
 
     if (bit_util > 65) {
-        debugs(72, 0, "Warning: " << pd->host.unsafeBuf() <<
+        debugs(72, 0, "Warning: " << pd->host <<
                " peer digest has too many bits on (" << bit_util << "%%).");
 
         return 0;
@@ -1106,7 +1106,7 @@ peerDigestStatsReport(const PeerDigest * pd, StoreEntry * e)
 
     assert(pd);
 
-    const char *host = pd->host.unsafeBuf();
+    const char *host = pd->host.termedBuf();
     storeAppendPrintf(e, "\npeer digest from %s\n", host);
 
     cacheDigestGuessStatsReport(&pd->stats.guess, e, host);
index 5351cbafac67eb1e39f1bf34f1e7925fdf14a97e..5d0baa815f07ac20955d1cffbba431f5a67f1f60 100644 (file)
@@ -696,9 +696,9 @@ StoreEntry::setPublicKey()
 #if X_ACCELERATOR_VARY
             vary = mem_obj->getReply()->header.getList(HDR_X_ACCELERATOR_VARY);
 
-            if (vary.unsafeBuf()) {
+            if (vary.defined()) {
                 /* Again, we own this structure layout */
-                rep->header.putStr(HDR_X_ACCELERATOR_VARY, vary.unsafeBuf());
+                rep->header.putStr(HDR_X_ACCELERATOR_VARY, vary.termedBuf());
                 vary.clean();
             }