Ignore:
Timestamp:
Sep 25, 2013, 8:55:43 AM (11 years ago)
Author:
Bruno Cornec
Message:
  • Modification to 3.1 branch to make it extremely similar to 3.0. What remains are function rewrite with allocation in the function and desallocation outside of the function. Will be next step
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3.1/mondo/src/common/libmondo-string.c

    r3147 r3190  
    141141
    142142
    143 
    144 
    145 
    146 
    147 
    148 
    149 
    150143/**
    151144 * Turn an entry from the RAID editor's disklist into a GUI-friendly string.
     
    186179    long outval;
    187180    int i;
    188     char *tmp1 = NULL;
     181    char *tmp = NULL;
    189182    char ch;
    190183
     
    198191    }
    199192
    200     mr_asprintf(tmp1, "%s", incoming);
    201     i = (int) strlen(tmp1);
    202     if (tmp1[i - 1] == 'B' || tmp1[i - 1] == 'b') {
    203         tmp1[i - 1] = '\0';
    204     }
    205     for (i = 0; i < (int) strlen(tmp1) && isdigit(tmp1[i]); i++);
    206     ch = tmp1[i];
    207     tmp1[i] = '\0';
    208     outval = atol(tmp1);
    209     paranoid_free(tmp1);
     193    mr_asprintf(tmp, "%s", incoming);
     194    i = (int) strlen(tmp);
     195    if (tmp[i - 1] == 'B' || tmp[i - 1] == 'b') {
     196        tmp[i - 1] = '\0';
     197    }
     198    for (i = 0; i < (int) strlen(tmp) && isdigit(tmp[i]); i++);
     199    ch = tmp[i];
     200    tmp[i] = '\0';
     201    outval = atol(tmp);
     202    mr_free(tmp);
    210203
    211204    if (ch == 'g' || ch == 'G') {
     
    224217        fatal_error("Integer overflow.");
    225218    } else if (ch != 'm' && ch != 'M') {
    226         mr_asprintf(tmp1, "Re: parameter '%s' - bad multiplier ('%c')", incoming, ch);
    227         fatal_error(tmp1);
     219        mr_asprintf(tmp, "Re: parameter '%s' - bad multiplier ('%c')", incoming, ch);
     220        fatal_error(tmp);
    228221    }
    229222    return (outval);
     
    10431036    assert(bkpinfo != NULL);
    10441037
    1045     if (bkpinfo->media_size[g_current_media_number] <= 0) {
     1038    if (bkpinfo->media_size <= 0) {
    10461039        mr_asprintf(tmp, "%lld", g_tape_posK);
    10471040        mr_asprintf(pos_w_commas, "%s", commarize(tmp));
     
    10521045    }
    10531046
    1054 /* update screen */
     1047    /* update screen */
    10551048    if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) {
    1056         percentage =
    1057             (int) (g_tape_posK / 10 /
    1058                    bkpinfo->media_size[g_current_media_number]);
     1049        percentage = (int) (g_tape_posK / 10 / bkpinfo->media_size);
    10591050        if (percentage > 100) {
    10601051            percentage = 100;
     
    10621053        mr_asprintf(outstr, "Volume %d: [", g_current_media_number);
    10631054    } else {
    1064         percentage =
    1065             (int) (space_occupied_by_cd(bkpinfo->scratchdir) * 100 / 1024 /
    1066                    bkpinfo->media_size[g_current_media_number]);
     1055        percentage = (int) (space_occupied_by_cd(bkpinfo->scratchdir) * 100 / 1024 / bkpinfo->media_size);
    10671056        mds = media_descriptor_string(bkpinfo->backup_media_type);
    10681057        mr_asprintf(outstr, "%s %d: [", mds, g_current_media_number);
Note: See TracChangeset for help on using the changeset viewer.