Changeset 2313


Ignore:
Timestamp:
Aug 18, 2009, 2:29:11 PM (10 years ago)
Author:
bruno
Message:

r3324@localhost: bruno | 2009-07-31 23:42:57 +0200
percent_media_full_comment now allocates memory

Location:
branches/2.2.10/mondo/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.10/mondo/src/common/libmondo-archive.c

    r2303 r2313  
    14071407            if (!get_bit_N_of_array
    14081408                (p_list_of_fileset_flags, storing_set_no)) {
    1409             misc_counter_that_is_not_important =
    1410                 (misc_counter_that_is_not_important + 1) % 5;
    1411             /* BCO the media_usage_comment is not really initialized there !
    1412             if (!misc_counter_that_is_not_important) {
    1413                 update_progress_form(media_usage_comment);
    1414             }
    1415             */
    1416             sleep(1);
     1409                misc_counter_that_is_not_important = (misc_counter_that_is_not_important + 1) % 5;
     1410                sleep(1);
    14171411            } else {
    14181412                // store set N
     
    14341428                    sleep(5);
    14351429                }
    1436                 mr_asprintf(&media_usage_comment, "%s", percent_media_full_comment());
    14371430                /* copy to CD (scratchdir) ... and an actual CD-R if necessary */
    14381431                if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) {
     
    14741467                retval += res;
    14751468                g_current_progress++;
     1469
     1470                media_usage_comment = percent_media_full_comment();
    14761471                update_progress_form(media_usage_comment);
    14771472                mr_free(media_usage_comment);
     
    22152210        }
    22162211
    2217         mr_asprintf(&media_usage_comment, "%s", percent_media_full_comment());
    2218 
    22192212        /* copy to CD (scratchdir) ... and an actual CD-R if necessary */
    22202213        if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) {
     
    22582251        retval += res;
    22592252        g_current_progress++;
     2253
     2254        media_usage_comment = percent_media_full_comment();
    22602255        update_progress_form(media_usage_comment);
    22612256        mr_free(media_usage_comment);
     
    30343029        mr_asprintf(&curr_slice_fname_compressed, "%s", slice_fname(biggie_file_number, slice_num, bkpinfo->tmpdir, suffix));
    30353030
    3036         mr_asprintf(&tmp, "%s", percent_media_full_comment());
     3031       
     3032        tmp = percent_media_full_comment();
    30373033        update_progress_form(tmp);
    3038         paranoid_free(tmp);
     3034        mr_free(tmp);
    30393035
    30403036        if (!(fout = fopen(curr_slice_fname_uncompressed, "w"))) {
  • branches/2.2.10/mondo/src/common/libmondo-string.c

    r2287 r2313  
    155155        tmp[j - 6] = ',';
    156156        strcpy(tmp + j - 5, pos_w_commas + j - 6);
    157 //      tmp[j-2] = ',';
    158 //      strcpy(tmp+j-1, pos_w_commas+j-3);
    159157        strcpy(pos_w_commas, tmp);
    160158    }
     
    10871085    /*@ int *********************************************** */
    10881086    int percentage;
    1089     int j;
    10901087
    10911088    /*@ buffers ******************************************* */
    1092     static char outstr[MAX_STR_LEN];
     1089    char *outstr = NULL;
    10931090    char *pos_w_commas, *tmp;
    10941091    char *mds = NULL;
    10951092
    10961093    assert(bkpinfo != NULL);
    1097     malloc_string(pos_w_commas);
    1098     malloc_string(tmp);
    1099     sprintf(tmp, "%lld", g_tape_posK);
    1100     strcpy(pos_w_commas, commarize(tmp));
    1101 
    1102 
    1103 
    1104     if (bkpinfo->media_size[g_current_media_number] <= 0)
    1105 //    { fatal_error( "percentage_media_full_comment() - unknown media size"); }
    1106     {
    1107         sprintf(outstr, "Volume %d: %s kilobytes archived so far",
    1108                 g_current_media_number, pos_w_commas);
     1094
     1095    if (bkpinfo->media_size[g_current_media_number] <= 0) {
     1096        malloc_string(pos_w_commas);
     1097        malloc_string(tmp);
     1098        sprintf(tmp, "%lld", g_tape_posK);
     1099        strcpy(pos_w_commas, commarize(tmp));
     1100        paranoid_free(tmp);
     1101        mr_asprintf(&outstr, "Volume %d: %s kilobytes archived so far", g_current_media_number, pos_w_commas);
     1102        paranoid_free(pos_w_commas);
    11091103        return (outstr);
    11101104    }
     
    11181112            percentage = 100;
    11191113        }
    1120         sprintf(outstr, "Volume %d: [", g_current_media_number);
     1114        mr_asprintf(&outstr, "Volume %d: [", g_current_media_number);
    11211115    } else {
    11221116        percentage =
     
    11241118                   bkpinfo->media_size[g_current_media_number]);
    11251119        mds = media_descriptor_string(bkpinfo->backup_media_type);
    1126         sprintf(outstr, "%s %d: [", mds, g_current_media_number);
     1120        mr_asprintf(&outstr, "%s %d: [", mds, g_current_media_number);
    11271121        mr_free(mds);
    11281122    }
    11291123    for (j = 0; j < percentage; j += 5) {
    1130         strcat(outstr, "*");
     1124        mr_strcat(outstr, "*");
    11311125    }
    11321126    for (; j < 100; j += 5) {
    1133         strcat(outstr, ".");
    1134     }
    1135     j = (int) strlen(outstr);
    1136     sprintf(outstr + j, "] %d%% used", percentage);
    1137     paranoid_free(pos_w_commas);
    1138     paranoid_free(tmp);
     1127        mr_strcat(outstr, ".");
     1128    }
     1129    mr_strcat(outstr, "] %d%% used", percentage);
    11391130    return (outstr);
    11401131}
  • branches/2.2.10/mondo/src/mondorestore/mondo-rstr-newt.c

    r2300 r2313  
    15881588    malloc_string(sz_parity_disks);
    15891589    malloc_string(sz_failed_disks);
    1590     if (!(bkp_raidrec = malloc(sizeof(struct raid_device_record)))) {
    1591         fatal_error("Cannot malloc space for raidrec");
    1592     }
    1593 
     1590
     1591    bkp_raidrec = mr_malloc(sizeof(struct raid_device_record));
    15941592    log_it("Started edit_raidlist_entry");
    15951593
    1596     memcpy((void *) bkp_raidrec, (void *) raidrec,
    1597            sizeof(struct raid_device_record));
     1594    memcpy((void *) bkp_raidrec, (void *) raidrec, sizeof(struct raid_device_record));
    15981595    sprintf(title_of_editraidForm_window, "%s", raidrec->raid_device);
    15991596    log_msg(2, "Opening newt window");
     
    16371634            choose_raid_level(raidrec);
    16381635        } else if (b_res == bSelectData) {
    1639             select_raid_disks(mountlist, raidlist, raidrec, "data",
    1640                               &raidrec->data_disks);
     1636            select_raid_disks(mountlist, raidlist, raidrec, "data", &raidrec->data_disks);
    16411637        } else if (b_res == bSelectSpare) {
    1642             select_raid_disks(mountlist, raidlist, raidrec, "spare",
    1643                               &raidrec->spare_disks);
     1638            select_raid_disks(mountlist, raidlist, raidrec, "spare", &raidrec->spare_disks);
    16441639        } else if (b_res == bSelectParity) {
    1645             select_raid_disks(mountlist, raidlist, raidrec, "parity",
    1646                               &raidrec->parity_disks);
     1640            select_raid_disks(mountlist, raidlist, raidrec, "parity", &raidrec->parity_disks);
    16471641        } else if (b_res == bSelectFailed) {
    1648             select_raid_disks(mountlist, raidlist, raidrec, "failed",
    1649                               &raidrec->failed_disks);
     1642            select_raid_disks(mountlist, raidlist, raidrec, "failed", &raidrec->failed_disks);
    16501643        } else if (b_res == bAdditional) {
    16511644            edit_raidrec_additional_vars(raidrec);
     
    16571650    }
    16581651    if (b_res == bCancel) {
    1659         memcpy((void *) raidrec, (void *) bkp_raidrec,
    1660                sizeof(struct raid_device_record));
     1652        memcpy((void *) raidrec, (void *) bkp_raidrec, sizeof(struct raid_device_record));
    16611653    }
    16621654    newtPopHelpLine();
    16631655    newtPopWindow();
    1664     mountlist->el[currline].size =
    1665         calculate_raid_device_size(mountlist, raidlist,
    1666                                    raidrec->raid_device);
     1656    mountlist->el[currline].size = calculate_raid_device_size(mountlist, raidlist, raidrec->raid_device);
    16671657    paranoid_free(title_of_editraidForm_window);
    16681658    paranoid_free(sz_raid_level);
     
    18731863
    18741864if (b_res == bCancel) {
    1875     memcpy((void *) raidrec, (void *) &bkp_raidrec,
    1876            sizeof(struct vinum_plex));
     1865    memcpy((void *) raidrec, (void *) &bkp_raidrec, sizeof(struct vinum_plex));
    18771866}
    18781867newtPopWindow();
Note: See TracChangeset for help on using the changeset viewer.