~ubuntu-branches/ubuntu/quantal/transmission/quantal

« back to all changes in this revision

Viewing changes to libtransmission/utils.c

  • Committer: Bazaar Package Importer
  • Author(s): Krzysztof Klimonda, Krzysztof Klimonda, Chris Coulson
  • Date: 2010-03-03 02:55:26 UTC
  • mfrom: (1.1.34 upstream) (2.1.17 sid)
  • Revision ID: james.westby@ubuntu.com-20100303025526-qcjmpnlvk9jv3y5o
Tags: 1.92-0ubuntu1
[ Krzysztof Klimonda ]
* New upstream release (LP: #538034), rebased on debian testing.
  Remaining changes:
  - debian/control:
    + Added replaces & provides clutch (now included as part of transmission).
      Can be removed in lucid+1
    + Added liblaunchpad-integration-dev and lsb-release to Build-Depends
  - debian/rules:
    + create a po template during package build.
  - debian/patches/01_lpi.patch:
    + integrate transmission with launchpad
  - debian/patches/20_add_x-ubuntu-gettext-domain.diff:
    + add x-ubuntu-gettext-domain to .desktop file.
  - debian/transmission-daemon.default:
    - remove --auth from OPTIONS
  - debian/control, debian/rules:
    + build transmission gtk+ client with both gconf and libcanberra support.
  - debian/patches/dont_build_libevent.patch:
    + disable libevent in configure.ac and Makefile.am because we use autotools
      to regenerate build files.
  - lucid/debian/patches/updateminiupnpcstrings_double_escape_slash.patch:
    + Deleted as the bug is fixed upstream
* Fixes bugs:
  - Fix directory selection error in GTK+ 2.19 (LP: #518692)
  - Transmission "Set Location" - dialog doesn't disappear (LP: #529037)
  - The "Torrent Options" dialog's Torrent Priority row gets too much
    vertical stretch (LP: #527299)
  - "Open Folder" behavior can be confusing for single-file torrents
    (LP: #505861)
* Refreshed 99_autoreconf.patch

[ Chris Coulson ]
* debian/patches/disable_web_ui.patch:
  - Disable the web UI by default again (LP: #542194)

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
 * This exemption does not extend to derived works not owned by
8
8
 * the Transmission project.
9
9
 *
10
 
 * $Id: utils.c 10239 2010-02-20 15:57:05Z charles $
 
10
 * $Id: utils.c 10305 2010-03-06 19:33:04Z charles $
11
11
 */
12
12
 
13
13
#ifdef HAVE_MEMMEM
14
14
 #define _GNU_SOURCE /* glibc's string.h needs this to pick up memmem */
15
15
#endif
16
16
 
 
17
#if defined(SYS_DARWIN)
 
18
 #define HAVE_GETPAGESIZE
 
19
 #define HAVE_VALLOC
 
20
 #undef HAVE_POSIX_MEMALIGN /* not supported on OS X 10.5 and lower */
 
21
#endif
 
22
 
17
23
#include <assert.h>
18
24
#include <ctype.h> /* isalpha, tolower */
19
25
#include <errno.h>
27
33
#include <sys/time.h>
28
34
#include <sys/types.h>
29
35
#include <sys/stat.h>
30
 
#include <unistd.h> /* usleep, stat, getcwd */
 
36
#include <unistd.h> /* usleep, stat, getcwd, getpagesize */
31
37
 
32
38
#include "event.h"
33
39
 
1416
1422
    in = tr_open_file_for_scanning( oldpath );
1417
1423
    out = tr_open_file_for_writing( newpath );
1418
1424
    buflen = stat( newpath, &st ) ? 4096 : st.st_blksize;
1419
 
    buf = tr_new( char, buflen );
 
1425
    buf = tr_valloc( buflen );
1420
1426
    while( bytesLeft > 0 )
1421
1427
    {
1422
1428
        ssize_t bytesWritten;
1440
1446
    unlink( oldpath );
1441
1447
    return 0;
1442
1448
}
 
1449
 
 
1450
/***
 
1451
****
 
1452
***/
 
1453
 
 
1454
void*
 
1455
tr_valloc( size_t bufLen )
 
1456
{
 
1457
    size_t allocLen;
 
1458
    void * buf = NULL;
 
1459
    static size_t pageSize = 0;
 
1460
 
 
1461
    if( !pageSize ) {
 
1462
#ifdef HAVE_GETPAGESIZE
 
1463
        pageSize = getpagesize();
 
1464
#else /* guess */
 
1465
        pageSize = 4096;
 
1466
#endif
 
1467
    }
 
1468
 
 
1469
    allocLen = pageSize;
 
1470
    while( allocLen < bufLen )
 
1471
        allocLen += pageSize;
 
1472
 
 
1473
#ifdef HAVE_POSIX_MEMALIGN
 
1474
    if( !buf )
 
1475
        posix_memalign( &buf, pageSize, allocLen );
 
1476
#endif
 
1477
#ifdef HAVE_VALLOC
 
1478
    if( !buf )
 
1479
        buf = valloc( allocLen );
 
1480
#endif
 
1481
    if( !buf )
 
1482
        buf = malloc( allocLen );
 
1483
 
 
1484
    tr_dbg( "tr_valloc(%zu) allocating %zu bytes", bufLen, allocLen );
 
1485
    return buf;
 
1486
}