Ignore:
Timestamp:
May 15, 2008, 3:44:51 PM (14 years ago)
Author:
charles
Message:

add tr_strdup_printf()

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/utils.h

    r5759 r5838  
    3131#include <stdio.h> /* FILE* */
    3232
    33 void tr_msgInit( void );
     33/***
     34****
     35***/
     36
     37#ifndef UNUSED
     38#ifdef __GNUC__
     39#define UNUSED __attribute__((unused))
     40#else
     41#define UNUSED
     42#endif
     43#endif
     44
     45#ifndef TR_GNUC_PRINTF
     46#ifdef __GNUC__
     47#define TR_GNUC_PRINTF( fmt, args ) __attribute__((format (printf, fmt, args)))
     48#else
     49#define TR_GNUC_PRINTF( fmt, args )
     50#endif
     51#endif
     52
     53#ifndef TR_GNUC_NULL_TERMINATED
     54#if __GNUC__ >= 4
     55#define TR_GNUC_NULL_TERMINATED __attribute__((__sentinel__))
     56#else
     57#define TR_GNUC_NULL_TERMINATED
     58#endif
     59#endif
     60
     61#ifndef TR_GNUC_NULL_TERMINATED
     62#if __GNUC__ >= 4
     63#define TR_GNUC_NULL_TERMINATED __attribute__((__sentinel__))
     64#else
     65#define TR_GNUC_NULL_TERMINATED
     66#endif
     67#endif
     68
     69#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
     70#define TR_GNUC_PURE __attribute__((__pure__))
     71#define TR_GNUC_MALLOC __attribute__((__malloc__))
     72#else
     73#define TR_GNUC_PURE
     74#define TR_GNUC_MALLOC
     75#endif
     76
     77
     78/***
     79****
     80***/
    3481
    3582#if !defined(_)
     
    55102#define tr_inf( a... ) tr_msg( __FILE__, __LINE__, TR_MSG_INF, NULL, ## a )
    56103#define tr_dbg( a... ) tr_msg( __FILE__, __LINE__, TR_MSG_DBG, NULL, ## a )
    57 void tr_msg  ( const char * file, int line, int level, const char * torrent, const char * fmt, ... );
     104
     105void tr_msgInit( void );
     106
     107void tr_msg( const char * file, int line,
     108             int level, const char * torrent,
     109             const char * fmt, ... ) TR_GNUC_PRINTF( 5, 6 );
     110
    58111FILE* tr_getLog( void );
    59112
    60 void tr_deepLog( const char * file, int line, const char * name, const char * fmt, ... );
     113void tr_deepLog( const char * file, int line,
     114                 const char * name,
     115                 const char * fmt, ... ) TR_GNUC_PRINTF( 4, 5 );
    61116
    62117char* tr_getLogTimeStr( char * buf, int buflen );
     
    83138
    84139
    85 uint8_t* tr_loadFile( const char * filename, size_t * size );
     140uint8_t* tr_loadFile( const char * filename, size_t * size ) TR_GNUC_MALLOC;
    86141
    87142
     
    89144   correct separator for filenames. */
    90145void tr_buildPath( char* buf, size_t buflen,
    91                    const char * first_element, ... );
     146                   const char * first_element, ... )
     147                                      TR_GNUC_NULL_TERMINATED;
    92148
    93149struct timeval tr_timevalMsec( uint64_t milliseconds );
     
    128184    ((struct_type *) realloc ((mem), ((size_t) sizeof (struct_type)) * ((size_t) (n_structs))))
    129185
    130 void* tr_malloc  ( size_t );
    131 void* tr_malloc0 ( size_t );
    132 void* tr_calloc  ( size_t nmemb, size_t size );
     186void* tr_malloc  ( size_t ) TR_GNUC_MALLOC;
     187void* tr_malloc0 ( size_t ) TR_GNUC_MALLOC;
     188void* tr_calloc  ( size_t nmemb, size_t size ) TR_GNUC_MALLOC;
    133189void  tr_free    ( void* );
    134190
    135 char* tr_strdup( const char * str );
    136 char* tr_strndup( const char * str, int len );
     191char* tr_strdup( const char * str ) TR_GNUC_MALLOC;
     192char* tr_strndup( const char * str, int len ) TR_GNUC_MALLOC;
     193char* tr_strdup_printf( const char * fmt, ... )  TR_GNUC_PRINTF( 1, 2 ) TR_GNUC_MALLOC;
    137194
    138195const char* tr_strerror( int );
     
    181238typedef struct tr_bitfield tr_bitfield_t;
    182239
    183 tr_bitfield* tr_bitfieldNew( size_t bitcount );
    184 tr_bitfield* tr_bitfieldDup( const tr_bitfield* );
     240tr_bitfield* tr_bitfieldNew( size_t bitcount ) TR_GNUC_MALLOC;
     241tr_bitfield* tr_bitfieldDup( const tr_bitfield* ) TR_GNUC_MALLOC;
    185242void tr_bitfieldFree( tr_bitfield*);
    186243
Note: See TracChangeset for help on using the changeset viewer.