Changeset 10909
- Timestamp:
- Jun 30, 2010, 6:03:55 AM (12 years ago)
- Location:
- trunk/libtransmission
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libtransmission/history.c
r10332 r10909 17 17 struct history_slice 18 18 { 19 doublen;19 unsigned int n; 20 20 uint64_t date; 21 21 }; … … 25 25 int newest; 26 26 int sliceCount; 27 int precision_msec;27 unsigned int precision_msec; 28 28 struct history_slice * slices; 29 29 }; 30 30 31 31 void 32 tr_historyAdd( tr_recentHistory * h, uint64_t now, doublen )32 tr_historyAdd( tr_recentHistory * h, uint64_t now, unsigned int n ) 33 33 { 34 34 if( h->slices[h->newest].date + h->precision_msec >= now ) … … 41 41 } 42 42 43 double 44 tr_historyGet( const tr_recentHistory * h, uint64_t now, int msec )43 unsigned int 44 tr_historyGet( const tr_recentHistory * h, uint64_t now, unsigned int msec ) 45 45 { 46 doublen = 0;46 unsigned int n = 0; 47 47 const uint64_t cutoff = (now?now:tr_date()) - msec; 48 48 int i = h->newest; … … 63 63 64 64 tr_recentHistory * 65 tr_historyNew( int seconds,int bins_per_second )65 tr_historyNew( unsigned int seconds, unsigned int bins_per_second ) 66 66 { 67 67 tr_recentHistory * h; … … 69 69 h = tr_new0( tr_recentHistory, 1 ); 70 70 h->precision_msec = 1000 / bins_per_second; 71 h->sliceCount = seconds * bins_per_second;71 h->sliceCount = (int)(seconds * bins_per_second); 72 72 h->slices = tr_new0( struct history_slice, h->sliceCount ); 73 73 -
trunk/libtransmission/history.h
r10332 r10909 33 33 * For a precision of 1/20th of a second, use a precision of 20. 34 34 */ 35 tr_recentHistory * tr_historyNew( int seconds,int precision );35 tr_recentHistory * tr_historyNew( unsigned int seconds, unsigned int precision ); 36 36 37 37 /** @brief destroy an existing tr_recentHistory object. */ … … 43 43 * @param n how many items to add to the history's counter 44 44 */ 45 void tr_historyAdd( tr_recentHistory *, uint64_t when, doublen );45 void tr_historyAdd( tr_recentHistory *, uint64_t when, unsigned int n ); 46 46 47 47 /** … … 50 50 * @param seconds how many seconds to count back through. 51 51 */ 52 double tr_historyGet( const tr_recentHistory *, uint64_t when,int seconds );52 unsigned int tr_historyGet( const tr_recentHistory *, uint64_t when, unsigned int seconds ); 53 53 54 54 #endif -
trunk/libtransmission/utils.c
r10844 r10909 123 123 tr_getMessageLevel( void ) 124 124 { 125 int ret; 126 tr_lockLock( messageLock ); 127 128 ret = messageLevel; 129 130 tr_lockUnlock( messageLock ); 131 return ret; 125 return messageLevel; 132 126 } 133 127 … … 135 129 tr_setMessageQueuing( tr_bool enabled ) 136 130 { 137 tr_lockLock( messageLock );138 139 131 messageQueuing = enabled; 140 141 tr_lockUnlock( messageLock );142 132 } 143 133 … … 145 135 tr_getMessageQueuing( void ) 146 136 { 147 int ret; 148 tr_lockLock( messageLock ); 149 150 ret = messageQueuing; 151 152 tr_lockUnlock( messageLock ); 153 return ret; 137 return messageQueuing != 0; 154 138 } 155 139 -
trunk/libtransmission/utils.h
r10844 r10909 323 323 * @return a newly-allocated copy of `src' that can be freed with tr_free() 324 324 */ 325 static inline void* tr_memdup( const void * src, int byteCount )325 static inline void* tr_memdup( const void * src, size_t byteCount ) 326 326 { 327 327 return memcpy( tr_malloc( byteCount ), src, byteCount ); … … 354 354 static inline char* tr_strdup( const void * in ) 355 355 { 356 return tr_strndup( in, in ? strlen( (const char *) in) : 0 );356 return tr_strndup( in, in ? (int)strlen((const char *)in) : 0 ); 357 357 } 358 358 … … 522 522 523 523 /** @brief convenience function to remove an item from an array */ 524 static inline void tr_removeElementFromArray( void * array,525 intindex_to_remove,526 size_t sizeof_element,527 size_t nmemb )524 static inline void tr_removeElementFromArray( void * array, 525 unsigned int index_to_remove, 526 size_t sizeof_element, 527 size_t nmemb ) 528 528 { 529 529 char * a = (char*) array;
Note: See TracChangeset
for help on using the changeset viewer.