mirror of
https://github.com/OpenVPN/openvpn3.git
synced 2024-09-20 20:13:05 +02:00
29bc40bf09
Disable retransmission of control channel packets when running in TCP mode.
62 lines
915 B
C++
62 lines
915 B
C++
#ifndef OPENVPN_COMMON_SCOPED_PTR_H
|
|
#define OPENVPN_COMMON_SCOPED_PTR_H
|
|
|
|
#include <algorithm>
|
|
|
|
#include <boost/assert.hpp>
|
|
#include <boost/noncopyable.hpp>
|
|
|
|
#include <openvpn/common/types.hpp>
|
|
|
|
namespace openvpn {
|
|
|
|
// like boost::scoped_ptr but has release method
|
|
template <typename T>
|
|
class ScopedPtr : boost::noncopyable
|
|
{
|
|
public:
|
|
explicit ScopedPtr(T* p)
|
|
: px(p) {}
|
|
|
|
T* release()
|
|
{
|
|
T* ret = px;
|
|
px = NULL;
|
|
return ret;
|
|
}
|
|
|
|
void swap(ScopedPtr& other)
|
|
{
|
|
std::swap(px, other.px);
|
|
}
|
|
|
|
T& operator*() const
|
|
{
|
|
BOOST_ASSERT( px != 0 );
|
|
return *px;
|
|
}
|
|
|
|
T* operator->() const
|
|
{
|
|
BOOST_ASSERT( px != 0 );
|
|
return px;
|
|
}
|
|
|
|
T* get() const
|
|
{
|
|
return px;
|
|
}
|
|
|
|
~ScopedPtr() {
|
|
if (px)
|
|
delete px;
|
|
}
|
|
|
|
private:
|
|
T* px;
|
|
};
|
|
|
|
} // namespace openvpn
|
|
|
|
#endif // OPENVPN_COMMON_SCOPED_PTR_H
|