This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

memleak.cpp

By: iwishiknew on Jun 22nd, 2013  |  syntax: C++  |  size: 1.53 KB  |  views: 53  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. int snapshot_menu(const basic_snap_data& snap, const int& num_of_snaps)
  2. {
  3.     int x = 0;
  4.     char ch;
  5.     chrono_date t; //time class...
  6.     fsys_class p = snap.path; //my filesystem class
  7.     t.asc_time = snap.date; //setting time class to the date of the snapshot (unimportant)
  8.     ULL path_count = 0;
  9.     //here is where the problems are:
  10.     snapshot_class snapshot = snap.path; //no problems here
  11.     path_count = snapshot.gsnap().size(); //here is when memory skyrockets
  12.     snapshot.clear(); //after this, there is remaining memory allocated...
  13.    
  14.    
  15.     while(x == 0)
  16.     {
  17.         cls();
  18.         cout<< endl;
  19.         cout<< "                         Snapshot Menu: "<< t.std_time_disp()<< endl;
  20.         cout<< "(Number of paths obtained: "<< path_count<< ")"<< endl;
  21.         cout<< endl<< endl<< endl;
  22.         cout<< " 1 -  Find Changes";
  23.         if(num_of_snaps < 2)
  24.         {
  25.             cout<< "  (Not enough snapshots...)";
  26.         }
  27.         cout<< endl;
  28.        
  29.         cout<< " 2 -  Delete Snapshot"<< endl;
  30.         cout<< " q -  Done"<< endl;
  31.         ch = gkey();
  32.         if(ch == '1')
  33.         {
  34.             compare_snapshot(snap);
  35.             continue;
  36.         }
  37.         if(ch == '2')
  38.         {
  39.             if(is_sure("Do you really want to delete this snapshot?") == true)
  40.             {
  41.                 p.del();
  42.                 return 1;
  43.             }
  44.             continue;
  45.         }
  46.         ch = tolower(ch);
  47.         if(ch == 'q')
  48.         {
  49.             return 0;
  50.         }
  51.     }
  52.     return 0;
  53. }
clone this paste RAW Paste Data