Ignore:
Timestamp:
Apr 6, 2011, 11:27:11 PM (11 years ago)
Author:
jordan
Message:

(trunk libT) more heap pruning: avoid four unnecessary malloc() + free() calls per tr_peer.

This commit also changes tr_recentHistory from being a general-purpose tool to being a little more hardcoded for the only purpose it's used, in tr_peerMgr. If its files (history.[ch]) don't find any other "customers" in libtransmission, eventually it should be demoted to being a private helper class inside of peer-mgr.c and have the history.[ch] files removed from the build.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/history.h

    r12013 r12328  
    2626 */
    2727
    28 struct tr_history_slice
     28enum
    2929{
    30     unsigned int n;
    31     time_t date;
     30    TR_RECENT_HISTORY_PERIOD_SEC = 60
    3231};
     32
     33
    3334typedef struct tr_recentHistory
    3435{
    3536    /* these are PRIVATE IMPLEMENTATION details included for composition only.
    3637     * Don't access these directly! */
     38
    3739    int newest;
    38     int sliceCount;
    39     unsigned int precision;
    40     struct tr_history_slice * slices;
     40
     41    struct {
     42        unsigned int n;
     43        time_t date;
     44    } slices[TR_RECENT_HISTORY_PERIOD_SEC];
    4145}
    4246tr_recentHistory;
    43 
    44 /**
    45  * @brief construct a new tr_recentHistory object
    46  * @param seconds how many seconds of history this object should remember
    47  * @param precision how precise the history should be, in seconds
    48  *        For a precision of 10 seconds and a history of 2 minutes, makes 12 bins.
    49  */
    50 void tr_historyConstruct( tr_recentHistory *, unsigned int seconds, unsigned int precision );
    51 
    52 /** @brief destruct an existing tr_recentHistory object. */
    53 void tr_historyDestruct( tr_recentHistory * );
    5447
    5548/**
Note: See TracChangeset for help on using the changeset viewer.