make tr_info.webseedCount and tr_info.trackerCount unsigned.

This commit is contained in:
Jordan Lee 2012-12-30 22:06:45 +00:00
parent 996670c4f2
commit 3c9640bb8f
13 changed files with 45 additions and 33 deletions

View File

@ -1351,7 +1351,7 @@ refreshWebseedList (struct DetailsImpl * di, tr_torrent ** torrents, int n)
/* step 2: add any new webseeds */
for (i=0; i<n; ++i) {
int j;
unsigned int j;
const tr_torrent * tor = torrents[i];
const tr_info * inf = tr_torrentInfo (tor);
total += inf->webseedCount;
@ -1375,7 +1375,7 @@ refreshWebseedList (struct DetailsImpl * di, tr_torrent ** torrents, int n)
/* step 3: update the webseeds */
for (i=0; i<n; ++i) {
int j;
unsigned int j;
tr_torrent * tor = torrents[i];
const tr_info * inf = tr_torrentInfo (tor);
double * speeds_KBps = tr_torrentWebSpeeds_KBps (tor);
@ -2159,7 +2159,7 @@ on_edit_trackers_response (GtkDialog * dialog, int response, gpointer data)
static void
get_editable_tracker_list (GString * gstr, const tr_torrent * tor)
{
int i;
unsigned int i;
int tier = 0;
const tr_info * inf = tr_torrentInfo (tor);
for (i=0; i<inf->trackerCount; ++i) {

View File

@ -552,7 +552,7 @@ test_category (tr_torrent * tor, int active_category_type, const char * host)
return tr_torrentGetPriority (tor) == TR_PRI_LOW;
case CAT_FILTER_TYPE_HOST: {
int i;
unsigned int i;
char tmp[1024];
for (i=0; i<inf->trackerCount; ++i) {
gtr_get_host_from_url (tmp, sizeof (tmp), inf->trackers[i].announce);

View File

@ -1011,7 +1011,7 @@ on_torrent_metadata_changed (tr_torrent * tor, void * gcore)
static unsigned int
build_torrent_trackers_hash (tr_torrent * tor)
{
int i;
unsigned int i;
const char * pch;
uint64_t hash = 0;
const tr_info * const inf = tr_torrentInfo (tor);

View File

@ -545,7 +545,7 @@ tr_metainfoParse (const tr_session * session,
void
tr_metainfoFree (tr_info * inf)
{
int i;
unsigned int i;
tr_file_index_t ff;
for (i=0; i<inf->webseedCount; i++)

View File

@ -513,7 +513,7 @@ static void peerCallbackFunc (tr_peer *, const tr_peer_event *, void *);
static void
rebuildWebseedArray (Torrent * t, tr_torrent * tor)
{
int i;
unsigned int i;
const tr_info * inf = &tor->info;
/* clear the array */
@ -2688,8 +2688,8 @@ tr_peerMgrTorrentStats (tr_torrent * tor,
double*
tr_peerMgrWebSpeeds_KBps (const tr_torrent * tor)
{
int i;
int webseedCount;
unsigned int i;
unsigned int webseedCount;
const Torrent * t;
const tr_webseed ** webseeds;
double * ret = NULL;

View File

@ -446,29 +446,29 @@ addFiles (const tr_torrent * tor,
}
static void
addWebseeds (const tr_info * info,
tr_variant * webseeds)
addWebseeds (const tr_info * info,
tr_variant * webseeds)
{
int i;
unsigned int i;
for (i = 0; i < info->webseedCount; ++i)
tr_variantListAddStr (webseeds, info->webseeds[i]);
for (i=0; i< info->webseedCount; ++i)
tr_variantListAddStr (webseeds, info->webseeds[i]);
}
static void
addTrackers (const tr_info * info,
tr_variant * trackers)
addTrackers (const tr_info * info,
tr_variant * trackers)
{
int i;
unsigned int i;
for (i = 0; i < info->trackerCount; ++i)
for (i=0; i<info->trackerCount; ++i)
{
const tr_tracker_info * t = &info->trackers[i];
tr_variant * d = tr_variantListAddDict (trackers, 4);
tr_variantDictAddStr (d, TR_KEY_announce, t->announce);
tr_variantDictAddInt (d, TR_KEY_id, t->id);
tr_variantDictAddStr (d, TR_KEY_scrape, t->scrape);
tr_variantDictAddInt (d, TR_KEY_tier, t->tier);
const tr_tracker_info * t = &info->trackers[i];
tr_variant * d = tr_variantListAddDict (trackers, 4);
tr_variantDictAddStr (d, TR_KEY_announce, t->announce);
tr_variantDictAddInt (d, TR_KEY_id, t->id);
tr_variantDictAddStr (d, TR_KEY_scrape, t->scrape);
tr_variantDictAddInt (d, TR_KEY_tier, t->tier);
}
}

View File

@ -373,7 +373,7 @@ tr_torrentGetMetadataPercent (const tr_torrent * tor)
char*
tr_torrentInfoGetMagnetLink (const tr_info * inf)
{
int i;
unsigned int i;
const char * name;
struct evbuffer * s = evbuffer_new ();

View File

@ -1256,7 +1256,7 @@ tr_torrentStat (tr_torrent * tor)
tor->etaDLSpeedCalculatedAt = now;
}
if ((s->leftUntilDone > s->desiredAvailable) && (tor->info.webseedCount < 0))
if ((s->leftUntilDone > s->desiredAvailable) && (tor->info.webseedCount < 1))
s->eta = TR_ETA_NOT_AVAIL;
else if (tor->etaDLSpeed_KBps < 1)
s->eta = TR_ETA_UNKNOWN;

View File

@ -1724,8 +1724,8 @@ struct tr_info
/* Torrent info */
time_t dateCreated;
int trackerCount;
int webseedCount;
unsigned int trackerCount;
unsigned int webseedCount;
tr_file_index_t fileCount;
uint32_t pieceSize;
tr_piece_index_t pieceCount;

View File

@ -469,6 +469,16 @@ MyApp :: notify( const QString& title, const QString& body ) const
int
main( int argc, char * argv[] )
{
std::cerr << "sizeof double " << sizeof(double) << std::endl;
std::cerr << "sizeof Speed " << sizeof(Speed) << std::endl;
std::cerr << "sizeof int " << sizeof(int) << std::endl;
std::cerr << "sizeof bool " << sizeof(bool) << std::endl;
std::cerr << "sizeof uint64_t " << sizeof(uint64_t) << std::endl;
std::cerr << "sizeof QString is " << sizeof(QString) << std::endl;
std::cerr << "sizeof TrFile is " << sizeof(struct TrFile) << std::endl;
std::cerr << "sizeof Peer is " << sizeof(Peer) << std::endl;
std::cerr << "sizeof TrackerStat is " << sizeof(TrackerStat) << std::endl;
// find .torrents, URLs, magnet links, etc in the command-line args
int c;
QStringList addme;

View File

@ -1,3 +1,4 @@
#/bin/sh
valgrind --tool=cachegrind ./transmission-qt 2>&1 | tee runlog
#valgrind --tool=cachegrind ./transmission-qt 2>&1 | tee runlog
valgrind --tool=massif --threshold=0.2 ./transmission-qt 2>&1 | tee runlog
#valgrind --tool=memcheck --leak-check=full --leak-resolution=high --num-callers=48 --log-file=x-valgrind --show-reachable=no ./transmission-qt 2>&1 | tee runlog

View File

@ -555,6 +555,7 @@ Torrent :: update (tr_variant * d)
tr_variant * child;
myFiles.clear ();
myFiles.reserve (tr_variantListSize (files));
while ((child = tr_variantListChild (files, i)))
{

View File

@ -122,7 +122,7 @@ compare_files_by_name (const void * va, const void * vb)
static void
showInfo (const tr_info * inf)
{
int i;
unsigned int i;
char buf[128];
tr_file ** files;
int prevTier = -1;
@ -185,10 +185,10 @@ showInfo (const tr_info * inf)
printf ("\nFILES\n\n");
files = tr_new (tr_file*, inf->fileCount);
for (i=0; i< (int)inf->fileCount; ++i)
for (i=0; i<inf->fileCount; ++i)
files[i] = &inf->files[i];
qsort (files, inf->fileCount, sizeof (tr_file*), compare_files_by_name);
for (i=0; i< (int)inf->fileCount; ++i)
for (i=0; i<inf->fileCount; ++i)
printf (" %s (%s)\n", files[i]->name, tr_formatter_size_B (buf, files[i]->length, sizeof (buf)));
tr_free (files);
}
@ -217,7 +217,7 @@ tr_curl_easy_init (struct evbuffer * writebuf)
static void
doScrape (const tr_info * inf)
{
int i;
unsigned int i;
for (i=0; i<inf->trackerCount; ++i)
{