]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Portability: migrate auto_ptr to C++11 unique_ptr
authorAmos Jeffries <squid3@treenet.co.nz>
Wed, 27 May 2015 23:28:09 +0000 (16:28 -0700)
committerAmos Jeffries <squid3@treenet.co.nz>
Wed, 27 May 2015 23:28:09 +0000 (16:28 -0700)
Improving the backward compatibility workaround for older compilers.

This is required for GCC 5.x which does not include any auto_ptr support
or compatibility at all.

This does apply for 3.5 where C++11 support is still optional, since it
is the portability definition to allow patch back-ports.

acinclude/ax_cxx_0x_types.m4
src/CollapsedForwarding.cc
src/CollapsedForwarding.h
src/DiskIO/IpcIo/IpcIoFile.cc
src/DiskIO/IpcIo/IpcIoFile.h
src/base/AsyncJobs.dox
src/base/TidyPointer.h
src/client_side_reply.cc
src/mgr/Inquirer.cc

index 2657b3f79e4f1a22524fbb2dff769252efca2acc..d08cb35958bdaa57bd8a46bb9db0b6262c88c4a7 100644 (file)
@@ -42,6 +42,9 @@ AC_DEFUN([AX_CXX_TYPE_UNIQUE_PTR],[
     AC_MSG_RESULT(yes)], [
     HAVE_UNIQUE_PTR=no
     AC_MSG_RESULT(no)])
+  if test "x$HAVE_UNIQUE_PTR" = xno; then
+    AC_DEFINE(unique_ptr, auto_ptr, [Leave undefined if std::unique_ptr<T> is supported])
+  fi
   if test "x$HAVE_UNIQUE_PTR" = xyes; then
     AC_DEFINE(HAVE_UNIQUE_PTR, 1, [Define to 1 if std::unique_ptr<T> is supported])
   fi
index c86e0306f43445074c8765e1a2dcfcaa3a5cf9f4..f95bbef913942b2c99ad65f8204d386a5caa6477 100644 (file)
@@ -27,7 +27,7 @@ static const char *const ShmLabel = "cf";
 // TODO: make configurable or compute from squid.conf settings if possible
 static const int QueueCapacity = 1024;
 
-std::auto_ptr<CollapsedForwarding::Queue> CollapsedForwarding::queue;
+std::unique_ptr<CollapsedForwarding::Queue> CollapsedForwarding::queue;
 
 /// IPC queue message
 class CollapsedForwardingMsg
index 89e18e46cb17debf63eb5018bfa938d71e1e8f23..b964b504b5b2a641643479a2f40d089ad702d7cc 100644 (file)
@@ -40,7 +40,7 @@ public:
 
 private:
     typedef Ipc::MultiQueue Queue;
-    static std::auto_ptr<Queue> queue; ///< IPC queue
+    static std::unique_ptr<Queue> queue; ///< IPC queue
 };
 
 #endif /* SQUID_COLLAPSED_FORWARDING_H */
index e57fc0172def48e65f32c7e2ace8ad2eea03dea6..2b4a34fd997d01dd6c876a6bc8b366ce31865178 100644 (file)
@@ -45,7 +45,7 @@ static const int QueueCapacity = 1024;
 const double IpcIoFile::Timeout = 7; // seconds;  XXX: ALL,9 may require more
 IpcIoFile::IpcIoFileList IpcIoFile::WaitingForOpen;
 IpcIoFile::IpcIoFilesMap IpcIoFile::IpcIoFiles;
-std::auto_ptr<IpcIoFile::Queue> IpcIoFile::queue;
+std::unique_ptr<IpcIoFile::Queue> IpcIoFile::queue;
 
 bool IpcIoFile::DiskerHandleMoreRequestsScheduled = false;
 
index 718a1367da79396cfbd5488edc59485be34970ba..fe1ba89893bce534f6c479e740c7aa18f772f928 100644 (file)
@@ -139,7 +139,7 @@ private:
     static IpcIoFilesMap IpcIoFiles;
 
     typedef Ipc::FewToFewBiQueue Queue;
-    static std::auto_ptr<Queue> queue; ///< IPC queue
+    static std::unique_ptr<Queue> queue; ///< IPC queue
 
     /// whether we are waiting for an event to handle still queued I/O requests
     static bool DiskerHandleMoreRequestsScheduled;
index 6e5f16f5ceb556e4787b611f007cebc111a2e3ee..854b83a7c9de65dec2a36e8211147d17f1b15c01 100644 (file)
@@ -37,7 +37,7 @@ If you want to do something before starting the job, do it in the constructor
 or some custom method that the job creator will call _before_ calling
 AsyncJob::Start():
 
-    std::auto_ptr<MyJob> job(new MyJob(...)); // sync/blocking
+    std::unique_ptr<MyJob> job(new MyJob(...)); // sync/blocking
     job->prepare(...); // sync/blocking
     job->prepareSomethingElse(...); // sync/blocking
     AsyncStart(job.release()); // non-blocking
index 4be17f415504d0fd594fe5ce5186696cd8b83147..19334dbeacef0916d182bee3cf64291c8a1d8628 100644 (file)
@@ -11,7 +11,7 @@
 
 /**
  * A pointer that deletes the object it points to when the pointer's owner or
- * context is gone. Similar to std::auto_ptr but without confusing assignment
+ * context is gone. Similar to std::unique_ptr but without confusing assignment
  * and with a customizable cleanup method. Prevents memory leaks in
  * the presence of exceptions and processing short cuts.
 */
index 5263bf242908e1bc1b8d0fed5947458b29ac0ce5..126815819fce62fc902e3dad92541a168a818b84 100644 (file)
@@ -786,7 +786,7 @@ clientReplyContext::blockedHit() const
         return false; // internal content "hits" cannot be blocked
 
     if (const HttpReply *rep = http->storeEntry()->getReply()) {
-        std::auto_ptr<ACLFilledChecklist> chl(clientAclChecklistCreate(Config.accessList.sendHit, http));
+        std::unique_ptr<ACLFilledChecklist> chl(clientAclChecklistCreate(Config.accessList.sendHit, http));
         chl->reply = const_cast<HttpReply*>(rep); // ACLChecklist API bug
         HTTPMSGLOCK(chl->reply);
         return chl->fastCheck() != ACCESS_ALLOWED; // when in doubt, block
index 1c53d1a39bf0dc89e920bb888877efb031f13e0b..9880f36436a6b6b9333e87c9bd126a75cbdc2e88 100644 (file)
@@ -72,28 +72,16 @@ Mgr::Inquirer::start()
     Must(Comm::IsConnOpen(conn));
     Must(aggrAction != NULL);
 
-#if HAVE_UNIQUE_PTR
     std::unique_ptr<MemBuf> replyBuf;
-#else
-    std::auto_ptr<MemBuf> replyBuf;
-#endif
     if (strands.empty()) {
         LOCAL_ARRAY(char, url, MAX_URL);
         snprintf(url, MAX_URL, "%s", aggrAction->command().params.httpUri.termedBuf());
         HttpRequest *req = HttpRequest::CreateFromUrl(url);
         ErrorState err(ERR_INVALID_URL, Http::scNotFound, req);
-#if HAVE_UNIQUE_PTR
         std::unique_ptr<HttpReply> reply(err.BuildHttpReply());
-#else
-        std::auto_ptr<HttpReply> reply(err.BuildHttpReply());
-#endif
         replyBuf.reset(reply->pack());
     } else {
-#if HAVE_UNIQUE_PTR
         std::unique_ptr<HttpReply> reply(new HttpReply);
-#else
-        std::auto_ptr<HttpReply> reply(new HttpReply);
-#endif
         reply->setHeaders(Http::scOkay, NULL, "text/plain", -1, squid_curtime, squid_curtime);
         reply->header.putStr(HDR_CONNECTION, "close"); // until we chunk response
         replyBuf.reset(reply->pack());