exception safety fixes to entry.cpp

This commit is contained in:
Arvid Norberg 2008-02-22 04:54:43 +00:00
parent ef9ef674d5
commit 5259d827b6
1 changed files with 16 additions and 9 deletions

View File

@ -142,14 +142,16 @@ namespace libtorrent
} }
#endif #endif
entry::entry(): m_type(undefined_t) entry::entry()
: m_type(undefined_t)
{ {
#ifndef NDEBUG #ifndef NDEBUG
m_type_queried = true; m_type_queried = true;
#endif #endif
} }
entry::entry(data_type t): m_type(t) entry::entry(data_type t)
: m_type(undefined_t)
{ {
construct(t); construct(t);
#ifndef NDEBUG #ifndef NDEBUG
@ -158,6 +160,7 @@ namespace libtorrent
} }
entry::entry(const entry& e) entry::entry(const entry& e)
: m_type(undefined_t)
{ {
copy(e); copy(e);
#ifndef NDEBUG #ifndef NDEBUG
@ -166,6 +169,7 @@ namespace libtorrent
} }
entry::entry(dictionary_type const& v) entry::entry(dictionary_type const& v)
: m_type(undefined_t)
{ {
#ifndef NDEBUG #ifndef NDEBUG
m_type_queried = true; m_type_queried = true;
@ -175,6 +179,7 @@ namespace libtorrent
} }
entry::entry(string_type const& v) entry::entry(string_type const& v)
: m_type(undefined_t)
{ {
#ifndef NDEBUG #ifndef NDEBUG
m_type_queried = true; m_type_queried = true;
@ -184,6 +189,7 @@ namespace libtorrent
} }
entry::entry(list_type const& v) entry::entry(list_type const& v)
: m_type(undefined_t)
{ {
#ifndef NDEBUG #ifndef NDEBUG
m_type_queried = true; m_type_queried = true;
@ -193,6 +199,7 @@ namespace libtorrent
} }
entry::entry(integer_type const& v) entry::entry(integer_type const& v)
: m_type(undefined_t)
{ {
#ifndef NDEBUG #ifndef NDEBUG
m_type_queried = true; m_type_queried = true;
@ -263,8 +270,7 @@ namespace libtorrent
void entry::construct(data_type t) void entry::construct(data_type t)
{ {
m_type = t; switch(t)
switch(m_type)
{ {
case int_t: case int_t:
new(data) integer_type; new(data) integer_type;
@ -279,9 +285,9 @@ namespace libtorrent
new (data) dictionary_type; new (data) dictionary_type;
break; break;
default: default:
TORRENT_ASSERT(m_type == undefined_t); TORRENT_ASSERT(t == undefined_t);
m_type = undefined_t;
} }
m_type = t;
#ifndef NDEBUG #ifndef NDEBUG
m_type_queried = true; m_type_queried = true;
#endif #endif
@ -289,8 +295,7 @@ namespace libtorrent
void entry::copy(entry const& e) void entry::copy(entry const& e)
{ {
m_type = e.type(); switch (e.type())
switch(m_type)
{ {
case int_t: case int_t:
new(data) integer_type(e.integer()); new(data) integer_type(e.integer());
@ -305,8 +310,9 @@ namespace libtorrent
new (data) dictionary_type(e.dict()); new (data) dictionary_type(e.dict());
break; break;
default: default:
m_type = undefined_t; TORRENT_ASSERT(e.type() == undefined_t);
} }
m_type = e.type();
#ifndef NDEBUG #ifndef NDEBUG
m_type_queried = true; m_type_queried = true;
#endif #endif
@ -332,6 +338,7 @@ namespace libtorrent
TORRENT_ASSERT(m_type == undefined_t); TORRENT_ASSERT(m_type == undefined_t);
break; break;
} }
m_type = undefined_t;
#ifndef NDEBUG #ifndef NDEBUG
m_type_queried = false; m_type_queried = false;
#endif #endif