Ignore:
Timestamp:
Feb 23, 2010, 6:06:45 AM (12 years ago)
Author:
charles
Message:

(trunk libT) add a wrapper function tr_valloc() to try posix_memalign(), getpagesize(), valloc() etc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/verify.c

    r10264 r10274  
    1919#if defined(HAVE_POSIX_FADVISE) || defined(SYS_DARWIN)
    2020 #include <fcntl.h> /* posix_fadvise() / fcntl() */
    21 #endif
    22 #if defined(SYS_DARWIN)
    23  #define HAVE_GETPAGESIZE
    24  //#define HAVE_POSIX_MEMALIGN requires Mac OS X 10.6
    25  #define HAVE_VALLOC
    2621#endif
    2722
     
    6661    const time_t begin = tr_time( );
    6762    time_t end;
    68     int64_t buflen;
    69     uint8_t * buffer = NULL;
    70     const int64_t maxbuf = 16384;
    71 
    72 #ifdef HAVE_GETPAGESIZE
    73     buflen = getpagesize();
    74     while( buflen * 2 <= maxbuf )
    75         buflen *= 2;
    76 #else
    77     buflen = maxbuf;
    78 #endif
    79 
    80 #ifdef HAVE_POSIX_MEMALIGN
    81     if( !buffer )
    82         posix_memalign( (void**)&buffer, getpagesize(), buflen );
    83 #endif
    84 #ifdef HAVE_VALLOC
    85     if( !buffer )
    86         buffer = valloc( buflen );
    87 #endif
    88     if( !buffer )
    89         buffer = malloc( buflen );
     63    const int64_t buflen = 16384;
     64    uint8_t * buffer = tr_valloc( buflen );
    9065
    9166    SHA1_Init( &sha );
Note: See TracChangeset for help on using the changeset viewer.