Ignore:
Timestamp:
Jun 29, 2009, 7:19:18 PM (10 years ago)
Author:
bruno
Message:

r3145@localhost: bruno | 2009-06-29 17:18:58 +0200

  • Remove 2 memory leaks and change the behavoir for function media_descriptor_string which now allocates the string it returns (which needs to be free by the caller)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.9/mondo/src/mondorestore/mondorestore.c

    r2230 r2242  
    10751075    char *bigblk;
    10761076    char *p;
     1077    char *mds = NULL;
    10771078    int retval = 0;
    10781079    int finished = FALSE;
     
    12421243                    g_current_media_number);
    12431244            g_current_media_number++;
     1245            mds = media_descriptor_string(bkpinfo->backup_media_type);
    12441246            sprintf(tmp,
    1245                     "Asking for %s #%d so that I may read slice #%ld\n",
    1246                     media_descriptor_string(bkpinfo->backup_media_type),
     1247                    "Asking for %s #%d so that I may read slice #%ld\n", mds,
    12471248                    g_current_media_number, sliceno);
    12481249            log_msg(2, tmp);
    1249             sprintf(tmp, "Restoring from %s #%d",
    1250                     media_descriptor_string(bkpinfo->backup_media_type),
    1251                     g_current_media_number);
     1250            sprintf(tmp, "Restoring from %s #%d", mds, g_current_media_number);
     1251            mr_free(mds);
     1252
    12521253            log_to_screen(tmp);
    12531254            insist_on_this_cd_number(g_current_media_number);
     
    13011302                                    suffix), MONDO_LOGFILE);
    13021303            }
    1303             sprintf(tmp, "Working on %s #%d, file #%ld, slice #%ld    ",
    1304                     media_descriptor_string(bkpinfo->backup_media_type),
     1304            mds = media_descriptor_string(bkpinfo->backup_media_type);
     1305            sprintf(tmp, "Working on %s #%d, file #%ld, slice #%ld    ", mds,
    13051306                    g_current_media_number, bigfileno + 1, sliceno);
     1307            mr_free(mds);
    13061308            log_msg(2, tmp);
    13071309
     
    19121914  /** malloc add ***/
    19131915    char *tmp;
     1916    char *mds = NULL;
    19141917    char *command;
    19151918    char *afio_fname;
     
    19321935    /* to do it with a file... */
    19331936    use_star = (strstr(tarball_fname, ".star")) ? TRUE : FALSE;
     1937    mds = media_descriptor_string(bkpinfo->backup_media_type);
    19341938    sprintf(tmp,
    19351939            "Restoring from fileset #%ld (%ld KB) on %s #%d",
    1936             current_tarball_number, (long) size >> 10,
    1937             media_descriptor_string(bkpinfo->backup_media_type),
    1938             g_current_media_number);
     1940            current_tarball_number, (long) size >> 10, mds, g_current_media_number);
     1941    mr_free(mds);
     1942
    19391943    log_msg(2, tmp);
    19401944    run_program_and_log_output("mkdir -p " MNT_RESTORING "/tmp", FALSE);
     
    21012105  /** malloc **/
    21022106    char *tmp;
     2107    char *mds = NULL;
    21032108    bool just_changed_cds = FALSE;
    21042109    char *xattr_fname;
     
    21492154            log_msg(3,
    21502155                    "...but its first slice isn't on this CD. Perhaps this was a selective restore?");
     2156            mds = media_descriptor_string(bkpinfo->backup_media_type);
    21512157            log_msg(3, "Cannot find bigfile #%ld 's first slice on %s #%d",
    2152                     bigfileno + 1,
    2153                     media_descriptor_string(bkpinfo->backup_media_type),
     2158                    bigfileno + 1, mds,
    21542159                    g_current_media_number);
    21552160            log_msg(3, "Slicename would have been %s",
     
    21622167            } else if (does_file_exist(MNT_CDROM "/archives/NOT-THE-LAST")) {
    21632168                insist_on_this_cd_number(++g_current_media_number);
    2164                 sprintf(tmp, "Restoring from %s #%d",
    2165                         media_descriptor_string(bkpinfo->backup_media_type),
     2169                sprintf(tmp, "Restoring from %s #%d", mds,
    21662170                        g_current_media_number);
    21672171                log_to_screen(tmp);
     
    21762180                bigfileno++;
    21772181            }
     2182            mr_free(mds);
    21782183        } else {
    21792184            just_changed_cds = FALSE;
     
    22512256  /**malloc ***/
    22522257    char *tmp = NULL;
     2258    char *mds = NULL;
    22532259    char *tmp1 = NULL;
    22542260    char *tarball_fname;
     
    22752281    paranoid_free(tmp);
    22762282
    2277     sprintf(progress_str, "Restoring from %s #%d",
    2278             media_descriptor_string(bkpinfo->backup_media_type),
    2279             g_current_media_number);
     2283    mds = media_descriptor_string(bkpinfo->backup_media_type);
     2284    sprintf(progress_str, "Restoring from %s #%d", mds, g_current_media_number);
     2285
    22802286    log_to_screen(progress_str);
    22812287    open_progress_form("Restoring from archives",
     
    23272333        } else {
    23282334            sprintf(progress_str, "Restoring from fileset #%ld on %s #%d",
    2329                     current_tarball_number,
    2330                     media_descriptor_string(bkpinfo->backup_media_type),
    2331                     g_current_media_number);
     2335                    current_tarball_number, mds, g_current_media_number);
    23322336//    log_msg(3, "progress_str = %s", progress_str);
    23332337            for (res = 999, attempts = 0; attempts < 3 && res != 0;
     
    23392343            }
    23402344            mr_asprintf(&tmp1, "%s #%d, fileset #%ld - restore ",
    2341                     media_descriptor_string(bkpinfo->backup_media_type),
    2342                     g_current_media_number, current_tarball_number);
     2345                    mds, g_current_media_number, current_tarball_number);
    23432346            if (res) {
    23442347                mr_strcat(tmp1, "reported errors");
     
    23622365        }
    23632366    }
     2367    mr_free(mds);
     2368
    23642369    close_progress_form();
    23652370    if (retval) {
     
    25762581  /** malloc **/
    25772582    char *tmp;
     2583    char *mds = NULL;
    25782584    char *progress_str;
    25792585    char *tmp_fname;
     
    26612667        current_afioball_number++;
    26622668        g_current_progress++;
     2669        mds = media_descriptor_string(bkpinfo->backup_media_type),
    26632670        sprintf(progress_str, "Restoring from fileset #%ld on %s #%d",
    2664                 current_afioball_number,
    2665                 media_descriptor_string(bkpinfo->backup_media_type),
     2671                current_afioball_number, mds,
    26662672                g_current_media_number);
     2673        mr_free(mds);
    26672674        res =
    26682675            read_header_block_from_stream(&tmp_size, tmp_fname, &ctrl_chr);
Note: See TracChangeset for help on using the changeset viewer.