diff --git a/include/libtorrent/bdecode.hpp b/include/libtorrent/bdecode.hpp index 27bc90a0e..322775d18 100644 --- a/include/libtorrent/bdecode.hpp +++ b/include/libtorrent/bdecode.hpp @@ -233,8 +233,9 @@ struct bdecode_token // There are 5 different types of nodes, see type_t. struct TORRENT_EXPORT bdecode_node { - friend int bdecode(char const* start, char const* end, bdecode_node& ret - , error_code& ec, int* error_pos, int depth_limit, int token_limit); + TORRENT_EXPORT friend int bdecode(char const* start, char const* end, bdecode_node& ret + , error_code& ec, int* error_pos, int depth_limit + , int token_limit); // creates a default constructed node, it will have the type ``none_t``. bdecode_node(); diff --git a/include/libtorrent/thread.hpp b/include/libtorrent/thread.hpp index 6aff9004b..02f11178a 100644 --- a/include/libtorrent/thread.hpp +++ b/include/libtorrent/thread.hpp @@ -61,6 +61,9 @@ namespace libtorrent typedef boost::asio::detail::mutex mutex; typedef boost::asio::detail::event event; + // internal + void sleep(int milliseconds); + struct TORRENT_EXTRA_EXPORT condition_variable { condition_variable(); diff --git a/src/string_util.cpp b/src/string_util.cpp index 8e9a57ceb..834ae8473 100644 --- a/src/string_util.cpp +++ b/src/string_util.cpp @@ -34,8 +34,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/string_util.hpp" #include "libtorrent/random.hpp" -#include // for malloc/free -#include // for strcpy/strlen +#include // for malloc +#include // for memmov/strcpy/strlen namespace libtorrent { @@ -138,9 +138,9 @@ namespace libtorrent char* allocate_string_copy(char const* str) { if (str == 0) return 0; - char* tmp = (char*)malloc(strlen(str) + 1); + char* tmp = (char*)std::malloc(std::strlen(str) + 1); if (tmp == 0) return 0; - strcpy(tmp, str); + std::strcpy(tmp, str); return tmp; } diff --git a/src/thread.cpp b/src/thread.cpp index edce6b3b2..8d4e60859 100644 --- a/src/thread.cpp +++ b/src/thread.cpp @@ -47,6 +47,17 @@ POSSIBILITY OF SUCH DAMAGE. namespace libtorrent { + void sleep(int milliseconds) + { +#if defined TORRENT_WINDOWS || defined TORRENT_CYGWIN + Sleep(milliseconds); +#elif defined TORRENT_BEOS + snooze_until(system_time() + boost::int64_t(milliseconds) * 1000, B_SYSTEM_TIMEBASE); +#else + usleep(milliseconds * 1000); +#endif + } + #ifdef BOOST_HAS_PTHREADS condition_variable::condition_variable()