Changeset 7652


Ignore:
Timestamp:
Jan 10, 2009, 2:22:13 AM (12 years ago)
Author:
charles
Message:

(trunk libT) win32 portability fixes, reported by Alexey

Location:
trunk/libtransmission
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/bencode.c

    r7590 r7652  
    162162                        ( count % LIST_SIZE ? LIST_SIZE -
    163163                          ( count % LIST_SIZE ) : 0 );
    164         void *    new = realloc( val->val.l.vals, len * sizeof( tr_benc ) );
    165         if( NULL == new )
     164        void * tmp = realloc( val->val.l.vals, len * sizeof( tr_benc ) );
     165        if( !tmp )
    166166            return 1;
    167167
    168168        val->val.l.alloc = len;
    169         val->val.l.vals  = new;
     169        val->val.l.vals  = tmp;
    170170    }
    171171
  • trunk/libtransmission/list.h

    r7469 r7652  
    6464};
    6565
    66 #define __tr_list_entry(ptr, type, member) ({            \
    67     const struct __tr_list *__mptr = (ptr);              \
    68     (void *)( (char *)__mptr - offsetof(type,member) );  \
    69 })
     66/**
     67 * Given a __tr_list node that's embedded in a struct, returns a pointer to the struct.
     68 * @param ptr     pointer to the embedded __tr_list
     69 * @param type    struct type that has contains the __tr_list
     70 * @param field   the name of the struct's _tr_list field
     71 */
     72#define __tr_list_entry(ptr,type,field) ((type*) (((char*)ptr) - offsetof(type,field)))
    7073
    7174typedef int  ( *__tr_list_cmp_t ) ( const void * a, const void * b );
  • trunk/libtransmission/net.c

    r7585 r7652  
    3333#ifdef WIN32
    3434 #include <winsock2.h> /* inet_addr */
     35 #include <WS2tcpip.h>
    3536#else
    3637 #include <arpa/inet.h> /* inet_addr */
  • trunk/libtransmission/net.h

    r7575 r7652  
    3333 #include <inttypes.h>
    3434 #include <winsock2.h>
     35 #include <WS2tcpip.h>
    3536 typedef int socklen_t;
    3637#else
  • trunk/libtransmission/peer-io.c

    r7641 r7652  
    1212
    1313#include <assert.h>
     14#include <errno.h>
    1415#include <limits.h> /* INT_MAX */
    1516#include <string.h>
     
    8889    while( bytes_transferred )
    8990    {
    90         struct tr_datatype * next = __tr_list_entry( io->outbuf_datatypes.next,
    91                                                      struct tr_datatype, head );
     91        struct tr_datatype * next = __tr_list_entry( io->outbuf_datatypes.next, struct tr_datatype, head );
    9292        const size_t payload = MIN( next->length, bytes_transferred );
    9393        const size_t overhead = getPacketOverhead( payload );
  • trunk/libtransmission/transmission.h

    r7646 r7652  
    5050#endif
    5151#include <time.h> /* time_t */
     52
     53#if defined(_MSC_VER) && !defined( __cplusplus )
     54 #define inline __inline
     55#endif
    5256
    5357#define SHA_DIGEST_LENGTH 20
Note: See TracChangeset for help on using the changeset viewer.