From 407824c9c8cae8f468e9f3fb1fd466e39f9170b6 Mon Sep 17 00:00:00 2001 From: rakshasa Date: Sun, 10 Sep 2006 03:28:09 +0000 Subject: [PATCH] * Switch the order rak::advance_bidirectional iterates. * When testing for mincore, cast the address pointer to (char*). * Failure during syncing causes the download to stop, unless flag_ignore_error is set. * Trigger storage error signal for HashTorrent in DownloadWrapper::receive_initial_hash. git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@774 e378c898-3ddf-0310-93e7-cc216c733640 --- rak/algorithm.h | 30 +++++++++++------------------- scripts/common.m4 | 4 ++-- 2 files changed, 13 insertions(+), 21 deletions(-) diff --git a/rak/algorithm.h b/rak/algorithm.h index df28d452..e8a1f173 100644 --- a/rak/algorithm.h +++ b/rak/algorithm.h @@ -56,15 +56,6 @@ for_each_pre(_InputIter __first, _InputIter __last, _Function __f) { return __f; } -template -Accumulator -accumulate(InputIter first, InputIter last, Function function, Accumulator acc) { - while (first != last) - acc += function(*first++); - - return acc; -} - // Return a range with a distance of no more than __distance and // between __first and __last, centered on __middle1. template @@ -73,6 +64,17 @@ advance_bidirectional(_InputIter __first, _InputIter __middle1, _InputIter __las _InputIter __middle2 = __middle1; do { + if (!__distance) + break; + + if (__middle2 != __last) { + ++__middle2; + --__distance; + + } else if (__middle1 == __first) { + break; + } + if (!__distance) break; @@ -84,16 +86,6 @@ advance_bidirectional(_InputIter __first, _InputIter __middle1, _InputIter __las break; } - if (!__distance) - break; - - if (__middle2 != __last) { - ++__middle2; - --__distance; - - } else if (__middle1 == __first) { - break; - } } while (true); return std::make_pair(__middle1, __middle2); diff --git a/scripts/common.m4 b/scripts/common.m4 index cb38fc2d..af7b9966 100644 --- a/scripts/common.m4 +++ b/scripts/common.m4 @@ -75,7 +75,7 @@ AC_DEFUN([TORRENT_MINCORE_SIGNEDNESS], [ AC_COMPILE_IFELSE( [[#include #include - void f() { mincore((void*)0, 0, (unsigned char*)0); } + void f() { mincore((char*)0, 0, (unsigned char*)0); } ]], [ AC_DEFINE(USE_MINCORE, 1, Use mincore) @@ -86,7 +86,7 @@ AC_DEFUN([TORRENT_MINCORE_SIGNEDNESS], [ AC_COMPILE_IFELSE( [[#include #include - void f() { mincore((void*)0, 0, (char*)0); } + void f() { mincore((char*)0, 0, (char*)0); } ]], [ AC_DEFINE(USE_MINCORE, 1, Use mincore)