Ignore:
Timestamp:
Mar 7, 2024, 1:33:54 AM (2 months ago)
Author:
Bruno Cornec
Message:

Fix build_partition_name to allocate dynamically and change proto accordingly

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3.3/mondo/src/mondorestore/mondo-prep.c

    r3741 r3859  
    13231323
    13241324/** buffers *********************************************************/
    1325 char *device_str;
     1325char *device_str = NULL;
    13261326char *format = NULL;
    13271327char *tmp = NULL;
     
    13511351#endif
    13521352
    1353 malloc_string(device_str);
    1354 
    13551353for (current_devno = 1; current_devno < 99; current_devno++) {
    1356     build_partition_name(device_str, drivename, current_devno);
     1354    device_str = build_partition_name(drivename, current_devno);
    13571355    lino = find_device_in_mountlist(mountlist, device_str);
    13581356
     
    13771375                                                 drivename,
    13781376                                                 0);
    1379                     char command[MAX_STR_LEN];
    1380                     sprintf(command, "disklabel -B %s",
    1381                             basename(drivename));
     1377                    mr_asprintf(command, "disklabel -B %s", basename(drivename));
    13821378                    if (system(command)) {
    13831379                        log_to_screen
    13841380                            ("Warning! Unable to make the drive bootable.");
    13851381                    }
    1386                     paranoid_free(device_str);
     1382                    mr_free(command);
     1383                    mr_free(device_str);
    13871384                    return r;
    13881385                }
    13891386            }
    13901387            for (c = 'a'; c <= 'z'; c++) {
    1391                 mr_assprintf(subdev_str, "%s%c", device_str, c);
     1388                mr_asprintf(subdev_str, "%s%c", device_str, c);
    13921389                if (find_device_in_mountlist(mountlist, subdev_str) > 0) {
    13931390                    fbsd_part = TRUE;
     
    14691466        if (current_devno == 5 && previous_devno == 4) {
    14701467            log_to_screen("You must leave at least one partition spare as the Extended partition.");
    1471             paranoid_free(device_str);
     1468            mr_free(device_str);
    14721469            mr_free(format);
    14731470            return (1);
     
    14921489
    14931490    previous_devno = current_devno;
     1491    mr_free(device_str);
    14941492}
    14951493
     
    15291527    }
    15301528}
    1531 paranoid_free(device_str);
    15321529return (retval);
    15331530}
     
    15501547/** buffers **********************************************************/
    15511548char *program = NULL;
    1552 char *partition_name;
     1549char *partition_name = NULL;
    15531550char *tmp = NULL;
    15541551char *output = NULL;
     
    15701567}
    15711568
    1572 malloc_string(partition_name);
    1573 build_partition_name(partition_name, drive, partno);
     1569partition_name = build_partition_name(drive, partno);
    15741570if (partsize <= 0) {
    15751571    mr_asprintf(tmp, "Partitioning device %s (max size)", partition_name);
     
    15831579if (is_this_device_mounted(partition_name)) {
    15841580    log_to_screen("%s is mounted, and should not be partitioned", partition_name);
    1585     paranoid_free(partition_name);
     1581    mr_free(partition_name);
    15861582    return (1);
    15871583}
     
    16031599            if (prev_partno >= 4) {
    16041600                log_to_screen("You need to leave at least one partition free, for 'extended/logical'");
    1605                 paranoid_free(partition_name);
     1601                mr_free(partition_name);
    16061602                paranoid_free(output);
    16071603                return (1);
     
    17121708mr_free(program);
    17131709mr_free(output);
     1710mr_free(partition_name);
    17141711
    17151712g_current_progress++;
    17161713log_it("partition_device() --- leaving");
    1717 paranoid_free(partition_name);
    17181714return (retval);
    17191715}
     
    18041800
    18051801/** buffers *********************************************************/
    1806 char *partition;
     1802char *partition = NULL;
    18071803char *command = NULL;
    18081804char *output = NULL;
     
    18211817assert(format != NULL);
    18221818
    1823 malloc_string(partition);
    1824 
    1825 build_partition_name(partition, drive, partno);
     1819partition = build_partition_name(drive, partno);
    18261820if (strcmp(format, "swap") == 0) {
    18271821    mr_asprintf(partcode, "82");
     
    18721866}
    18731867log_msg(1, "Setting %s's type to %s (%s)", partition, format, partcode);
     1868mr_free(partition);
     1869
    18741870if ((strcmp(partcode,"") != 0) && strcmp(partcode, "83")) { /* no need to set type if 83: 83 is default */
    18751871
     
    19251921}
    19261922mr_free(partcode);
    1927 
    1928 paranoid_free(partition);
    19291923
    19301924return (res);
Note: See TracChangeset for help on using the changeset viewer.