mirror of
https://github.com/transmission/transmission
synced 2025-02-20 21:26:53 +00:00
(trunk libT) #2952: "When possible, use posix_memalign() instead of valloc()" -- fixed in trunk for 1.91
This commit is contained in:
parent
f3b98a6c18
commit
204243c5bd
2 changed files with 23 additions and 7 deletions
|
@ -108,7 +108,7 @@ fi
|
|||
AC_HEADER_STDC
|
||||
AC_HEADER_TIME
|
||||
|
||||
AC_CHECK_FUNCS([pread pwrite lrintf strlcpy daemon dirname basename strcasecmp localtime_r fallocate64 posix_fallocate memmem strtold syslog valloc])
|
||||
AC_CHECK_FUNCS([pread pwrite lrintf strlcpy daemon dirname basename strcasecmp localtime_r fallocate64 posix_fallocate memmem strtold syslog valloc getpagesize posix_memalign])
|
||||
AC_PROG_INSTALL
|
||||
AC_PROG_MAKE_SET
|
||||
ACX_PTHREAD
|
||||
|
|
|
@ -47,10 +47,6 @@ enum
|
|||
|
||||
/* #define STOPWATCH */
|
||||
|
||||
#ifndef HAVE_VALLOC
|
||||
#define valloc malloc
|
||||
#endif
|
||||
|
||||
static tr_bool
|
||||
verifyTorrent( tr_torrent * tor, tr_bool * stopFlag )
|
||||
{
|
||||
|
@ -65,10 +61,30 @@ verifyTorrent( tr_torrent * tor, tr_bool * stopFlag )
|
|||
tr_file_index_t fileIndex = 0;
|
||||
tr_file_index_t prevFileIndex = !fileIndex;
|
||||
tr_piece_index_t pieceIndex = 0;
|
||||
const int64_t buflen = 4096;
|
||||
uint8_t * buffer = valloc( buflen );
|
||||
const time_t begin = tr_time( );
|
||||
time_t end;
|
||||
int64_t buflen;
|
||||
uint8_t * buffer = NULL;
|
||||
const int64_t maxbuf = 16384;
|
||||
|
||||
#ifdef HAVE_GETPAGESIZE
|
||||
buflen = getpagesize();
|
||||
while( buflen * 2 <= maxbuf )
|
||||
buflen *= 2;
|
||||
#else
|
||||
buflen = maxbuf;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_POSIX_MEMALIGN
|
||||
if( !buffer )
|
||||
posix_memalign( (void**)&buffer, getpagesize(), buflen );
|
||||
#endif
|
||||
#ifdef HAVE_VALLOC
|
||||
if( !buffer )
|
||||
buffer = valloc( buflen );
|
||||
#endif
|
||||
if( !buffer )
|
||||
buffer = malloc( buflen );
|
||||
|
||||
SHA1_Init( &sha );
|
||||
|
||||
|
|
Loading…
Reference in a new issue