Ignore:
Timestamp:
Jun 29, 2009, 7:19:18 PM (15 years ago)
Author:
Bruno Cornec
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/common/libmondo-archive.c

    r2241 r2242  
    15861586    char *message_to_screen = NULL;
    15871587    char *old_pwd;
     1588    char *mds = NULL;
    15881589
    15891590    malloc_string(old_pwd);
     
    15971598    (void)chdir(bkpinfo->scratchdir);
    15981599
    1599     mr_asprintf(&message_to_screen, "Copying data to make %s #%d",
    1600                 media_descriptor_string(bkpinfo->backup_media_type),
    1601                 g_current_media_number);
     1600    mds = media_descriptor_string(bkpinfo->backup_media_type);
     1601    mr_asprintf(&message_to_screen, "Copying data to make %s #%d",mds, g_current_media_number);
     1602    mr_free(mds);
    16021603    log_msg(1, message_to_screen);
    16031604
     
    16891690    char *tmp2;
    16901691    char *tmp3;
     1692    char *mds = NULL;
    16911693    bool cd_is_mountable;
    16921694
     
    17461748        log_msg(2, "bkpinfo->call_make_iso = %s", bkpinfo->call_make_iso);
    17471749        sprintf(tmp, "%s/archives/NOT-THE-LAST", bkpinfo->scratchdir);
    1748         mr_asprintf(&message_to_screen, "Making an ISO (%s #%d)",
    1749                 media_descriptor_string(bkpinfo->backup_media_type),
    1750                 g_current_media_number);
     1750        mds = media_descriptor_string(bkpinfo->backup_media_type);
     1751        mr_asprintf(&message_to_screen, "Making an ISO (%s #%d)", mds, g_current_media_number);
     1752        mr_free(mds);
    17511753
    17521754        pause_and_ask_for_cdr(2, &cd_is_mountable); /* if g_current_media_number >= 2 then pause & ask */
     
    18431845        paranoid_free(message_to_screen);
    18441846    } else {
    1845         mr_asprintf(&message_to_screen, "Running mkisofs to make %s #%d",
    1846                 media_descriptor_string(bkpinfo->backup_media_type),
    1847                 g_current_media_number);
     1847        mds = media_descriptor_string(bkpinfo->backup_media_type);
     1848        mr_asprintf(&message_to_screen, "Running mkisofs to make %s #%d", mds, g_current_media_number);
    18481849        log_msg(1, message_to_screen);
    1849         mr_asprintf(&result_sz, "Call to mkisofs to make ISO (%s #%d) ",
    1850                 media_descriptor_string(bkpinfo->backup_media_type),
    1851                 g_current_media_number);
     1850        mr_asprintf(&result_sz, "Call to mkisofs to make ISO (%s #%d) ", mds,  g_current_media_number);
     1851        mr_free(mds);
    18521852        if (bkpinfo->nonbootable_backup) {
    18531853            log_msg(1, "Making nonbootable backup");
     
    19251925    if (bkpinfo->call_burn_iso[0] != '\0') {
    19261926        log_msg(2, "bkpinfo->call_burn_iso = %s", bkpinfo->call_burn_iso);
    1927         mr_asprintf(&message_to_screen, "Burning %s #%d",
    1928                 media_descriptor_string(bkpinfo->backup_media_type),
    1929                 g_current_media_number);
     1927        mds = media_descriptor_string(bkpinfo->backup_media_type);
     1928        mr_asprintf(&message_to_screen, "Burning %s #%d", mds, g_current_media_number);
     1929        mr_free(mds);
    19301930        pause_and_ask_for_cdr(2, &cd_is_mountable);
    19311931        res =
     
    19451945
    19461946    if (bkpinfo->call_after_iso[0] != '\0') {
    1947         mr_asprintf(&message_to_screen, "Running post-ISO call (%s #%d)",
    1948                 media_descriptor_string(bkpinfo->backup_media_type),
    1949                 g_current_media_number);
     1947        mds = media_descriptor_string(bkpinfo->backup_media_type);
     1948        mr_asprintf(&message_to_screen, "Running post-ISO call (%s #%d)", mds, g_current_media_number);
     1949        mr_free(mds);
    19501950        res =
    19511951            eval_call_to_make_ISO(bkpinfo->call_after_iso,
     
    20522052    assert_string_is_neither_NULL_nor_zerolength(biggielist_fname);
    20532053
    2054     malloc_string(bigfile_fname);
    20552054    estimated_total_noof_slices =
    20562055        size_of_all_biggiefiles_K() / bkpinfo->optimal_set_size + 1;
     
    20782077        return (1);
    20792078    }
     2079
     2080    malloc_string(bigfile_fname);
    20802081    for (fgets(bigfile_fname, MAX_STR_LEN, fin); !feof(fin);
    20812082         fgets(bigfile_fname, MAX_STR_LEN, fin), biggie_file_number++) {
     
    27592760    char *szserfname;
    27602761    char *szunmount;
     2762    char *mds = NULL;
    27612763
    27622764    malloc_string(tmp);
     
    27692771    malloc_string(szunmount);
    27702772
    2771     sprintf(szmsg, "I am about to burn %s #%d",
    2772             media_descriptor_string(g_backup_media_type),
    2773             g_current_media_number);
     2773    mds = media_descriptor_string(g_backup_media_type);
     2774    sprintf(szmsg, "I am about to burn %s #%d", mds, g_current_media_number);
     2775    mr_free(mds);
    27742776    log_to_screen(szmsg);
    27752777    if (g_current_media_number < ask_for_one_if_more_than_this) {
     
    28122814        } else if (!does_file_exist(szcdno)
    28132815                   || !does_file_exist(szserfname)) {
     2816            mds = media_descriptor_string(g_backup_media_type);
    28142817            log_to_screen
    2815                 ("%s has data on it but it's probably not a Mondo CD.",
    2816                  media_descriptor_string(g_backup_media_type));
     2818                ("%s has data on it but it's probably not a Mondo CD.", mds);
     2819            mr_free(mds);
    28172820        } else {
    2818             log_to_screen("%s found in drive. It's a Mondo disk.",
    2819                           media_descriptor_string(g_backup_media_type));
     2821            mds = media_descriptor_string(g_backup_media_type);
     2822            log_to_screen("%s found in drive. It's a Mondo disk.", mds);
     2823            mr_free(mds);
     2824
    28202825            cd_number = atoi(last_line_of_file(szcdno));
    28212826            sprintf(tmp, "cat %s 2> /dev/null", szserfname);
     
    28302835                our_serial_str, g_serial_string);
    28312836        if (cd_number > 0 && !strcmp(our_serial_str, g_serial_string)) {
    2832             log_msg(2, "This %s is part of this backup set!",
    2833                     media_descriptor_string(g_backup_media_type));
     2837            mds = media_descriptor_string(g_backup_media_type);
     2838            log_msg(2, "This %s is part of this backup set!", mds);
    28342839            ok_go_ahead_burn_it = FALSE;
    28352840            if (cd_number == g_current_media_number - 1) {
    2836                 log_to_screen
    2837                     ("I think you've left the previous %s in the drive.",
    2838                      media_descriptor_string(g_backup_media_type));
     2841                log_to_screen("I think you've left the previous %s in the drive.", mds);
    28392842            } else {
    2840                 log_to_screen
    2841                     ("Please remove this %s. It is part of the backup set you're making now.",
    2842                      media_descriptor_string(g_backup_media_type));
     2843                log_to_screen("Please remove this %s. It is part of the backup set you're making now.", mds);
    28432844            }
     2845            mr_free(mds);
     2846
    28442847        } else {
    28452848            log_to_screen("...but not part of _our_ backup set.");
     
    28472850        mr_free(our_serial_str);
    28482851    } else {
     2852        mds = media_descriptor_string(g_backup_media_type);
    28492853        log_msg(2,
    2850                 "paafcd: Can't find CD-ROM drive. Perhaps it has a blank %s in it?",
    2851                 media_descriptor_string(g_backup_media_type));
     2854                "paafcd: Can't find CD-ROM drive. Perhaps it has a blank %s in it?", mds);
    28522855        if (interrogate_disk_currently_in_cdrw_drive(cdrw_dev, FALSE)) {
    28532856            ok_go_ahead_burn_it = FALSE;
    2854             log_to_screen("There isn't a writable %s in the drive.",
    2855                           media_descriptor_string(g_backup_media_type));
    2856         }
    2857     }
    2858 
    2859 /*
    2860   if (g_current_media_number > ask_for_one_if_more_than_this)
    2861     {
    2862       ok_go_ahead_burn_it = FALSE;
    2863       log_it("paafcd: %d > %d, so I'll definitely pause.", g_current_media_number > ask_for_one_if_more_than_this);
    2864     }
    2865 */
     2857            log_to_screen("There isn't a writable %s in the drive.", mds);
     2858        }
     2859        mr_free(mds);
     2860    }
    28662861
    28672862    if (!ok_go_ahead_burn_it) {
    28682863        eject_device(cdrom_dev);
     2864        mds = media_descriptor_string(g_backup_media_type);
    28692865        sprintf(tmp,
    2870                 "I am about to burn %s #%d of the backup set. Please insert %s and press Enter.",
    2871                 media_descriptor_string(g_backup_media_type),
    2872                 g_current_media_number,
    2873                 media_descriptor_string(g_backup_media_type));
     2866                "I am about to burn %s #%d of the backup set. Please insert %s and press Enter.", 
     2867                mds, g_current_media_number, mds);
     2868        mr_free(mds);
     2869
    28742870        popup_and_OK(tmp);
    28752871        goto gotos_make_me_puke;
     
    28782874    }
    28792875
     2876    mds = media_descriptor_string(g_backup_media_type);
    28802877    log_msg(2,
    2881             "paafcd: OK, I assume I have a blank/reusable %s in the drive...",
    2882             media_descriptor_string(g_backup_media_type));
     2878            "paafcd: OK, I assume I have a blank/reusable %s in the drive...", mds);
    28832879
    28842880    //  if (ask_for_one_if_more_than_this>1) { popup_and_OK(szmsg); }
    28852881
    2886     log_to_screen("Proceeding w/ %s in drive.",
    2887                   media_descriptor_string(g_backup_media_type));
     2882    log_to_screen("Proceeding w/ %s in drive.", mds);
     2883    mr_free(mds);
     2884
    28882885    paranoid_free(tmp);
    28892886    paranoid_free(szmsg);
     
    33693366    char *lastcd_fname;
    33703367    char *isofile;
     3368    char *mds = NULL;
    33713369
    33723370    /*@ bool ******************************************************** */
     
    33883386    }
    33893387
    3390     log_msg(1, "OK, time to make %s #%d",
    3391             media_descriptor_string(bkpinfo->backup_media_type),
    3392             g_current_media_number);
     3388    mds = media_descriptor_string(bkpinfo->backup_media_type);
     3389    log_msg(1, "OK, time to make %s #%d", mds, g_current_media_number);
     3390    mr_free(mds);
    33933391
    33943392    /* label the ISO with its number */
     
    34473445        }
    34483446        if (bkpinfo->verify_data && !res) {
     3447            mds = media_descriptor_string(g_backup_media_type);
    34493448            log_to_screen
    3450                 ("Please reboot from the 1st %s in Compare Mode, as a precaution.",
    3451                  media_descriptor_string(g_backup_media_type));
     3449                ("Please reboot from the 1st %s in Compare Mode, as a precaution.", mds);
     3450            mr_free(mds);
    34523451            chdir("/");
    34533452            log_it("Before calling verification of image()");
     
    34623461            that_one_was_ok = TRUE;
    34633462        } else {
    3464             sprintf(tmp, "Failed to create %s #%d. Retry?",
    3465                     media_descriptor_string(bkpinfo->backup_media_type),
    3466                     g_current_media_number);
     3463            mds = media_descriptor_string(bkpinfo->backup_media_type);
     3464            sprintf(tmp, "Failed to create %s #%d. Retry?", mds, g_current_media_number);
     3465            mr_free(mds);
    34673466            res = ask_me_yes_or_no(tmp);
    34683467            if (!res) {
     
    35253524    int res = 0, retval = 0, cdno = 0;
    35263525    char *tmp;
     3526    char *mds = NULL;
    35273527    long diffs = 0;
    35283528
     
    35643564            retval += res;
    35653565            if (res) {
     3566                mds = media_descriptor_string(bkpinfo->backup_media_type);
    35663567                sprintf(tmp,
    3567                         "Warnings/errors were reported while checking %s #%d",
    3568                         media_descriptor_string(bkpinfo->backup_media_type),
    3569                         g_current_media_number);
     3568                        "Warnings/errors were reported while checking %s #%d", mds, g_current_media_number);
     3569                mr_free(mds);
    35703570                log_to_screen(tmp);
    35713571
Note: See TracChangeset for help on using the changeset viewer.