Ignore:
Timestamp:
Aug 31, 2006, 5:09:20 PM (18 years ago)
Author:
Bruno Cornec
Message:
  • Massive rewrite continues for memory management.
  • main structure should now have all parameters allocated dynamically
  • new lib libmr.a + dir + build process reviewed to support it.
  • new include subdir to host external definitions of the new lib
  • code now compiles. Still one remaining link issues for mondorestore. This should allow for some tests soon.

(goal is to separate completely reviewed code and functions and provide clean interfaces)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/mondo/mondo/mondorestore/mondo-rstr-newt.c

    r764 r783  
    537537    char *personalities = NULL;
    538538    char *prompt = NULL;
    539     char *sz = NULL;
    540539    int out = 0, res = 0;
    541540
     
    544543    system
    545544        ("grep Pers /proc/mdstat > /tmp/raid-personalities.txt 2> /dev/null");
    546     personalities = last_line_of_file("/tmp/raid-personalities.txt"));
     545    personalities = last_line_of_file("/tmp/raid-personalities.txt");
    547546    asprintf(&prompt, _("Please enter the RAID level you want. %s"),
    548547             personalities);
     
    616615    int i = 0;
    617616    int pos = 0;
    618 
    619     /** buffers ***********************************************************/
    620     char *tmp = NULL;
    621617
    622618    assert(mountlist != NULL);
     
    858854            popup_and_OK(tmp);
    859855        } else {
     856            paranoid_free(av->el[lino].label);
     857            paranoid_free(av->el[lino].value);
    860858            memcpy((void *) &av->el[lino], (void *) &av->el[av->entries--],
    861859                   sizeof(struct raid_var_line));
     860            /* BERLIOS: New way of doing should be replaced by line below. Hope it's ok.
     861             * Will be when memory for struct is also dynamically allocated
     862            av->el[lino] = av->el[av->entries--];
     863                   */
    862864        }
    863865    }
     
    13231325                                                 device);
    13241326                if (j < 0) {
    1325                     sprintf(tmp,
     1327                    asprintf(&tmp,
    13261328                            _
    13271329                            ("/etc/raidtab does not have an entry for %s; please delete it and add it again"),
    13281330                            mountlist->el[currline].device);
    13291331                    popup_and_OK(tmp);
     1332                    paranoid_free(tmp);
    13301333                } else {
    13311334                    log_it(_("edit_raidlist_entry - calling"));
     
    14991502
    15001503    void *keylist[10];
    1501     void *curr_choice;
     1504    void *curr_choice = NULL;
    15021505
    15031506    int currline2 = 0;
     
    19711974            raidrec->additional_vars.el[lino].label, sz_out);
    19721975    if (popup_and_get_string(header, comment, sz_out)) {
    1973         strcpy(raidrec->additional_vars.el[lino].value, sz_out);
     1976        paranoid_free(raidrec->additional_vars.el[lino].value);
     1977        raidrec->additional_vars.el[lino].value = sz_out;
    19741978    }
    19751979    paranoid_free(header);
    19761980    paranoid_free(comment);
    1977     paranoid_free(sz_out);
    19781981}
    19791982#endif
     
    20152018    int currline = 0;
    20162019    int finished = FALSE;
     2020    int res = 0;
    20172021
    20182022    /** buffers **********************************************************/
     
    20252029    assert(raidlist != NULL);
    20262030
    2027     asprintf(&flaws_str_A, "xxxxxxxxx");
    2028     asprintf(&flaws_str_B, "xxxxxxxxx");
    2029     asprintf(&flaws_str_C, "xxxxxxxxx");
    20302031    if (mountlist->entries > ARBITRARY_MAXIMUM) {
    20312032        log_to_screen(_("Arbitrary limits suck, man!"));
     
    20452046            _("Format"), _("Size (MB)"));
    20462047    headerMsg = newtLabel(2, 1, tmp);
    2047     flawsLabelA = newtLabel(2, 13, flaws_str_A);
    2048     flawsLabelB = newtLabel(2, 14, flaws_str_B);
    2049     flawsLabelC = newtLabel(2, 15, flaws_str_C);
     2048    flawsLabelA = newtLabel(2, 13, "x");
     2049    flawsLabelB = newtLabel(2, 14, "x");
     2050    flawsLabelC = newtLabel(2, 15, "x");
    20502051    partitionsListbox =
    20512052        newtListbox(2, 2, 10, NEWT_FLAG_SCROLL | NEWT_FLAG_RETURNEXIT);
     
    20572058                          bEdit, bDelete, bReload, bCancel, bOK, NULL);
    20582059    while (!finished) {
    2059         evaluate_mountlist(mountlist, flaws_str_A, flaws_str_B,
     2060        res = evaluate_mountlist(mountlist, flaws_str_A, flaws_str_B,
    20602061                           flaws_str_C);
    20612062        newtLabelSetText(flawsLabelA, flaws_str_A);
    20622063        newtLabelSetText(flawsLabelB, flaws_str_B);
    20632064        newtLabelSetText(flawsLabelC, flaws_str_C);
     2065
     2066        paranoid_free(flaws_str_A);
     2067        paranoid_free(flaws_str_B);
     2068        paranoid_free(flaws_str_C);
     2069
    20642070        b_res = newtRunForm(myForm);
    20652071        /* BERLIOS: This needs to be re-written */
    20662072        if (b_res == bOK) {
    2067             if (!evaluate_mountlist
    2068                 (mountlist, flaws_str_A, flaws_str_B, flaws_str_C)) {
     2073            if (!res) {
    20692074                finished =
    20702075                    ask_me_yes_or_no
     
    21132118            }
    21142119        }
    2115         paranoid_free(flaws_str_A);
    2116         paranoid_free(flaws_str_B);
    2117         paranoid_free(flaws_str_C);
    21182120    }
    21192121    newtFormDestroy(myForm);
     
    24132415    raidrec = &raidlist->el[pos_in_raidlist];
    24142416    initialize_raidrec(raidrec);
    2415     strcpy(raidrec->OSSWAP(raid_device, volname),
     2417    asprintf(&raidrec->OSSWAP(raid_device, volname),
    24162418           OSSWAP(device, basename(device)));
    24172419#ifndef __FreeBSD__
     
    26472649                   (void *) &raidrec->additional_vars.el[i],
    26482650                   sizeof(struct raid_var_line));
     2651            /* BERLIOS : To be changed */
    26492652        }
    26502653        raidrec->additional_vars.entries--;
Note: See TracChangeset for help on using the changeset viewer.