Changeset 10256


Ignore:
Timestamp:
Feb 22, 2010, 1:01:59 AM (12 years ago)
Author:
charles
Message:

(trunk libT) #2952: "When possible, use posix_memalign() instead of valloc()" -- fixed in trunk for 1.91

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/configure.ac

    r10226 r10256  
    109109AC_HEADER_TIME
    110110
    111 AC_CHECK_FUNCS([pread pwrite lrintf strlcpy daemon dirname basename strcasecmp localtime_r fallocate64 posix_fallocate memmem strtold syslog valloc])
     111AC_CHECK_FUNCS([pread pwrite lrintf strlcpy daemon dirname basename strcasecmp localtime_r fallocate64 posix_fallocate memmem strtold syslog valloc getpagesize posix_memalign])
    112112AC_PROG_INSTALL
    113113AC_PROG_MAKE_SET
  • trunk/libtransmission/verify.c

    r10191 r10256  
    4848/* #define STOPWATCH */
    4949
    50 #ifndef HAVE_VALLOC
    51  #define valloc malloc
    52 #endif
    53 
    5450static tr_bool
    5551verifyTorrent( tr_torrent * tor, tr_bool * stopFlag )
     
    6662    tr_file_index_t prevFileIndex = !fileIndex;
    6763    tr_piece_index_t pieceIndex = 0;
    68     const int64_t buflen = 4096;
    69     uint8_t * buffer = valloc( buflen );
    7064    const time_t begin = tr_time( );
    7165    time_t end;
     66    int64_t buflen;
     67    uint8_t * buffer = NULL;
     68    const int64_t maxbuf = 16384;
     69
     70#ifdef HAVE_GETPAGESIZE
     71    buflen = getpagesize();
     72    while( buflen * 2 <= maxbuf )
     73        buflen *= 2;
     74#else
     75    buflen = maxbuf;
     76#endif
     77
     78#ifdef HAVE_POSIX_MEMALIGN
     79    if( !buffer )
     80        posix_memalign( (void**)&buffer, getpagesize(), buflen );
     81#endif
     82#ifdef HAVE_VALLOC
     83    if( !buffer )
     84        buffer = valloc( buflen );
     85#endif
     86    if( !buffer )
     87        buffer = malloc( buflen );
    7288
    7389    SHA1_Init( &sha );
Note: See TracChangeset for help on using the changeset viewer.