/* void gettimeofday(struct timeval, void* time_zone){ struct _timeb cur; _ftime(&cur); tv->tv_sec =cur.time; tv->tv_usec = cur.millitm * 1000; } */ CodeTorrent::~CodeTorrent() { HAGGLE_DBG2("Calling codetorrent destructor\n"); CleanMGData(); if (identity == CT_SERVER) { HAGGLE_DBG2("Cleaning up server\n"); CleanData(); } if (identity == CT_CLIENT) { HAGGLE_DBG2("Cleaning up client\n"); CleanMHelpful(); CleanBuffer(); delete[] rank_vec; delete[] rank_vec_in_buf; } // CBMEN, HL - Memory leak, only allocate when needed. /*if (cb) FreeCodedBlock(cb); */ delete[] num_blocks_gen; delete nc; }
// decode! bool CodeTorrent::Decode() { int i; //struct timeval start_dec, end_dec; if (identity != CT_CLIENT) {// if I'm a server, why do it? HAGGLE_ERR("Server is trying to decode\n"); return false; } //why in the world does the identity get reset to server? //identity = CT_SERVER; if (GetGenCompleted() != GetNumGens()) { // make sure all generations are in! HAGGLE_DBG("The file is not complete, decoding failed - GenCompleted=%d NumGens=%d\n",GetGenCompleted(),GetNumGens()); //fprintf(stderr, "The file download is not complete, decoding failed.\n"); return false; } //gettimeofday(&start_dec, &ct_tz); //printf("Decoding: "); for (i = 0; i < GetNumGens(); i++) { //printf("%d : ", i); if(!DecodeGen(i)) { HAGGLE_ERR("Decoding failure\n"); // MOS return false; } } /* gettimeofday(&end_dec, &ct_tz); printf("Decoding time: %ld.%ld\n", CT_GetTimeDifference(start_dec, end_dec)/1000, CT_GetTimeDifference(start_dec, end_dec)%1000); */ //printf("done!\n"); //gettimeofday(&ct_tv_end, &ct_tz); //printf("TIME!!! %ld.%ld\n", CT_GetTimeDifference(ct_tv_beg, ct_tv_end)/1000, CT_GetTimeDifference(ct_tv_beg, ct_tv_end)%1000); // we don't need this stuff anymore CleanBuffer(); CleanTempFiles(); return true; }
Texture::~Texture() { CleanBuffer(); }