• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

C++ベースのLightweightなHTTPサーバー


Commit MetaInfo

Revision24799dfb90671b1757c0ca809347fea5babcb8c4 (tree)
Time2013-01-20 21:45:09
AuthorMichio Hirai <smg_ykz@user...>
CommiterMichio Hirai

Log Message

[BugFix] Fix the problem that mt::AutoPtr doesn't properly release resources in template

copy ctor operations.

Change Summary

Incremental Difference

--- a/cm/test/cm_vector_socket_test.cpp
+++ b/cm/test/cm_vector_socket_test.cpp
@@ -95,7 +95,7 @@ TEST(CmVectorSocketTest, ownership_move_from_socket_via_auto_ptr)
9595 {
9696 mt::AutoPtr<cm::SocketIf> original_socket(new cm::Socket(STDOUT_FILENO));
9797
98- mt::AutoPtr<cm::VectorSocket> vec_sock(original_socket);
98+ mt::AutoPtr<cm::VectorSocket> vec_sock(new cm::VectorSocket(*original_socket));
9999
100100 const cm::IOVectorBase& iov = cm::IOVec()(string1, sizeof(string1) - 1)
101101 (string2, sizeof(string2) - 1)
@@ -104,14 +104,10 @@ TEST(CmVectorSocketTest, ownership_move_from_socket_via_auto_ptr)
104104 size_t bytes_written = 0u;
105105 vec_sock->writev(bytes_written, iov);
106106
107- mt::AutoPtr<cm::Socket> renewed_socket(vec_sock);
107+ mt::AutoPtr<cm::Socket> renewed_socket(new cm::Socket(*vec_sock));
108108
109109 std::cout << std::endl;
110110 renewed_socket->write(bytes_written, "hello world(2)!!!", sizeof("hello world(2)!!!") - 1);
111-
112- vec_sock = renewed_socket;
113-
114- vec_sock->writev(bytes_written, iov);
115111 }
116112
117113 } // namespace
--- a/inc/mt_auto_ptr.h
+++ b/inc/mt_auto_ptr.h
@@ -33,11 +33,6 @@ public:
3333 : raw_ptr_(rhs.release())
3434 {}
3535
36- template <typename X>
37- AutoPtr(AutoPtr<X>& rhs)
38- : raw_ptr_(rhs.get() ? new T(*(rhs.release())) : 0)
39- {}
40-
4136 AutoPtr(AutoPtrRef<T> ref)
4237 : raw_ptr_(ref.raw_ptr_)
4338 {}
@@ -101,14 +96,6 @@ public:
10196 return *this;
10297 }
10398
104- template <typename X>
105- AutoPtr& operator=(AutoPtr<X>& rhs)
106- {
107- X* ptr = rhs.get();
108- raw_ptr_ = ptr ? new T(*ptr) : 0;
109- return *this;
110- }
111-
11299 T* operator->()
113100 {
114101 return raw_ptr_;