Changeset 3289 for branches/3.2


Ignore:
Timestamp:
May 6, 2014, 10:24:14 AM (5 years ago)
Author:
bruno
Message:
  • change function number_of_disks_as_string into one returning a dynamically allocates tring
Location:
branches/3.2/mondo/src
Files:
2 edited

Legend:

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

    r3288 r3289  
    381381 * there will be a weird double space in the middle, so pass *something*.
    382382 * @return The string containing "X blah blah disk(s)".
    383  * @note The returned string points to static storage and will be overwritten with each call.
     383 * @note The returned string is dynamically allocated and should be freed by caller
    384384 */
    385385char *number_of_disks_as_string(int noof_disks, char *label)
    386386{
    387387
    388     /*@ buffers ********************************************************* */
    389     static char output[MAX_STR_LEN];
    390 
    391     /*@ char     ******************************************************** */
    392     char p;
    393 
    394     assert(label != NULL);
    395 
    396     if (noof_disks > 1) {
    397         p = 's';
    398     } else {
    399         p = ' ';
    400     }
    401     sprintf(output, "%d %s disk%c", noof_disks, label, p);
    402     while (strlen(output) < 14) {
    403         strcat(output, " ");
    404     }
    405     return (output);
     388/*@ buffers ********************************************************* */
     389char *output = NULL;
     390
     391/*@ char     ******************************************************** */
     392char p;
     393
     394assert(label != NULL);
     395
     396if (noof_disks > 1) {
     397    p = 's';
     398} else {
     399    p = ' ';
     400}
     401mr_asprintf(output, "%d %s disk%c", noof_disks, label, p);
     402/* Useful ??
     403while (strlen(output) < 14) {
     404    strcat(output, " ");
     405}
     406*/
     407return (output);
    406408}
    407409
  • branches/3.2/mondo/src/mondorestore/mondo-rstr-newt.c

    r3236 r3289  
    15811581        mr_asprintf(title_of_editraidForm_window, "Edit %s", raidrec->raid_device);
    15821582        mr_asprintf(sz_raid_level, "%s", turn_raid_level_number_to_string(raidrec->raid_level));
    1583         mr_asprintf(sz_data_disks, "%s", number_of_disks_as_string(raidrec->data_disks.entries, "data"));
    1584         mr_asprintf(sz_spare_disks, "%s", number_of_disks_as_string(raidrec->spare_disks.entries, "spare"));
    1585         mr_asprintf(sz_parity_disks, "%s", number_of_disks_as_string(raidrec->parity_disks.entries, "parity"));
    1586         mr_asprintf(sz_failed_disks, "%s", number_of_disks_as_string(raidrec->failed_disks.entries, "failed"));
     1583        sz_data_disks = number_of_disks_as_string(raidrec->data_disks.entries, "data");
     1584        sz_spare_disks = number_of_disks_as_string(raidrec->spare_disks.entries, "spare");
     1585        sz_parity_disks = number_of_disks_as_string(raidrec->parity_disks.entries, "parity");
     1586        sz_failed_disks = number_of_disks_as_string(raidrec->failed_disks.entries, "failed");
    15871587        bSelectData = newtButton(1, 1, sz_data_disks);
    15881588        bSelectSpare = newtButton(20, 1, sz_spare_disks);
Note: See TracChangeset for help on using the changeset viewer.