Ignore:
Timestamp:
Jan 2, 2009, 7:56:06 PM (12 years ago)
Author:
charles
Message:

(trunk libT) avoid some unnecessary memory fragmentation... for composited objects that have a tr_bandwidth, contain the it directly rather than a pointer to one allocated elsewhere on the heap.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/bandwidth.h

    r7579 r7580  
    2020#include "transmission.h"
    2121#include "ptrarray.h"
     22#include "utils.h" /* tr_new(), tr_free() */
    2223
    2324struct tr_peerIo;
     
    103104    tr_session * session;
    104105    tr_ptrArray children; /* struct tr_bandwidth */
    105     tr_ptrArray peers; /* tr_peerIo */
     106    struct tr_peerIo * peer;
    106107}
    107108tr_bandwidth;
     
    112113**/
    113114
     115tr_bandwidth* tr_bandwidthConstruct( tr_bandwidth * bandwidth,
     116                                     tr_session   * session,
     117                                     tr_bandwidth * parent );
     118
    114119/** @brief create a new tr_bandwidth object */
    115 tr_bandwidth*
    116          tr_bandwidthNew              ( tr_session          * session,
    117                                         tr_bandwidth        * parent );
    118 
    119 /** @brief destroy a tr_bandwidth object */
    120 void     tr_bandwidthFree             ( tr_bandwidth        * bandwidth );
     120static inline tr_bandwidth* tr_bandwidthNew( tr_session * session, tr_bandwidth * parent )
     121{
     122    return tr_bandwidthConstruct( tr_new0( tr_bandwidth, 1 ), session, parent );
     123}
     124
     125tr_bandwidth* tr_bandwidthDestruct( tr_bandwidth * bandwidth );
     126
     127/** @brief free a tr_bandwidth object */
     128static inline void tr_bandwidthFree( tr_bandwidth * bandwidth )
     129{
     130    tr_free( tr_bandwidthDestruct( bandwidth ) );
     131}
    121132
    122133/** @brief test to see if the pointer refers to a live bandwidth object */
     
    220231 * in that particular case we want to ignore the global speed limit...
    221232 */
    222 void    tr_bandwidthHonorParentLimits ( tr_bandwidth        * bandwidth,
    223                                         tr_direction          direction,
    224                                         tr_bool               isEnabled );
    225 
    226 /******
    227 *******
    228 ******/
    229 
    230 /**
    231  * @brief add a tr_peerIo to this bandwidth's list.
    232  * They will be notified when more bandwidth is made available for them to consume.
    233  */
    234 void tr_bandwidthAddPeer( tr_bandwidth        * bandwidth,
     233static inline void tr_bandwidthHonorParentLimits ( tr_bandwidth        * bandwidth,
     234                                                   tr_direction          direction,
     235                                                   tr_bool               isEnabled )
     236{
     237    assert( tr_isBandwidth( bandwidth ) );
     238    assert( tr_isDirection( direction ) );
     239
     240    bandwidth->band[direction].honorParentLimits = isEnabled;
     241}
     242
     243/******
     244*******
     245******/
     246
     247void tr_bandwidthSetPeer( tr_bandwidth        * bandwidth,
    235248                          struct tr_peerIo    * peerIo );
    236249
    237 /**
    238  * @brief remove a peer-io from this bandwidth's list.
    239  */
    240 void tr_bandwidthRemovePeer( tr_bandwidth        * bandwidth,
    241                              struct tr_peerIo    * peerIo );
    242 
    243250#endif
Note: See TracChangeset for help on using the changeset viewer.