Changeset 13924


Ignore:
Timestamp:
Feb 1, 2013, 7:21:38 PM (8 years ago)
Author:
jordan
Message:

(libT) #5259 'Minor memory leaks in tr_torrentDeleteLocalData()': cleaner patch suggested by cfpp2p

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/torrent.c

    r13913 r13924  
    28482848    for (f=0; f<tor->info.fileCount; ++f)
    28492849    {
     2850        char * dir;
     2851        char * filename;
     2852
    28502853        /* get the directory that this file goes in... */
    2851         char * filename = tr_buildPath (top, tor->info.files[f].name, NULL);
    2852         char * dir = tr_dirname (filename);
     2854        filename = tr_buildPath (top, tor->info.files[f].name, NULL);
     2855        dir = tr_dirname (filename);
     2856        tr_free (filename);
     2857
     2858        /* walk up the directory tree until we reach 'top' */
    28532859        if (!tr_is_same_file (top, dir) && strcmp (top, dir)) {
    2854             for (;;) {
    2855                 char * parent = tr_dirname (dir);
    2856                 const bool done_walking = tr_is_same_file (top, parent) || !strcmp (top, parent);
    2857                 if (done_walking && tr_ptrArrayFindSorted (&folders, dir, vstrcmp))
    2858                   tr_ptrArrayInsertSorted (&folders, dir, vstrcmp); /* folders assumes ownership of dir */
    2859                 else
    2860                   tr_free (dir);
    2861                 dir = parent;
    2862                 if (done_walking)
     2860          for (;;) {
     2861              char * parent = tr_dirname (dir);
     2862              if (tr_is_same_file (top, parent) || !strcmp (top, parent)) {
     2863                  if (tr_ptrArrayFindSorted (&folders, dir, vstrcmp) == NULL)
     2864                    tr_ptrArrayInsertSorted (&folders, tr_strdup(dir), vstrcmp);
     2865                  tr_free (parent);
    28632866                  break;
     2867                }
     2868
     2869              /* walk upwards to parent */
     2870              tr_free (dir);
     2871              dir = parent;
    28642872            }
    28652873        }
    2866         tr_free (dir);
    2867         tr_free (filename);
    2868     }
     2874
     2875      tr_free (dir);
     2876    }
     2877
    28692878    for (i=0, n=tr_ptrArraySize (&folders); i<n; ++i)
    28702879        removeEmptyFoldersAndJunkFiles (tr_ptrArrayNth (&folders, i));
Note: See TracChangeset for help on using the changeset viewer.