Changeset 900 in MondoRescue for trunk


Ignore:
Timestamp:
Oct 24, 2006, 8:49:18 AM (17 years ago)
Author:
Bruno Cornec
Message:

Huge patch to introduce low level functions that will bw used everywhere (mr_free, mr_asprintf, ...)
Nearly linking now due to that.

Location:
trunk
Files:
8 added
1 deleted
43 edited
2 moved

Legend:

Unmodified
Added
Removed
  • trunk/mondo-doc/Makefile.man

    r588 r900  
    3838
    3939%.8.ps: %.8
    40     @man2dvi ./$< > $<.dvi
    41     @dvips -q $<.dvi -o $@
    42     @rm -f $<.dvi
     40    @groff -Tps -mandoc ./$< > $@
    4341
    4442%.8.pdf: %.8.ps
  • trunk/mondo/src/common/libmondo-archive.c

    r815 r900  
    99 * This is the main file (at least the longest one) in libmondo.
    1010 */
     11#include <sys/sem.h>
     12#include <sys/types.h>
     13#include <sys/ipc.h>
     14#include <stdarg.h>
     15#include <unistd.h>
    1116
    1217#include "my-stuff.h"
    1318#include "../common/mondostructures.h"
    1419#include "mr_conf.h"
     20#include "mr_mem.h"
     21#include "mr_err.h"
     22
    1523#include "libmondo-string-EXT.h"
    1624#include "libmondo-stream-EXT.h"
     
    2432#include "libmondo-verify-EXT.h"
    2533#include "libmondo-archive.h"
    26 #include <sys/sem.h>
    27 #include <sys/types.h>
    28 #include <sys/ipc.h>
    29 #include <stdarg.h>
    30 #include <unistd.h>
    3134#define DVDRWFORMAT 1
    3235
     
    201204
    202205    if (!does_file_exist(filelist)) {
    203         asprintf(&tmp,
     206        mr_asprintf(&tmp,
    204207                 "(archive_this_fileset) - filelist %s does not exist",
    205208                 filelist);
    206209        log_to_screen(tmp);
    207         paranoid_free(tmp);
     210        mr_free(tmp);
    208211        return (1);
    209212    }
    210213
    211     asprintf(&tmp, "echo hi > %s 2> /dev/null", fname);
     214    mr_asprintf(&tmp, "echo hi > %s 2> /dev/null", fname);
    212215    if (system(tmp)) {
    213216        fatal_error("Unable to write tarball to scratchdir");
    214217    }
    215     paranoid_free(tmp);
    216 
    217     asprintf(&command, "star H=star list=%s -c " STAR_ACL_SZ " file=%s",
     218    mr_free(tmp);
     219
     220    mr_asprintf(&command, "star H=star list=%s -c " STAR_ACL_SZ " file=%s",
    218221             filelist, fname);
    219222    if (bkpinfo->use_lzo) {
     
    221224    }
    222225    if (bkpinfo->compression_level > 0) {
    223         asprintf(&tmp, "%s -bz", command);
    224         paranoid_free(command);
     226        mr_asprintf(&tmp, "%s -bz", command);
     227        mr_free(command);
    225228        command = tmp;
    226229    }
    227     asprintf(&tmp, "%s 2>> %s", command, MONDO_LOGFILE);
    228     paranoid_free(command);
     230    mr_asprintf(&tmp, "%s 2>> %s", command, MONDO_LOGFILE);
     231    mr_free(command);
    229232    command = tmp;
    230233    log_msg(4, "command = '%s'", command);
     
    241244            res = 0;
    242245        }
    243         paranoid_free(tmp);
     246        mr_free(tmp);
    244247        if (res) {
    245248            log_OS_error(command);
     
    256259        }
    257260    }
    258     paranoid_free(command);
     261    mr_free(command);
    259262
    260263    retval += res;
     
    314317
    315318    if (!does_file_exist(filelist)) {
    316         asprintf(&tmp,
     319        mr_asprintf(&tmp,
    317320                 "(archive_this_fileset) - filelist %s does not exist",
    318321                 filelist);
    319322        log_to_screen(tmp);
    320         paranoid_free(tmp)
     323        mr_free(tmp);
    321324            return (1);
    322325    }
    323     asprintf(&tmp, "echo hi > %s 2> /dev/null", fname);
     326    mr_asprintf(&tmp, "echo hi > %s 2> /dev/null", fname);
    324327    if (system(tmp)) {
    325328        fatal_error("Unable to write tarball to scratchdir");
    326329    }
    327     paranoid_free(tmp)
     330    mr_free(tmp);
    328331
    329332
    330333    if (bkpinfo->compression_level > 0) {
    331         asprintf(&tmp, "%s/do-not-compress-these", g_mondo_home);
     334        mr_asprintf(&tmp, "%s/do-not-compress-these", g_mondo_home);
    332335        //       -b %ld, TAPE_BLOCK_SIZE
    333         asprintf(&zipparams, "-Z -P %s -G %d -T 3k", bkpinfo->zip_exe,
     336        mr_asprintf(&zipparams, "-Z -P %s -G %d -T 3k", bkpinfo->zip_exe,
    334337                 bkpinfo->compression_level);
    335338        if (does_file_exist(tmp)) {
    336             asprintf(&tmp1, "%s -E %s", zipparams, tmp);
    337             paranoid_free(zipparams)
     339            mr_asprintf(&tmp1, "%s -E %s", zipparams, tmp);
     340            mr_free(zipparams);
    338341            zipparams = tmp1;
    339342        } else {
    340             asprintf(&zipparams, " ");
     343            mr_asprintf(&zipparams, " ");
    341344            log_msg(3, "%s not found. Cannot exclude zipfiles, etc.", tmp);
    342345        }
    343         paranoid_free(tmp)
     346        mr_free(tmp);
    344347    } else {
    345         asprintf(&zipparams, " ");
     348        mr_asprintf(&zipparams, " ");
    346349    }
    347350
     
    356359        fatal_error("scratchdir not found");
    357360    }
    358     asprintf(&command, "rm -f %s %s. %s.gz %s.%s", fname, fname, fname,
     361    mr_asprintf(&command, "rm -f %s %s. %s.gz %s.%s", fname, fname, fname,
    359362             fname, bkpinfo->zip_suffix);
    360363    paranoid_system(command);
    361     paranoid_free(command);
    362 
    363     asprintf(&command, "afio -o -b %ld -M 16m %s %s < %s 2>> %s",
     364    mr_free(command);
     365
     366    mr_asprintf(&command, "afio -o -b %ld -M 16m %s %s < %s 2>> %s",
    364367             TAPE_BLOCK_SIZE, zipparams, fname, filelist, MONDO_LOGFILE);
    365     paranoid_free(zipparams);
    366 
    367     asprintf(&tmp, "echo hi > %s 2> /dev/null", fname);
     368    mr_free(zipparams);
     369
     370    mr_asprintf(&tmp, "echo hi > %s 2> /dev/null", fname);
    368371    if (system(tmp)) {
    369372        fatal_error("Unable to write tarball to scratchdir");
    370373    }
    371     paranoid_free(tmp);
     374    mr_free(tmp);
    372375
    373376    for (res = 99, tries = 0; tries < 3 && res != 0; tries++) {
     
    382385        }
    383386    }
    384     paranoid_free(command);
     387    mr_free(command);
    385388
    386389    retval += res;
     
    396399                 ("df -m -P | grep dev/shm | grep -v none | tr -s ' ' '\t' | cut -f4");
    397400        i = atoi(tmp);
    398         paranoid_free(tmp);
     401        mr_free(tmp);
    399402
    400403        if (i > 0) {
     
    440443                ("Cannot find dvd+rw-format. Please install it or fix your PATH.");
    441444        }
    442         paranoid_free(tmp);
     445        mr_free(tmp);
    443446#endif
    444447        tmp = find_home_of_exe("growisofs");
     
    447450                ("Cannot find growisofs. Please install it or fix your PATH.");
    448451        }
    449         paranoid_free(tmp);
     452        mr_free(tmp);
    450453    }
    451454
     
    458461
    459462/*
    460       asprintf(&tmp, "wc -l %s/archives/filelist.full > %s/archives/filelist.count",bkpinfo->scratchdir, bkpinfo->scratchdir);
     463      mr_asprintf(&tmp, "wc -l %s/archives/filelist.full > %s/archives/filelist.count",bkpinfo->scratchdir, bkpinfo->scratchdir);
    461464      if (run_program_and_log_output(tmp, 2))
    462465        { fatal_error("Failed to count filelist.full"); }
    463466*/
    464     asprintf(&tmp, "gzip -9 %s/archives/filelist.full",
     467    mr_asprintf(&tmp, "gzip -9 %s/archives/filelist.full",
    465468             bkpinfo->scratchdir);
    466469    if (run_program_and_log_output(tmp, 2)) {
    467470        fatal_error("Failed to gzip filelist.full");
    468471    }
    469     paranoid_free(tmp);
    470     asprintf(&tmp, "cp -f %s/archives/*list*.gz %s", bkpinfo->scratchdir,
     472    mr_free(tmp);
     473    mr_asprintf(&tmp, "cp -f %s/archives/*list*.gz %s", bkpinfo->scratchdir,
    471474             bkpinfo->tmpdir);
    472475    if (run_program_and_log_output(tmp, 2)) {
    473476        fatal_error("Failed to copy to tmpdir");
    474477    }
    475     paranoid_free(tmp);
     478    mr_free(tmp);
    476479
    477480    copy_mondo_and_mindi_stuff_to_scratchdir(bkpinfo);  // payload, too, if it exists
    478481#if __FreeBSD__ == 5
    479     paranoid_alloc(bkpinfo->kernel_path, "/boot/kernel/kernel");
     482    mr_allocstr(bkpinfo->kernel_path, "/boot/kernel/kernel");
    480483#elif __FreeBSD__ == 4
    481     paranoid_alloc(bkpinfo->kernel_path, "/kernel");
     484    mr_allocstr(bkpinfo->kernel_path, "/kernel");
    482485#elif linux
    483486    if (figure_out_kernel_path_interactively_if_necessary
     
    493496    }
    494497    retval += do_that_initial_phase(bkpinfo);   // prepare
    495     asprintf(&tmp, "rm -f %s/images/*.iso", bkpinfo->scratchdir);
     498    mr_asprintf(&tmp, "rm -f %s/images/*.iso", bkpinfo->scratchdir);
    496499    run_program_and_log_output(tmp, 1);
    497     paranoid_free(tmp);
     500    mr_free(tmp);
    498501    retval += make_those_slices_phase(bkpinfo); // backup BIG files
    499502    retval += do_that_final_phase(bkpinfo); // clean up
     
    564567    assert(bkpinfo != NULL);
    565568
    566     asprintf(&tmp,
     569    mr_asprintf(&tmp,
    567570             "echo '%s' | tr -s ' ' '\n' | grep -x '/dev/.*' | tr -s '\n' ' ' | awk '{print $0\"\\n\";}'",
    568571             bkpinfo->exclude_paths);
    569572    devs_to_exclude = call_program_and_get_last_line_of_output(tmp);
    570     paranoid_free(tmp);
    571     asprintf(&tmp, "devs_to_exclude = '%s'", devs_to_exclude);
     573    mr_free(tmp);
     574    mr_asprintf(&tmp, "devs_to_exclude = '%s'", devs_to_exclude);
    572575    log_msg(2, tmp);
    573     paranoid_free(tmp);
     576    mr_free(tmp);
    574577    mvaddstr_and_log_it(g_currentY, 0,
    575578                        "Calling MINDI to create boot+data disks");
    576     asprintf(&tmp, "%s/filelist.full", bkpinfo->tmpdir);
     579    mr_asprintf(&tmp, "%s/filelist.full", bkpinfo->tmpdir);
    577580    if (!does_file_exist(tmp)) {
    578         paranoid_free(tmp);
    579         asprintf(&tmp, "%s/tmpfs/filelist.full", bkpinfo->tmpdir);
     581        mr_free(tmp);
     582        mr_asprintf(&tmp, "%s/tmpfs/filelist.full", bkpinfo->tmpdir);
    580583        if (!does_file_exist(tmp)) {
    581584            fatal_error
     
    584587    }
    585588    lines_in_filelist = count_lines_in_file(tmp);
    586     paranoid_free(tmp);
    587     asprintf(&tmp, "%s/LAST-FILELIST-NUMBER", bkpinfo->tmpdir);
     589    mr_free(tmp);
     590    mr_asprintf(&tmp, "%s/LAST-FILELIST-NUMBER", bkpinfo->tmpdir);
    588591    last_filelist_number = last_line_of_file(tmp);
    589     paranoid_free(tmp);
     592    mr_free(tmp);
    590593    if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) {
    591         asprintf(&tape_size_sz, "%ld", bkpinfo->media_size[1]);
    592         asprintf(&tape_device, bkpinfo->media_device);
     594        mr_asprintf(&tape_size_sz, "%ld", bkpinfo->media_size[1]);
     595        mr_asprintf(&tape_device, bkpinfo->media_device);
    593596    } else {
    594         asprintf(&tape_size_sz, " ");
    595         asprintf(&tape_device, " ");
     597        mr_asprintf(&tape_size_sz, " ");
     598        mr_asprintf(&tape_device, " ");
    596599    }
    597600    if (bkpinfo->use_lzo) {
    598         asprintf(&use_lzo_sz, "yes");
     601        mr_asprintf(&use_lzo_sz, "yes");
    599602    } else {
    600         asprintf(&use_lzo_sz, "no");
     603        mr_asprintf(&use_lzo_sz, "no");
    601604    }
    602605    if (bkpinfo->use_star) {
    603         asprintf(&use_star_sz, "yes");
     606        mr_asprintf(&use_star_sz, "yes");
    604607    } else {
    605         asprintf(&use_star_sz, "no");
     608        mr_asprintf(&use_star_sz, "no");
    606609    }
    607610
    608611    if (bkpinfo->compression_level > 0) {
    609         asprintf(&use_comp_sz, "yes");
     612        mr_asprintf(&use_comp_sz, "yes");
    610613    } else {
    611         asprintf(&use_comp_sz, "no");
    612     }
    613 
    614     asprintf(&broken_bios_sz, "yes");   /* assume so */
     614        mr_asprintf(&use_comp_sz, "no");
     615    }
     616
     617    mr_asprintf(&broken_bios_sz, "yes");    /* assume so */
    615618    if (g_cd_recovery) {
    616         asprintf(&cd_recovery_sz, "yes");
     619        mr_asprintf(&cd_recovery_sz, "yes");
    617620    } else {
    618         asprintf(&cd_recovery_sz, "no");
     621        mr_asprintf(&cd_recovery_sz, "no");
    619622    }
    620623    /* Field shared between LILO/ELILO */
    621624    if (bkpinfo->make_cd_use_lilo) {
    622         asprintf(&use_lilo_sz, "yes");
     625        mr_asprintf(&use_lilo_sz, "yes");
    623626    } else {
    624         asprintf(&use_lilo_sz, "no");
     627        mr_asprintf(&use_lilo_sz, "no");
    625628    }
    626629
     
    644647        }
    645648        if ((bootdev) && (strstr(bootdev, "/dev/cciss/"))) {
    646             paranoid_free(bootdev);
     649            mr_free(bootdev);
    647650            bootdev = call_program_and_get_last_line_of_output
    648651                     ("mount | grep ' /boot ' | head -1 | cut -d' ' -f1 | cut -dp -f1");
     
    655658
    656659        if (bkpinfo->boot_loader != '\0') {
    657             asprintf(&tmp, "User specified boot loader. It is '%c'.",
     660            mr_asprintf(&tmp, "User specified boot loader. It is '%c'.",
    658661                     bkpinfo->boot_loader);
    659662            log_msg(2, tmp);
    660             paranoid_free(tmp);
     663            mr_free(tmp);
    661664        } else {
    662665            bkpinfo->boot_loader = ch;
    663666        }
    664667        if (bkpinfo->boot_device != NULL) {
    665             asprintf(&tmp, "User specified boot device. It is '%s'.",
     668            mr_asprintf(&tmp, "User specified boot device. It is '%s'.",
    666669                     bkpinfo->boot_device);
    667670            log_msg(2, tmp);
    668             paranoid_free(tmp);
    669             paranoid_free(bootdev);
     671            mr_free(tmp);
     672            mr_free(bootdev);
    670673        } else {
    671674            bkpinfo->boot_device = bootdev;
     
    687690    }
    688691    if (bkpinfo->boot_loader == 'L') {
    689         asprintf(&bootldr_str, "LILO");
     692        mr_asprintf(&bootldr_str, "LILO");
    690693        if (!does_file_exist("/etc/lilo.conf")) {
    691694            fatal_error
     
    693696        }
    694697    } else if (bkpinfo->boot_loader == 'G') {
    695         asprintf(&bootldr_str, "GRUB");
     698        mr_asprintf(&bootldr_str, "GRUB");
    696699        if (!does_file_exist("/etc/grub.conf")
    697700            && does_file_exist("/boot/grub/grub.conf")) {
     
    710713        }
    711714    } else if (bkpinfo->boot_loader == 'E') {
    712         asprintf(&bootldr_str, "ELILO");
     715        mr_asprintf(&bootldr_str, "ELILO");
    713716        /* BERLIOS: fix it for SuSE, Debian, Mandrake, ... */
    714717        if (!does_file_exist("/etc/elilo.conf")
     
    723726        }
    724727    } else if (bkpinfo->boot_loader == 'R') {
    725         asprintf(&bootldr_str, "RAW");
     728        mr_asprintf(&bootldr_str, "RAW");
    726729    }
    727730#ifdef __FreeBSD__
    728731    else if (bkpinfo->boot_loader == 'D') {
    729         asprintf(&bootldr_str, "DD");
     732        mr_asprintf(&bootldr_str, "DD");
    730733    }
    731734
    732735    else if (bkpinfo->boot_loader == 'B') {
    733         asprintf(&bootldr_str, "BOOT0");
     736        mr_asprintf(&bootldr_str, "BOOT0");
    734737    }
    735738#endif
    736739    else {
    737         asprintf(&bootldr_str, "unknown");
    738     }
    739     asprintf(&tmp, "Your boot loader is %s and it boots from %s",
     740        mr_asprintf(&bootldr_str, "unknown");
     741    }
     742    mr_asprintf(&tmp, "Your boot loader is %s and it boots from %s",
    740743             bootldr_str, bkpinfo->boot_device);
    741744    log_to_screen(tmp);
    742     paranoid_free(tmp);
    743     asprintf(&tmp, "%s/BOOTLOADER.DEVICE", bkpinfo->tmpdir);
     745    mr_free(tmp);
     746    mr_asprintf(&tmp, "%s/BOOTLOADER.DEVICE", bkpinfo->tmpdir);
    744747    if (write_one_liner_data_file(tmp, bkpinfo->boot_device)) {
    745748        log_msg(1, "%ld: Unable to write one-liner boot device", __LINE__);
    746749    }
    747     paranoid_free(tmp);
     750    mr_free(tmp);
    748751    /* BERLIOS: Use bkptype_to_string without LANG */
    749752    switch (bkpinfo->backup_media_type) {
    750753    case cdr:
    751         asprintf(&value, "cdr");
     754        mr_asprintf(&value, "cdr");
    752755        break;
    753756    case cdrw:
    754         asprintf(&value, "cdrw");
     757        mr_asprintf(&value, "cdrw");
    755758        break;
    756759    case cdstream:
    757         asprintf(&value, "cdstream");
     760        mr_asprintf(&value, "cdstream");
    758761        break;
    759762    case tape:
    760         asprintf(&value, "tape");
     763        mr_asprintf(&value, "tape");
    761764        break;
    762765    case udev:
    763         asprintf(&value, "udev");
     766        mr_asprintf(&value, "udev");
    764767        break;
    765768    case iso:
    766         asprintf(&value, "iso");
     769        mr_asprintf(&value, "iso");
    767770        break;
    768771    case nfs:
    769         asprintf(&value, "nfs");
     772        mr_asprintf(&value, "nfs");
    770773        break;
    771774    case dvd:
    772         asprintf(&value, "dvd");
     775        mr_asprintf(&value, "dvd");
    773776        break;
    774777    default:
    775778        fatal_error("Unknown backup_media_type");
    776779    }
    777     asprintf(&tmp, "%s/BACKUP-MEDIA-TYPE", bkpinfo->tmpdir);
     780    mr_asprintf(&tmp, "%s/BACKUP-MEDIA-TYPE", bkpinfo->tmpdir);
    778781    if (write_one_liner_data_file(tmp, value)) {
    779782        res++;
     
    781784                __LINE__);
    782785    }
    783     paranoid_free(value);
    784     paranoid_free(tmp);
     786    mr_free(value);
     787    mr_free(tmp);
    785788    log_to_screen(bkpinfo->tmpdir);
    786     asprintf(&tmp, "%s/BOOTLOADER.NAME", bkpinfo->tmpdir);
     789    mr_asprintf(&tmp, "%s/BOOTLOADER.NAME", bkpinfo->tmpdir);
    787790    if (write_one_liner_data_file(tmp, bootldr_str)) {
    788791        res++;
     
    790793                __LINE__);
    791794    }
    792     paranoid_free(bootldr_str);
    793     paranoid_free(tmp);
    794     asprintf(&tmp, "%s/DIFFERENTIAL", bkpinfo->tmpdir);
     795    mr_free(bootldr_str);
     796    mr_free(tmp);
     797    mr_asprintf(&tmp, "%s/DIFFERENTIAL", bkpinfo->tmpdir);
    795798    if (bkpinfo->differential) {
    796799        res += write_one_liner_data_file(tmp, "1");
     
    798801        res += write_one_liner_data_file(tmp, "0");
    799802    }
    800     paranoid_free(tmp);
     803    mr_free(tmp);
    801804
    802805    estimated_total_noof_slices =
    803806        size_of_all_biggiefiles_K(bkpinfo) / bkpinfo->optimal_set_size + 1;
    804     asprintf(&command, "mkdir -p %s/images", bkpinfo->scratchdir);
     807    mr_asprintf(&command, "mkdir -p %s/images", bkpinfo->scratchdir);
    805808    if (system(command)) {
    806809        res++;
    807810        log_OS_error("Unable to make images directory");
    808811    }
    809     paranoid_free(command);
    810 
    811     asprintf(&command, "mkdir -p %s%s", bkpinfo->scratchdir, MNT_FLOPPY);
     812    mr_free(command);
     813
     814    mr_asprintf(&command, "mkdir -p %s%s", bkpinfo->scratchdir, MNT_FLOPPY);
    812815    if (system(command)) {
    813816        res++;
    814817        log_OS_error("Unable to make mnt floppy directory");
    815818    }
    816     paranoid_free(command);
    817 
    818     asprintf(&tmp, "BTW, I'm telling Mindi your kernel is '%s'",
     819    mr_free(command);
     820
     821    mr_asprintf(&tmp, "BTW, I'm telling Mindi your kernel is '%s'",
    819822             bkpinfo->kernel_path);
    820823    log_to_screen(tmp);
    821     paranoid_free(tmp);
     824    mr_free(tmp);
    822825
    823826    log_msg(1, "lines_in_filelist = %ld", lines_in_filelist);
     
    825828    // Watch it! This next line adds a parameter...
    826829    if (bkpinfo->nonbootable_backup) {
    827         asprintf(&tmp, " NONBOOTABLE");
     830        mr_asprintf(&tmp, " NONBOOTABLE");
    828831    } else {
    829         asprintf(&tmp, " ");
    830     }
    831 
    832     asprintf(&command,
     832        mr_asprintf(&tmp, " ");
     833    }
     834
     835    mr_asprintf(&command,
    833836/*     "mindi --custom 2=%s 3=%s/images 4=\"%s\" 5=\"%s\" \
    8348376=\"%s\" 7=%ld 8=\"%s\" 9=\"%s\" 10=\"%s\" \
     
    855858             bkpinfo->differential, // parameter #19 (INT)
    856859             tmp);
    857     paranoid_free(tmp);
    858     paranoid_free(tape_size_sz);
    859     paranoid_free(use_lzo_sz);
    860     paranoid_free(tape_device);
    861     paranoid_free(use_star_sz);
    862     paranoid_free(use_comp_sz);
    863     paranoid_free(broken_bios_sz);
    864     paranoid_free(cd_recovery_sz);
    865     paranoid_free(last_filelist_number);
    866     paranoid_free(devs_to_exclude);
    867     paranoid_free(use_lilo_sz);
     860    mr_free(tmp);
     861    mr_free(tape_size_sz);
     862    mr_free(use_lzo_sz);
     863    mr_free(tape_device);
     864    mr_free(use_star_sz);
     865    mr_free(use_comp_sz);
     866    mr_free(broken_bios_sz);
     867    mr_free(cd_recovery_sz);
     868    mr_free(last_filelist_number);
     869    mr_free(devs_to_exclude);
     870    mr_free(use_lilo_sz);
    868871
    869872    log_msg(2, command);
     
    872875    res = run_program_and_log_to_screen(command,
    873876                                        "Generating boot+data disks");
    874     paranoid_free(command);
     877    mr_free(command);
    875878
    876879    if (bkpinfo->nonbootable_backup) {
     
    879882    if (!res) {
    880883        log_to_screen("Boot+data disks were created OK");
    881         asprintf(&command, "mkdir -p /var/cache/mindi/");
     884        mr_asprintf(&command, "mkdir -p /var/cache/mindi/");
    882885        log_msg(2, command);
    883886        run_program_and_log_output(command, FALSE);
    884         paranoid_free(command);
    885 
    886         asprintf(&command,
     887        mr_free(command);
     888
     889        mr_asprintf(&command,
    887890                 "cp -f %s/images/mindi.iso /var/cache/mindi/mondorescue.iso",
    888891                 bkpinfo->scratchdir);
    889892        log_msg(2, command);
    890893        run_program_and_log_output(command, FALSE);
    891         paranoid_free(command);
     894        mr_free(command);
    892895
    893896        if (bkpinfo->nonbootable_backup) {
    894             asprintf(&command, "cp -f %s/all.tar.gz %s/images",
     897            mr_asprintf(&command, "cp -f %s/all.tar.gz %s/images",
    895898                     bkpinfo->tmpdir, bkpinfo->scratchdir);
    896899            if (system(command)) {
    897900                fatal_error("Unable to create temporary duff tarball");
    898                 paranoid_free(command);
    899             }
    900         }
    901         asprintf(&command, "cp -f %s/mindi-*oot*.img %s/images",
     901                mr_free(command);
     902            }
     903        }
     904        mr_asprintf(&command, "cp -f %s/mindi-*oot*.img %s/images",
    902905                 bkpinfo->tmpdir, bkpinfo->scratchdir);
    903906        log_msg(2, command);
    904907        run_program_and_log_output(command, FALSE);
    905         paranoid_free(command);
    906 
    907         asprintf(&tmp, "cp -f %s/images/all.tar.gz %s",
     908        mr_free(command);
     909
     910        mr_asprintf(&tmp, "cp -f %s/images/all.tar.gz %s",
    908911                 bkpinfo->scratchdir, bkpinfo->tmpdir);
    909912        if (system(tmp)) {
    910913            fatal_error("Cannot find all.tar.gz in tmpdir");
    911914        }
    912         paranoid_free(tmp);
     915        mr_free(tmp);
    913916
    914917        if (res) {
     
    919922    } else {
    920923        log_to_screen("Mindi failed to create your boot+data disks.");
    921         asprintf(&command, "grep 'Fatal error' /var/log/mindi.log");
     924        mr_asprintf(&command, "grep 'Fatal error' /var/log/mindi.log");
    922925        tmp = call_program_and_get_last_line_of_output(command);
    923         paranoid_free(command);
     926        mr_free(command);
    924927        if (strlen(tmp) > 1) {
    925928            popup_and_OK(tmp);
    926929        }
    927         paranoid_free(tmp);
     930        mr_free(tmp);
    928931    }
    929932    return (res);
     
    990993    bkpinfo = (struct s_bkpinfo *) (inbuf + BKPINFO_LOC_OFFSET);
    991994
    992     asprintf(&archiving_filelist_fname, FILELIST_FNAME_RAW_SZ,
     995    mr_asprintf(&archiving_filelist_fname, FILELIST_FNAME_RAW_SZ,
    993996             bkpinfo->tmpdir, 0L);
    994997    archiving_set_no = 0;
    995998    while (does_file_exist(archiving_filelist_fname)) {
    996         paranoid_free(archiving_filelist_fname);
     999        mr_free(archiving_filelist_fname);
    9971000        if (g_exiting) {
    9981001            fatal_error("Execution run aborted (pthread)");
     
    10151018
    10161019        /* backup this set of files */
    1017         asprintf(&archiving_afioball_fname, AFIOBALL_FNAME_RAW_SZ,
     1020        mr_asprintf(&archiving_afioball_fname, AFIOBALL_FNAME_RAW_SZ,
    10181021                 bkpinfo->tmpdir, archiving_set_no, bkpinfo->zip_suffix);
    1019         asprintf(&archiving_filelist_fname, FILELIST_FNAME_RAW_SZ,
     1022        mr_asprintf(&archiving_filelist_fname, FILELIST_FNAME_RAW_SZ,
    10201023                 bkpinfo->tmpdir, archiving_set_no);
    10211024        if (!does_file_exist(archiving_filelist_fname)) {
     
    10241027                    FORTY_SPACES, getpid(), this_thread_no,
    10251028                    archiving_set_no);
    1026             paranoid_free(archiving_filelist_fname);
    1027             paranoid_free(archiving_afioball_fname);
     1029            mr_free(archiving_filelist_fname);
     1030            mr_free(archiving_afioball_fname);
    10281031            break;
    10291032        }
    10301033
    1031         asprintf(&tmp, AFIOBALL_FNAME_RAW_SZ, bkpinfo->tmpdir,
     1034        mr_asprintf(&tmp, AFIOBALL_FNAME_RAW_SZ, bkpinfo->tmpdir,
    10321035                 archiving_set_no - ARCH_BUFFER_NUM, bkpinfo->zip_suffix);
    10331036        if (does_file_exist(tmp)) {
     
    10391042            log_msg(4, "[%d] - continuing", getpid());
    10401043        }
    1041         paranoid_free(tmp);
     1044        mr_free(tmp);
    10421045
    10431046        log_msg(4, "%s[%d:%d] - EXATing %d...", FORTY_SPACES, getpid(),
    10441047                this_thread_no, archiving_set_no);
    1045         asprintf(&curr_xattr_list_fname, XATTR_LIST_FNAME_RAW_SZ,
     1048        mr_asprintf(&curr_xattr_list_fname, XATTR_LIST_FNAME_RAW_SZ,
    10461049                 bkpinfo->tmpdir, archiving_set_no);
    1047         asprintf(&curr_acl_list_fname, ACL_LIST_FNAME_RAW_SZ,
     1050        mr_asprintf(&curr_acl_list_fname, ACL_LIST_FNAME_RAW_SZ,
    10481051                 bkpinfo->tmpdir, archiving_set_no);
    10491052        get_fattr_list(archiving_filelist_fname, curr_xattr_list_fname);
    1050         paranoid_free(curr_xattr_list_fname);
     1053        mr_free(curr_xattr_list_fname);
    10511054        get_acl_list(archiving_filelist_fname, curr_acl_list_fname);
    1052         paranoid_free(curr_acl_list_fname);
     1055        mr_free(curr_acl_list_fname);
    10531056
    10541057        log_msg(4, "%s[%d:%d] - archiving %d...", FORTY_SPACES, getpid(),
     
    10571060                                   archiving_afioball_fname,
    10581061                                   archiving_set_no);
    1059         paranoid_free(archiving_afioball_fname);
    1060         paranoid_free(archiving_filelist_fname);
     1062        mr_free(archiving_afioball_fname);
     1063        mr_free(archiving_filelist_fname);
    10611064        retval += res;
    10621065
    10631066        if (res) {
    1064             asprintf(&tmp,
     1067            mr_asprintf(&tmp,
    10651068                     "Errors occurred while archiving set %ld. Please review logs.",
    10661069                     archiving_set_no);
    10671070            log_to_screen(tmp);
    1068             paranoid_free(tmp);
     1071            mr_free(tmp);
    10691072        }
    10701073        if (!semaphore_p()) {
     
    10841087                this_thread_no, archiving_set_no);
    10851088        archiving_set_no++;
    1086         asprintf(&archiving_filelist_fname, FILELIST_FNAME_RAW_SZ,
     1089        mr_asprintf(&archiving_filelist_fname, FILELIST_FNAME_RAW_SZ,
    10871090                 bkpinfo->tmpdir, archiving_set_no);
    10881091    }
     
    10961099    log_msg(3, "%s[%d:%d] - exiting", FORTY_SPACES, getpid(),
    10971100            this_thread_no);
    1098     paranoid_free(archiving_filelist_fname);
     1101    mr_free(archiving_filelist_fname);
    10991102    pthread_exit(NULL);
    11001103}
     
    11781181
    11791182    assert(bkpinfo != NULL);
    1180     asprintf(&data_disks_file, "%s/all.tar.gz", bkpinfo->tmpdir);
     1183    mr_asprintf(&data_disks_file, "%s/all.tar.gz", bkpinfo->tmpdir);
    11811184
    11821185    g_serial_string = call_program_and_get_last_line_of_output("dd \
    11831186if=/dev/urandom bs=16 count=1 2> /dev/null | \
    11841187hexdump | tr -s ' ' '0' | head -n1");
    1185     asprintf(&tmp, "%s...word.", g_serial_string);
    1186     paranoid_free(g_serial_string);
     1188    mr_asprintf(&tmp, "%s...word.", g_serial_string);
     1189    mr_free(g_serial_string);
    11871190    g_serial_string = tmp;
    11881191    log_msg(2, "g_serial_string = '%s'", g_serial_string);
    11891192
    1190     asprintf(&tmpfile, "%s/archives/SERIAL-STRING", bkpinfo->scratchdir);
     1193    mr_asprintf(&tmpfile, "%s/archives/SERIAL-STRING", bkpinfo->scratchdir);
    11911194    if (write_one_liner_data_file(tmpfile, g_serial_string)) {
    11921195        log_msg(1, "%ld: Failed to write serial string", __LINE__);
    11931196    }
    1194     paranoid_free(g_serial_string);
    1195     paranoid_free(tmpfile);
     1197    mr_free(g_serial_string);
     1198    mr_free(tmpfile);
    11961199
    11971200    mvaddstr_and_log_it(g_currentY, 0, "Preparing to archive your data");
     
    12101213        log_msg(1, "Backing up to CD's");
    12111214    }
    1212     paranoid_free(data_disks_file);
    1213 
    1214     asprintf(&command, "rm -f %s/%s/%s-[1-9]*.iso", bkpinfo->isodir,
     1215    mr_free(data_disks_file);
     1216
     1217    mr_asprintf(&command, "rm -f %s/%s/%s-[1-9]*.iso", bkpinfo->isodir,
    12151218             bkpinfo->nfs_remote_dir, bkpinfo->prefix);
    12161219    paranoid_system(command);
    1217     paranoid_free(command);
     1220    mr_free(command);
    12181221    wipe_archives(bkpinfo->scratchdir);
    12191222    mvaddstr_and_log_it(g_currentY++, 74, "Done.");
     
    12741277/* if not Debian then go ahead & use fdformat */
    12751278    tempfile = call_program_and_get_last_line_of_output("mktemp -q /tmp/mondo.XXXXXXXX");
    1276     asprintf(&command, "%s >> %s 2>> %s; rm -f %s", cmd, tempfile,
     1279    mr_asprintf(&command, "%s >> %s 2>> %s; rm -f %s", cmd, tempfile,
    12771280             tempfile, tempfile);
    12781281    log_msg(3, command);
     
    12871290        maxtracks = 80;
    12881291    }
    1289     paranoid_free(command);
     1292    mr_free(command);
    12901293
    12911294    for (sleep(1); does_file_exist(tempfile); sleep(1)) {
     
    13091312    }
    13101313    unlink(tempfile);
    1311     paranoid_free(tempfile);
     1314    mr_free(tempfile);
    13121315    return (res);
    13131316}
     
    13381341    assert_string_is_neither_NULL_nor_zerolength(device);
    13391342    if (!system("which superformat > /dev/null 2> /dev/null")) {
    1340         asprintf(&command, "superformat %s", device);
     1343        mr_asprintf(&command, "superformat %s", device);
    13411344    } else {
    13421345#ifdef __FreeBSD__
    1343         asprintf(&command, "fdformat -y %s", device);
     1346        mr_asprintf(&command, "fdformat -y %s", device);
    13441347#else
    1345         asprintf(&command, "fdformat %s", device);
     1348        mr_asprintf(&command, "fdformat %s", device);
    13461349#endif
    13471350    }
    1348     asprintf(&title, "Formatting disk %s", device);
     1351    mr_asprintf(&title, "Formatting disk %s", device);
    13491352    while ((res = format_disk_SUB(command, title))) {
    13501353        if (!ask_me_yes_or_no("Failed to format disk. Retry?")) {
     
    13521355        }
    13531356    }
    1354     paranoid_free(title);
    1355     paranoid_free(command);
     1357    mr_free(title);
     1358    mr_free(command);
    13561359    return (res);
    13571360}
     
    15021505            /* maybe  */
    15031506            tmp = percent_media_full_comment(bkpinfo);
    1504             asprintf(&media_usage_comment, "%s", tmp);
    1505             paranoid_free(tmp);
     1507            mr_asprintf(&media_usage_comment, "%s", tmp);
     1508            mr_free(tmp);
    15061509            if (!misc_counter_that_is_not_important) {
    15071510                update_progress_form(media_usage_comment);
    15081511            }
    1509             paranoid_free(media_usage_comment);
     1512            mr_free(media_usage_comment);
    15101513            sleep(1);
    15111514        } else {
    15121515            // store set N
    1513             asprintf(&storing_filelist_fname, FILELIST_FNAME_RAW_SZ,
     1516            mr_asprintf(&storing_filelist_fname, FILELIST_FNAME_RAW_SZ,
    15141517                     bkpinfo->tmpdir, storing_set_no);
    1515             asprintf(&storing_afioball_fname, AFIOBALL_FNAME_RAW_SZ,
     1518            mr_asprintf(&storing_afioball_fname, AFIOBALL_FNAME_RAW_SZ,
    15161519                     bkpinfo->tmpdir, storing_set_no, bkpinfo->zip_suffix);
    1517             asprintf(&curr_xattr_list_fname, XATTR_LIST_FNAME_RAW_SZ,
     1520            mr_asprintf(&curr_xattr_list_fname, XATTR_LIST_FNAME_RAW_SZ,
    15181521                     bkpinfo->tmpdir, storing_set_no);
    1519             asprintf(&curr_acl_list_fname, ACL_LIST_FNAME_RAW_SZ,
     1522            mr_asprintf(&curr_acl_list_fname, ACL_LIST_FNAME_RAW_SZ,
    15201523                     bkpinfo->tmpdir, storing_set_no);
    15211524
     
    15291532            }
    15301533            tmp = percent_media_full_comment(bkpinfo);
    1531             asprintf(&media_usage_comment, "%s", tmp);
    1532             paranoid_free(tmp);
     1534            mr_asprintf(&media_usage_comment, "%s", tmp);
     1535            mr_free(tmp);
    15331536            /* copy to CD (scratchdir) ... and an actual CD-R if necessary */
    15341537            if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) {
     
    15521555                                     storing_afioball_fname, NULL);
    15531556            }
    1554             paranoid_free(storing_filelist_fname);
    1555             paranoid_free(storing_afioball_fname);
    1556             paranoid_free(curr_xattr_list_fname);
    1557             paranoid_free(curr_acl_list_fname);
     1557            mr_free(storing_filelist_fname);
     1558            mr_free(storing_afioball_fname);
     1559            mr_free(curr_xattr_list_fname);
     1560            mr_free(curr_acl_list_fname);
    15581561            retval += res;
    15591562            g_current_progress++;
    15601563            update_progress_form(media_usage_comment);
    1561             paranoid_free(media_usage_comment);
     1564            mr_free(media_usage_comment);
    15621565
    15631566            if (res) {
    1564                 asprintf(&tmp,
     1567                mr_asprintf(&tmp,
    15651568                         "Failed to add archive %ld's files to CD dir\n",
    15661569                         storing_set_no);
    15671570                log_to_screen(tmp);
    1568                 paranoid_free(tmp);
     1571                mr_free(tmp);
    15691572                fatal_error
    15701573                    ("Is your hard disk full? If not, please send the author the logfile.");
     
    15841587    log_msg(2, "Done.");
    15851588    if (retval) {
    1586         asprintf(&tmp,
     1589        mr_asprintf(&tmp,
    15871590                 "Your regular files have been archived (with errors).");
    15881591    } else {
    1589         asprintf(&tmp,
     1592        mr_asprintf(&tmp,
    15901593                 "Your regular files have been archived successfully");
    15911594    }
    15921595    log_to_screen(tmp);
    1593     paranoid_free(tmp);
    1594     paranoid_free(transfer_block);
    1595     paranoid_free(result_str);
     1596    mr_free(tmp);
     1597    mr_free(transfer_block);
     1598    mr_free(result_str);
    15961599    return (retval);
    15971600}
     
    16471650    assert_string_is_neither_NULL_nor_zerolength(destfile);
    16481651
    1649     asprintf(&tmp, "%s/isolinux.bin", bkpinfo->scratchdir);
    1650     asprintf(&tmp2, "%s/isolinux.bin", bkpinfo->tmpdir);
     1652    mr_asprintf(&tmp, "%s/isolinux.bin", bkpinfo->scratchdir);
     1653    mr_asprintf(&tmp2, "%s/isolinux.bin", bkpinfo->tmpdir);
    16511654    if (does_file_exist(tmp)) {
    1652         asprintf(&tmp3, "cp -f %s %s", tmp, tmp2);
     1655        mr_asprintf(&tmp3, "cp -f %s %s", tmp, tmp2);
    16531656        paranoid_system(tmp3);
    1654         paranoid_free(tmp3);
     1657        mr_free(tmp3);
    16551658    }
    16561659    if (!does_file_exist(tmp) && does_file_exist(tmp2)) {
    1657         asprintf(&tmp3, "cp -f %s %s", tmp2, tmp);
     1660        mr_asprintf(&tmp3, "cp -f %s %s", tmp2, tmp);
    16581661        paranoid_system(tmp3);
    1659         paranoid_free(tmp3);
    1660     }
    1661     paranoid_free(tmp2);
    1662     paranoid_free(tmp);
     1662        mr_free(tmp3);
     1663    }
     1664    mr_free(tmp2);
     1665    mr_free(tmp);
    16631666
    16641667    if (bkpinfo->backup_media_type == iso && bkpinfo->manual_cd_tray) {
     
    16701673    /* BERLIOS: Do not ignore getcwd result */
    16711674    (void) getcwd(old_pwd, MAX_STR_LEN - 1);
    1672     asprintf(&tmp, "chmod 755 %s", bkpinfo->scratchdir);
     1675    mr_asprintf(&tmp, "chmod 755 %s", bkpinfo->scratchdir);
    16731676    run_program_and_log_output(tmp, FALSE);
    1674     paranoid_free(tmp);
     1677    mr_free(tmp);
    16751678    chdir(bkpinfo->scratchdir);
    16761679
    16771680    if (bkpinfo->call_before_iso != NULL) {
    1678         asprintf(&message_to_screen, "Running pre-ISO call for CD#%d",
     1681        mr_asprintf(&message_to_screen, "Running pre-ISO call for CD#%d",
    16791682                 g_current_media_number);
    16801683        res = eval_call_to_make_ISO(bkpinfo, bkpinfo->call_before_iso,
     
    16861689            log_to_screen("%s...OK", message_to_screen);
    16871690        }
    1688         paranoid_free(message_to_screen);
     1691        mr_free(message_to_screen);
    16891692        retval += res;
    16901693    }
     
    16921695    if (bkpinfo->call_make_iso != NULL) {
    16931696        log_msg(2, "bkpinfo->call_make_iso = %s", bkpinfo->call_make_iso);
    1694         asprintf(&tmp, "%s/archives/NOT-THE-LAST", bkpinfo->scratchdir);
    1695         asprintf(&message_to_screen, "Making an ISO (%s #%d)",
     1697        mr_asprintf(&tmp, "%s/archives/NOT-THE-LAST", bkpinfo->scratchdir);
     1698        mr_asprintf(&message_to_screen, "Making an ISO (%s #%d)",
    16961699                 bkpinfo->backup_media_string,
    16971700                 g_current_media_number);
     
    17201723            retval += res;
    17211724#ifdef DVDRWFORMAT
    1722             asprintf(&tmp,
     1725            mr_asprintf(&tmp,
    17231726                     "tail -n8 %s | grep 'blank=full.*dvd-compat.*DAO'",
    17241727                     MONDO_LOGFILE);
     
    17381741                }
    17391742                pause_for_N_seconds(5, "Letting DVD drive settle");
    1740                 asprintf(&sz_blank_disk, "dvd+rw-format %s",
     1743                mr_asprintf(&sz_blank_disk, "dvd+rw-format %s",
    17411744                         bkpinfo->media_device);
    17421745                log_msg(3, "sz_blank_disk = '%s'", sz_blank_disk);
     
    17571760                        ("Format succeeded. Sleeping for 5 seconds to take a breath...");
    17581761                }
    1759                 paranoid_free(sz_blank_disk);
     1762                mr_free(sz_blank_disk);
    17601763                pause_for_N_seconds(5, "Letting DVD drive settle");
    17611764                if (!bkpinfo->please_dont_eject) {
     
    17831786                }
    17841787            }
    1785             paranoid_free(tmp);
     1788            mr_free(tmp);
    17861789#endif
    17871790            if (g_backup_media_type == dvd && !bkpinfo->please_dont_eject) {
     
    17891792            }
    17901793        }
    1791         paranoid_free(message_to_screen);
     1794        mr_free(message_to_screen);
    17921795    } else {
    1793         asprintf(&message_to_screen, "Running mkisofs to make %s #%d",
     1796        mr_asprintf(&message_to_screen, "Running mkisofs to make %s #%d",
    17941797                 bkpinfo->backup_media_string,
    17951798                 g_current_media_number);
    17961799        log_msg(1, message_to_screen);
    1797         asprintf(&result_sz, "Call to mkisofs to make ISO (%s #%d) ",
     1800        mr_asprintf(&result_sz, "Call to mkisofs to make ISO (%s #%d) ",
    17981801                 bkpinfo->backup_media_string,
    17991802                 g_current_media_number);
     
    18211824#ifdef __IA64__
    18221825                log_msg(1, "IA64 --> elilo");
    1823                 asprintf(&tmp2,"mkisofs -no-emul-boot -b images/mindi-bootroot.%s.img -c boot.cat -o _ISO_ -J -r -p MondoRescue -publisher www.mondorescue.org -A Mondo_Rescue_GPL -V _CD#_ .", bkpinfo->mrconf->mindi_ia64_boot_size);
     1826                mr_asprintf(&tmp2,"mkisofs -no-emul-boot -b images/mindi-bootroot.%s.img -c boot.cat -o _ISO_ -J -r -p MondoRescue -publisher www.mondorescue.org -A Mondo_Rescue_GPL -V _CD#_ .", bkpinfo->mrconf->mindi_ia64_boot_size);
    18241827                res = eval_call_to_make_ISO(bkpinfo,
    18251828                                            tmp2,
     
    18311834// FIXME --- change mkisofs string to MONDO_MKISOFS_REGULAR_SYSLINUX/LILO depending on bkpinfo->make_cd_usE_lilo
    18321835// and add ' .' at end
    1833                 paranoid_free(tmp2);
     1836                mr_free(tmp2);
    18341837                log_msg(1, "Non-ia64 --> lilo");
    18351838                res = eval_call_to_make_ISO(bkpinfo,
     
    18571860        }
    18581861        retval += res;
    1859         paranoid_free(message_to_screen);
    1860         paranoid_free(result_sz);
     1862        mr_free(message_to_screen);
     1863        mr_free(result_sz);
    18611864    }
    18621865
     
    18671870                    "Warning - %s mounted. I'm unmounting it before I burn to it.",
    18681871                    bkpinfo->media_device);
    1869             asprintf(&tmp, "umount %s", bkpinfo->media_device);
     1872            mr_asprintf(&tmp, "umount %s", bkpinfo->media_device);
    18701873            run_program_and_log_output(tmp, FALSE);
    1871             paranoid_free(tmp);
     1874            mr_free(tmp);
    18721875        }
    18731876    }
     
    18751878    if (bkpinfo->call_burn_iso != NULL) {
    18761879        log_msg(2, "bkpinfo->call_burn_iso = %s", bkpinfo->call_burn_iso);
    1877         asprintf(&message_to_screen, "Burning %s #%d",
     1880        mr_asprintf(&message_to_screen, "Burning %s #%d",
    18781881                 bkpinfo->backup_media_string,
    18791882                 g_current_media_number);
     
    18871890            log_to_screen("%s...OK", message_to_screen);
    18881891        }
    1889         paranoid_free(message_to_screen);
     1892        mr_free(message_to_screen);
    18901893        retval += res;
    18911894    }
    18921895
    18931896    if (bkpinfo->call_after_iso != NULL) {
    1894         asprintf(&message_to_screen, "Running post-ISO call (%s #%d)",
     1897        mr_asprintf(&message_to_screen, "Running post-ISO call (%s #%d)",
    18951898                 bkpinfo->backup_media_string,
    18961899                 g_current_media_number);
     
    19031906            log_to_screen("%s...OK", message_to_screen);
    19041907        }
    1905         paranoid_free(message_to_screen);
     1908        mr_free(message_to_screen);
    19061909        retval += res;
    19071910    }
     
    19111914        log_msg(1, "WARNING - make_iso_fs returned an error");
    19121915    }
    1913     paranoid_free(old_pwd);
     1916    mr_free(old_pwd);
    19141917    return (retval);
    19151918}
     
    19211924    char *command;
    19221925    bool ret = TRUE;
    1923     asprintf(&command,
     1926    mr_asprintf(&command,
    19241927             "dd if=%s bs=512 count=1 2> /dev/null | strings | head -n1",
    19251928             bigfile_fname);
     
    19271930    tmp = call_program_and_get_last_line_of_output(command);
    19281931    log_msg(1, "--> tmp = '%s'", tmp);
    1929     paranoid_free(command);
     1932    mr_free(command);
    19301933    if (strstr(tmp, "NTFS")) {
    19311934        iamhere("TRUE");
     
    19341937        ret = FALSE;
    19351938    }
    1936     paranoid_free(tmp);
     1939    mr_free(tmp);
    19371940    return(ret);
    19381941}
     
    19972000        return (0);
    19982001    }
    1999     asprintf(&tmp, "I am now backing up all large files.");
     2002    mr_asprintf(&tmp, "I am now backing up all large files.");
    20002003    log_to_screen(tmp);
    20012004    noof_biggie_files = count_lines_in_file(biggielist_fname);
     
    20032006                       "Please wait. This may take some time.", "",
    20042007                       estimated_total_noof_slices);
    2005     paranoid_free(tmp);
     2008    mr_free(tmp);
    20062009
    20072010    if (!(fin = fopen(biggielist_fname, "r"))) {
     
    20092012        return (1);
    20102013    }
    2011     for (getline(&bigfile_fname, &n, fin); !feof(fin);
    2012          getline(&bigfile_fname, &n, fin), biggie_file_number++) {
     2014    for (mr_getline(&bigfile_fname, &n, fin); !feof(fin);
     2015         mr_getline(&bigfile_fname, &n, fin), biggie_file_number++) {
    20132016        use_ntfsprog = FALSE;
    20142017        if (bigfile_fname[strlen(bigfile_fname) - 1] < 32) {
     
    20212024            ftmp = fopen(bigfile_fname, "w");
    20222025            paranoid_fclose(ftmp);
    2023             asprintf(&tmp, "bigfile %s was deleted - creating a dummy",
     2026            mr_asprintf(&tmp, "bigfile %s was deleted - creating a dummy",
    20242027                     bigfile_fname);
    20252028            delete_when_done = TRUE;
     
    20352038                        "Calling ntfsclone in background because %s is an NTFS partition",
    20362039                        bigfile_fname);
    2037                 asprintf(&sz_devfile, "%s/%d.%d.000",
     2040                mr_asprintf(&sz_devfile, "%s/%d.%d.000",
    20382041                        bkpinfo->tmpdir,
    20392042                         (int) (random() % 32768),
     
    20562059                            (long int) (pid));
    20572060
    2058                     paranoid_free(sz_devfile);
     2061                    mr_free(sz_devfile);
    20592062                }
    20602063            }
     
    20812084                tmp = calc_checksum_of_file(bigfile_fname);
    20822085                write_header_block_to_stream((off_t)0, tmp, BLK_STOP_A_BIGGIE);
    2083                 paranoid_free(tmp);
     2086                mr_free(tmp);
    20842087            }
    20852088            retval += res;
     
    20912094            }
    20922095            if (res) {
    2093                 asprintf(&tmp, "Archiving %s ... Failed!", bigfile_fname);
     2096                mr_asprintf(&tmp, "Archiving %s ... Failed!", bigfile_fname);
    20942097            } else {
    2095                 asprintf(&tmp, "Archiving %s ... OK!", bigfile_fname);
     2098                mr_asprintf(&tmp, "Archiving %s ... OK!", bigfile_fname);
    20962099            }
    20972100
     
    21082111#endif
    21092112    }
    2110     paranoid_free(tmp);
    2111     paranoid_free(bigfile_fname);
     2113    mr_free(tmp);
     2114    mr_free(bigfile_fname);
    21122115    paranoid_fclose(fin);
    21132116
     
    21412144
    21422145    /* BERLIOS: Useless ?
    2143        asprintf(&tmp, "%s/archives/filelist.full", bkpinfo->scratchdir);
     2146       mr_asprintf(&tmp, "%s/archives/filelist.full", bkpinfo->scratchdir);
    21442147     */
    21452148
     
    21522155                       get_last_filelist_number(bkpinfo) + 1);
    21532156
    2154     asprintf(&curr_filelist_fname, FILELIST_FNAME_RAW_SZ, bkpinfo->tmpdir,
     2157    mr_asprintf(&curr_filelist_fname, FILELIST_FNAME_RAW_SZ, bkpinfo->tmpdir,
    21552158             0L);
    21562159
     
    21582161    while (does_file_exist(curr_filelist_fname)) {
    21592162        /* backup this set of files */
    2160         asprintf(&curr_afioball_fname, AFIOBALL_FNAME_RAW_SZ,
     2163        mr_asprintf(&curr_afioball_fname, AFIOBALL_FNAME_RAW_SZ,
    21612164                 bkpinfo->tmpdir, curr_set_no, bkpinfo->zip_suffix);
    21622165
    21632166        log_msg(1, "EXAT'g set %ld", curr_set_no);
    2164         asprintf(&curr_xattr_list_fname, XATTR_LIST_FNAME_RAW_SZ,
     2167        mr_asprintf(&curr_xattr_list_fname, XATTR_LIST_FNAME_RAW_SZ,
    21652168                 bkpinfo->tmpdir, curr_set_no);
    2166         asprintf(&curr_acl_list_fname, ACL_LIST_FNAME_RAW_SZ,
     2169        mr_asprintf(&curr_acl_list_fname, ACL_LIST_FNAME_RAW_SZ,
    21672170                 bkpinfo->tmpdir, curr_set_no);
    21682171        get_fattr_list(curr_filelist_fname, curr_xattr_list_fname);
     
    21742177        retval += res;
    21752178        if (res) {
    2176             asprintf(&tmp,
     2179            mr_asprintf(&tmp,
    21772180                     "Errors occurred while archiving set %ld. Perhaps your live filesystem changed?",
    21782181                     curr_set_no);
    21792182            log_to_screen(tmp);
    2180             paranoid_free(tmp);
     2183            mr_free(tmp);
    21812184        }
    21822185
    21832186        tmp = percent_media_full_comment(bkpinfo);
    2184         asprintf(&media_usage_comment, "%s", tmp);
    2185         paranoid_free(tmp);
     2187        mr_asprintf(&media_usage_comment, "%s", tmp);
     2188        mr_free(tmp);
    21862189
    21872190        /* copy to CD (scratchdir) ... and an actual CD-R if necessary */
     
    22062209        g_current_progress++;
    22072210        update_progress_form(media_usage_comment);
    2208         paranoid_free(media_usage_comment);
     2211        mr_free(media_usage_comment);
    22092212
    22102213        if (res) {
    2211             asprintf(&tmp, "Failed to add archive %ld's files to CD dir\n",
     2214            mr_asprintf(&tmp, "Failed to add archive %ld's files to CD dir\n",
    22122215                     curr_set_no);
    22132216            log_to_screen(tmp);
    2214             paranoid_free(tmp);
     2217            mr_free(tmp);
    22152218            fatal_error
    22162219                ("Is your hard disk is full? If not, please send the author the logfile.");
    22172220        }
    2218         paranoid_free(curr_filelist_fname);
    2219         paranoid_free(curr_afioball_fname);
    2220         paranoid_free(curr_xattr_list_fname);
    2221         paranoid_free(curr_acl_list_fname);
    2222         asprintf(&curr_filelist_fname, FILELIST_FNAME_RAW_SZ,
     2221        mr_free(curr_filelist_fname);
     2222        mr_free(curr_afioball_fname);
     2223        mr_free(curr_xattr_list_fname);
     2224        mr_free(curr_acl_list_fname);
     2225        mr_asprintf(&curr_filelist_fname, FILELIST_FNAME_RAW_SZ,
    22232226                 bkpinfo->tmpdir, ++curr_set_no);
    22242227    }
    2225     paranoid_free(curr_filelist_fname);
     2228    mr_free(curr_filelist_fname);
    22262229    close_progress_form();
    22272230    if (retval) {
     
    23102313    mvaddstr_and_log_it(g_currentY, 0,
    23112314                        "Archiving large files to media           ");
    2312     asprintf(&biggielist, "%s/archives/biggielist.txt",
     2315    mr_asprintf(&biggielist, "%s/archives/biggielist.txt",
    23132316             bkpinfo->scratchdir);
    2314     asprintf(&xattr_fname, XATTR_BIGGLST_FNAME_RAW_SZ, bkpinfo->tmpdir);
    2315     asprintf(&acl_fname, ACL_BIGGLST_FNAME_RAW_SZ, bkpinfo->tmpdir);
    2316 
    2317     asprintf(&command, "cp %s/biggielist.txt %s", bkpinfo->tmpdir,
     2317    mr_asprintf(&xattr_fname, XATTR_BIGGLST_FNAME_RAW_SZ, bkpinfo->tmpdir);
     2318    mr_asprintf(&acl_fname, ACL_BIGGLST_FNAME_RAW_SZ, bkpinfo->tmpdir);
     2319
     2320    mr_asprintf(&command, "cp %s/biggielist.txt %s", bkpinfo->tmpdir,
    23182321             biggielist);
    23192322    paranoid_system(command);
    2320     paranoid_free(command);
    2321 
    2322     asprintf(&blah, "biggielist = %s", biggielist);
     2323    mr_free(command);
     2324
     2325    mr_asprintf(&blah, "biggielist = %s", biggielist);
    23232326    log_msg(2, blah);
    2324     paranoid_free(blah);
     2327    mr_free(blah);
    23252328
    23262329    if (!does_file_exist(biggielist)) {
     
    23302333    get_fattr_list(biggielist, xattr_fname);
    23312334    get_acl_list(biggielist, acl_fname);
    2332     asprintf(&command, "cp %s %s/archives/", xattr_fname,
     2335    mr_asprintf(&command, "cp %s %s/archives/", xattr_fname,
    23332336             bkpinfo->scratchdir);
    23342337    paranoid_system(command);
    2335     paranoid_free(command);
    2336 
    2337     asprintf(&command, "cp %s %s/archives/", acl_fname,
     2338    mr_free(command);
     2339
     2340    mr_asprintf(&command, "cp %s %s/archives/", acl_fname,
    23382341             bkpinfo->scratchdir);
    23392342    paranoid_system(command);
    2340     paranoid_free(command);
     2343    mr_free(command);
    23412344
    23422345    if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) {
    23432346        res += write_EXAT_files_to_tape(bkpinfo, xattr_fname, acl_fname);
    2344         asprintf(&blah, "%ld", count_lines_in_file(biggielist));
     2347        mr_asprintf(&blah, "%ld", count_lines_in_file(biggielist));
    23452348        write_header_block_to_stream((off_t)0, blah, BLK_START_BIGGIEFILES);
    2346         paranoid_free(blah);
    2347     }
    2348     paranoid_free(xattr_fname);
    2349     paranoid_free(acl_fname);
     2349        mr_free(blah);
     2350    }
     2351    mr_free(xattr_fname);
     2352    mr_free(acl_fname);
    23502353
    23512354    res = make_slices_and_images(bkpinfo, biggielist);
    2352     paranoid_free(biggielist);
     2355    mr_free(biggielist);
    23532356
    23542357    if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) {
     
    24182421            continue;
    24192422        }
    2420         asprintf(&curr_file, "%s", cf);
     2423        mr_asprintf(&curr_file, "%s", cf);
    24212424        if (!does_file_exist(curr_file)) {
    24222425            log_msg(1,
     
    24272430            would_occupy += length_of_file(curr_file) / 1024;
    24282431        }
    2429         paranoid_free(curr_file);
     2432        mr_free(curr_file);
    24302433    }
    24312434    va_end(ap);
     
    24482451            continue;
    24492452        }
    2450         asprintf(&curr_file, "%s", cf);
    2451 
    2452         asprintf(&tmp, "mv -f %s %s/archives/", curr_file,
     2453        mr_asprintf(&curr_file, "%s", cf);
     2454
     2455        mr_asprintf(&tmp, "mv -f %s %s/archives/", curr_file,
    24532456                 bkpinfo->scratchdir);
    24542457        res = run_program_and_log_output(tmp, 5);
     
    24592462            log_msg(8, "Moved %s to CD OK", tmp);
    24602463        }
    2461         paranoid_free(tmp);
    2462         paranoid_free(curr_file);
     2464        mr_free(tmp);
     2465        mr_free(curr_file);
    24632466        //      unlink (curr_file);
    24642467    }
     
    25182521        system("/usr/sbin/fdcontrol -F 1722 /dev/fd0.1722");
    25192522#endif
    2520         asprintf(&bootdisk_dev, "%s", DEFAULT_1722MB_DISK);
     2523        mr_asprintf(&bootdisk_dev, "%s", DEFAULT_1722MB_DISK);
    25212524    } else if (does_device_exist(BACKUP_1722MB_DISK)) {
    2522         asprintf(&bootdisk_dev, "/dev/fd0H1722");
     2525        mr_asprintf(&bootdisk_dev, "/dev/fd0H1722");
    25232526    } else {
    25242527        log_msg(1, "Warning - can't find a 1.72MB floppy device *sigh*");
    2525         asprintf(&bootdisk_dev, DEFAULT_1722MB_DISK);
    2526     }
    2527     asprintf(&datadisk_dev, "%s", "/dev/fd0");
     2528        mr_asprintf(&bootdisk_dev, DEFAULT_1722MB_DISK);
     2529    }
     2530    mr_asprintf(&datadisk_dev, "%s", "/dev/fd0");
    25282531    if (!does_device_exist(datadisk_dev)) {
    25292532        log_msg(1, "Warning - can't find a 1.44MB floppy device *sigh*");
    2530         paranoid_free(datadisk_dev);
    2531         asprintf(&datadisk_dev, "%s", "/dev/fd0");
     2533        mr_free(datadisk_dev);
     2534        mr_asprintf(&datadisk_dev, "%s", "/dev/fd0");
    25322535    }
    25332536    format_first = ask_me_yes_or_no
     
    25382541        log_to_screen("Writing boot floppy");
    25392542#ifdef __FreeBSD__
    2540         asprintf(&tmp, "%s/mindi-kern.1722.img", imagesdir);
     2543        mr_asprintf(&tmp, "%s/mindi-kern.1722.img", imagesdir);
    25412544        if (format_first) {
    25422545            format_disk(bootdisk_dev);
    25432546        }
    25442547        res += write_image_to_floppy(bootdisk_dev, tmp);
    2545         paranoid_free(tmp);
     2548        mr_free(tmp);
    25462549
    25472550        if (ask_me_OK_or_cancel("About to write 1.44MB mfsroot disk")) {
     
    25502553                format_disk(datadisk_dev);
    25512554            }
    2552             asprintf(&tmp, "%s/mindi-mfsroot.1440.img", imagesdir);
     2555            mr_asprintf(&tmp, "%s/mindi-mfsroot.1440.img", imagesdir);
    25532556            write_image_to_floppy(datadisk_dev, tmp);
    2554             paranoid_free(tmp);
     2557            mr_free(tmp);
    25552558        }
    25562559#else
    2557         asprintf(&bootdisk_file, "%s/mindi-bootroot.1722.img", imagesdir);
     2560        mr_asprintf(&bootdisk_file, "%s/mindi-bootroot.1722.img", imagesdir);
    25582561        if (does_file_exist(bootdisk_file)) {
    25592562            if (format_first) {
     
    25622565            res += write_image_to_floppy(bootdisk_dev, bootdisk_file);
    25632566        } else {
    2564             paranoid_free(bootdisk_file);
    2565             asprintf(&bootdisk_file, "%s/mindi-boot.1440.img", imagesdir);
    2566             asprintf(&rootdisk_file, "%s/mindi-root.1440.img", imagesdir);
     2567            mr_free(bootdisk_file);
     2568            mr_asprintf(&bootdisk_file, "%s/mindi-boot.1440.img", imagesdir);
     2569            mr_asprintf(&rootdisk_file, "%s/mindi-root.1440.img", imagesdir);
    25672570            root_disk_exists = TRUE;
    25682571            if (!does_file_exist(rootdisk_file)
     
    25722575                log_to_screen
    25732576                    ("Failed to find boot/root floppy images. Oh dear.");
    2574                 paranoid_free(bootdisk_file);
    2575                 paranoid_free(rootdisk_file);
    2576                 paranoid_free(bootdisk_dev);
     2577                mr_free(bootdisk_file);
     2578                mr_free(rootdisk_file);
     2579                mr_free(bootdisk_dev);
    25772580                return (1);
    25782581            }
     
    25862589                    format_disk(datadisk_dev);
    25872590                }
    2588                 asprintf(&tmp, "cat %s > %s", rootdisk_file, datadisk_dev);
     2591                mr_asprintf(&tmp, "cat %s > %s", rootdisk_file, datadisk_dev);
    25892592                log_msg(1, "tmp = '%s'", tmp);
    25902593                res +=
     
    25922595                    ("Writing root floppy", tmp);
    25932596//              res += write_image_to_floppy (datadisk_dev, rootdisk_file);
    2594                 paranoid_free(tmp);
    2595             }
    2596             paranoid_free(rootdisk_file);
    2597             paranoid_free(bootdisk_file);
     2597                mr_free(tmp);
     2598            }
     2599            mr_free(rootdisk_file);
     2600            mr_free(bootdisk_file);
    25982601        }
    25992602#endif
    26002603    }
    2601     paranoid_free(bootdisk_dev);
     2604    mr_free(bootdisk_dev);
    26022605
    26032606    if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) {
     
    26072610    }
    26082611    for (i = 1; i < 99; i++) {
    2609         asprintf(&tmp, "%s/mindi-data-%d.img", imagesdir, i);
     2612        mr_asprintf(&tmp, "%s/mindi-data-%d.img", imagesdir, i);
    26102613        log_msg(3, tmp);
    26112614        if (!does_file_exist(tmp)) {
     
    26132616            break;
    26142617        }
    2615         asprintf(&comment, "About to write data disk #%d", i);
     2618        mr_asprintf(&comment, "About to write data disk #%d", i);
    26162619        if (ask_me_OK_or_cancel(comment)) {
    2617             paranoid_free(comment);
    2618             asprintf(&comment, "Writing data disk #%3d", i);
     2620            mr_free(comment);
     2621            mr_asprintf(&comment, "Writing data disk #%3d", i);
    26192622            log_to_screen(comment);
    2620             paranoid_free(comment);
     2623            mr_free(comment);
    26212624            if (format_first) {
    26222625                res += format_disk(datadisk_dev);
     
    26252628        }
    26262629    }
    2627     paranoid_free(tmp);
    2628     paranoid_free(datadisk_dev);
     2630    mr_free(tmp);
     2631    mr_free(datadisk_dev);
    26292632    return (res);
    26302633}
     
    27292732            continue;
    27302733        }
    2731         asprintf(&curr_file, "%s", cf);
     2734        mr_asprintf(&curr_file, "%s", cf);
    27322735        if (!does_file_exist(curr_file)) {
    27332736            log_msg(1,
     
    27522755        retval += res;
    27532756        unlink(curr_file);
    2754         paranoid_free(curr_file);
     2757        mr_free(curr_file);
    27552758        /* write closing header */
    27562759        write_header_block_to_stream((off_t)0, "finished-writing-file", stop_chr);
     
    27862789    if ((cdrw_device = find_cdrw_device()) != NULL) {
    27872790        if (!system("which cdrecord > /dev/null 2> /dev/null")) {
    2788             asprintf(&cdrecord, "cdrecord dev=%s -atip", cdrw_device);
     2791            mr_asprintf(&cdrecord, "cdrecord dev=%s -atip", cdrw_device);
    27892792        } else if (!system("which dvdrecord > /dev/null 2> /dev/null")) {
    2790             asprintf(&cdrecord, "cdrecord dev=%s -atip", cdrw_device);
     2793            mr_asprintf(&cdrecord, "cdrecord dev=%s -atip", cdrw_device);
    27912794        } else {
    2792             asprintf(&cdrecord, " ");
     2795            mr_asprintf(&cdrecord, " ");
    27932796            log_msg(2, "Found no cdrecord nor dvdrecord in path.");
    27942797        }
     
    27972800                run_program_and_log_output(cdrecord, 5);
    27982801        }
    2799         paranoid_free(cdrecord);
     2802        mr_free(cdrecord);
    28002803    }
    28012804    return(cdrw_device);
     
    28272830    char *szunmount;
    28282831
    2829     asprintf(&szmsg, "I am about to burn %s #%d",
     2832    mr_asprintf(&szmsg, "I am about to burn %s #%d",
    28302833             g_backup_media_string,
    28312834             g_current_media_number);
    28322835    log_to_screen(szmsg);
    2833     paranoid_free(szmsg);
     2836    mr_free(szmsg);
    28342837    if (g_current_media_number < ask_for_one_if_more_than_this) {
    28352838        return;
    28362839    }
    28372840    log_to_screen("Scanning CD-ROM drive...");
    2838     asprintf(&mtpt, "/tmp/cd.mtpt.%ld.%ld", (long int) random(),
     2841    mr_asprintf(&mtpt, "/tmp/cd.mtpt.%ld.%ld", (long int) random(),
    28392842             (long int) random());
    28402843    make_hole_for_dir(mtpt);
     
    28482851      retract_CD_tray_and_defeat_autorun();
    28492852*/
    2850         asprintf(&tmp, "umount %s", cdrom_dev);
     2853        mr_asprintf(&tmp, "umount %s", cdrom_dev);
    28512854        run_program_and_log_output(tmp, 1);
    2852         paranoid_free(tmp);
    2853         asprintf(&szcdno, "%s/archives/THIS-CD-NUMBER", mtpt);
    2854         asprintf(&szserfname, "%s/archives/SERIAL-STRING", mtpt);
    2855         asprintf(&szunmount, "umount %s", mtpt);
     2855        mr_free(tmp);
     2856        mr_asprintf(&szcdno, "%s/archives/THIS-CD-NUMBER", mtpt);
     2857        mr_asprintf(&szserfname, "%s/archives/SERIAL-STRING", mtpt);
     2858        mr_asprintf(&szunmount, "umount %s", mtpt);
    28562859        cd_number = -1;
    2857         asprintf(&tmp, "mount %s %s", cdrom_dev, mtpt);
     2860        mr_asprintf(&tmp, "mount %s %s", cdrom_dev, mtpt);
    28582861        if ((attempt_to_mount_returned_this =
    28592862             run_program_and_log_output(tmp, 1))) {
    28602863            log_msg(4, "Failed to mount %s at %s", cdrom_dev, mtpt);
    28612864            log_to_screen("If there's a CD/DVD in the drive, it's blank.");
    2862             asprintf(&our_serial_str, "%s", "");
     2865            mr_asprintf(&our_serial_str, "%s", "");
    28632866        } else if (!does_file_exist(szcdno)
    28642867                   || !does_file_exist(szserfname)) {
     
    28662869                ("%s has data on it but it's probably not a Mondo CD.",
    28672870                 g_backup_media_string);
    2868             asprintf(&our_serial_str, "%s", "");
     2871            mr_asprintf(&our_serial_str, "%s", "");
    28692872        } else {
    28702873            log_to_screen("%s found in drive. It's a Mondo disk.",
     
    28722875            tmp1 = last_line_of_file(szcdno);
    28732876            cd_number = atoi(tmp1);
    2874             paranoid_free(tmp1);
    2875             asprintf(&tmp1, "cat %s 2> /dev/null", szserfname);
     2877            mr_free(tmp1);
     2878            mr_asprintf(&tmp1, "cat %s 2> /dev/null", szserfname);
    28762879            our_serial_str = call_program_and_get_last_line_of_output(tmp1);
    2877             paranoid_free(tmp1);
     2880            mr_free(tmp1);
    28782881            // FIXME - should be able to use last_line_of_file(), surely?
    28792882        }
    2880         paranoid_free(szcdno);
    2881         paranoid_free(szserfname);
    2882         paranoid_free(tmp);
     2883        mr_free(szcdno);
     2884        mr_free(szserfname);
     2885        mr_free(tmp);
    28832886
    28842887        run_program_and_log_output(szunmount, 1);
    2885         paranoid_free(szunmount);
     2888        mr_free(szunmount);
    28862889
    28872890        log_msg(2, "paafcd: cd_number = %d", cd_number);
     
    29042907            log_to_screen("...but not part of _our_ backup set.");
    29052908        }
    2906         paranoid_free(our_serial_str);
     2909        mr_free(our_serial_str);
    29072910    } else {
    29082911        log_msg(2,
     
    29142917                          g_backup_media_string);
    29152918        }
    2916         paranoid_free(cdrw_device);
    2917     }
    2918     paranoid_free(mtpt);
     2919        mr_free(cdrw_device);
     2920    }
     2921    mr_free(mtpt);
    29192922
    29202923    if (!ok_go_ahead_burn_it) {
    29212924        eject_device(cdrom_dev);
    2922         asprintf(&tmp,
     2925        mr_asprintf(&tmp,
    29232926                 "I am about to burn %s #%d of the backup set. Please insert %s and press Enter.",
    29242927                 g_backup_media_string,
     
    29262929                 g_backup_media_string);
    29272930        popup_and_OK(tmp);
    2928         paranoid_free(tmp);
     2931        mr_free(tmp);
    29292932        goto gotos_make_me_puke;
    29302933    } else {
    29312934        log_msg(2, "paafcd: OK, going ahead and burning it.");
    29322935    }
    2933     paranoid_free(cdrom_dev);
     2936    mr_free(cdrom_dev);
    29342937
    29352938    log_msg(2,
     
    30483051    if (is_this_file_compressed(biggie_filename)
    30493052        || bkpinfo->compression_level == 0) {
    3050         asprintf(&suffix, "%s", "");
     3053        mr_asprintf(&suffix, "%s", "");
    30513054        //      log_it("%s is indeed compressed :-)", filename);
    30523055        should_I_compress_slices = FALSE;
    30533056    } else {
    3054         asprintf(&suffix, "%s", bkpinfo->zip_suffix);
     3057        mr_asprintf(&suffix, "%s", bkpinfo->zip_suffix);
    30553058        should_I_compress_slices = TRUE;
    30563059    }
     
    30613064    if (ntfsprog_fifo) {
    30623065        file_to_openin = ntfsprog_fifo;
    3063         asprintf(&checksum_line, "IGNORE");
     3066        mr_asprintf(&checksum_line, "IGNORE");
    30643067        log_msg(2,
    30653068                "Not calculating checksum for %s: it would take too long",
     
    30693072            fatal_error("ntfsresize not found");
    30703073        }
    3071         paranoid_free(tmp);
    3072 
    3073         asprintf(&command, "ntfsresize --force --info %s|grep '^You might resize at '|cut -d' ' -f5", biggie_filename);
     3074        mr_free(tmp);
     3075
     3076        mr_asprintf(&command, "ntfsresize --force --info %s|grep '^You might resize at '|cut -d' ' -f5", biggie_filename);
    30743077        log_it("command = %s", command);
    30753078        tmp = call_program_and_get_last_line_of_output(command);
    3076         paranoid_free(command);
     3079        mr_free(command);
    30773080
    30783081        log_it("res of it = %s", tmp);
    30793082        totallength = (off_t)atoll(tmp);
    3080         paranoid_free(tmp);
     3083        mr_free(tmp);
    30813084    } else {
    30823085        file_to_openin = biggie_filename;
    30833086        if (strchr(biggie_filename,'\'') != NULL) {
    3084             asprintf(&command, "md5sum \"%s\"", biggie_filename);
     3087            mr_asprintf(&command, "md5sum \"%s\"", biggie_filename);
    30853088        } else {
    3086             asprintf(&command, "md5sum '%s'", biggie_filename);
     3089            mr_asprintf(&command, "md5sum '%s'", biggie_filename);
    30873090        }
    30883091        if (!(fin = popen(command, "r"))) {
    30893092            log_OS_error("Unable to popen-in command");
    3090             paranoid_free(command);
     3093            mr_free(command);
    30913094            return (1);
    30923095        }
    3093         paranoid_free(command);
    3094         (void) getline(&checksum_line, &n, fin);
     3096        mr_free(command);
     3097        mr_getline(&checksum_line, &n, fin);
    30953098        pclose(fin);
    30963099        totallength = length_of_file (biggie_filename);
     
    31143117        fatal_error("checksum_line too big");
    31153118    }
    3116     paranoid_free(checksum_line);
     3119    mr_free(checksum_line);
    31173120
    31183121    tmp = slice_fname(biggie_file_number, 0, bkpinfo->tmpdir, "");
    31193122    fout = fopen(tmp, "w");
    3120     paranoid_free(tmp);
     3123    mr_free(tmp);
    31213124    (void) fwrite((void *) &biggiestruct, 1, sizeof(biggiestruct), fout);
    31223125    paranoid_fclose(fout);
     
    31263129    if (!(fin = fopen(file_to_openin, "r"))) {
    31273130        log_OS_error("Unable to openin biggie_filename");
    3128         asprintf(&tmp, "Cannot archive bigfile '%s': not found",
     3131        mr_asprintf(&tmp, "Cannot archive bigfile '%s': not found",
    31293132                 biggie_filename);
    31303133        log_to_screen(tmp);
    3131         paranoid_free(tmp);
    3132 
    3133         paranoid_free(suffix);
     3134        mr_free(tmp);
     3135
     3136        mr_free(suffix);
    31343137        return (1);
    31353138    }
     
    31403143        res = move_files_to_cd(bkpinfo, tmp, NULL);
    31413144    }
    3142     paranoid_free(tmp);
     3145    mr_free(tmp);
    31433146    i = bkpinfo->optimal_set_size / 256;
    31443147    for (slice_num = 1; !finished; slice_num++) {
     
    31483151        tmp = percent_media_full_comment(bkpinfo);
    31493152        update_progress_form(tmp);
    3150         paranoid_free(tmp);
     3153        mr_free(tmp);
    31513154
    31523155        if (!(fout = fopen(curr_slice_fname_uncompressed, "w"))) {
    31533156            log_OS_error(curr_slice_fname_uncompressed);
    31543157
    3155             paranoid_free(curr_slice_fname_uncompressed);
    3156             paranoid_free(curr_slice_fname_compressed);
    3157             paranoid_free(suffix);
     3158            mr_free(curr_slice_fname_uncompressed);
     3159            mr_free(curr_slice_fname_compressed);
     3160            mr_free(suffix);
    31583161            return (1);
    31593162        }
     
    31753178            i = 0;
    31763179        }
    3177         paranoid_free(tempblock);
     3180        mr_free(tempblock);
    31783181        paranoid_fclose(fout);
    31793182        if (i > 0)              // length_of_file (curr_slice_fname_uncompressed)
     
    31853188            }
    31863189            if (should_I_compress_slices && bkpinfo->compression_level > 0) {
    3187                 asprintf(&command, "%s -%d %s", bkpinfo->zip_exe,
     3190                mr_asprintf(&command, "%s -%d %s", bkpinfo->zip_exe,
    31883191                         bkpinfo->compression_level,
    31893192                         curr_slice_fname_uncompressed);
     
    31953198            } else {
    31963199                /* BERLIOS: Useless
    3197                    asprintf(&command, "mv %s %s 2>> %s",
     3200                   mr_asprintf(&command, "mv %s %s 2>> %s",
    31983201                   curr_slice_fname_uncompressed,
    31993202                   curr_slice_fname_compressed, MONDO_LOGFILE);
     
    32123215            }
    32133216            if (res) {
    3214                 asprintf(&tmp, "Problem with slice # %ld", slice_num);
     3217                mr_asprintf(&tmp, "Problem with slice # %ld", slice_num);
    32153218            } else {
    3216                 asprintf(&tmp,
     3219                mr_asprintf(&tmp,
    32173220                         "%s - Bigfile #%ld, slice #%ld compressed OK          ",
    32183221                         biggie_filename, biggie_file_number + 1,
     
    32293232            log_msg(2, tmp);
    32303233#endif
    3231             paranoid_free(tmp);
    3232             asprintf(&file_to_archive, "%s", curr_slice_fname_compressed);
     3234            mr_free(tmp);
     3235            mr_asprintf(&file_to_archive, "%s", curr_slice_fname_compressed);
    32333236            g_current_progress++;
    32343237        } else {                /* if i==0 then ... */
    32353238
    32363239            finished = TRUE;
    3237             asprintf(&file_to_archive, "%s",
     3240            mr_asprintf(&file_to_archive, "%s",
    32383241                     curr_slice_fname_uncompressed);
    32393242            if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) {
     
    32513254            res = move_files_to_cd(bkpinfo, file_to_archive, NULL);
    32523255        }
    3253         paranoid_free(file_to_archive);
     3256        mr_free(file_to_archive);
    32543257        retval += res;
    32553258        if (res) {
    3256             asprintf(&tmp,
     3259            mr_asprintf(&tmp,
    32573260                     "Failed to add slice %ld of bigfile %ld to scratchdir",
    32583261                     slice_num, biggie_file_number + 1);
    32593262            log_to_screen(tmp);
    3260             paranoid_free(tmp);
     3263            mr_free(tmp);
    32613264            fatal_error
    32623265                ("Hard disk full. You should have bought a bigger one.");
    32633266        }
    3264         paranoid_free(curr_slice_fname_uncompressed);
    3265         paranoid_free(curr_slice_fname_compressed);
    3266     }
    3267     paranoid_free(suffix);
     3267        mr_free(curr_slice_fname_uncompressed);
     3268        mr_free(curr_slice_fname_compressed);
     3269    }
     3270    mr_free(suffix);
    32683271    paranoid_fclose(fin);
    32693272    if (retval) {
    3270         asprintf(&tmp, "Sliced bigfile #%ld...FAILED",
     3273        mr_asprintf(&tmp, "Sliced bigfile #%ld...FAILED",
    32713274                 biggie_file_number + 1);
    32723275    } else {
    3273         asprintf(&tmp, "Sliced bigfile #%ld...OK!",
     3276        mr_asprintf(&tmp, "Sliced bigfile #%ld...OK!",
    32743277                 biggie_file_number + 1);
    32753278    }
    32763279    log_msg(1, tmp);
    3277     paranoid_free(tmp);
     3280    mr_free(tmp);
    32783281    return (retval);
    32793282}
     
    33003303    assert_string_is_neither_NULL_nor_zerolength(d);
    33013304
    3302     asprintf(&dir, "%s/archives", d);
    3303     asprintf(&tmp, "find %s -name '*.afio*' -exec rm -f '{}' \\;", dir);
     3305    mr_asprintf(&dir, "%s/archives", d);
     3306    mr_asprintf(&tmp, "find %s -name '*.afio*' -exec rm -f '{}' \\;", dir);
    33043307    run_program_and_log_output(tmp, FALSE);
    3305     paranoid_free(tmp);
    3306 
    3307     asprintf(&tmp, "find %s -name '*list.[0-9]*' -exec rm -f '{}' \\;",
     3308    mr_free(tmp);
     3309
     3310    mr_asprintf(&tmp, "find %s -name '*list.[0-9]*' -exec rm -f '{}' \\;",
    33083311             dir);
    33093312    run_program_and_log_output(tmp, FALSE);
    3310     paranoid_free(tmp);
    3311 
    3312     asprintf(&tmp, "find %s -name 'slice*' -exec rm -f '{}' \\;", dir);
     3313    mr_free(tmp);
     3314
     3315    mr_asprintf(&tmp, "find %s -name 'slice*' -exec rm -f '{}' \\;", dir);
    33133316    run_program_and_log_output(tmp, FALSE);
    3314     paranoid_free(tmp);
    3315 
    3316     asprintf(&tmp, "rm -f %s/cklist*", dir);
     3317    mr_free(tmp);
     3318
     3319    mr_asprintf(&tmp, "rm -f %s/cklist*", dir);
    33173320    run_program_and_log_output(tmp, FALSE);
    3318     paranoid_free(tmp);
    3319 
    3320     asprintf(&tmp, "rm -f %s/zero", dir);
     3321    mr_free(tmp);
     3322
     3323    mr_asprintf(&tmp, "rm -f %s/zero", dir);
    33213324    run_program_and_log_output(tmp, FALSE);
    3322     paranoid_free(tmp);
     3325    mr_free(tmp);
    33233326
    33243327    log_msg(1, "Wiped %s's archives", dir);
    3325     asprintf(&tmp, "ls -l %s", dir);
     3328    mr_asprintf(&tmp, "ls -l %s", dir);
    33263329    run_program_and_log_output(tmp, FALSE);
    3327     paranoid_free(tmp);
    3328 
    3329     paranoid_free(dir);
     3330    mr_free(tmp);
     3331
     3332    mr_free(dir);
    33303333}
    33313334
     
    33573360// I should really check if there are any slices or tarballs to be copied to CD-R(W)'s; the odds are approx. 1 in a million that there are no files here, so I'll just go ahead & make one more CD anyway
    33583361
    3359     asprintf(&tmp, "Writing the final ISO");
     3362    mr_asprintf(&tmp, "Writing the final ISO");
    33603363    log_msg(2, tmp);
    33613364    /* BERLIOS: center_string is now broken
     
    33673370    }
    33683371#endif
    3369     paranoid_free(tmp);
     3372    mr_free(tmp);
    33703373    res = write_iso_and_go_on(bkpinfo, TRUE);
    33713374#ifndef _XWIN
     
    34323435    /* label the ISO with its number */
    34333436
    3434     asprintf(&cdno_fname, "%s/archives/THIS-CD-NUMBER",
     3437    mr_asprintf(&cdno_fname, "%s/archives/THIS-CD-NUMBER",
    34353438             bkpinfo->scratchdir);
    34363439    fout = fopen(cdno_fname, "w");
    34373440    fprintf(fout, "%d", g_current_media_number);
    34383441    paranoid_fclose(fout);
    3439     paranoid_free(cdno_fname);
    3440 
    3441     asprintf(&tmp, "cp -f %s/autorun %s/", g_mondo_home,
     3442    mr_free(cdno_fname);
     3443
     3444    mr_asprintf(&tmp, "cp -f %s/autorun %s/", g_mondo_home,
    34423445             bkpinfo->scratchdir);
    34433446    if (run_program_and_log_output(tmp, FALSE)) {
    34443447        log_msg(2, "Warning - unable to copy autorun to scratchdir");
    34453448    }
    3446     paranoid_free(tmp);
     3449    mr_free(tmp);
    34473450
    34483451    /* last CD or not? Label accordingly */
    3449     asprintf(&lastcd_fname, "%s/archives/NOT-THE-LAST",
     3452    mr_asprintf(&lastcd_fname, "%s/archives/NOT-THE-LAST",
    34503453             bkpinfo->scratchdir);
    34513454    if (last_cd) {
     
    34593462        paranoid_fclose(fout);
    34603463    }
    3461     paranoid_free(lastcd_fname);
     3464    mr_free(lastcd_fname);
    34623465
    34633466    if (space_occupied_by_cd(bkpinfo->scratchdir) / 1024 >
    34643467        bkpinfo->media_size[g_current_media_number]) {
    3465         asprintf(&tmp,
     3468        mr_asprintf(&tmp,
    34663469                 "Warning! CD is too big. It occupies %ld KB, which is more than the %ld KB allowed.",
    34673470                 (long) space_occupied_by_cd(bkpinfo->scratchdir),
    34683471                 (long) bkpinfo->media_size[g_current_media_number]);
    34693472        log_to_screen(tmp);
    3470         paranoid_free(tmp);
    3471     }
    3472     asprintf(&isofile, "%s/%s/%s-%d.iso", bkpinfo->isodir,
     3473        mr_free(tmp);
     3474    }
     3475    mr_asprintf(&isofile, "%s/%s/%s-%d.iso", bkpinfo->isodir,
    34733476             bkpinfo->nfs_remote_dir, bkpinfo->prefix,
    34743477             g_current_media_number);
     
    34853488            else {
    34863489                log_msg(3, "Great. Found Mike's CD-ROM drive.");
    3487                 paranoid_free(tmp);
     3490                mr_free(tmp);
    34883491            }
    34893492        }
     
    35003503            that_one_was_ok = TRUE;
    35013504        } else {
    3502             asprintf(&tmp, "Failed to burn %s #%d. Retry?",
     3505            mr_asprintf(&tmp, "Failed to burn %s #%d. Retry?",
    35033506                     bkpinfo->backup_media_string,
    35043507                     g_current_media_number);
    35053508            res = ask_me_yes_or_no(tmp);
    3506             paranoid_free(tmp);
     3509            mr_free(tmp);
    35073510            if (!res) {
    35083511                if (ask_me_yes_or_no("Abort the backup?")) {
     
    35203523  if (using_nfs)
    35213524    {
    3522       asprintf(&tmp,"mv -f %s %s/%s/", isofile, bkpinfo->isodir, bkpinfo->nfs_remote_dir);
     3525      mr_asprintf(&tmp,"mv -f %s %s/%s/", isofile, bkpinfo->isodir, bkpinfo->nfs_remote_dir);
    35233526      if (run_program_and_log_output(tmp, FALSE))
    35243527        { log_to_screen("Unable to move ISO to NFS dir"); }
    35253528    }
    35263529*/
    3527     paranoid_free(isofile);
     3530    mr_free(isofile);
    35283531
    35293532    g_current_media_number++;
     
    35323535    }
    35333536    wipe_archives(bkpinfo->scratchdir);
    3534     asprintf(&tmp, "rm -Rf %s/images/*gz %s/images/*data*img",
     3537    mr_asprintf(&tmp, "rm -Rf %s/images/*gz %s/images/*data*img",
    35353538             bkpinfo->scratchdir, bkpinfo->scratchdir);
    35363539    if (system(tmp)) {
     
    35383541                "Error occurred when I tried to delete the redundant IMGs and GZs");
    35393542    }
    3540     paranoid_free(tmp);
     3543    mr_free(tmp);
    35413544
    35423545    if (last_cd) {
     
    35763579                            "Verifying archives against live filesystem");
    35773580        if (bkpinfo->backup_media_type == cdstream) {
    3578             paranoid_alloc(bkpinfo->media_device,"/dev/cdrom");
     3581            mr_allocstr(bkpinfo->media_device,"/dev/cdrom");
    35793582        }
    35803583        verify_tape_backups(bkpinfo);
     
    36063609            retval += res;
    36073610            if (res) {
    3608                 asprintf(&tmp,
     3611                mr_asprintf(&tmp,
    36093612                         "Warnings/errors were reported while checking %s #%d",
    36103613                         bkpinfo->backup_media_string,
    36113614                         g_current_media_number);
    36123615                log_to_screen(tmp);
    3613                 paranoid_free(tmp);
    3614 
    3615             }
    3616         }
    3617         asprintf(&tmp,
     3616                mr_free(tmp);
     3617
     3618            }
     3619        }
     3620        mr_asprintf(&tmp,
    36183621                 "grep 'afio: ' %s | sed 's/afio: //' | grep -vx '/dev/.*' >> /tmp/changed.files",
    36193622                 MONDO_LOGFILE);
    36203623        system(tmp);
    3621         paranoid_free(tmp);
    3622 
    3623         asprintf(&tmp,
     3624        mr_free(tmp);
     3625
     3626        mr_asprintf(&tmp,
    36243627                 "grep 'star: ' %s | sed 's/star: //' | grep -vx '/dev/.*' >> /tmp/changed.files",
    36253628                 MONDO_LOGFILE);
    36263629        system(tmp);
    3627         paranoid_free(tmp);
     3630        mr_free(tmp);
    36283631
    36293632        run_program_and_log_output("umount " MNT_CDROM, FALSE);
     
    36763679        p++;
    36773680    }
    3678     asprintf(&title, "Writing %s to floppy", p);
     3681    mr_asprintf(&title, "Writing %s to floppy", p);
    36793682    open_evalcall_form(title);
    3680     paranoid_free(title);
     3683    mr_free(title);
    36813684
    36823685    /* functional stuff */
     
    36873690        maxblocks = 1440;
    36883691    }
    3689     asprintf(&tmp, "maxblocks = %d; p=%s", maxblocks, p);
     3692    mr_asprintf(&tmp, "maxblocks = %d; p=%s", maxblocks, p);
    36903693    log_msg(2, tmp);
    3691     paranoid_free(tmp);
     3694    mr_free(tmp);
    36923695
    36933696    /* copy data from image to floppy */
     
    37633766    char *param = NULL;
    37643767
    3765     mr_conf = (struct s_mr_conf *)malloc(sizeof(struct s_mr_conf));
    3766     if (mr_conf == NULL) {
    3767             fatal_error("Unable to malloc mr_conf");
    3768     }
    3769     /* Default for everything int : 0 char * : NULL */
     3768    mr_conf = (struct s_mr_conf *)mr_malloc(sizeof(struct s_mr_conf));
    37703769
    37713770    /* mindi conf parameters also needed in mondo */
    3772     mr_conf->mindi_ia64_boot_size = 0;
    3773 
    3774     asprintf(&command, "mindi -printvar IA64_BOOT_SIZE");
     3771    mr_asprintf(&command, "mindi -printvar IA64_BOOT_SIZE");
    37753772    fin = popen(command, "r");
    3776     getline(&param, &n, fin);
     3773    mr_getline(&param, &n, fin);
    37773774    pclose(fin);
    3778     paranoid_free(command);
     3775    mr_free(command);
     3776
    37793777    mr_conf->mindi_ia64_boot_size = atoi(param);
    3780     paranoid_free(param);
    3781 
    3782     mr_conf->mondo_iso_creation_cmd = NULL;
     3778    mr_free(param);
    37833779
    37843780    /* Finds mondo conf file */
     
    37863782
    37873783    /* mondo conf parameters needed */
    3788     mr_conf->mondo_iso_creation_cmd = mr_conf_sread("mondo_iso_creation_cmd");
     3784    if ((mr_conf->mondo_iso_creation_cmd = mr_conf_sread("mondo_iso_creation_cmd")) == NULL) {;
     3785        mr_log_exit(-1,"Unable to get mondo_iso_creation_cmd parameter from conf file\nAborting...\n");
     3786    }
     3787
     3788    if ((mr_conf->mondo_logfile = mr_conf_sread("mondo_logfile")) == NULL) {
     3789        mr_log_exit(-1,"Unable to get mondo_logfile parameter from conf file\nAborting...\n");
     3790    }
    37893791
    37903792    mr_conf_close();
  • trunk/mondo/src/common/libmondo-devices.c

    r839 r900  
    1717#include "libmondo-fork-EXT.h"
    1818#include "libmondo-stream-EXT.h"
     19#include "mr_mem.h"
    1920
    2021#include <sys/ioctl.h>
     
    6263{
    6364    if (bkpinfo->media_device != NULL) {
    64         paranoid_alloc(g_cdrom_drive_is_here, bkpinfo->media_device);   // just in case
    65         paranoid_alloc(g_dvd_drive_is_here, bkpinfo->media_device); // just in case
     65        mr_allocstr(g_cdrom_drive_is_here, bkpinfo->media_device);  // just in case
     66        mr_allocstr(g_dvd_drive_is_here, bkpinfo->media_device);    // just in case
    6667    }
    6768}
     
    113114    make_hole_for_dir(mountpoint);
    114115    if (isdigit(device[0])) {
    115         paranoid_free(device);
     116        mr_free(device);
    116117        device = find_cdrom_device(FALSE);
    117118    }
     
    123124        dev = make_vn(device));
    124125        if (!dev) {
    125             asprintf(&command, "Unable to mount ISO (make_vn(%s) failed)",
     126            mr_asprintf(&command, "Unable to mount ISO (make_vn(%s) failed)",
    126127                    device);
    127128            fatal_error(command);
    128129        }
    129         paranoid_free(device);
     130        mr_free(device);
    130131        device = dev;
    131132#endif
     
    137138
    138139#ifdef __FreeBSD__
    139     asprintf(&command, "mount_cd9660 -r %s %s 2>> %s",
     140    mr_asprintf(&command, "mount_cd9660 -r %s %s 2>> %s",
    140141            device, mountpoint, MONDO_LOGFILE);
    141142#else
    142     asprintf(&command, "mount %s -o ro,loop -t iso9660 %s 2>> %s",
     143    mr_asprintf(&command, "mount %s -o ro,loop -t iso9660 %s 2>> %s",
    143144            device, mountpoint, MONDO_LOGFILE);
    144145#endif
     
    150151    retval = system(command);
    151152    log_msg(1, "system(%s) returned %d", command, retval);
    152     paranoid_free(command);
     153    mr_free(command);
    153154
    154155    if (retval == 0) {
     
    171172    bool is_this_a_ramdisk = FALSE;
    172173
    173     asprintf(&tmp, where_is_root_mounted());
    174     asprintf(&comment, "root is mounted at %s\n", tmp);
     174    mr_asprintf(&tmp, where_is_root_mounted());
     175    mr_asprintf(&comment, "root is mounted at %s\n", tmp);
    175176    log_msg(0, comment);
    176     paranoid_free(comment);
     177    mr_free(comment);
    177178
    178179    log_msg(0,
     
    194195    }
    195196#endif
    196     paranoid_free(tmp);
     197    mr_free(tmp);
    197198
    198199    if (is_this_a_ramdisk) {
     
    222223    char *output = NULL;
    223224
    224     paranoid_free(output);
     225    mr_free(output);
    225226
    226227    switch (bt) {
    227228    case none:
    228         asprintf(&output, _("none"));
     229        mr_asprintf(&output, _("none"));
    229230        break;
    230231    case iso:
    231         asprintf(&output, _("iso"));
     232        mr_asprintf(&output, _("iso"));
    232233        break;
    233234    case cdr:
    234         asprintf(&output, _("cdr"));
     235        mr_asprintf(&output, _("cdr"));
    235236        break;
    236237    case cdrw:
    237         asprintf(&output, _("cdrw"));
     238        mr_asprintf(&output, _("cdrw"));
    238239        break;
    239240    case cdstream:
    240         asprintf(&output, _("cdstream"));
     241        mr_asprintf(&output, _("cdstream"));
    241242        break;
    242243    case nfs:
    243         asprintf(&output, _("nfs"));
     244        mr_asprintf(&output, _("nfs"));
    244245        break;
    245246    case tape:
    246         asprintf(&output, _("tape"));
     247        mr_asprintf(&output, _("tape"));
    247248        break;
    248249    case udev:
    249         asprintf(&output, _("udev"));
     250        mr_asprintf(&output, _("udev"));
    250251        break;
    251252    default:
    252         asprintf(&output, _("default"));
     253        mr_asprintf(&output, _("default"));
    253254    }
    254255    return (output);
     
    272273    if (IS_THIS_A_STREAMING_BACKUP(g_backup_media_type)
    273274        && g_backup_media_type != udev) {
    274         asprintf(&command, "mt -f %s offline", dev);
     275        mr_asprintf(&command, "mt -f %s offline", dev);
    275276        res1 = run_program_and_log_output(command, 1);
    276         paranoid_free(command);
     277        mr_free(command);
    277278    } else {
    278279        res1 = 0;
     
    281282#ifdef __FreeBSD__
    282283    if (strstr(dev, "acd")) {
    283         asprintf(&command, "cdcontrol -f %s eject", dev);
    284     } else {
    285         asprintf(&command, "camcontrol eject `echo %s | sed 's|/dev/||'`",
     284        mr_asprintf(&command, "cdcontrol -f %s eject", dev);
     285    } else {
     286        mr_asprintf(&command, "camcontrol eject `echo %s | sed 's|/dev/||'`",
    286287                dev);
    287288    }
    288289#else
    289     asprintf(&command, "eject %s", dev);
     290    mr_asprintf(&command, "eject %s", dev);
    290291#endif
    291292
    292293    log_msg(3, "Ejecting %s", dev);
    293294    res2 = run_program_and_log_output(command, 1);
    294     paranoid_free(command);
     295    mr_free(command);
    295296    if (res1 && res2) {
    296297        return (1);
     
    313314#ifdef __FreeBSD__
    314315    if (strstr(dev, "acd")) {
    315         asprintf(&command, "cdcontrol -f %s close", dev);
    316     } else {
    317         asprintf(&command, "camcontrol load `echo %s | sed 's|/dev/||'`",
     316        mr_asprintf(&command, "cdcontrol -f %s close", dev);
     317    } else {
     318        mr_asprintf(&command, "camcontrol load `echo %s | sed 's|/dev/||'`",
    318319                dev);
    319320    }
    320321#else
    321     asprintf(&command, "eject -t %s", dev);
     322    mr_asprintf(&command, "eject -t %s", dev);
    322323#endif
    323324    i = run_program_and_log_output(command, FALSE);
    324     paranoid_free(command);
     325    mr_free(command);
    325326    return (i);
    326327}
     
    341342    assert_string_is_neither_NULL_nor_zerolength(device);
    342343
    343     asprintf(&tmp, "ls %s > /dev/null 2> /dev/null", device);
     344    mr_asprintf(&tmp, "ls %s > /dev/null 2> /dev/null", device);
    344345
    345346    if (system(tmp)) {
     
    348349        ret = TRUE;
    349350    }
    350     paranoid_free(tmp);
     351    mr_free(tmp);
    351352    return(ret);
    352353}
     
    398399#ifdef __FreeBSD__
    399400    // We assume here that this is running from mondorestore. (It is.)
    400     asprintf(&program, "ls %s >/dev/null 2>&1", drive);
     401    mr_asprintf(&program, "ls %s >/dev/null 2>&1", drive);
    401402    res = system(program);
    402     paranoid_free(program);
     403    mr_free(program);
    403404    return(res);
    404405#endif
    405406
    406     asprintf(&program, "parted2fdisk -l %s 2> /dev/null", drive);
     407    mr_asprintf(&program, "parted2fdisk -l %s 2> /dev/null", drive);
    407408    fin = popen(program, "r");
    408409    if (!fin) {
    409410        log_it("program=%s", program);
    410411        log_OS_error("Cannot popen-in program");
    411         paranoid_free(program);
     412        mr_free(program);
    412413        return (0);
    413414    }
    414     paranoid_free(program);
     415    mr_free(program);
    415416
    416417    searchstr = build_partition_name(drive, partno);
    417     asprintf(&tmp, "%s ", searchstr);
    418     paranoid_free(searchstr);
    419 
    420     for (res = 0; !res && getline(&incoming, &n, fin);) {
     418    mr_asprintf(&tmp, "%s ", searchstr);
     419    mr_free(searchstr);
     420
     421    for (res = 0; !res ;) {
     422        mr_getline(&incoming, &n, fin);
    421423        if (strstr(incoming, tmp)) {
    422424            res = 1;
    423425        }
    424426    }
    425     paranoid_free(incoming);
     427    mr_free(incoming);
    426428
    427429    if (pclose(fin)) {
    428430        log_OS_error("Cannot pclose fin");
    429431    }
    430     paranoid_free(tmp);
     432    mr_free(tmp);
    431433    return (res);
    432434}
     
    450452    assert_string_is_neither_NULL_nor_zerolength(str);
    451453
    452     asprintf(&command,
     454    mr_asprintf(&command,
    453455            "dd if=%s bs=446 count=1 2> /dev/null | strings | grep \"%s\" > /dev/null 2> /dev/null",
    454456            dev, str);
    455457    ret = system(command);
    456     paranoid_free(command);
     458    mr_free(command);
    457459    if (ret) {
    458460        return (FALSE);
     
    477479    int ret;
    478480
    479     asprintf(&command,
     481    mr_asprintf(&command,
    480482            "dd if=%s bs=512 count=%i 2> /dev/null | strings | grep \"%s\" > /dev/null 2> /dev/null",
    481483            dev, n, str);
    482484    ret = system(command);
    483     paranoid_free(command);
     485    mr_free(command);
    484486
    485487    if (ret) {
     
    514516    if (g_backup_media_type == dvd) {
    515517        if (g_dvd_drive_is_here != NULL) {
    516             asprintf(&dev, g_dvd_drive_is_here);
     518            mr_asprintf(&dev, g_dvd_drive_is_here);
    517519        } else {
    518520            dev = find_dvd_device();
     
    520522    } else {
    521523        if (g_cdrom_drive_is_here != NULL) {
    522             asprintf(&dev, g_cdrom_drive_is_here);
     524            mr_asprintf(&dev, g_cdrom_drive_is_here);
    523525        } else {
    524526            // find_cdrom_device allocates the string
     
    532534
    533535    if ((dev == NULL) || (! mount_CDROM_here(dev, mountpoint))) {
    534         paranoid_free(dev);
     536        mr_free(dev);
    535537        if (!popup_and_get_string
    536538            (_("CD-ROM device"), _("Please enter your CD-ROM's /dev device"), dev)) {
     
    545547        log_msg(1, _("mount succeeded with %s"), dev);
    546548    }
    547     paranoid_free(dev);
     549    mr_free(dev);
    548550    return(res);
    549551}
     
    565567
    566568    if (g_cdrw_drive_is_here != NULL) {
    567         asprintf(&cdrw_device, g_cdrw_drive_is_here);
     569        mr_asprintf(&cdrw_device, g_cdrw_drive_is_here);
    568570        log_msg(3, "Been there, done that. Returning %s", cdrw_device);
    569571        return(cdrw_device);
     
    577579    tmp = find_home_of_exe("cdrecord");
    578580    if (tmp) {
    579         asprintf(&cdr_exe, "cdrecord");
    580     } else {
    581         asprintf(&cdr_exe, "dvdrecord");
    582     }
    583     paranoid_free(tmp);
     581        mr_asprintf(&cdr_exe, "cdrecord");
     582    } else {
     583        mr_asprintf(&cdr_exe, "dvdrecord");
     584    }
     585    mr_free(tmp);
    584586
    585587    tmp1 = find_home_of_exe(cdr_exe);
    586588    if (tmp1) {
    587         asprintf(&command,
     589        mr_asprintf(&command,
    588590                "%s -scanbus 2> /dev/null | tr -s '\t' ' ' | grep \"[0-9]*,[0-9]*,[0-9]*\" | grep -v \"[0-9]*) \\*\" | grep CD | cut -d' ' -f2 | head -n1",
    589591                cdr_exe);
    590         asprintf(&tmp, call_program_and_get_last_line_of_output(command));
    591         paranoid_free(command);
    592     } else {
    593         asprintf(&tmp, " ");
    594     }
    595     paranoid_free(tmp1);
    596     paranoid_free(cdr_exe);
     592        mr_asprintf(&tmp, call_program_and_get_last_line_of_output(command));
     593        mr_free(command);
     594    } else {
     595        mr_asprintf(&tmp, " ");
     596    }
     597    mr_free(tmp1);
     598    mr_free(cdr_exe);
    597599
    598600    if (strlen(tmp) < 2) {
    599         paranoid_free(tmp);
     601        mr_free(tmp);
    600602        return(NULL);
    601603    } else {
    602604        cdrw_device = tmp;
    603605
    604         asprintf(&comment, "Found CDRW device - %s", cdrw_device);
     606        mr_asprintf(&comment, "Found CDRW device - %s", cdrw_device);
    605607        log_it(comment);
    606         paranoid_free(comment);
    607 
    608         paranoid_free(g_cdrw_drive_is_here);
    609         asprintf(&g_cdrw_drive_is_here, cdrw_device);
     608        mr_free(comment);
     609
     610        mr_free(g_cdrw_drive_is_here);
     611        mr_asprintf(&g_cdrw_drive_is_here, cdrw_device);
    610612        return(cdrw_device);
    611613    }
     
    649651
    650652    if ((g_cdrom_drive_is_here != NULL) && !isdigit(g_cdrom_drive_is_here[0])) {
    651         asprintf(&output, g_cdrom_drive_is_here);
     653        mr_asprintf(&output, g_cdrom_drive_is_here);
    652654        log_msg(3, "Been there, done that. Returning %s", output);
    653655        return(output);
    654656    }
    655657    if ((the_last_place_i_found_it != NULL) && !try_to_mount) {
    656         asprintf(&output, the_last_place_i_found_it);
     658        mr_asprintf(&output, the_last_place_i_found_it);
    657659        log_msg(3,
    658660                "find_cdrom_device() --- returning last found location - '%s'",
     
    663665    tmp = find_home_of_exe("cdrecord");
    664666    if (tmp) {
    665         asprintf(&cdr_exe, "cdrecord");
    666     } else {
    667         asprintf(&cdr_exe, "dvdrecord");
    668     }
    669     paranoid_free(tmp);
     667        mr_asprintf(&cdr_exe, "cdrecord");
     668    } else {
     669        mr_asprintf(&cdr_exe, "dvdrecord");
     670    }
     671    mr_free(tmp);
    670672
    671673    tmp = find_home_of_exe(cdr_exe);
    672674    if (!tmp) {
    673         asprintf(&output, "/dev/cdrom");
     675        mr_asprintf(&output, "/dev/cdrom");
    674676        log_msg(4, "Can't find cdrecord; assuming %s", output);
    675677        if (!does_device_exist(output)) {
    676678            log_msg(4, "That didn't work. Sorry.");
    677             paranoid_free(cdr_exe);
    678             paranoid_free(output);
     679            mr_free(cdr_exe);
     680            mr_free(output);
    679681            return(NULL);
    680682        } else {
    681             paranoid_free(cdr_exe);
     683            mr_free(cdr_exe);
    682684            return(output);
    683685        }
    684686    }
    685     paranoid_free(tmp);
    686 
    687     asprintf(&command, "%s -scanbus 2> /dev/null", cdr_exe);
     687    mr_free(tmp);
     688
     689    mr_asprintf(&command, "%s -scanbus 2> /dev/null", cdr_exe);
    688690    fin = popen(command, "r");
    689691    if (!fin) {
    690692        log_msg(4, "command=%s", command);
    691693        log_OS_error("Cannot popen command");
    692         paranoid_free(cdr_exe);
    693         paranoid_free(command);
     694        mr_free(cdr_exe);
     695        mr_free(command);
    694696        return (NULL);
    695697    }
    696     paranoid_free(command);
    697 
    698     for (getline(&tmp, &n, fin); !feof(fin);
    699          getline(&tmp, &n, fin)) {
     698    mr_free(command);
     699
     700    for (mr_getline(&tmp, &n, fin); !feof(fin);
     701         mr_getline(&tmp, &n, fin)) {
    700702        p = strchr(tmp, '\'');
    701703        if (p) {
     
    713715                        *q = '\0';
    714716#ifndef __FreeBSD__
    715                         paranoid_free(phrase_two);
    716                         asprintf(&phrase_two, p);
     717                        mr_free(phrase_two);
     718                        mr_asprintf(&phrase_two, p);
    717719#endif
    718720                    }
     
    722724    }
    723725    paranoid_pclose(fin);
    724     paranoid_free(tmp);
     726    mr_free(tmp);
    725727    tmp = NULL;
    726728    n = 0;
     
    730732        log_msg(4, "Not running phase two. String is empty.");
    731733    } else {
    732         asprintf(&command, "dmesg | grep \"%s\" 2> /dev/null", phrase_two);
     734        mr_asprintf(&command, "dmesg | grep \"%s\" 2> /dev/null", phrase_two);
    733735        fin = popen(command, "r");
    734736        if (!fin) {
    735737            log_msg(4, "Cannot run 2nd command - non-fatal, fortunately");
    736738        } else {
    737             for (getline(&tmp, &n, fin); !feof(fin);
    738                  getline(&tmp, &n, fin)) {
     739            for (mr_getline(&tmp, &n, fin); !feof(fin);
     740                 mr_getline(&tmp, &n, fin)) {
    739741                log_msg(5, "--> '%s'", tmp);
    740742                if (tmp[0] != ' ' && tmp[1] != ' ') {
     
    743745                        *p = '\0';
    744746                        if (strstr(tmp, "DVD")) {
    745                             paranoid_free(dvd_last_resort);
    746                             asprintf(&dvd_last_resort, "/dev/%s", tmp);
     747                            mr_free(dvd_last_resort);
     748                            mr_asprintf(&dvd_last_resort, "/dev/%s", tmp);
    747749                            log_msg(4,
    748750                                    "Ignoring '%s' because it's a DVD drive",
    749751                                    tmp);
    750752                        } else {
    751                             asprintf(&output, "/dev/%s", tmp);
     753                            mr_asprintf(&output, "/dev/%s", tmp);
    752754                            found_it = TRUE;
    753755                        }
     
    755757                }
    756758            }
    757             paranoid_free(tmp);
     759            mr_free(tmp);
    758760            paranoid_pclose(fin);
    759761        }
    760         paranoid_free(command);
    761     }
    762     paranoid_free(phrase_two);
     762        mr_free(command);
     763    }
     764    mr_free(phrase_two);
    763765
    764766#endif
     
    789791                                                              "/dev/cd1")))
    790792                                {
    791                                     paranoid_free(cdr_exe);
     793                                    mr_free(cdr_exe);
    792794                                    return(NULL);
    793795                                }
     
    804806            log_msg(4, "Well, I'll use the DVD - %s - as a last resort",
    805807                    dvd_last_resort);
    806             paranoid_free(output);
    807             asprintf(&output, dvd_last_resort);
     808            mr_free(output);
     809            mr_asprintf(&output, dvd_last_resort);
    808810            found_it = TRUE;
    809811        }
    810812    }
    811     paranoid_free(dvd_last_resort);
     813    mr_free(dvd_last_resort);
    812814
    813815    if (found_it) {
    814         asprintf(&tmp, "grep \"%s=ide-scsi\" /proc/cmdline &> /dev/null",
     816        mr_asprintf(&tmp, "grep \"%s=ide-scsi\" /proc/cmdline &> /dev/null",
    815817                strrchr(output, '/') + 1);
    816818        if (system(tmp) == 0) {
     
    819821                    output);
    820822            found_it = FALSE;
    821             paranoid_free(output);
    822         }
    823         paranoid_free(tmp);
     823            mr_free(output);
     824        }
     825        mr_free(tmp);
    824826    }
    825827
     
    829831            log_msg(4, "OK, I was wrong, I haven't found it... yet.");
    830832            found_it = FALSE;
    831             paranoid_free(output);
     833            mr_free(output);
    832834        }
    833835    }
     
    862864                                                                  g_cdrw_drive_is_here)))
    863865                                    {
    864                                         paranoid_free(cdr_exe);
     866                                        mr_free(cdr_exe);
    865867                                        return(NULL);
    866868                                    }
     
    875877#endif
    876878
    877     asprintf(&mountpoint, "/tmp/cd.%d", (int) (random() % 32767));
     879    mr_asprintf(&mountpoint, "/tmp/cd.%d", (int) (random() % 32767));
    878880    make_hole_for_dir(mountpoint);
    879881
     
    882884            log_msg(4, "[Cardigans] I've changed my mind");
    883885            found_it = FALSE;
    884             paranoid_free(output);
     886            mr_free(output);
    885887        } else {
    886             asprintf(&tmp, "%s/archives", mountpoint);
     888            mr_asprintf(&tmp, "%s/archives", mountpoint);
    887889            if (!does_file_exist(tmp)) {
    888890                log_msg(4, "[Cardigans] I'll take it back");
    889891                found_it = FALSE;
    890                 paranoid_free(output);
     892                mr_free(output);
    891893            } else {
    892                 asprintf(&command, "umount %s", output);
     894                mr_asprintf(&command, "umount %s", output);
    893895                paranoid_system(command);
    894                 paranoid_free(command);
     896                mr_free(command);
    895897                log_msg(4, "I'm confident the Mondo CD is in %s", output);
    896898            }
    897             paranoid_free(tmp);
     899            mr_free(tmp);
    898900        }
    899901    }
    900902    unlink(mountpoint);
    901     paranoid_free(mountpoint);
     903    mr_free(mountpoint);
    902904
    903905    if (found_it) {
    904906        if (!does_file_exist(output)) {
    905907            log_msg(3, "I still haven't found it.");
    906             paranoid_free(output);
     908            mr_free(output);
    907909            return(NULL);
    908910        }
    909911        log_msg(3, "(find_cdrom_device) --> '%s'", output);
    910         asprintf(&the_last_place_i_found_it, output);
    911         paranoid_free(g_cdrom_drive_is_here);
    912         asprintf(&g_cdrom_drive_is_here, output);
     912        mr_asprintf(&the_last_place_i_found_it, output);
     913        mr_free(g_cdrom_drive_is_here);
     914        mr_asprintf(&g_cdrom_drive_is_here, output);
    913915        return(output);
    914916    }
    915917
    916     asprintf(&command,
     918    mr_asprintf(&command,
    917919            "%s -scanbus | grep \"[0-9],[0-9],[0-9]\" | grep \"[D|C][V|D]\" | grep -n \"\" | grep \"%s\" | cut -d':' -f2",
    918920            cdr_exe, g_cdrw_drive_is_here);
    919     paranoid_free(cdr_exe);
     921    mr_free(cdr_exe);
    920922
    921923    log_msg(1, "command=%s", command);
    922     asprintf(&tmp, call_program_and_get_last_line_of_output(command));
    923     paranoid_free(command);
     924    mr_asprintf(&tmp, call_program_and_get_last_line_of_output(command));
     925    mr_free(command);
    924926
    925927    if (tmp[0]) {
     
    927929        log_msg(4, "Finally found it at %s", output);
    928930    } else {
    929         paranoid_free(tmp);
    930         paranoid_free(output);
     931        mr_free(tmp);
     932        mr_free(output);
    931933        log_msg(4, "Still couldn't find it.");
    932934    }
     
    942944
    943945    if (g_dvd_drive_is_here != NULL) {
    944         asprintf(&output, g_dvd_drive_is_here);
     946        mr_asprintf(&output, g_dvd_drive_is_here);
    945947        log_msg(3, "Been there, done that. Returning %s", output);
    946948        return (output);
    947949    }
    948950
    949     asprintf(&tmp, call_program_and_get_last_line_of_output
     951    mr_asprintf(&tmp, call_program_and_get_last_line_of_output
    950952            ("dvdrecord -scanbus 2> /dev/null | grep \") '\" | grep -n \"\" | grep DVD | cut -d':' -f1")
    951953        );
    952954    log_msg(5, "tmp = '%s'", tmp);
    953955    if (!tmp[0]) {
    954         paranoid_free(tmp);
    955         asprintf(&tmp, call_program_and_get_last_line_of_output
     956        mr_free(tmp);
     957        mr_asprintf(&tmp, call_program_and_get_last_line_of_output
    956958                ("cdrecord -scanbus 2> /dev/null | grep \") '\" | grep -n \"\" | grep DVD | cut -d':' -f1")
    957959            );
     
    960962        devno = atoi(tmp) - 1;
    961963    }
    962     paranoid_free(tmp);
     964    mr_free(tmp);
    963965
    964966    if (devno >= 0) {
    965967        retval = 0;
    966         asprintf(&output, "/dev/scd%d", devno);
    967         paranoid_free(g_dvd_drive_is_here);
    968         asprintf(&g_dvd_drive_is_here, output);
     968        mr_asprintf(&output, "/dev/scd%d", devno);
     969        mr_free(g_dvd_drive_is_here);
     970        mr_asprintf(&g_dvd_drive_is_here, output);
    969971        log_msg(2, "I think DVD is at %s", output);
    970972    } else {
     
    10921094    assert_string_is_neither_NULL_nor_zerolength(format);
    10931095
    1094     asprintf(&format_sz, "%s ", format);
     1096    mr_asprintf(&format_sz, "%s ", format);
    10951097
    10961098#ifdef __FreeBSD__
    1097     asprintf(&command,
     1099    mr_asprintf(&command,
    10981100            "lsvfs | tr -s '\t' ' ' | grep -v Filesys | grep -v -- -- | cut -d' ' -f1 | tr -s '\n' ' '");
    10991101#else
    1100     asprintf(&command,
     1102    mr_asprintf(&command,
    11011103            "grep -v nodev /proc/filesystems | tr -s '\t' ' ' | cut -d' ' -f2 | tr -s '\n' ' '");
    11021104#endif
    11031105
    11041106    pin = popen(command, "r");
    1105     paranoid_free(command);
     1107    mr_free(command);
    11061108
    11071109    if (!pin) {
     
    11091111        retval = FALSE;
    11101112    } else {
    1111         getline(&good_formats, &n , pin);
     1113        mr_getline(&good_formats, &n , pin);
    11121114        if (pclose(pin)) {
    11131115            log_OS_error("Cannot pclose good formats");
     
    11151117        strip_spaces(good_formats);
    11161118        // " ntfs 7 " -- um, cheating much? :)
    1117         asprintf(&tmp, " %s swap lvm raid ntfs 7 ",good_formats);
    1118         paranoid_free(good_formats);
     1119        mr_asprintf(&tmp, " %s swap lvm raid ntfs 7 ",good_formats);
     1120        mr_free(good_formats);
    11191121        good_formats = tmp;
    11201122
     
    11241126            retval = FALSE;
    11251127        }
    1126         paranoid_free(good_formats);
    1127     }
    1128     paranoid_free(format_sz);
     1128        mr_free(good_formats);
     1129    }
     1130    mr_free(format_sz);
    11291131    return (retval);
    11301132}
     
    11641166        log_msg(1, "%s needs to have a '/' prefixed - I'll do it",
    11651167                device_raw);
    1166         asprintf(&tmp, "/%s", device_raw);
    1167     } else {
    1168         asprintf(&tmp, device_raw);
     1168        mr_asprintf(&tmp, "/%s", device_raw);
     1169    } else {
     1170        mr_asprintf(&tmp, device_raw);
    11691171    }
    11701172    log_msg(1, "Is %s mounted?", tmp);
     
    11741176        return (FALSE);
    11751177    }
    1176     asprintf(&device_with_tab, "%s\t", tmp);
    1177     asprintf(&device_with_space, "%s ", tmp);
    1178     paranoid_free(tmp);
     1178    mr_asprintf(&device_with_tab, "%s\t", tmp);
     1179    mr_asprintf(&device_with_space, "%s ", tmp);
     1180    mr_free(tmp);
    11791181
    11801182    if (!(fin = popen("mount", "r"))) {
     
    11821184        return (FALSE);
    11831185    }
    1184     for (getline(&incoming, &n, fin); !feof(fin);
    1185          getline(&incoming, &n, fin)) {
     1186    for (mr_getline(&incoming, &n, fin); !feof(fin);
     1187         mr_getline(&incoming, &n, fin)) {
    11861188        if (strstr(incoming, device_with_space) //> incoming
    11871189            || strstr(incoming, device_with_tab))   // > incoming)
     
    11911193        }
    11921194    }
    1193     paranoid_free(incoming);
    1194     paranoid_free(device_with_tab);
     1195    mr_free(incoming);
     1196    mr_free(device_with_tab);
    11951197    paranoid_pclose(fin);
    11961198
    1197     asprintf(&tmp, "%s | grep -w \"%s\" > /dev/null 2> /dev/null",
     1199    mr_asprintf(&tmp, "%s | grep -w \"%s\" > /dev/null 2> /dev/null",
    11981200            SWAPLIST_COMMAND, device_with_space);
    1199     paranoid_free(device_with_space);
     1201    mr_free(device_with_space);
    12001202
    12011203    log_msg(4, "tmp (command) = '%s'", tmp);
    12021204    if (!system(tmp)) {
    1203         paranoid_free(tmp);
     1205        mr_free(tmp);
    12041206        return(TRUE);
    12051207    }
    1206     paranoid_free(tmp);
     1208    mr_free(tmp);
    12071209    return (FALSE);
    12081210}
     
    12281230         ("/sbin/sysctl -n kern.osreldate")) < 500000) {
    12291231        do {
    1230             paranoid_free(mddevice);
    1231             asprintf(&mddevice, "vn%ic", vndev++);
    1232 
    1233             paranoid_free(command);
    1234             asprintf(&command, "vnconfig %s %s", mddevice, fname);
     1232            mr_free(mddevice);
     1233            mr_asprintf(&mddevice, "vn%ic", vndev++);
     1234
     1235            mr_free(command);
     1236            mr_asprintf(&command, "vnconfig %s %s", mddevice, fname);
    12351237
    12361238            if (vndev > 10) {
    1237                 paranoid_free(command);
    1238                 paranoid_free(mddevice);
     1239                mr_free(command);
     1240                mr_free(mddevice);
    12391241                return NULL;
    12401242            }
    12411243        }
    12421244        while (system(command));
    1243         paranoid_free(command);
    1244     } else {
    1245         asprintf(&command, "mdconfig -a -t vnode -f %s", fname);
    1246         asprintf(&mddevice, call_program_and_get_last_line_of_output(command));
    1247         paranoid_free(command);
     1245        mr_free(command);
     1246    } else {
     1247        mr_asprintf(&command, "mdconfig -a -t vnode -f %s", fname);
     1248        mr_asprintf(&mddevice, call_program_and_get_last_line_of_output(command));
     1249        mr_free(command);
    12481250
    12491251        if (!strstr(mddevice, "md")) {
    1250             paranoid_free(mddevice);
     1252            mr_free(mddevice);
    12511253            return NULL;
    12521254        }
    12531255    }
    1254     asprintf(&device, "/dev/%s", mddevice);
    1255     paranoid_free(mddevice);
     1256    mr_asprintf(&device, "/dev/%s", mddevice);
     1257    mr_free(mddevice);
    12561258    return(device);
    12571259}
     
    12781280        (call_program_and_get_last_line_of_output
    12791281         ("/sbin/sysctl -n kern.osreldate")) < 500000) {
    1280         asprintf(&command, "vnconfig -d %s", dname);
     1282        mr_asprintf(&command, "vnconfig -d %s", dname);
    12811283        ret = system(command);
    1282         paranoid_free(command);
     1284        mr_free(command);
    12831285        return(ret);
    12841286    } else {
    1285         asprintf(&command, "mdconfig -d -u %s", dname);
     1287        mr_asprintf(&command, "mdconfig -d -u %s", dname);
    12861288        ret = system(command);
    1287         paranoid_free(command);
     1289        mr_free(command);
    12881290        return(ret);
    12891291    }
     
    13271329    }
    13281330
    1329     asprintf(&tmp, "mkdir -p " MNT_CDROM);
     1331    mr_asprintf(&tmp, "mkdir -p " MNT_CDROM);
    13301332    run_program_and_log_output(tmp, 5);
    1331     paranoid_free(tmp);
     1333    mr_free(tmp);
    13321334
    13331335    if (g_ISO_restore_mode || bkpinfo->backup_media_type == iso
     
    13411343        }
    13421344        system("mkdir -p /tmp/isodir &> /dev/null");
    1343         asprintf(&tmp, "%s/%s/%s-%d.iso", bkpinfo->isodir,
     1345        mr_asprintf(&tmp, "%s/%s/%s-%d.iso", bkpinfo->isodir,
    13441346                bkpinfo->nfs_remote_dir, bkpinfo->prefix,
    13451347                cd_number_i_want);
    13461348        if (!does_file_exist(tmp)) {
    1347             paranoid_free(tmp);
    1348             asprintf(&tmp, "/tmp/isodir/%s/%s-%d.iso",
     1349            mr_free(tmp);
     1350            mr_asprintf(&tmp, "/tmp/isodir/%s/%s-%d.iso",
    13491351                    bkpinfo->nfs_remote_dir, bkpinfo->prefix,
    13501352                    cd_number_i_want);
     
    13531355                        "FIXME - hacking bkpinfo->isodir from '%s' to /tmp/isodir",
    13541356                        bkpinfo->isodir);
    1355                 paranoid_alloc(bkpinfo->isodir, "/tmp/isodir");
     1357                mr_allocstr(bkpinfo->isodir, "/tmp/isodir");
    13561358            }
    13571359        }
     
    13601362            fatal_error("Mommy!");
    13611363        }
    1362         paranoid_free(tmp);
     1364        mr_free(tmp);
    13631365    }
    13641366    if ((res = what_number_cd_is_this(bkpinfo)) != cd_number_i_want) {
    13651367        log_msg(3, "Currently, we hold %d but we want %d", res,
    13661368                cd_number_i_want);
    1367         asprintf(&tmp, "Insisting on %s #%d",
     1369        mr_asprintf(&tmp, "Insisting on %s #%d",
    13681370                bkpinfo->backup_media_string,
    13691371                cd_number_i_want);
    1370         asprintf(&request, "Please insert %s #%d and press Enter.",
     1372        mr_asprintf(&request, "Please insert %s #%d and press Enter.",
    13711373                bkpinfo->backup_media_string,
    13721374                cd_number_i_want);
    13731375        log_msg(3, tmp);
    1374         paranoid_free(tmp);
     1376        mr_free(tmp);
    13751377
    13761378        while (what_number_cd_is_this(bkpinfo) != cd_number_i_want) {
     
    13991401            sync();
    14001402        }
    1401         paranoid_free(request);
     1403        mr_free(request);
    14021404
    14031405        log_msg(1, "Thankyou. Proceeding...");
     
    14941496                finish(1);
    14951497            }
    1496             asprintf(&comment, _("What speed is your %s (re)writer?"),
     1498            mr_asprintf(&comment, _("What speed is your %s (re)writer?"),
    14971499                    bkpinfo->backup_media_string);
    14981500            if (bkpinfo->backup_media_type == dvd) {
    1499                 paranoid_free(bkpinfo->media_device);
     1501                mr_free(bkpinfo->media_device);
    15001502                bkpinfo->media_device = find_dvd_device();
    1501                 asprintf(&tmp, "1");
    1502                 asprintf(&sz_size, "%d", DEFAULT_DVD_DISK_SIZE);    // 4.7 salesman's GB = 4.482 real GB = 4582 MB
     1503                mr_asprintf(&tmp, "1");
     1504                mr_asprintf(&sz_size, "%d", DEFAULT_DVD_DISK_SIZE); // 4.7 salesman's GB = 4.482 real GB = 4582 MB
    15031505                log_msg(1, "Setting to DVD defaults");
    15041506            } else {
    1505                 paranoid_alloc(bkpinfo->media_device,VANILLA_SCSI_CDROM );
    1506                 asprintf(&tmp, "4");
    1507                 asprintf(&sz_size, "650");
     1507                mr_allocstr(bkpinfo->media_device,VANILLA_SCSI_CDROM );
     1508                mr_asprintf(&tmp, "4");
     1509                mr_asprintf(&sz_size, "650");
    15081510                log_msg(1, "Setting to CD defaults");
    15091511            }
     
    15141516                }
    15151517            }
    1516             paranoid_free(comment);
     1518            mr_free(comment);
    15171519
    15181520            bkpinfo->cdrw_speed = atoi(tmp);    // if DVD then this shouldn't ever be used anyway :)
    1519             paranoid_free(tmp);
    1520 
    1521             asprintf(&comment,
     1521            mr_free(tmp);
     1522
     1523            mr_asprintf(&comment,
    15221524                    _("How much data (in Megabytes) will each %s store?"),
    15231525                    bkpinfo->backup_media_string);
     
    15271529                finish(1);
    15281530            }
    1529             paranoid_free(comment);
     1531            mr_free(comment);
    15301532
    15311533            for (i = 0; i <= MAX_NOOF_MEDIA; i++) {
    15321534                bkpinfo->media_size[i] = atoi(sz_size);
    15331535            }
    1534             paranoid_free(sz_size);
     1536            mr_free(sz_size);
    15351537
    15361538            if (bkpinfo->media_size[0] <= 0) {
     
    15411543    case cdstream:
    15421544        if (bkpinfo->disaster_recovery) {
    1543             paranoid_alloc(bkpinfo->media_device, "/dev/cdrom");
     1545            mr_allocstr(bkpinfo->media_device, "/dev/cdrom");
    15441546            log_msg(2, "CD-ROM device assumed to be at %s",
    15451547                    bkpinfo->media_device);
     
    15471549                   || bkpinfo->backup_media_type == dvd) {
    15481550            if (bkpinfo->media_device == NULL) {
    1549                 asprintf(&bkpinfo->media_device, "/dev/cdrom");
     1551                mr_asprintf(&bkpinfo->media_device, "/dev/cdrom");
    15501552            }                   // just for the heck of it :)
    15511553            log_msg(1, "bkpinfo->media_device = %s",
     
    15541556            if ((bkpinfo->backup_media_type == dvd)
    15551557                || (tmp != NULL)) {
    1556                 paranoid_alloc(bkpinfo->media_device, tmp);
     1558                mr_allocstr(bkpinfo->media_device, tmp);
    15571559                log_msg(1, "bkpinfo->media_device = %s",
    15581560                        bkpinfo->media_device);
    1559                 asprintf(&comment,
     1561                mr_asprintf(&comment,
    15601562                        _("Please specify your %s drive's /dev entry"),
    15611563                        bkpinfo->backup_media_string);
     
    15651567                    finish(1);
    15661568                }
    1567                 paranoid_free(comment);
    1568             }
    1569             paranoid_free(tmp);
     1569                mr_free(comment);
     1570            }
     1571            mr_free(tmp);
    15701572
    15711573            log_msg(2, "%s device found at %s",
     
    15751577            bkpinfo->media_device = find_cdrw_device();
    15761578            if (bkpinfo->media_device != NULL) {
    1577                 asprintf(&tmp,
     1579                mr_asprintf(&tmp,
    15781580                        _("I think I've found your %s burner at SCSI node %s; am I right on the money? Say no if you have an IDE burner and you are running a 2.6 kernel. Instead, specify the IDE burner's /dev address at the next screen."),
    15791581                        bkpinfo->backup_media_string,
    15801582                        bkpinfo->media_device);
    15811583                if (!ask_me_yes_or_no(tmp)) {
    1582                     paranoid_free(bkpinfo->media_device);
     1584                    mr_free(bkpinfo->media_device);
    15831585                }
    1584                 paranoid_free(tmp);
     1586                mr_free(tmp);
    15851587            } else {
    15861588                if (g_kernel_version < 2.6) {
     
    16131615    case tape:
    16141616
    1615         paranoid_free(bkpinfo->media_device);
     1617        mr_free(bkpinfo->media_device);
    16161618        if (find_tape_device_and_size(bkpinfo->media_device, sz_size)) {
    16171619            log_msg(3, _("Ok, using vanilla scsi tape."));
    1618             paranoid_alloc(bkpinfo->media_device,VANILLA_SCSI_TAPE"0" );
     1620            mr_allocstr(bkpinfo->media_device,VANILLA_SCSI_TAPE"0" );
    16191621            if ((fin = fopen(bkpinfo->media_device, "r"))) {
    16201622                paranoid_fclose(fin);
    16211623            } else {
    1622                 paranoid_alloc(bkpinfo->media_device,"/dev/osst0");
     1624                mr_allocstr(bkpinfo->media_device,"/dev/osst0");
    16231625            }
    16241626        }
     
    16281630            } else {
    16291631                if (does_file_exist("/tmp/mondo-restore.cfg")) {
    1630                     paranoid_free(bkpinfo->media_device);
     1632                    mr_free(bkpinfo->media_device);
    16311633                    read_cfg_var("/tmp/mondo-restore.cfg", "media-dev",
    16321634                                 bkpinfo->media_device);
    16331635                }
    16341636            }
    1635             asprintf(&tmp,
     1637            mr_asprintf(&tmp,
    16361638                    _("I think I've found your tape streamer at %s; am I right on the money?"),
    16371639                    bkpinfo->media_device);
    16381640            if (!ask_me_yes_or_no(tmp)) {
    1639                 paranoid_free(bkpinfo->media_device);
    1640             }
    1641             paranoid_free(tmp);
     1641                mr_free(bkpinfo->media_device);
     1642            }
     1643            mr_free(tmp);
    16421644        } else {
    16431645            if (!popup_and_get_string
     
    16491651            }
    16501652        }
    1651         asprintf(&tmp, "ls -l %s", bkpinfo->media_device);
     1653        mr_asprintf(&tmp, "ls -l %s", bkpinfo->media_device);
    16521654        if (run_program_and_log_output(tmp, FALSE)) {
    16531655            log_to_screen(_("User has not specified a valid /dev entry"));
    16541656            finish(1);
    16551657        }
    1656         paranoid_free(tmp);
     1658        mr_free(tmp);
    16571659        log_msg(4, "sz_size = %s", sz_size);
    1658         paranoid_free(sz_size);
     1660        mr_free(sz_size);
    16591661        bkpinfo->media_size[0] = 0;
    16601662        log_msg(4, "media_size[0] = %ld", bkpinfo->media_size[0]);
     
    17081710            if (bkpinfo->nfs_mount[strlen(bkpinfo->nfs_mount) - 1] == '/')
    17091711                bkpinfo->nfs_mount[strlen(bkpinfo->nfs_mount) - 1] = '\0';
    1710             asprintf(&command, "mount | grep \"%s \" | cut -d' ' -f3",
     1712            mr_asprintf(&command, "mount | grep \"%s \" | cut -d' ' -f3",
    17111713                    bkpinfo->nfs_mount);
    1712             paranoid_free(bkpinfo->isodir);
     1714            mr_free(bkpinfo->isodir);
    17131715            bkpinfo->isodir = call_program_and_get_last_line_of_output(command);
    1714             paranoid_free(command);
    1715 
    1716             asprintf(&comment,
     1716            mr_free(command);
     1717
     1718            mr_asprintf(&comment,
    17171719                    _("How much data (in Megabytes) will each media store?"));
    17181720            if (!popup_and_get_string(_("Size"), comment, sz_size)) {
     
    17271729                finish(1);
    17281730            }
    1729             paranoid_free(comment);
     1731            mr_free(comment);
    17301732        }
    17311733        if (bkpinfo->disaster_recovery) {
     
    17391741        }
    17401742        if (!is_this_device_mounted(bkpinfo->nfs_mount)) {
    1741             paranoid_free(bkpinfo->isodir);
    1742             asprintf(&bkpinfo->isodir, "/tmp/isodir.mondo.%d",
     1743            mr_free(bkpinfo->isodir);
     1744            mr_asprintf(&bkpinfo->isodir, "/tmp/isodir.mondo.%d",
    17431745                    (int) (random() % 32768));
    1744             asprintf(&command, "mkdir -p %s", bkpinfo->isodir);
     1746            mr_asprintf(&command, "mkdir -p %s", bkpinfo->isodir);
    17451747            run_program_and_log_output(command, 5);
    1746             paranoid_free(command);
    1747 
    1748             asprintf(&tmp, "mount -t nfs -o nolock %s %s", bkpinfo->nfs_mount,
     1748            mr_free(command);
     1749
     1750            mr_asprintf(&tmp, "mount -t nfs -o nolock %s %s", bkpinfo->nfs_mount,
    17491751                    bkpinfo->isodir);
    17501752            run_program_and_log_output(tmp, 5);
    1751             paranoid_free(tmp);
    1752             asprintf(&g_selfmounted_isodir, bkpinfo->isodir);
     1753            mr_free(tmp);
     1754            mr_asprintf(&g_selfmounted_isodir, bkpinfo->isodir);
    17531755        }
    17541756        if (!is_this_device_mounted(bkpinfo->nfs_mount)) {
     
    17631765        }
    17641766
    1765         asprintf(&command, "echo hi > '%s/%s/.dummy.txt'", bkpinfo->isodir,
     1767        mr_asprintf(&command, "echo hi > '%s/%s/.dummy.txt'", bkpinfo->isodir,
    17661768                bkpinfo->nfs_remote_dir);
    17671769        while (run_program_and_log_output(command, FALSE)) {
    1768             asprintf(&prompt,
     1770            mr_asprintf(&prompt,
    17691771                     _("Directory '%s' under mountpoint '%s' does not exist or is not writable. You can fix this or change the directory and retry or cancel the backup."),
    17701772                     bkpinfo->nfs_remote_dir, bkpinfo->isodir);
     
    17741776                finish(1);
    17751777            }
    1776             paranoid_free(prompt);
    1777 
    1778             paranoid_free(command);
    1779             asprintf(&command, "echo hi > %s/%s/.dummy.txt",
     1778            mr_free(prompt);
     1779
     1780            mr_free(command);
     1781            mr_asprintf(&command, "echo hi > %s/%s/.dummy.txt",
    17801782                     bkpinfo->isodir, bkpinfo->nfs_remote_dir);
    17811783        }
    1782         paranoid_free(command);
     1784        mr_free(command);
    17831785
    17841786        if (!popup_and_get_string
     
    18451847
    18461848        if (bkpinfo->boot_device) {
    1847             paranoid_free(bkpinfo->boot_device);
     1849            mr_free(bkpinfo->boot_device);
    18481850        }
    18491851#ifdef __FreeBSD__
     
    19031905        }
    19041906        bkpinfo->boot_loader = i;
    1905         asprintf(&bkpinfo->include_paths, "/");
     1907        mr_asprintf(&bkpinfo->include_paths, "/");
    19061908        if (!popup_and_get_string
    19071909            (_("Backup paths"),
     
    19161918            if (bkpinfo->exclude_paths != NULL) {
    19171919                tmp1 = bkpinfo->exclude_paths;
    1918                 asprintf(&bkpinfo->exclude_paths, "%s %s", tmp1, tmp);
    1919                 paranoid_free(tmp1);
     1920                mr_asprintf(&bkpinfo->exclude_paths, "%s %s", tmp1, tmp);
     1921                mr_free(tmp1);
    19201922            } else {
    19211923                bkpinfo->exclude_paths = tmp;
    19221924            }
    19231925        }
    1924         paranoid_free(tmp);
     1926        mr_free(tmp);
    19251927// NTFS
    19261928        tmp = call_program_and_get_last_line_of_output
     
    19361938            if (bkpinfo->image_devs != NULL) {
    19371939                tmp2 = bkpinfo->image_devs;
    1938                 asprintf(&bkpinfo->image_devs, "%s %s", tmp2, tmp1);
    1939                 paranoid_free(tmp2);
     1940                mr_asprintf(&bkpinfo->image_devs, "%s %s", tmp2, tmp1);
     1941                mr_free(tmp2);
    19401942            } else {
    19411943                bkpinfo->image_devs = tmp1;
    19421944            }
    1943             paranoid_free(tmp1);
    1944         }
    1945         paranoid_free(tmp);
     1945            mr_free(tmp1);
     1946        }
     1947        mr_free(tmp);
    19461948
    19471949        if (!popup_and_get_string
     
    19611963        if (!ask_me_yes_or_no
    19621964            (_("Are you confident that your kernel is a sane, sensible, standard Linux kernel? Say 'no' if you are using a Gentoo <1.4 or Debian <3.0, please."))){
    1963             paranoid_alloc(bkpinfo->kernel_path, "FAILSAFE");
     1965            mr_allocstr(bkpinfo->kernel_path, "FAILSAFE");
    19641966        }
    19651967#endif
     
    19921994    log_it("media size = %ld", bkpinfo->media_size[1]);
    19931995    log_it("media type = %s", bkpinfo->backup_media_string);
    1994     paranoid_free(tmp);
     1996    mr_free(tmp);
    19951997    log_it("prefix = %s", bkpinfo->prefix);
    19961998    log_it("compression = %ld", bkpinfo->compression_level);
     
    20242026           ("mount -t coda,ncpfs,nfs,smbfs,cifs,afs,mvfs | tr -s '\t' ' ' | cut -d' ' -f3 | tr -s '\n' ' ' | awk '{print $0;}'"));
    20252027    /* BERLIOS : Useless
    2026     asprintf(&exclude_these_devices,
     2028    mr_asprintf(&exclude_these_devices,
    20272029           call_program_and_get_last_line_of_output
    20282030           ("tr -s '\t' ' ' < /etc/fstab | grep -E '( (coda|ncpfs|nfs|smbfs|cifs|mvfs) )' | cut -d' ' -f1 | tr -s '\n' ' ' | awk '{print $0;}'"));
     
    20572059
    20582060    if (tmp[0] != '/') {
    2059         asprintf(&sz, "/%s", tmp);
    2060         paranoid_free(tmp);
     2061        mr_asprintf(&sz, "/%s", tmp);
     2062        mr_free(tmp);
    20612063        tmp = sz;
    20622064    }
     
    20652067    }
    20662068    i = (int) (random() % 32768);
    2067     paranoid_free(bkpinfo->tmpdir);
    2068     asprintf(&bkpinfo->tmpdir, "%s/mondo.tmp.%d", tmp, i);
     2069    mr_free(bkpinfo->tmpdir);
     2070    mr_asprintf(&bkpinfo->tmpdir, "%s/mondo.tmp.%d", tmp, i);
    20692071    log_it("bkpinfo->tmpdir is being set to %s", bkpinfo->tmpdir);
    20702072
    2071     paranoid_free(bkpinfo->scratchdir);
    2072     asprintf(&bkpinfo->scratchdir, "%s/mondo.scratch.%d", tmp, i);
     2073    mr_free(bkpinfo->scratchdir);
     2074    mr_asprintf(&bkpinfo->scratchdir, "%s/mondo.scratch.%d", tmp, i);
    20732075    log_it("bkpinfo->scratchdir is being set to %s", bkpinfo->scratchdir);
    20742076
    2075     asprintf(&g_erase_tmpdir_and_scratchdir, "rm -Rf %s %s", bkpinfo->tmpdir,
     2077    mr_asprintf(&g_erase_tmpdir_and_scratchdir, "rm -Rf %s %s", bkpinfo->tmpdir,
    20762078            bkpinfo->scratchdir);
    20772079
    2078     asprintf(&command, "rm -Rf %s/mondo.tmp.* %s/mondo.scratch.*", tmp, tmp);
    2079     paranoid_free(tmp);
     2080    mr_asprintf(&command, "rm -Rf %s/mondo.tmp.* %s/mondo.scratch.*", tmp, tmp);
     2081    mr_free(tmp);
    20802082
    20812083    paranoid_system(command);
    2082     paranoid_free(command);
     2084    mr_free(command);
    20832085}
    20842086
     
    20992101    char *command;
    21002102
    2101     paranoid_free(output);
     2103    mr_free(output);
    21022104    if (!dev || dev[0] == '\0') {
    21032105        return (FALSE);
     
    21092111        return (FALSE);
    21102112    }
    2111     asprintf(&command, "dd bs=%ld count=1 if=%s of=/dev/null &> /dev/null",
     2113    mr_asprintf(&command, "dd bs=%ld count=1 if=%s of=/dev/null &> /dev/null",
    21122114            512L, dev);
    21132115    if (!run_program_and_log_output(command, FALSE)
    21142116        && !run_program_and_log_output(command, FALSE)) {
    2115         asprintf(&output, dev);
     2117        mr_asprintf(&output, dev);
    21162118        log_msg(4, "Found it - %s", dev);
    2117         paranoid_free(command);
     2119        mr_free(command);
    21182120        return (TRUE);
    21192121    } else {
    21202122        log_msg(4, "It's not %s", dev);
    2121         paranoid_free(command);
     2123        mr_free(command);
    21222124        return (FALSE);
    21232125    }
     
    21412143    assert(bkpinfo != NULL);
    21422144    if (g_ISO_restore_mode) {
    2143         asprintf(&tmp, "mount | grep iso9660 | awk '{print $3;}'");
     2145        mr_asprintf(&tmp, "mount | grep iso9660 | awk '{print $3;}'");
    21442146
    21452147        tmp1 = call_program_and_get_last_line_of_output(tmp);
    2146         paranoid_free(tmp);
    2147 
    2148         asprintf(&mountdev, "%s/archives/THIS-CD-NUMBER", tmp1);
    2149         paranoid_free(tmp1);
     2148        mr_free(tmp);
     2149
     2150        mr_asprintf(&mountdev, "%s/archives/THIS-CD-NUMBER", tmp1);
     2151        mr_free(tmp1);
    21502152
    21512153        tmp = last_line_of_file(mountdev);
    21522154        cd_number = atoi(tmp);
    2153         paranoid_free(mountdev);
    2154         paranoid_free(tmp);
     2155        mr_free(mountdev);
     2156        mr_free(tmp);
    21552157
    21562158        return (cd_number);
     
    21672169    tmp = last_line_of_file(MNT_CDROM "/archives/THIS-CD-NUMBER");
    21682170    cd_number = atoi(tmp);
    2169     paranoid_free(tmp);
     2171    mr_free(tmp);
    21702172    return (cd_number);
    21712173}
     
    21902192           ("mount | grep \" on / \" | cut -d' ' -f1 | sed s/[0-9]// | sed s/[0-9]//");
    21912193    if (strstr(tmp, "/dev/cciss/")) {
    2192         paranoid_free(tmp);
     2194        mr_free(tmp);
    21932195        tmp = call_program_and_get_last_line_of_output
    21942196               ("mount | grep \" on / \" | cut -d' ' -f1 | cut -dp -f1");
    21952197    }
    21962198    if (strstr(tmp, "/dev/md")) {
    2197         paranoid_free(tmp);
     2199        mr_free(tmp);
    21982200        tmp = call_program_and_get_last_line_of_output
    21992201               ("mount | grep \" on / \" | cut -d' ' -f1");
     
    22782280#endif
    22792281    assert(which_device != NULL);
    2280     asprintf(&list_drives_cmd,
     2282    mr_asprintf(&list_drives_cmd,
    22812283            "parted2fdisk -l 2>/dev/null | grep \"/dev/.*:\" | tr -s ':' ' ' | tr -s ' ' '\n' | grep /dev/; echo %s",
    22822284            where_is_root_mounted());
     
    22852287    if (!(pdrives = popen(list_drives_cmd, "r"))) {
    22862288        log_OS_error("Unable to open list of drives");
    2287         paranoid_free(list_drives_cmd);
     2289        mr_free(list_drives_cmd);
    22882290        return ('\0');
    22892291    }
    2290     paranoid_free(list_drives_cmd);
    2291 
    2292     for (getline(&current_drive, &n, pdrives); !feof(pdrives);
    2293          getline(&current_drive, &n, pdrives)) {
     2292    mr_free(list_drives_cmd);
     2293
     2294    for (mr_getline(&current_drive, &n, pdrives); !feof(pdrives);
     2295         mr_getline(&current_drive, &n, pdrives)) {
    22942296        strip_spaces(current_drive);
    22952297        log_it("looking at drive %s's MBR", current_drive);
    22962298        if (does_string_exist_in_boot_block(current_drive, "GRUB")) {
    22972299            count_grubs++;
    2298             paranoid_alloc(which_device,current_drive);
     2300            mr_allocstr(which_device,current_drive);
    22992301            break;
    23002302        }
    23012303        if (does_string_exist_in_boot_block(current_drive, "LILO")) {
    23022304            count_lilos++;
    2303             paranoid_alloc(which_device,current_drive);
     2305            mr_allocstr(which_device,current_drive);
    23042306            break;
    23052307        }
     
    23712373        log_it
    23722374            ("resolve_softlinks_to_get_to_actual_device_file --- device not found");
    2373         asprintf(&output, incoming);
    2374     } else {
    2375         asprintf(&curr_fname, incoming);
     2375        mr_asprintf(&output, incoming);
     2376    } else {
     2377        mr_asprintf(&curr_fname, incoming);
    23762378        lstat(curr_fname, &statbuf);
    23772379        while (S_ISLNK(statbuf.st_mode)) {
    23782380            log_msg(1, "curr_fname = %s", curr_fname);
    2379             asprintf(&command, "file %s", curr_fname);
     2381            mr_asprintf(&command, "file %s", curr_fname);
    23802382            tmp = call_program_and_get_last_line_of_output(command);
    2381             paranoid_free(command);
     2383            mr_free(command);
    23822384
    23832385            for (p = tmp + strlen(tmp); p != tmp && *p != '`' && *p != ' ';
    23842386                 p--);
    23852387            p++;
    2386             asprintf(&scratch, p);
     2388            mr_asprintf(&scratch, p);
    23872389            for (p = scratch; *p != '\0' && *p != '\''; p++);
    23882390            *p = '\0';
    23892391            log_msg(0, "curr_fname %s --> '%s' --> %s", curr_fname, tmp, scratch);
    2390             paranoid_free(tmp);
     2392            mr_free(tmp);
    23912393
    23922394            if (scratch[0] == '/') {
    2393                 paranoid_free(curr_fname);
    2394                 asprintf(&curr_fname, scratch); // copy whole thing because it's an absolute softlink
     2395                mr_free(curr_fname);
     2396                mr_asprintf(&curr_fname, scratch);  // copy whole thing because it's an absolute softlink
    23952397            } else {            // copy over the basename cos it's a relative softlink
    23962398                p = curr_fname + strlen(curr_fname);
     
    24022404                }
    24032405                *p = '\0';
    2404                 asprintf(&tmp, "%s%s", curr_fname, scratch);
    2405                 paranoid_free(curr_fname);
     2406                mr_asprintf(&tmp, "%s%s", curr_fname, scratch);
     2407                mr_free(curr_fname);
    24062408                curr_fname = tmp;
    24072409            }
    2408             paranoid_free(scratch);
     2410            mr_free(scratch);
    24092411            lstat(curr_fname, &statbuf);
    24102412        }
    2411         asprintf(&output, curr_fname);
     2413        mr_asprintf(&output, curr_fname);
    24122414        log_it("resolved %s to %s", incoming, output);
    2413         paranoid_free(curr_fname);
     2415        mr_free(curr_fname);
    24142416    }
    24152417    return (output);
     
    24312433
    24322434    log_msg(0, "Looking for partition table format type");
    2433     asprintf(&fdisk, "/sbin/parted2fdisk");
     2435    mr_asprintf(&fdisk, "/sbin/parted2fdisk");
    24342436    log_msg(1, "Using %s", fdisk);
    2435     asprintf(&command, "%s -l %s | grep 'EFI GPT'", fdisk, drive);
    2436     paranoid_free(fdisk);
     2437    mr_asprintf(&command, "%s -l %s | grep 'EFI GPT'", fdisk, drive);
     2438    mr_free(fdisk);
    24372439
    24382440    tmp = call_program_and_get_last_line_of_output(command);
    2439     paranoid_free(command);
     2441    mr_free(command);
    24402442
    24412443    if (strstr(tmp, "GPT") == NULL) {
    2442         asprintf(&output, "MBR");
    2443     } else {
    2444         asprintf(&output, "GPT");
    2445     }
    2446     paranoid_free(tmp);
     2444        mr_asprintf(&output, "MBR");
     2445    } else {
     2446        mr_asprintf(&output, "GPT");
     2447    }
     2448    mr_free(tmp);
    24472449    log_msg(0, "Found %s partition table format type", output);
    24482450    return (output);
  • trunk/mondo/src/common/libmondo-fifo.c

    r808 r900  
    2828#include "mondostructures.h"
    2929#include "libmondo.h"
     30#include "mr_mem.h"
    3031
    3132/**
     
    8283    assert_string_is_neither_NULL_nor_zerolength(device);
    8384    assert(direction == 'w' || direction == 'r');
    84     asprintf(&sz_dir, "%c", direction);
     85    mr_asprintf(&sz_dir, "%c", direction);
    8586    wise_upper_limit = (am_I_in_disaster_recovery_mode()? 8 : 32);
    8687    wise_lower_limit = 1;       // wise_upper_limit/2 + 1;
     
    8889    for (bufsize = wise_upper_limit, res = -1;
    8990         res != 0 && bufsize >= wise_lower_limit; bufsize--) {
    90         asprintf(&tmp,
     91        mr_asprintf(&tmp,
    9192                 "dd if=/dev/zero bs=1024 count=16k 2> /dev/null | buffer -o /dev/null -s %ld -m %d%c",
    9293                 internal_tape_block_size, bufsize, 'm');
    9394        res = run_program_and_log_output(tmp, 2);
    94         paranoid_free(tmp);
     95        mr_free(tmp);
    9596    }
    9697    if (!res) {
    9798        bufsize++;
    98         asprintf(&tmp, _("Negotiated max buffer of %d MB "), bufsize);
     99        mr_asprintf(&tmp, _("Negotiated max buffer of %d MB "), bufsize);
    99100        log_to_screen(tmp);
    100         paranoid_free(tmp);
     101        mr_free(tmp);
    101102    } else {
    102103        bufsize = 0;
     
    111112    }
    112113    if (bufsize) {
    113         asprintf(&g_sz_call_to_buffer,
     114        mr_asprintf(&g_sz_call_to_buffer,
    114115                 "buffer -m %d%c -p%d -B -s%ld -%c %s 2>> %s", bufsize,
    115116                 'm', (direction == 'r') ? 20 : 75,
    116117                 internal_tape_block_size, keych, device, MONDO_LOGFILE);
    117118    } else {
    118         asprintf(&g_sz_call_to_buffer, "dd bs=%ld %cf=%s",
     119        mr_asprintf(&g_sz_call_to_buffer, "dd bs=%ld %cf=%s",
    119120                 internal_tape_block_size, keych, device);
    120121    }
    121122    log_msg(2, "Calling buffer --- command = '%s'", g_sz_call_to_buffer);
    122123    fres = popen(g_sz_call_to_buffer, sz_dir);
    123     paranoid_free(sz_dir);
     124    mr_free(sz_dir);
    124125    if (fres) {
    125126        log_msg(2, "Successfully opened ('%c') tape device %s", direction,
     
    130131    }
    131132    sleep(2);
    132     asprintf(&tmp, "ps %s | grep \"%s\"", ps_options, g_sz_call_to_buffer);
     133    mr_asprintf(&tmp, "ps %s | grep \"%s\"", ps_options, g_sz_call_to_buffer);
    133134    if (run_program_and_log_output(tmp, 2)) {
    134135        log_msg(2, "Warning - I think I failed to open tape, actually.");
    135136    }
    136     paranoid_free(tmp);
     137    mr_free(tmp);
    137138    g_tape_buffer_size_MB = bufsize;
    138     asprintf(&tmp, "ps %s | grep buffer | grep -v grep", ps_options);
     139    mr_asprintf(&tmp, "ps %s | grep buffer | grep -v grep", ps_options);
    139140    if (run_program_and_log_output(tmp, 1)) {
    140141        fres = NULL;
     
    143144        log_to_screen(_("Buffer successfully started."));
    144145    }
    145     paranoid_free(tmp);
     146    mr_free(tmp);
    146147    return (fres);
    147148}
     
    157158
    158159    sync();
    159     asprintf(&command,
     160    mr_asprintf(&command,
    160161            "ps %s | grep -F \"%s\" | grep -Fv grep | awk '{print $1;}' | grep -v PID | tr -s '\n' ' ' | awk '{ print $1; }'", ps_options,
    161162            g_sz_call_to_buffer);
    162     paranoid_free(g_sz_call_to_buffer);
     163    mr_free(g_sz_call_to_buffer);
    163164    log_msg(2, "kill_buffer() --- command = %s", command);
    164165
    165166    tmp = call_program_and_get_last_line_of_output(command);
    166     paranoid_free(command);
     167    mr_free(command);
    167168
    168     asprintf(&command, "kill %s", tmp);
     169    mr_asprintf(&command, "kill %s", tmp);
    169170    log_msg(2, "kill_buffer() --- command = %s", command);
    170171
     
    172173        run_program_and_log_output(command, TRUE);
    173174    }
    174     paranoid_free(tmp);
    175     paranoid_free(command);
     175    mr_free(tmp);
     176    mr_free(command);
    176177}
    177178
  • trunk/mondo/src/common/libmondo-filelist.c

    r863 r900  
    1717#include "newt-specific-EXT.h"
    1818#include "libmondo-tools-EXT.h"
    19 #include "mr_string.h"
     19#include "mr_str.h"
     20#include "mr_mem.h"
    2021
    2122#include <time.h>
     
    102103    { i=0; log_to_screen ("This will take more time. Please be patient."); }
    103104*/
    104     asprintf(&filelist, "%s/archives/filelist.full", bkpinfo->scratchdir);
     105    mr_asprintf(&filelist, "%s/archives/filelist.full", bkpinfo->scratchdir);
    105106    if (!does_file_exist(filelist)) {
    106107        log_it("filelist %s not found", filelist);
     
    111112        chop_filelist(filelist, bkpinfo->tmpdir,
    112113                      bkpinfo->optimal_set_size);
    113     paranoid_free(filelist);
     114    mr_free(filelist);
    114115
    115116    estimate_noof_media_required(bkpinfo, noof_sets);   // for cosmetic purposes
    116117
    117     asprintf(&tempfile, "%s/biggielist.txt", bkpinfo->tmpdir);
     118    mr_asprintf(&tempfile, "%s/biggielist.txt", bkpinfo->tmpdir);
    118119    if (!(fout = fopen(tempfile, "a"))) {
    119120        log_OS_error("Cannot append to biggielist");
    120121        retval++;
    121122    }
    122     paranoid_free(tempfile);
     123    mr_free(tempfile);
    123124    log_it(bkpinfo->image_devs);
    124125
     
    126127
    127128    while (ptr && *ptr) {
    128         asprintf(&dev, ptr);
     129        mr_asprintf(&dev, ptr);
    129130        log_it("Examining imagedev %s", dev);
    130131        for (i = 0; i < (int) strlen(dev) && dev[i] != ' '; i++);
     
    135136        fprintf(fout, "%s\n", dev);
    136137        log_it("Adding '%s' to biggielist", dev);
    137         paranoid_free(dev);
     138        mr_free(dev);
    138139
    139140        if ((ptr = strchr(ptr, ' '))) {
     
    156157
    157158    log_msg(1, "Sorting file %s", orig_fname);
    158     asprintf(&tmp_fname, "/tmp/sort.%d.%d.%d", (int) (random() % 32768),
     159    mr_asprintf(&tmp_fname, "/tmp/sort.%d.%d.%d", (int) (random() % 32768),
    159160             (int) (random() % 32768), (int) (random() % 32768));
    160161
     
    163164    }                           // no sense in trying to sort an empty file
    164165
    165     asprintf(&command, "sort %s > %s 2>> %s", orig_fname, tmp_fname,
     166    mr_asprintf(&command, "sort %s > %s 2>> %s", orig_fname, tmp_fname,
    166167             MONDO_LOGFILE);
    167168    retval = system(command);
    168     paranoid_free(command);
     169    mr_free(command);
    169170
    170171    if (retval) {
     
    173174        log_msg(2, "Sorted %s --> %s OK. Copying it back to %s now",
    174175                orig_fname, tmp_fname, orig_fname);
    175         asprintf(&command, "mv -f %s %s", tmp_fname, orig_fname);
     176        mr_asprintf(&command, "mv -f %s %s", tmp_fname, orig_fname);
    176177        retval += run_program_and_log_output(command, 2);
    177         paranoid_free(command);
     178        mr_free(command);
    178179
    179180        if (retval) {
     
    184185        }
    185186    }
    186     paranoid_free(tmp_fname);
     187    mr_free(tmp_fname);
    187188    log_msg(1, "Finished sorting file %s", orig_fname);
    188189    return (retval);
     
    248249    curr_set_no = 0;
    249250    curr_set_size = 0;
    250     asprintf(&outfname, "%s/filelist.%ld", outdir, curr_set_no);
    251     asprintf(&biggie_fname, "%s/biggielist.txt", outdir);
     251    mr_asprintf(&outfname, "%s/filelist.%ld", outdir, curr_set_no);
     252    mr_asprintf(&biggie_fname, "%s/biggielist.txt", outdir);
    252253    log_it("outfname=%s; biggie_fname=%s", outfname, biggie_fname);
    253254    if (!(fbig = fopen(biggie_fname, "w"))) {
     
    259260        return (0);
    260261    }
    261     (void) getline(&incoming, &n, fin);
     262    mr_getline(&incoming, &n, fin);
    262263    while (!feof(fin)) {
    263264        lino++;
     
    286287                paranoid_fclose(fout);
    287288                sort_file(outfname);
    288                 paranoid_free(outfname);
     289                mr_free(outfname);
    289290
    290291                curr_set_no++;
    291292                curr_set_size = 0;
    292                 asprintf(&outfname, "%s/filelist.%ld", outdir,
     293                mr_asprintf(&outfname, "%s/filelist.%ld", outdir,
    293294                         curr_set_no);
    294295                if (!(fout = fopen(outfname, "w"))) {
     
    299300            }
    300301        }
    301         (void) getline(&incoming, &n, fin);
     302        mr_getline(&incoming, &n, fin);
    302303    }
    303304    paranoid_fclose(fin);
     
    312313    sort_file(outfname);
    313314    sort_file(biggie_fname);
    314     paranoid_free(biggie_fname);
    315     paranoid_free(outfname);
    316 
    317     asprintf(&outfname, "%s/LAST-FILELIST-NUMBER", outdir);
    318     asprintf(&tmp, "%ld", curr_set_no);
     315    mr_free(biggie_fname);
     316    mr_free(outfname);
     317
     318    mr_asprintf(&outfname, "%s/LAST-FILELIST-NUMBER", outdir);
     319    mr_asprintf(&tmp, "%ld", curr_set_no);
    319320    if (write_one_liner_data_file(outfname, tmp)) {
    320321        log_OS_error
     
    322323        return (0);
    323324    }
    324     paranoid_free(outfname);
    325     paranoid_free(tmp);
     325    mr_free(outfname);
     326    mr_free(tmp);
    326327
    327328    if (curr_set_no == 0) {
    328         asprintf(&tmp, "Only one fileset. Fine.");
     329        mr_asprintf(&tmp, "Only one fileset. Fine.");
    329330    } else {
    330         asprintf(&tmp, "Filelist divided into %ld sets", curr_set_no + 1);
     331        mr_asprintf(&tmp, "Filelist divided into %ld sets", curr_set_no + 1);
    331332    }
    332333    log_msg(1, tmp);
    333     paranoid_free(tmp);
     334    mr_free(tmp);
    334335    close_evalcall_form();
    335336    /* This is to work around an obscure bug in Newt; open a form, close it,
     
    391392    }
    392393    filelist->ch = '\0';
    393     paranoid_free(filelist);
     394    mr_free((void *)filelist);
    394395    depth--;
    395396    if (depth == 0) {
     
    416417        return (2);
    417418    }
    418     for (getline(&tmp, &n, pattr); !feof(pattr); getline(&tmp, &n, pattr)) {
     419    for (mr_getline(&tmp, &n, pattr); !feof(pattr); mr_getline(&tmp, &n, pattr)) {
    419420        fputs(tmp, pout);
    420421    }
    421422    paranoid_pclose(pattr);
    422     paranoid_free(tmp);
     423    mr_free(tmp);
    423424    return (0);
    424425}
     
    432433    char *pout_command;
    433434    char *syscall;
    434     char *tmp;
    435435    char *file_to_analyze = NULL;
    436436    int i;
     
    441441        return (1);
    442442    }
    443     asprintf(&pout_command, "gzip -c1 > %s", auxlist_fname);
     443    mr_asprintf(&pout_command, "gzip -c1 > %s", auxlist_fname);
    444444    if (!(pout = popen(pout_command, "w"))) {
    445445        log_msg(1, "Cannot openout auxlist_fname %s", auxlist_fname);
    446446        fclose(fin);
    447         paranoid_free(pout_command);
     447        mr_free(pout_command);
    448448        return (4);
    449449    }
    450     paranoid_free(pout_command);
    451 
    452     for (getline(&file_to_analyze, &n, fin); !feof(fin);
    453          getline(&file_to_analyze, &n, fin)) {
     450    mr_free(pout_command);
     451
     452    for (mr_getline(&file_to_analyze, &n, fin); !feof(fin);
     453         mr_getline(&file_to_analyze, &n, fin)) {
    454454        i = strlen(file_to_analyze);
    455455        if (i > 0 && file_to_analyze[i - 1] < 32) {
     
    458458        log_msg(8, "Analyzing %s", file_to_analyze);
    459459        /* BERLIOS : to be checked */
    460         asprintf(&syscall, "%s %s 2>> /dev/null", syscall_sprintf,mr_stresc(file_to_analyze, "`$\\\"", '\\'));
     460        mr_asprintf(&syscall, "%s %s 2>> /dev/null", syscall_sprintf,mr_stresc(file_to_analyze, "`$\\\"", '\\'));
    461461        call_exe_and_pipe_output_to_fd(syscall, pout);
    462         paranoid_free(syscall);
     462        mr_free(syscall);
    463463    }
    464464    paranoid_fclose(fin);
    465465    paranoid_pclose(pout);
    466     paranoid_free(file_to_analyze);
     466    mr_free(file_to_analyze);
    467467    return (0);
    468468}
     
    475475    int retval = 0;
    476476
    477     asprintf(&command, "touch %s", facl_fname);
     477    mr_asprintf(&command, "touch %s", facl_fname);
    478478    run_program_and_log_output(command, 8);
    479     paranoid_free(command);
     479    mr_free(command);
    480480
    481481    tmp = find_home_of_exe("getfacl");
    482482    if (tmp) {
    483483//      sort_file(filelist); // FIXME - filelist chopper sorts, so this isn't necessary
    484         asprintf(&command,
     484        mr_asprintf(&command,
    485485                 "getfacl --all-effective -P %s 2>> %s | gzip -c1 > %s 2>> %s",
    486486                 filelist, MONDO_LOGFILE, facl_fname, MONDO_LOGFILE);
    487487        iamhere(command);
    488488        retval = system(command);
    489         paranoid_free(command);
    490     }
    491     paranoid_free(tmp);
     489        mr_free(command);
     490    }
     491    mr_free(tmp);
    492492    return (retval);
    493493}
     
    500500    int retval = 0;
    501501
    502     asprintf(&command, "touch %s", fattr_fname);
     502    mr_asprintf(&command, "touch %s", fattr_fname);
    503503    run_program_and_log_output(command, 8);
    504     paranoid_free(command);
     504    mr_free(command);
    505505
    506506    tmp = find_home_of_exe("getfattr");
     
    511511                         fattr_fname);
    512512    }
    513     paranoid_free(tmp);
     513    mr_free(tmp);
    514514    return (retval);
    515515}
     
    531531      retval = system(command);
    532532    }
    533   paranoid_free(command);
     533  mr_free(command);
    534534  return(retval);
    535535}
     
    557557        log_msg(1,
    558558                "No masklist provided. I shall therefore set ALL attributes.");
    559         asprintf(&command, "gzip -dc %s | %s --restore - 2>> %s",
     559        mr_asprintf(&command, "gzip -dc %s | %s --restore - 2>> %s",
    560560                 original_exat_fname, executable, MONDO_LOGFILE);
    561561        log_msg(1, "command = %s", command);
    562562        retval = system(command);
    563         paranoid_free(command);
     563        mr_free(command);
    564564        log_msg(1, "Returning w/ retval=%d", retval);
    565565        return (retval);
     
    571571        return (0);
    572572    }
    573     asprintf(&masklist, "/tmp/%d.%d.mask", (int) (random() % 32768),
     573    mr_asprintf(&masklist, "/tmp/%d.%d.mask", (int) (random() % 32768),
    574574             (int) (random() % 32768));
    575     asprintf(&command, "cp -f %s %s", orig_msklist, masklist);
     575    mr_asprintf(&command, "cp -f %s %s", orig_msklist, masklist);
    576576    run_program_and_log_output(command, 1);
    577     paranoid_free(command);
     577    mr_free(command);
    578578
    579579    sort_file(masklist);
    580     asprintf(&syscall_pin, "gzip -dc %s", original_exat_fname);
    581     asprintf(&syscall_pout, "%s --restore - 2>> %s", executable,
     580    mr_asprintf(&syscall_pin, "gzip -dc %s", original_exat_fname);
     581    mr_asprintf(&syscall_pout, "%s --restore - 2>> %s", executable,
    582582             MONDO_LOGFILE);
    583583
     
    589589        return (1);
    590590    }
    591     paranoid_free(syscall_pout);
     591    mr_free(syscall_pout);
    592592
    593593    pin = popen(syscall_pin, "r");
     
    597597        return (1);
    598598    }
    599     paranoid_free(syscall_pin);
     599    mr_free(syscall_pin);
    600600
    601601    faclin = fopen(masklist, "r");
     
    608608//  printf("Hi there. Starting the loop\n");
    609609
    610     getline(&current_subset_file, &n, faclin);
    611     getline(&incoming, &n, pin);
     610    mr_getline(&current_subset_file, &n, faclin);
     611    mr_getline(&incoming, &n, pin);
    612612    while (!feof(pin) && !feof(faclin)) {
    613613//      printf("incoming = %s", incoming);
    614614
    615         asprintf(&current_master_file, incoming + 8);
     615        mr_asprintf(&current_master_file, incoming + 8);
    616616
    617617        p = current_subset_file;
     
    641641        if (i < 0) {            // read another subset file in.
    642642            log_msg(my_depth, "Reading next subset line in\n\n");
    643             getline(&current_subset_file, &n, faclin);
     643            mr_getline(&current_subset_file, &n, faclin);
    644644            continue;
    645645        }
     
    648648            fputs(incoming, pout);
    649649        }
    650         getline(&incoming, &n, pin);
     650        mr_getline(&incoming, &n, pin);
    651651        if (!i) {
    652652            log_msg(my_depth, "Copying master %s", q);
     
    661661                fputs(incoming, pout);
    662662            }
    663             getline(&incoming, &n, pin);
     663            mr_getline(&incoming, &n, pin);
    664664        }
    665665        if (!i) {
    666             getline(&current_subset_file, &n, faclin);
    667         }
    668         paranoid_free(current_master_file);
    669     }
    670     paranoid_free(current_subset_file);
     666            mr_getline(&current_subset_file, &n, faclin);
     667        }
     668        mr_free(current_master_file);
     669    }
     670    mr_free(current_subset_file);
    671671
    672672    while (!feof(pin)) {
    673         getline(&incoming, &n, pin);
    674     }
    675     paranoid_free(incoming);
     673        mr_getline(&incoming, &n, pin);
     674    }
     675    mr_free(incoming);
    676676    fclose(faclin);
    677677    pclose(pin);
     
    681681
    682682    unlink(masklist);
    683     paranoid_free(masklist);
     683    mr_free(masklist);
    684684
    685685    return (retval);
     
    719719    assert(bkpinfo != NULL);
    720720
    721     asprintf(&cfg_fname, "%s/mondo-restore.cfg", bkpinfo->tmpdir);
     721    mr_asprintf(&cfg_fname, "%s/mondo-restore.cfg", bkpinfo->tmpdir);
    722722    read_cfg_var(cfg_fname, "last-filelist-number", val_sz);
    723723    val_i = atoi(val_sz);
    724     paranoid_free(val_sz);
     724    mr_free(val_sz);
    725725
    726726    if (val_i <= 0) {
    727727        val_i = 500;
    728728    }
    729     paranoid_free(cfg_fname);
     729    mr_free(cfg_fname);
    730730    return (val_i);
    731731}
     
    866866    }
    867867    log_to_screen(_("Loading filelist"));
    868     asprintf(&command_to_open_fname, "gzip -dc %s", filelist_fname);
    869     asprintf(&tmp, "zcat %s | wc -l", filelist_fname);
     868    mr_asprintf(&command_to_open_fname, "gzip -dc %s", filelist_fname);
     869    mr_asprintf(&tmp, "zcat %s | wc -l", filelist_fname);
    870870    log_msg(6, "tmp = %s", tmp);
    871871    tmp1 = call_program_and_get_last_line_of_output(tmp);
    872     paranoid_free(tmp);
     872    mr_free(tmp);
    873873
    874874    lines_in_filelist = atol(tmp1);
    875     paranoid_free(tmp1);
     875    mr_free(tmp1);
    876876
    877877    if (lines_in_filelist < 3) {
     
    893893        return (NULL);
    894894    }
    895     paranoid_free(command_to_open_fname);
     895    mr_free(command_to_open_fname);
    896896
    897897    open_evalcall_form(_("Loading filelist from disk"));
    898     for (getline(&fname, &n, pin); !feof(pin); getline(&fname, &n, pin)) {
     898    for (mr_getline(&fname, &n, pin); !feof(pin); mr_getline(&fname, &n, pin)) {
    899899        if ((fname[strlen(fname) - 1] == 13
    900900             || fname[strlen(fname) - 1] == 10) && strlen(fname) > 0) {
     
    908908                continue;
    909909            }
    910             asprintf(&tmp, fname);
     910            mr_asprintf(&tmp, fname);
    911911            tmp[pos_in_fname] = '\0';
    912912            if (strlen(tmp)) {
    913913                add_string_at_node(filelist, tmp);
    914914            }
    915             paranoid_free(tmp);
     915            mr_free(tmp);
    916916        }
    917917        add_string_at_node(filelist, fname);
     
    921921        }
    922922    }
    923     paranoid_free(fname);
     923    mr_free(fname);
    924924    paranoid_pclose(pin);
    925925    close_evalcall_form();
     
    13521352    if (!depth) {
    13531353        malloc_string(find_skeleton_marker);
    1354         asprintf(&find_excludes, " ");
     1354        mr_asprintf(&find_excludes, " ");
    13551355        while((token = mr_strtok (sth, delims, &lastpos))) {
    1356           asprintf(&strtmp,"%s", find_excludes);
    1357           paranoid_free(find_excludes);
    1358           asprintf(&find_excludes,"%s -path %s -prune -o", strtmp, token);
    1359           paranoid_free(strtmp);
    1360           paranoid_free(token);
     1356          mr_asprintf(&strtmp,"%s", find_excludes);
     1357          mr_free(find_excludes);
     1358          mr_asprintf(&find_excludes,"%s -path %s -prune -o", strtmp, token);
     1359          mr_free(strtmp);
     1360          mr_free(token);
    13611361        }
    13621362#if linux
    13631363        // 2.6 has /sys as a proc-type thing -- must be excluded
    1364         asprintf(&strtmp,
     1364        mr_asprintf(&strtmp,
    13651365             "find %s -maxdepth %d -fstype mvfs -prune -o -path /dev/shm -prune -o %s -type d -print > %s 2> /dev/null",
    13661366             dir, MAX_SKEL_DEPTH, find_excludes, skeleton_filelist);
    13671367#else
    13681368        // On BSD, for example, /sys is the kernel sources -- don't exclude
    1369         asprintf(&strtmp,
     1369        mr_asprintf(&strtmp,
    13701370             "find %s -maxdepth %d -fstype mvfs -prune -o -path /proc -prune -o %s -type d -print > %s 2> /dev/null",
    13711371                dir, MAX_SKEL_DEPTH, find_excludes, skeleton_filelist);
    13721372#endif
    1373         paranoid_free(find_excludes);
     1373        mr_free(find_excludes);
    13741374        log_msg(5, "find command = %s", strtmp);
    13751375        system(strtmp);
    1376         paranoid_free(strtmp);
    1377         paranoid_free(tmp);
    1378 
    1379         asprintf(&tmp, "wc -l %s | awk '{print $1;}'", skeleton_filelist);
     1376        mr_free(strtmp);
     1377        mr_free(tmp);
     1378
     1379        mr_asprintf(&tmp, "wc -l %s | awk '{print $1;}'", skeleton_filelist);
    13801380        tmp1 = call_program_and_get_last_line_of_output(tmp);
    1381         paranoid_free(tmp);
     1381        mr_free(tmp);
    13821382
    13831383        g_skeleton_entries = 1 + atol(tmp1);
    1384         paranoid_free(tmp1);
    1385 
    1386         asprintf(&name_of_evalcall_form, "Making catalog of %s", dir);
     1384        mr_free(tmp1);
     1385
     1386        mr_asprintf(&name_of_evalcall_form, "Making catalog of %s", dir);
    13871387        open_evalcall_form(name_of_evalcall_form);
    13881388        find_skeleton_marker[0] = '\0';
     
    14101410#ifndef _XWIN
    14111411                if (!g_text_mode) {
    1412                     asprintf(&tmp, _("Reading %-68s"), dir);
     1412                    mr_asprintf(&tmp, _("Reading %-68s"), dir);
    14131413                    newtDrawRootText(0, g_noof_rows - 3, tmp);
    1414                     paranoid_free(tmp);
     1414                    mr_free(tmp);
    14151415                }
    14161416#endif
     
    14241424//  log_msg(0, "Cataloguing %s", dir);
    14251425    if (sth[0] == ' ') {
    1426         asprintf(&skip_these, "%s", sth);
     1426        mr_asprintf(&skip_these, "%s", sth);
    14271427    } else {
    1428         asprintf(&skip_these, " %s ", sth);
    1429     }
    1430     asprintf(&new_with_spaces, " %s ", dir);
     1428        mr_asprintf(&skip_these, " %s ", sth);
     1429    }
     1430    mr_asprintf(&new_with_spaces, " %s ", dir);
    14311431    if ((dip = opendir(dir)) == NULL) {
    14321432        log_OS_error("opendir");
     
    14381438            i++;
    14391439            if (strcmp(dir, "/")) {
    1440                 asprintf(&new, "%s/%s", dir, dit->d_name);
     1440                mr_asprintf(&new, "%s/%s", dir, dit->d_name);
    14411441            } else {
    1442                 asprintf(&new, "%s%s", dir, dit->d_name);
     1442                mr_asprintf(&new, "%s%s", dir, dit->d_name);
    14431443            }
    1444             paranoid_free(new_with_spaces);
    1445             asprintf(&new_with_spaces, " %s ", new);
     1444            mr_free(new_with_spaces);
     1445            mr_asprintf(&new_with_spaces, " %s ", new);
    14461446            /* BERLIOS: Old code
    14471447               new_with_spaces[0] = ' ';
     
    14661466                                counter = 0;
    14671467                                uberctr++;
    1468                                 asprintf(&tmp, " %c ",
     1468                                mr_asprintf(&tmp, " %c ",
    14691469                                         special_dot_char(uberctr));
    14701470#ifndef _XWIN
     
    14741474                                    newtRefresh();
    14751475                                }
    1476                                 paranoid_free(tmp);
     1476                                mr_free(tmp);
    14771477#endif
    14781478                            }
     
    14811481                }
    14821482            }
    1483             paranoid_free(new);
    1484         }
    1485     }
    1486     paranoid_free(new_with_spaces);
    1487     paranoid_free(skip_these);
     1483            mr_free(new);
     1484        }
     1485    }
     1486    mr_free(new_with_spaces);
     1487    mr_free(skip_these);
    14881488
    14891489    if (dip) {
     
    14951495    if (!depth) {
    14961496        close_evalcall_form();
    1497         paranoid_free(name_of_evalcall_form);
    1498         paranoid_free(find_skeleton_marker);
     1497        mr_free(name_of_evalcall_form);
     1498        mr_free(find_skeleton_marker);
    14991499        unlink(skeleton_filelist);
    15001500        log_msg(5, "g_skeleton_entries = %ld", g_skeleton_entries);
     
    15651565
    15661566    // The pathname to the skeleton filelist, used to give better progress reporting for mondo_makefilelist().
    1567     asprintf(&sz_datefile, sz_datefile_wildcard, 0);
     1567    mr_asprintf(&sz_datefile, sz_datefile_wildcard, 0);
    15681568    if (!include_paths && !userdef_filelist) {
    15691569        fatal_error
     
    15711571    }
    15721572// make hole for filelist
    1573     asprintf(&command, "mkdir -p %s/archives", scratchdir);
     1573    mr_asprintf(&command, "mkdir -p %s/archives", scratchdir);
    15741574    paranoid_system(command);
    1575     paranoid_free(command);
    1576 
    1577     asprintf(&sz_filelist, "%s/tmpfs/filelist.full", tmpdir);
     1575    mr_free(command);
     1576
     1577    mr_asprintf(&sz_filelist, "%s/tmpfs/filelist.full", tmpdir);
    15781578    make_hole_for_file(sz_filelist);
    15791579
    15801580    if (differential == 0) {
    15811581        // restore last good datefile if it exists
    1582         asprintf(&command, "cp -f %s.aborted %s", sz_datefile,
     1582        mr_asprintf(&command, "cp -f %s.aborted %s", sz_datefile,
    15831583                 sz_datefile);
    15841584        run_program_and_log_output(command, 3);
    1585         paranoid_free(command);
     1585        mr_free(command);
    15861586
    15871587        // backup last known good datefile just in case :)
    15881588        if (does_file_exist(sz_datefile)) {
    1589             asprintf(&command, "mv -f %s %s.aborted", sz_datefile,
     1589            mr_asprintf(&command, "mv -f %s %s.aborted", sz_datefile,
    15901590                     sz_datefile);
    15911591            paranoid_system(command);
    1592             paranoid_free(command);
     1592            mr_free(command);
    15931593        }
    15941594        make_hole_for_file(sz_datefile);
    15951595        tmp = call_program_and_get_last_line_of_output("date +%s");
    15961596        write_one_liner_data_file(sz_datefile, tmp);
    1597         paranoid_free(tmp);
     1597        mr_free(tmp);
    15981598    } else if (lstat(sz_datefile, &statbuf)) {
    15991599        log_msg(2,
     
    16051605        log_msg(2, "Differential backup. Yay.");
    16061606    }
    1607     paranoid_free(sz_datefile);
     1607    mr_free(sz_datefile);
    16081608
    16091609// use user-specified filelist (if specified)
     
    16121612                "Using the user-specified filelist - %s - instead of calculating one",
    16131613                userdef_filelist);
    1614         asprintf(&command, "cp -f %s %s", userdef_filelist, sz_filelist);
     1614        mr_asprintf(&command, "cp -f %s %s", userdef_filelist, sz_filelist);
    16151615        if (run_program_and_log_output(command, 3)) {
    16161616            fatal_error("Failed to copy user-specified filelist");
    16171617        }
    1618         paranoid_free(command);
     1618        mr_free(command);
    16191619    } else {
    16201620        log_msg(2, "include_paths = '%s'", include_paths);
     
    16231623        tmp1 = call_program_and_get_last_line_of_output("locate /hiberfil.sys 2> /dev/null");
    16241624        tmp2 = call_program_and_get_last_line_of_output("locate /pagefile.sys 2> /dev/null");
    1625         asprintf(&exclude_paths, " %s %s %s %s %s %s . .. \
     1625        mr_asprintf(&exclude_paths, " %s %s %s %s %s %s . .. \
    16261626" MNT_CDROM " " MNT_FLOPPY " /media/cdrom /media/cdrecorder \
    16271627/proc /sys /tmp /var/cache/mondo /var/cache/mindi", excp, tmp, tmp1, tmp2, (tmpdir[0] == '/' && tmpdir[1] == '/') ? (tmpdir + 1) : tmpdir, (scratchdir[0] == '/' && scratchdir[1] == '/') ? (scratchdir + 1) : scratchdir);
    1628         paranoid_free(tmp);
    1629         paranoid_free(tmp1);
    1630         paranoid_free(tmp2);
     1628        mr_free(tmp);
     1629        mr_free(tmp1);
     1630        mr_free(tmp2);
    16311631
    16321632        log_msg(2, "Excluding paths = '%s'", exclude_paths);
    16331633        log_msg(2,
    16341634                "Generating skeleton filelist so that we can track our progress");
    1635         asprintf(&skeleton_filelist, "%s/tmpfs/skeleton.txt", tmpdir);
     1635        mr_asprintf(&skeleton_filelist, "%s/tmpfs/skeleton.txt", tmpdir);
    16361636        make_hole_for_file(skeleton_filelist);
    16371637
     
    16611661        }
    16621662        paranoid_fclose(fout);
    1663         paranoid_free(skeleton_filelist);
    1664         paranoid_free(exclude_paths);
     1663        mr_free(skeleton_filelist);
     1664        mr_free(exclude_paths);
    16651665    }
    16661666    log_msg(2, "Copying new filelist to scratchdir");
    1667     asprintf(&command, "mkdir -p %s/archives", scratchdir);
     1667    mr_asprintf(&command, "mkdir -p %s/archives", scratchdir);
    16681668    paranoid_system(command);
    1669     paranoid_free(command);
    1670 
    1671     asprintf(&command, "cp -f %s %s/archives/", sz_filelist, scratchdir);
     1669    mr_free(command);
     1670
     1671    mr_asprintf(&command, "cp -f %s %s/archives/", sz_filelist, scratchdir);
    16721672    paranoid_system(command);
    1673     paranoid_free(command);
    1674 
    1675     asprintf(&command, "mv -f %s %s", sz_filelist, tmpdir);
     1673    mr_free(command);
     1674
     1675    mr_asprintf(&command, "mv -f %s %s", sz_filelist, tmpdir);
    16761676    paranoid_system(command);
    1677     paranoid_free(command);
    1678     paranoid_free(sz_filelist);
     1677    mr_free(command);
     1678    mr_free(sz_filelist);
    16791679
    16801680    log_msg(2, "Exiting");
     
    17771777    }
    17781778    while (!feof(fin)) {
    1779         getline(&fname, &len, fin);
     1779        mr_getline(&fname, &len, fin);
    17801780        if (!use_star) {
    17811781            if (fname[0] == '/') {
    1782                 asprintf(&tmp, fname);
     1782                mr_asprintf(&tmp, fname);
    17831783            } else {
    1784                 asprintf(&tmp, "/%s", fname);
     1784                mr_asprintf(&tmp, "/%s", fname);
    17851785            }
    1786             paranoid_free(fname);
     1786            mr_free(fname);
    17871787            fname = tmp;
    17881788        }
     
    17961796            if (found_node->selected) {
    17971797                if (fname[0] == '/') {
    1798                     asprintf(&tmp, fname + 1);
    1799                     paranoid_free(fname);
     1798                    mr_asprintf(&tmp, fname + 1);
     1799                    mr_free(fname);
    18001800                    fname = tmp;
    18011801                }
     
    18031803                turn_wildcard_chars_into_literal_chars(tmp, fname);
    18041804                fprintf(fout, "%s\n", tmp);
    1805                 paranoid_free(tmp);
     1805                mr_free(tmp);
    18061806                retval++;
    18071807            }
    18081808        }
    1809         paranoid_free(fname);
     1809        mr_free(fname);
    18101810    }
    18111811    paranoid_fclose(fout);
     
    18361836        return (1);
    18371837    }
    1838     for (getline(&tmp, &n, fin); !feof(fin); getline(&tmp, &n, fin)) {
     1838    for (mr_getline(&tmp, &n, fin); !feof(fin); mr_getline(&tmp, &n, fin)) {
    18391839        if (!tmp[0]) {
    18401840            continue;
     
    18611861    }
    18621862    paranoid_fclose(fin);
    1863     paranoid_free(tmp);
     1863    mr_free(tmp);
    18641864    return (0);
    18651865}
  • trunk/mondo/src/common/libmondo-files-EXT.h

    r783 r900  
    4848extern int read_one_liner_data_file(char *fname, char *contents);
    4949extern int mode_of_file(char *fname);
    50 extern void paranoid_alloc(char *alloc, char *orig);
  • trunk/mondo/src/common/libmondo-files.c

    r839 r900  
    1818#include "libmondo-fork-EXT.h"
    1919#include "libmondo-string-EXT.h"
     20#include "mr_mem.h"
    2021
    2122/*@unused@*/
     
    5960
    6061    if (does_file_exist(filename)) {
    61         asprintf(&command, "md5sum \"%s\"", filename);
     62        mr_asprintf(&command, "md5sum \"%s\"", filename);
    6263        fin = popen(command, "r");
    63         paranoid_free(command);
     64        mr_free(command);
    6465
    6566        if (fin) {
    66             (void) getline(&output, &n, fin);
     67            mr_getline(&output, &n, fin);
    6768            p = strchr(output, ' ');
    6869            paranoid_pclose(fin);
    6970        }
    7071    } else {
    71         asprintf(&tmp, "File '%s' not found; cannot calc checksum",
     72        mr_asprintf(&tmp, "File '%s' not found; cannot calc checksum",
    7273                filename);
    7374        log_it(tmp);
    74         paranoid_free(tmp);
     75        mr_free(tmp);
    7576    }
    7677    if (p) {
     
    106107    assert_string_is_neither_NULL_nor_zerolength(filename);
    107108    if (!does_file_exist(filename)) {
    108         asprintf(&tmp,
     109        mr_asprintf(&tmp,
    109110                "%s does not exist, so I cannot found the number of lines in it",
    110111                filename);
    111112        log_it(tmp);
    112         paranoid_free(tmp);
     113        mr_free(tmp);
    113114        return (0);
    114115    }
    115     asprintf(&command, "cat %s | wc -l", filename);
     116    mr_asprintf(&command, "cat %s | wc -l", filename);
    116117    if (!does_file_exist(filename)) {
    117118        return (-1);
    118119    }
    119120    fin = popen(command, "r");
    120     paranoid_free(command);
     121    mr_free(command);
    121122
    122123    if (fin) {
     
    124125            noof_lines = 0;
    125126        } else {
    126             (void) getline(&incoming, &n, fin);
     127            mr_getline(&incoming, &n, fin);
    127128            while (strlen(incoming) > 0
    128129                   && incoming[strlen(incoming) - 1] < 32) {
     
    130131            }
    131132            noof_lines = atol(incoming);
    132             paranoid_free(incoming);
     133            mr_free(incoming);
    133134        }
    134135        paranoid_pclose(fin);
     
    189190    assert_string_is_neither_NULL_nor_zerolength(inout);
    190191
    191     asprintf(&infname, "%s.in", inout);
    192 
    193     asprintf(&tmp, "cp -f %s %s", inout, infname);
     192    mr_asprintf(&infname, "%s.in", inout);
     193
     194    mr_asprintf(&tmp, "cp -f %s %s", inout, infname);
    194195    run_program_and_log_output(tmp, FALSE);
    195     paranoid_free(tmp);
     196    mr_free(tmp);
    196197
    197198    if (!(fin = fopen(infname, "r"))) {
    198199        log_OS_error("Unable to openin infname");
    199         paranoid_free(infname);
     200        mr_free(infname);
    200201        return;
    201202    }
    202203
    203     asprintf(&outfname, "%s", inout);
     204    mr_asprintf(&outfname, "%s", inout);
    204205    if (!(fout = fopen(outfname, "w"))) {
    205206        log_OS_error("Unable to openout outfname");
    206         paranoid_free(outfname);
     207        mr_free(outfname);
    207208        return;
    208209    }
    209     paranoid_free(outfname);
    210 
    211     for (getline(&incoming, &n, fin); !feof(fin);
    212          getline(&incoming, &n, fin)) {
     210    mr_free(outfname);
     211
     212    for (mr_getline(&incoming, &n, fin); !feof(fin);
     213         mr_getline(&incoming, &n, fin)) {
    213214        i = strlen(incoming) - 1;
    214215        if (i >= 0 && incoming[i] < 32) {
     
    218219            fprintf(fout, "%s\n", incoming);
    219220        } else {
    220             asprintf(&tmp, "Excluding '%s'-nonexistent\n", incoming);
     221            mr_asprintf(&tmp, "Excluding '%s'-nonexistent\n", incoming);
    221222            log_it(tmp);
    222             paranoid_free(tmp);
    223         }
    224     }
    225     paranoid_free(incoming);
     223            mr_free(tmp);
     224        }
     225    }
     226    mr_free(incoming);
    226227    paranoid_fclose(fout);
    227228    paranoid_fclose(fin);
    228229    unlink(infname);
    229     paranoid_free(infname);
     230    mr_free(infname);
    230231}
    231232
     
    249250    // If we didn't get anything back, check whether mindi raised a fatal error
    250251    if (kernel == NULL) {
    251         asprintf(&command, "grep 'Fatal error' /var/log/mindi.log");
     252        mr_asprintf(&command, "grep 'Fatal error' /var/log/mindi.log");
    252253        tmp = call_program_and_get_last_line_of_output(command);
    253254        if (strlen(tmp) > 1) {
     
    255256            fatal_error("Mindi gave a fatal error. Please check '/var/log/mindi.log'.");
    256257        }
    257         paranoid_free(command);
    258         paranoid_free(tmp);
     258        mr_free(command);
     259        mr_free(tmp);
    259260    }
    260261
     
    303304    assert_string_is_neither_NULL_nor_zerolength(fname);
    304305
    305     asprintf(&command, "which %s 2> /dev/null", fname);
     306    mr_asprintf(&command, "which %s 2> /dev/null", fname);
    306307    incoming = call_program_and_get_last_line_of_output(command);
    307     paranoid_free(command);
     308    mr_free(command);
    308309
    309310    if (incoming == NULL) {
     
    311312            return (NULL);      // forget it :)
    312313        }
    313         asprintf(&command,
     314        mr_asprintf(&command,
    314315                "file %s 2> /dev/null | cut -d':' -f1 2> /dev/null",
    315316                incoming);
    316         paranoid_free(incoming);
     317        mr_free(incoming);
    317318
    318319        incoming = call_program_and_get_last_line_of_output(command);
    319         paranoid_free(command);
     320        mr_free(command);
    320321    }
    321322    if (incoming == NULL)   // yes, it is == '\0' twice, not once :)
    322323    {
    323         asprintf(&command, "dirname %s 2> /dev/null", incoming);
    324         paranoid_free(incoming);
     324        mr_asprintf(&command, "dirname %s 2> /dev/null", incoming);
     325        mr_free(incoming);
    325326
    326327        incoming = call_program_and_get_last_line_of_output(command);
    327         paranoid_free(command);
     328        mr_free(command);
    328329    }
    329330    output = incoming;
     
    332333        log_msg(4, "find_home_of_exe () --- Found %s at %s", fname, output);
    333334    } else {
    334         paranoid_free(output);
     335        mr_free(output);
    335336        log_msg(4, "find_home_of_exe() --- Could not find %s", fname);
    336337    }
     
    395396         && !strstr(err_log_lines[i], "% done"); i--);
    396397    if (i < 0) {
    397         asprintf(&command,
     398        mr_asprintf(&command,
    398399                "tail -n3 %s | grep -Fi \"%c\" | tail -n1 | awk '{print $0;}'",
    399400                filename, '%');
    400401        lastline = call_program_and_get_last_line_of_output(command);
    401         paranoid_free(command);
     402        mr_free(command);
    402403        if (!lastline) {
    403404            return (0);
    404405        }
    405406    } else {
    406         asprintf(&lastline, err_log_lines[i]);
     407        mr_asprintf(&lastline, err_log_lines[i]);
    407408    }
    408409
     
    412413    }
    413414    if (!p) {
    414         paranoid_free(lastline);
     415        mr_free(lastline);
    415416        return (0);
    416417    }
     
    421422    }
    422423    i = atoi(p);
    423     paranoid_free(lastline);
     424    mr_free(lastline);
    424425
    425426    return (i);
     
    447448
    448449    if (!does_file_exist(filename)) {
    449         asprintf(&tmp, _("Tring to get last line of nonexistent file (%s)"),
     450        mr_asprintf(&tmp, _("Tring to get last line of nonexistent file (%s)"),
    450451                filename);
    451452        log_it(tmp);
    452         paranoid_free(tmp);
     453        mr_free(tmp);
    453454        return (NULL);
    454455    }
    455     asprintf(&command, "tail -n1 %s", filename);
     456    mr_asprintf(&command, "tail -n1 %s", filename);
    456457    fin = popen(command, "r");
    457     paranoid_free(command);
    458 
    459     getline(&output, &n, fin);
     458    mr_free(command);
     459
     460    mr_getline(&output, &n, fin);
    460461    paranoid_pclose(fin);
    461462    while (strlen(output) > 0 && output[strlen(output) - 1] < 32) {
     
    504505
    505506    assert_string_is_neither_NULL_nor_zerolength(outdir_fname);
    506     asprintf(&tmp, "mkdir -p %s", outdir_fname);
     507    mr_asprintf(&tmp, "mkdir -p %s", outdir_fname);
    507508    res = system(tmp);
    508     paranoid_free(tmp);
     509    mr_free(tmp);
    509510    return (res);
    510511}
     
    532533    assert(!strstr(outfile_fname, "/dev/cdrom"));
    533534
    534     asprintf(&command, "mkdir -p \"%s\" 2> /dev/null", outfile_fname);
     535    mr_asprintf(&command, "mkdir -p \"%s\" 2> /dev/null", outfile_fname);
    535536    res += system(command);
    536     paranoid_free(command);
    537 
    538     asprintf(&command, "rmdir \"%s\" 2> /dev/null", outfile_fname);
     537    mr_free(command);
     538
     539    mr_asprintf(&command, "rmdir \"%s\" 2> /dev/null", outfile_fname);
    539540    res += system(command);
    540     paranoid_free(command);
    541 
    542     asprintf(&command, "rm -f \"%s\" 2> /dev/null", outfile_fname);
     541    mr_free(command);
     542
     543    mr_asprintf(&command, "rm -f \"%s\" 2> /dev/null", outfile_fname);
    543544    res += system(command);
    544     paranoid_free(command);
     545    mr_free(command);
    545546    unlink(outfile_fname);
    546547    return (0);
     
    575576        return (0);
    576577    }
    577     (void) getline(&incoming, &n, fin);
     578    mr_getline(&incoming, &n, fin);
    578579    while (!feof(fin)) {
    579580        if (strstr(incoming, wildcard)) {
    580581            matches++;
    581582        }
    582         (void) getline(&incoming, &n, fin);
     583        mr_getline(&incoming, &n, fin);
    583584    }
    584585    paranoid_fclose(fin);
    585     paranoid_free(incoming);
     586    mr_free(incoming);
    586587    return (matches);
    587588}
     
    603604    FILE *fin;
    604605
    605     asprintf(&lockfile_fname, "/var/run/monitas-%s.pid", name_str);
     606    mr_asprintf(&lockfile_fname, "/var/run/monitas-%s.pid", name_str);
    606607    if (!pid) {
    607608        log_it("Unregistering PID");
     
    609610            log_it("Error unregistering PID");
    610611        }
    611         paranoid_free(lockfile_fname);
     612        mr_free(lockfile_fname);
    612613        return;
    613614    }
    614615    if (does_file_exist(lockfile_fname)) {
    615616        if ((fin = fopen(lockfile_fname, "r"))) {
    616             (void) getline(&tmp, &n, fin);
     617            mr_getline(&tmp, &n, fin);
    617618            paranoid_fclose(fin);
    618619        } else {
     
    620621        }
    621622        pid = (pid_t) atol(tmp);
    622         paranoid_free(tmp);
    623 
    624         asprintf(&tmp, "ps %ld > /dev/null 2> /dev/null", (long int) pid);
     623        mr_free(tmp);
     624
     625        mr_asprintf(&tmp, "ps %ld > /dev/null 2> /dev/null", (long int) pid);
    625626        res = system(tmp);
    626         paranoid_free(tmp);
     627        mr_free(tmp);
    627628        if (!res) {
    628629            log_it
     
    631632        }
    632633    }
    633     asprintf(&tmp, "echo %ld > %s 2> /dev/null", (long int) getpid(),
     634    mr_asprintf(&tmp, "echo %ld > %s 2> /dev/null", (long int) getpid(),
    634635            lockfile_fname);
    635     paranoid_free(lockfile_fname);
     636    mr_free(lockfile_fname);
    636637
    637638    if (system(tmp)) {
    638639        fatal_error("Cannot register PID");
    639640    }
    640     paranoid_free(tmp);
     641    mr_free(tmp);
    641642    return;
    642643}
     
    655656    long file_len_K = 0L;
    656657
    657     asprintf(&command,
     658    mr_asprintf(&command,
    658659            "grep '%s ' %s/mountlist.txt | head -n1 | awk '{print $4;}'",
    659660            dev, tmpdir);
     
    662663    file_len_K = atol(sz_res);
    663664    log_msg(4, "%s --> %s --> %ld", command, sz_res, file_len_K);
    664     paranoid_free(command);
    665     paranoid_free(sz_res);
     665    mr_free(command);
     666    mr_free(sz_res);
    666667    return (file_len_K);
    667668}
     
    692693
    693694    log_it("Calculating size of all biggiefiles (in total)");
    694     asprintf(&biggielist, "%s/biggielist.txt", bkpinfo->tmpdir);
     695    mr_asprintf(&biggielist, "%s/biggielist.txt", bkpinfo->tmpdir);
    695696    log_it("biggielist = %s", biggielist);
    696697    if (!(fin = fopen(biggielist, "r"))) {
     
    699700    } else {
    700701        log_msg(4, "Reading it...");
    701         for (getline(&fname, &n, fin); !feof(fin);
    702              getline(&fname, &n, fin)) {
     702        for (mr_getline(&fname, &n, fin); !feof(fin);
     703             mr_getline(&fname, &n, fin)) {
    703704            if (fname[strlen(fname) - 1] <= 32) {
    704705                fname[strlen(fname) - 1] = '\0';
     
    710711                        fatal_error("ntfsresize not found");
    711712                    }
    712                     paranoid_free(tmp);
    713 
    714                     asprintf(&command, "ntfsresize --force --info %s|grep '^You might resize at '|cut -d' ' -f5", fname);
     713                    mr_free(tmp);
     714
     715                    mr_asprintf(&command, "ntfsresize --force --info %s|grep '^You might resize at '|cut -d' ' -f5", fname);
    715716                    log_it("command = %s", command);
    716717                    tmp = call_program_and_get_last_line_of_output(command);
    717                     paranoid_free(command);
     718                    mr_free(command);
    718719
    719720                    log_it("res of it = %s", tmp);
    720721                    file_len_K = atoll(tmp) / 1024L;
    721                     paranoid_free(tmp);
     722                    mr_free(tmp);
    722723                } else {
    723724                    file_len_K = get_phys_size_of_drive(fname) * 1024L;
     
    731732                log_msg(4, "%s --> %ld K", fname, file_len_K);
    732733            }
    733             asprintf(&comment,
     734            mr_asprintf(&comment,
    734735                    "After adding %s, scratchL+%ld now equals %ld", fname,
    735736                    file_len_K, scratchL);
    736737            log_msg(4, comment);
    737             paranoid_free(comment);
     738            mr_free(comment);
    738739
    739740            if (feof(fin)) {
     
    741742            }
    742743        }
    743         paranoid_free(fname);
    744     }
    745     paranoid_free(biggielist);
     744        mr_free(fname);
     745    }
     746    mr_free(biggielist);
    746747
    747748    log_it("Closing...");
     
    771772    /*@ end vars *************************************************** */
    772773
    773     asprintf(&command, "du -sk %s", mountpt);
     774    mr_asprintf(&command, "du -sk %s", mountpt);
    774775    errno = 0;
    775776    fin = popen(command, "r");
     
    778779      llres = 0;
    779780    } else {
    780         (void) getline(&tmp, &n, fin);
     781        mr_getline(&tmp, &n, fin);
    781782        paranoid_pclose(fin);
    782783        p = strchr(tmp, '\t');
     
    790791    }
    791792
    792     paranoid_free(command);
    793     paranoid_free(tmp);
     793    mr_free(command);
     794    mr_free(tmp);
    794795    return (llres);
    795796}
     
    842843
    843844
    844     asprintf(&command, "which %s > /dev/null 2> /dev/null", fname);
     845    mr_asprintf(&command, "which %s > /dev/null 2> /dev/null", fname);
    845846    res = system(command);
    846     paranoid_free(command);
     847    mr_free(command);
    847848
    848849    if (res) {
    849         asprintf(&errorstr,
     850        mr_asprintf(&errorstr,
    850851            _("Please install '%s'. I cannot find it on your system."),
    851852            fname);
    852853        log_to_screen(errorstr);
    853         paranoid_free(errorstr);
     854        mr_free(errorstr);
    854855        log_to_screen
    855856            (_("There may be an hyperlink at http://www.mondorescue.org which"));
     
    949950    log_msg(4, "g_mondo_home='%s'", g_mondo_home);
    950951    if ((g_mondo_home == NULL) || strlen(g_mondo_home) < 2) {
    951         paranoid_free(g_mondo_home);
     952        mr_free(g_mondo_home);
    952953        g_mondo_home = find_and_store_mondoarchives_home();
    953954    }
    954     asprintf(&command, CP_BIN " --parents -pRdf %s %s", g_mondo_home,
     955    mr_asprintf(&command, CP_BIN " --parents -pRdf %s %s", g_mondo_home,
    955956            bkpinfo->scratchdir);
    956957
     
    959960        fatal_error("Failed to copy Mondo's stuff to scratchdir");
    960961    }
    961     paranoid_free(command);
    962 
    963     asprintf(&tmp, "%s/payload.tgz", g_mondo_home);
     962    mr_free(command);
     963
     964    mr_asprintf(&tmp, "%s/payload.tgz", g_mondo_home);
    964965
    965966    /* i18n */
    966     asprintf(&command, CP_BIN " --parents /usr/share/locale/*/LC_MESSAGES/mondo.mo %s",bkpinfo->scratchdir);
     967    mr_asprintf(&command, CP_BIN " --parents /usr/share/locale/*/LC_MESSAGES/mondo.mo %s",bkpinfo->scratchdir);
    967968    log_msg(4, "command = %s", command);
    968969    run_program_and_log_output(command, 1);
    969     paranoid_free(command);
     970    mr_free(command);
    970971
    971972    if (does_file_exist(tmp)) {
     
    974975        (void) getcwd(old_pwd, MAX_STR_LEN - 1);
    975976        chdir(bkpinfo->scratchdir);
    976         asprintf(&command, "tar -zxvf %s", tmp);
     977        mr_asprintf(&command, "tar -zxvf %s", tmp);
    977978        if (run_program_and_log_output(command, FALSE)) {
    978979            fatal_error("Failed to untar payload");
    979980        }
    980         paranoid_free(command);
     981        mr_free(command);
    981982        chdir(old_pwd);
    982983    }
    983     paranoid_free(tmp);
    984 
    985     asprintf(&command, "cp -f %s/LAST-FILELIST-NUMBER %s", bkpinfo->tmpdir,
     984    mr_free(tmp);
     985
     986    mr_asprintf(&command, "cp -f %s/LAST-FILELIST-NUMBER %s", bkpinfo->tmpdir,
    986987            bkpinfo->scratchdir);
    987988    if (run_program_and_log_output(command, FALSE)) {
    988989        fatal_error("Failed to copy LAST-FILELIST-NUMBER to scratchdir");
    989990    }
    990     paranoid_free(command);
     991    mr_free(command);
    991992
    992993    tmp = call_program_and_get_last_line_of_output("which mondorestore");
     
    995996            ("'which mondorestore' returned null. Where's your mondorestore? `which` can't find it. That's odd. Did you install mondorestore?");
    996997    }
    997     asprintf(&command, "cp -f %s %s", tmp, bkpinfo->tmpdir);
    998     paranoid_free(tmp);
     998    mr_asprintf(&command, "cp -f %s %s", tmp, bkpinfo->tmpdir);
     999    mr_free(tmp);
    9991000
    10001001    if (run_program_and_log_output(command, FALSE)) {
    10011002        fatal_error("Failed to copy mondorestore to tmpdir");
    10021003    }
    1003     paranoid_free(command);
    1004 
    1005     asprintf(&command, "hostname > %s/HOSTNAME", bkpinfo->scratchdir);
     1004    mr_free(command);
     1005
     1006    mr_asprintf(&command, "hostname > %s/HOSTNAME", bkpinfo->scratchdir);
    10061007    paranoid_system(command);
    1007     paranoid_free(command);
     1008    mr_free(command);
    10081009
    10091010    if (bkpinfo->postnuke_tarball) {
    1010         asprintf(&command, "cp -f %s %s/post-nuke.tgz",
     1011        mr_asprintf(&command, "cp -f %s %s/post-nuke.tgz",
    10111012                bkpinfo->postnuke_tarball, bkpinfo->tmpdir);
    10121013        if (run_program_and_log_output(command, FALSE)) {
    10131014            fatal_error("Unable to copy post-nuke tarball to tmpdir");
    10141015        }
    1015         paranoid_free(command);
     1016        mr_free(command);
    10161017    }
    10171018
     
    10471048
    10481049    log_it("Storing NFS configuration");
    1049     asprintf(&tmp, bkpinfo->nfs_mount);
     1050    mr_asprintf(&tmp, bkpinfo->nfs_mount);
    10501051    p = strchr(tmp, ':');
    10511052    if (!p) {
     
    10541055    }
    10551056    *(p++) = '\0';
    1056     asprintf(&nfs_server_ipaddr, tmp);
    1057     paranoid_free(tmp);
    1058 
    1059     asprintf(&nfs_mount, p);
     1057    mr_asprintf(&nfs_server_ipaddr, tmp);
     1058    mr_free(tmp);
     1059
     1060    mr_asprintf(&nfs_mount, p);
    10601061    /* BERLIOS : there is a bug #67 here as it only considers the first NIC */
    1061     asprintf(&command,
     1062    mr_asprintf(&command,
    10621063            "ifconfig | tr '\n' '#' | sed s/##// | tr '#' ' ' | tr '' '\n' | head -n1 | cut -d' ' -f1");
    10631064    nfs_dev = call_program_and_get_last_line_of_output(command);
    1064     paranoid_free(command);
    1065 
    1066     asprintf(&command,
     1065    mr_free(command);
     1066
     1067    mr_asprintf(&command,
    10671068            "ifconfig | tr '\n' '#' | sed s/##// | tr '#' ' ' | tr '' '\\n' | head -n1 | tr -s '\t' ' ' | cut -d' ' -f7 | cut -d':' -f2");
    10681069    nfs_client_ipaddr = call_program_and_get_last_line_of_output(command);
    1069     paranoid_free(command);
    1070 
    1071     asprintf(&command,
     1070    mr_free(command);
     1071
     1072    mr_asprintf(&command,
    10721073            "ifconfig | tr '\n' '#' | sed s/##// | tr '#' ' ' | tr '' '\\n' | head -n1 | tr -s '\t' ' ' | cut -d' ' -f9 | cut -d':' -f2");
    10731074    nfs_client_netmask = call_program_and_get_last_line_of_output(command);
    1074     paranoid_free(command);
    1075 
    1076     asprintf(&command,
     1075    mr_free(command);
     1076
     1077    mr_asprintf(&command,
    10771078            "ifconfig | tr '\n' '#' | sed s/##// | tr '#' ' ' | tr '' '\\n' | head -n1 | tr -s '\t' ' ' | cut -d' ' -f8 | cut -d':' -f2");
    10781079    nfs_client_broadcast = call_program_and_get_last_line_of_output(command);
    1079     paranoid_free(command);
    1080 
    1081     asprintf(&command,
     1080    mr_free(command);
     1081
     1082    mr_asprintf(&command,
    10821083            "route -n | grep '^0.0.0.0' | awk '{print $2}'");
    10831084    nfs_client_defgw = call_program_and_get_last_line_of_output(command);
    1084     paranoid_free(command);
    1085 
    1086     asprintf(&tmp,
     1085    mr_free(command);
     1086
     1087    mr_asprintf(&tmp,
    10871088            "nfs_client_ipaddr=%s; nfs_client_netmask=%s; nfs_server_ipaddr=%s; nfs_mount=%s; nfs_client_defgw=%s;  ",
    10881089            nfs_client_ipaddr, nfs_client_netmask, nfs_server_ipaddr, nfs_mount, nfs_client_defgw);
    1089     paranoid_free(nfs_mount);
     1090    mr_free(nfs_mount);
    10901091    log_it(tmp);
    1091     paranoid_free(tmp);
     1092    mr_free(tmp);
    10921093
    10931094    if (strlen(nfs_dev) < 2) {
     
    11071108    if (!strncmp(nfs_dev, "bond", 4)) {
    11081109        log_to_screen("Found bonding device %s; looking for corresponding ethN slave device\n", nfs_dev);
    1109         asprintf(&command,
     1110        mr_asprintf(&command,
    11101111                "ifconfig %s | awk '{print $5}'", nfs_dev);
    11111112        mac_addr = call_program_and_get_last_line_of_output(command);
    1112         asprintf(&command,
     1113        mr_asprintf(&command,
    11131114                "ifconfig | grep -E '%s' | head -n1  | cut -d' ' -f1", mac_addr);
    1114         paranoid_free(nfs_dev);
     1115        mr_free(nfs_dev);
    11151116        nfs_dev = call_program_and_get_last_line_of_output(command);
    1116         paranoid_free(command);
    1117         paranoid_free(mac_addr);
     1117        mr_free(command);
     1118        mr_free(mac_addr);
    11181119
    11191120        log_to_screen("Replacing it with %s\n", nfs_dev);
    11201121    }
    11211122
    1122     asprintf(&tmp, "%s/NFS-DEV", bkpinfo->tmpdir);
     1123    mr_asprintf(&tmp, "%s/NFS-DEV", bkpinfo->tmpdir);
    11231124    write_one_liner_data_file(tmp, nfs_dev);
    1124     paranoid_free(nfs_dev);
    1125     paranoid_free(tmp);
    1126 
    1127     asprintf(&tmp, "%s/NFS-CLIENT-IPADDR", bkpinfo->tmpdir);
     1125    mr_free(nfs_dev);
     1126    mr_free(tmp);
     1127
     1128    mr_asprintf(&tmp, "%s/NFS-CLIENT-IPADDR", bkpinfo->tmpdir);
    11281129    write_one_liner_data_file(tmp, nfs_client_ipaddr);
    1129     paranoid_free(nfs_client_ipaddr);
    1130     paranoid_free(tmp);
    1131 
    1132     asprintf(&tmp, "%s/NFS-CLIENT-NETMASK", bkpinfo->tmpdir);
     1130    mr_free(nfs_client_ipaddr);
     1131    mr_free(tmp);
     1132
     1133    mr_asprintf(&tmp, "%s/NFS-CLIENT-NETMASK", bkpinfo->tmpdir);
    11331134    write_one_liner_data_file(tmp, nfs_client_netmask);
    1134     paranoid_free(nfs_client_netmask);
    1135     paranoid_free(tmp);
    1136 
    1137     asprintf(&tmp, "%s/NFS-CLIENT-DEFGW", bkpinfo->tmpdir);
     1135    mr_free(nfs_client_netmask);
     1136    mr_free(tmp);
     1137
     1138    mr_asprintf(&tmp, "%s/NFS-CLIENT-DEFGW", bkpinfo->tmpdir);
    11381139    write_one_liner_data_file(tmp, nfs_client_defgw);
    1139     paranoid_free(nfs_client_defgw);
    1140     paranoid_free(tmp);
    1141 
    1142     asprintf(&tmp, "%s/NFS-CLIENT-BROADCAST", bkpinfo->tmpdir);
     1140    mr_free(nfs_client_defgw);
     1141    mr_free(tmp);
     1142
     1143    mr_asprintf(&tmp, "%s/NFS-CLIENT-BROADCAST", bkpinfo->tmpdir);
    11431144    write_one_liner_data_file(tmp, nfs_client_broadcast);
    1144     paranoid_free(nfs_client_broadcast);
    1145     paranoid_free(tmp);
    1146 
    1147     asprintf(&tmp, "%s/NFS-SERVER-IPADDR", bkpinfo->tmpdir);
     1145    mr_free(nfs_client_broadcast);
     1146    mr_free(tmp);
     1147
     1148    mr_asprintf(&tmp, "%s/NFS-SERVER-IPADDR", bkpinfo->tmpdir);
    11481149    write_one_liner_data_file(tmp, nfs_server_ipaddr);
    1149     paranoid_free(nfs_server_ipaddr);
    1150     paranoid_free(tmp);
    1151 
    1152     asprintf(&tmp, "%s/NFS-SERVER-MOUNT", bkpinfo->tmpdir);
     1150    mr_free(nfs_server_ipaddr);
     1151    mr_free(tmp);
     1152
     1153    mr_asprintf(&tmp, "%s/NFS-SERVER-MOUNT", bkpinfo->tmpdir);
    11531154    write_one_liner_data_file(tmp, bkpinfo->nfs_mount);
    1154     paranoid_free(tmp);
    1155 
    1156     asprintf(&tmp, "%s/NFS-SERVER-PATH", bkpinfo->tmpdir);
     1155    mr_free(tmp);
     1156
     1157    mr_asprintf(&tmp, "%s/NFS-SERVER-PATH", bkpinfo->tmpdir);
    11571158    write_one_liner_data_file(tmp, bkpinfo->nfs_remote_dir);
    1158     paranoid_free(tmp);
    1159 
    1160     asprintf(&tmp, "%s/ISO-PREFIX", bkpinfo->tmpdir);
     1159    mr_free(tmp);
     1160
     1161    mr_asprintf(&tmp, "%s/ISO-PREFIX", bkpinfo->tmpdir);
    11611162    write_one_liner_data_file(tmp, bkpinfo->prefix);
    1162     paranoid_free(tmp);
     1163    mr_free(tmp);
    11631164
    11641165    log_it("Finished storing NFS configuration");
     
    12111212    }
    12121213    if (scratchLL <= 1) {
    1213         asprintf(&tmp,
     1214        mr_asprintf(&tmp,
    12141215                _("Your backup will probably occupy a single %s. Maybe two."),
    12151216                bkpinfo->backup_media_string);
    12161217    } else {
    1217         asprintf(&tmp, _("Your backup will occupy approximately %s media."),
     1218        mr_asprintf(&tmp, _("Your backup will occupy approximately %s media."),
    12181219                number_to_text((int) (scratchLL + 1)));
    12191220    }
     
    12211222        log_to_screen(tmp);
    12221223    }
    1223     paranoid_free(tmp);
     1224    mr_free(tmp);
    12241225    return;
    12251226}
     
    12381239    char *p = NULL;
    12391240
    1240     asprintf(&tmp, "%s/do-not-compress-these", g_mondo_home);
     1241    mr_asprintf(&tmp, "%s/do-not-compress-these", g_mondo_home);
    12411242    if (!does_file_exist(tmp)) {
    1242         paranoid_free(tmp);
     1243        mr_free(tmp);
    12431244        return (FALSE);
    12441245    }
    1245     paranoid_free(tmp);
     1246    mr_free(tmp);
    12461247
    12471248    do_not_compress_these = last_line_of_file(tmp);
    12481249    for (p = do_not_compress_these; p != NULL; p++) {
    1249         asprintf(&tmp, p);
     1250        mr_asprintf(&tmp, p);
    12501251        if (strchr(tmp, ' ')) {
    12511252            *(strchr(tmp, ' ')) = '\0';
    12521253        }
    12531254        if (!strcmp(strrchr(filename, '.'), tmp)) {
    1254             paranoid_free(do_not_compress_these);
    1255             paranoid_free(tmp);
     1255            mr_free(do_not_compress_these);
     1256            mr_free(tmp);
    12561257            return (TRUE);
    12571258        }
    1258         paranoid_free(tmp);
     1259        mr_free(tmp);
    12591260
    12601261        if (!(p = strchr(p, ' '))) {
     
    12621263        }
    12631264    }
    1264     paranoid_free(do_not_compress_these);
     1265    mr_free(do_not_compress_these);
    12651266    return (FALSE);
    12661267}
     
    12961297        paranoid_fclose(fout);
    12971298        log_msg(2, "Created %s", outfile);
    1298         asprintf(&tmp, "chmod +x %s", outfile);
     1299        mr_asprintf(&tmp, "chmod +x %s", outfile);
    12991300        paranoid_system(tmp);
    1300         paranoid_free(tmp);
     1301        mr_free(tmp);
    13011302
    13021303        retval = 0;
     
    13081309
    13091310/* @} - end fileGroup */
    1310 
    1311 void paranoid_alloc(char *alloc, char *orig)
    1312 {
    1313         paranoid_free(alloc);
    1314         asprintf(&alloc, orig);
    1315 }
    1316 
  • trunk/mondo/src/common/libmondo-fork.c

    r783 r900  
    1010#include "libmondo-files-EXT.h"
    1111#include "libmondo-tools-EXT.h"
     12#include "mr_mem.h"
    1213
    1314extern bool g_text_mode;
     
    3031
    3132    if ((fin = popen(call, "r"))) {
    32         for (getline(&result, &n, fin); !feof(fin); getline(&result, &n, fin));
     33        for (mr_getline(&result, &n, fin); !feof(fin); mr_getline(&result, &n, fin));
    3334        paranoid_pclose(fin);
    3435    } else {
     
    8990    }
    9091
    91     asprintf(&cd_number_str, "%d", cd_no);
     92    mr_asprintf(&cd_number_str, "%d", cd_no);
    9293    resolve_naff_tokens(midway_call, basic_call, isofile, "_ISO_");
    9394    resolve_naff_tokens(tmp, midway_call, cd_number_str, "_CD#_");
    94     paranoid_free(cd_number_str);
     95    mr_free(cd_number_str);
    9596
    9697    resolve_naff_tokens(ultimate_call, tmp, MONDO_LOGFILE, "_ERR_");
     
    99100    log_msg(4, "tmp = '%s'", tmp);
    100101    log_msg(4, "ultimate call = '%s'", ultimate_call);
    101     asprintf(&command, "%s >> %s", ultimate_call, MONDO_LOGFILE);
     102    mr_asprintf(&command, "%s >> %s", ultimate_call, MONDO_LOGFILE);
    102103
    103104    log_to_screen
     
    138139            (what_i_am_doing, command);
    139140    }
    140     paranoid_free(command);
    141 
    142     paranoid_free(midway_call);
    143     paranoid_free(ultimate_call);
    144     paranoid_free(tmp);
     141    mr_free(command);
     142
     143    mr_free(midway_call);
     144    mr_free(ultimate_call);
     145    mr_free(tmp);
    145146    return (retval);
    146147}
     
    181182        log_if_failure = TRUE;
    182183    }
    183     asprintf(&callstr,
     184    mr_asprintf(&callstr,
    184185            "%s > /tmp/mondo-run-prog-thing.tmp 2> /tmp/mondo-run-prog-thing.err",
    185186            program);
     
    198199                "--------------------------------start of output-----------------------------");
    199200    }
    200     paranoid_free(callstr);
     201    mr_free(callstr);
    201202
    202203    if (log_if_failure
     
    210211    fin = fopen("/tmp/mondo-run-prog-thing.tmp", "r");
    211212    if (fin) {
    212         for (getline(&incoming, &n, fin); !feof(fin);
    213              getline(&incoming, &n, fin)) {
     213        for (mr_getline(&incoming, &n, fin); !feof(fin);
     214             mr_getline(&incoming, &n, fin)) {
    214215            /* patch by Heiko Schlittermann */
    215216            p = incoming;
     
    227228            }
    228229        }
    229         paranoid_free(incoming);
     230        mr_free(incoming);
    230231        paranoid_fclose(fin);
    231232    }
     
    273274    assert_string_is_neither_NULL_nor_zerolength(basic_call);
    274275
    275     asprintf(&lockfile, "/tmp/mojo-jojo.blah.XXXXXX");
     276    mr_asprintf(&lockfile, "/tmp/mojo-jojo.blah.XXXXXX");
    276277    mkstemp(lockfile);
    277     asprintf(&command,
     278    mr_asprintf(&command,
    278279            "echo hi > %s ; %s >> %s 2>> %s; res=$?; sleep 1; rm -f %s; exit $res",
    279280            lockfile, basic_call, MONDO_LOGFILE, MONDO_LOGFILE, lockfile);
    280281    open_evalcall_form(what_i_am_doing);
    281     asprintf(&tmp, "Executing %s", basic_call);
     282    mr_asprintf(&tmp, "Executing %s", basic_call);
    282283    log_msg(2, tmp);
    283     paranoid_free(tmp);
     284    mr_free(tmp);
    284285
    285286    if (!(fin = popen(command, "r"))) {
    286287        log_OS_error("Unable to popen-in command");
    287         asprintf(&tmp, _("Failed utterly to call '%s'"), command);
     288        mr_asprintf(&tmp, _("Failed utterly to call '%s'"), command);
    288289        log_to_screen(tmp);
    289         paranoid_free(tmp);
    290         paranoid_free(lockfile);
    291         paranoid_free(command);
     290        mr_free(tmp);
     291        mr_free(lockfile);
     292        mr_free(command);
    292293        return (1);
    293294    }
    294     paranoid_free(command);
     295    mr_free(command);
    295296
    296297    if (!does_file_exist(lockfile)) {
     
    320321    close_evalcall_form();
    321322    unlink(lockfile);
    322     paranoid_free(lockfile);
     323    mr_free(lockfile);
    323324
    324325    return (retval);
     
    357358        fin = f_orig;
    358359        fout = f_archived;
    359         asprintf(&tmp, "%-64s", PIMP_START_SZ);
     360        mr_asprintf(&tmp, "%-64s", PIMP_START_SZ);
    360361        if (fwrite(tmp, 1, 64, fout) != 64) {
    361362            fatal_error("Can't write the introductory block");
    362363        }
    363         paranoid_free(tmp);
     364        mr_free(tmp);
    364365
    365366        while (1) {
     
    368369                break;
    369370            }
    370             asprintf(&tmp, "%-64ld", bytes_read_in);
     371            mr_asprintf(&tmp, "%-64ld", bytes_read_in);
    371372            if (fwrite(tmp, 1, 64, fout) != 64) {
    372373                fatal_error("Cannot write introductory block");
    373374            }
    374             paranoid_free(tmp);
     375            mr_free(tmp);
    375376
    376377            log_msg(7,
     
    378379                    subsliceno, bytes_read_in, bytes_to_be_read);
    379380            bytes_written_out += fwrite(buf, 1, bytes_read_in, fout);
    380             asprintf(&tmp, "%-64ld", subsliceno);
     381            mr_asprintf(&tmp, "%-64ld", subsliceno);
    381382            if (fwrite(tmp, 1, 64, fout) != 64) {
    382383                fatal_error("Cannot write post-thingy block");
    383384            }
    384             paranoid_free(tmp);
     385            mr_free(tmp);
    385386
    386387            log_msg(7, "Subslice #%d written OK", subsliceno);
    387388            subsliceno++;
    388389        }
    389         asprintf(&tmp, "%-64ld", 0L);
     390        mr_asprintf(&tmp, "%-64ld", 0L);
    390391        if (fwrite(tmp, 1, 64L, fout) != 64L) {
    391392            fatal_error("Cannot write final introductory block");
     
    436437
    437438    if (direction == 'w') {
    438         paranoid_free(tmp);
    439         asprintf(&tmp, "%-64s", PIMP_END_SZ);
     439        mr_free(tmp);
     440        mr_asprintf(&tmp, "%-64s", PIMP_END_SZ);
    440441        if (fwrite(tmp, 1, 64L, fout) != 64L) {
    441442            fatal_error("Can't write the final block");
    442443        }
    443         paranoid_free(tmp);
     444        mr_free(tmp);
    444445    } else {
    445446        log_msg(1, "tmpA is %s", tmp);
     
    456457                fwrite(tmp, 1, bytes_read_in, ftmp);
    457458               
    458                 paranoid_free(tmp);
     459                mr_free(tmp);
    459460                if (!(tmp = malloc(512))) {
    460461                    fatal_error("Failed to malloc() tmp");
     
    471472            }
    472473        }
    473         paranoid_free(tmp);
    474     }
    475 
    476     paranoid_free(buf);
     474        mr_free(tmp);
     475    }
     476
     477    mr_free(buf);
    477478    log_msg(3, "Successfully copied %ld bytes", bytes_written_out);
    478479    return (retval);
     
    499500        fatal_error("ntfsclone not found");
    500501    }
    501     paranoid_free(tmp);
    502 
    503     asprintf(&command, "ntfsclone --force --save-image --overwrite %s %s", output_fname, input_device);
     502    mr_free(tmp);
     503
     504    mr_asprintf(&command, "ntfsclone --force --save-image --overwrite %s %s", output_fname, input_device);
    504505    res = run_program_and_log_output(command, 5);
    505     paranoid_free(command);
     506    mr_free(command);
    506507
    507508    unlink(output_fname);
     
    526527
    527528    tempfile = call_program_and_get_last_line_of_output("mktemp -q /tmp/mondo.XXXXXXXX");
    528     asprintf(&command, "%s >> %s 2>> %s; rm -f %s", cmd, tempfile, tempfile,
     529    mr_asprintf(&command, "%s >> %s 2>> %s; rm -f %s", cmd, tempfile, tempfile,
    529530            tempfile);
    530531    log_msg(3, command);
     
    533534    if (!(pin = popen(command, "r"))) {
    534535        log_OS_error("fmt err");
    535         paranoid_free(command);
    536         paranoid_free(tempfile);
     536        mr_free(command);
     537        mr_free(tempfile);
    537538        return (1);
    538539    }
    539     paranoid_free(command);
     540    mr_free(command);
    540541
    541542    maxpc = 100;
     
    562563    }
    563564    unlink(tempfile);
    564     paranoid_free(tempfile);
     565    mr_free(tempfile);
    565566    return (res);
    566567}
     
    608609    *pchild_result = 999;
    609610
    610     asprintf(&command, "%s 2>> %s", cmd, MONDO_LOGFILE);
     611    mr_asprintf(&command, "%s 2>> %s", cmd, MONDO_LOGFILE);
    611612    log_msg(3, "command = '%s'", command);
    612613    if ((res =
     
    636637        update_evalcall_form(percentage);
    637638    }
    638     paranoid_free(command);
     639    mr_free(command);
    639640
    640641    log_file_end_to_screen(MONDO_LOGFILE, "");
     
    668669        fatal_error("ntfsclone not found");
    669670    }
    670     paranoid_free(tmp);
    671 
    672     asprintf(&command, "ntfsclone --force --restore-image --overwrite %s %s", output_device, input_fifo);
     671    mr_free(tmp);
     672
     673    mr_asprintf(&command, "ntfsclone --force --restore-image --overwrite %s %s", output_device, input_fifo);
    673674    res = run_program_and_log_output(command, 5);
    674     paranoid_free(command);
     675    mr_free(command);
    675676    return (res);
    676677}
  • trunk/mondo/src/common/libmondo-mountlist.c

    r783 r900  
    1616#include "libmondo-string-EXT.h"
    1717#include "newt-specific-EXT.h"
     18#include "mr_mem.h"
    1819
    1920/*@unused@*/
     
    8182
    8283    if (physical_drive_size < 0) {
    83         asprintf(&tmp, " %s does not exist.", drive);
     84        mr_asprintf(&tmp, " %s does not exist.", drive);
    8485        flaws_str = tmp;
    8586    } else {
    86         asprintf(&tmp, "%s is %ld MB", drive, physical_drive_size);
     87        mr_asprintf(&tmp, "%s is %ld MB", drive, physical_drive_size);
    8788        flaws_str = NULL;
    8889    }
    8990    log_it(tmp);
    90     paranoid_free(tmp);
     91    mr_free(tmp);
    9192
    9293
    9394    /* check DD */
    9495    for (cur_sp_no = 'a'; cur_sp_no < 'z'; ++cur_sp_no) {
    95         asprintf(&device, "%s%c", drive, cur_sp_no);
     96        mr_asprintf(&device, "%s%c", drive, cur_sp_no);
    9697        if (find_device_in_mountlist(mountlist, device) >= 0)
    9798            foundsome = TRUE;
    98         paranoid_free(device);
     99        mr_free(device);
    99100    }
    100101    if (foundsome) {
    101102        for (cur_sp_no = 'a'; cur_sp_no < 'z'; ++cur_sp_no) {
    102             asprintf(&device, "%s%c", drive, cur_sp_no);
     103            mr_asprintf(&device, "%s%c", drive, cur_sp_no);
    103104            pos = find_device_in_mountlist(mountlist, device);
    104105            if (pos < 0) {
    105106                continue;
    106107            }
    107             // BERLIOS : useless ? asprintf(&mountpoint, mountlist->el[pos].mountpoint);
     108            // BERLIOS : useless ? mr_asprintf(&mountpoint, mountlist->el[pos].mountpoint);
    108109            /* is it too big? */
    109110            if (curr_part_no > 'h') {
    110                 asprintf(&tmp, " Can only have up to 'h' in disklabel.");
     111                mr_asprintf(&tmp, " Can only have up to 'h' in disklabel.");
    111112                log_it(tmp);
    112113                if (flaws_str) {
    113                     asprintf(&tmp1, "%s%s",flaws_str, tmp);
     114                    mr_asprintf(&tmp1, "%s%s",flaws_str, tmp);
    114115                } else {
    115                     asprintf(&tmp1, "%s", tmp);
    116                 }
    117                 paranoid_free(flaws_str);
     116                    mr_asprintf(&tmp1, "%s", tmp);
     117                }
     118                mr_free(flaws_str);
    118119                flaws_str = tmp1;
    119                 paranoid_free(tmp);
     120                mr_free(tmp);
    120121                res++;
    121122            }
     
    128129            }
    129130            if (device_copies > 1) {
    130                 asprintf(&tmp, " %s %s's.", number_to_text(device_copies),
     131                mr_asprintf(&tmp, " %s %s's.", number_to_text(device_copies),
    131132                         device);
    132133                if (!strstr(flaws_str, tmp)) {
    133134                    log_it(tmp);
    134135                    if (flaws_str) {
    135                         asprintf(&tmp1, "%s%s",flaws_str, tmp);
     136                        mr_asprintf(&tmp1, "%s%s",flaws_str, tmp);
    136137                    } else {
    137                         asprintf(&tmp1, "%s", tmp);
     138                        mr_asprintf(&tmp1, "%s", tmp);
    138139                    }
    139                     paranoid_free(flaws_str);
     140                    mr_free(flaws_str);
    140141                    flaws_str = tmp1;
    141142                    res++;
    142143                }
    143                 paranoid_free(tmp);
     144                mr_free(tmp);
    144145            }
    145146            /* silly partition size? */
    146147            if (mountlist->el[pos].size < 8192
    147148                && strcmp(mountlist->el[pos].mountpoint, "lvm")) {
    148                 asprintf(&tmp, " %s is tiny!", device);
     149                mr_asprintf(&tmp, " %s is tiny!", device);
    149150                log_it(tmp);
    150151                if (flaws_str) {
    151                     asprintf(&tmp1, "%s%s",flaws_str, tmp);
     152                    mr_asprintf(&tmp1, "%s%s",flaws_str, tmp);
    152153                } else {
    153                     asprintf(&tmp1, "%s", tmp);
    154                 }
    155                 paranoid_free(flaws_str);
     154                    mr_asprintf(&tmp1, "%s", tmp);
     155                }
     156                mr_free(flaws_str);
    156157                flaws_str = tmp1;
    157                 paranoid_free(tmp);
     158                mr_free(tmp);
    158159                res++;
    159160            }
     
    165166                && strcmp(mountlist->el[pos].mountpoint, "none")
    166167                && mountlist->el[pos].mountpoint[0] != '/') {
    167                 asprintf(&tmp, " %s has a weird mountpoint.", device);
     168                mr_asprintf(&tmp, " %s has a weird mountpoint.", device);
    168169                log_it(tmp);
    169170                if (flaws_str) {
    170                     asprintf(&tmp1, "%s%s",flaws_str, tmp);
     171                    mr_asprintf(&tmp1, "%s%s",flaws_str, tmp);
    171172                } else {
    172                     asprintf(&tmp1, "%s", tmp);
    173                 }
    174                 paranoid_free(flaws_str);
     173                    mr_asprintf(&tmp1, "%s", tmp);
     174                }
     175                mr_free(flaws_str);
    175176                flaws_str = tmp1;
    176                 paranoid_free(tmp);
     177                mr_free(tmp);
    177178                res++;
    178179            }
    179180            /* is format sensible? */
    180181            if (!is_this_a_valid_disk_format(mountlist->el[pos].format)) {
    181                 asprintf(&tmp, " %s has unsupported format %s.", device, mountlist->el[pos].format);
     182                mr_asprintf(&tmp, " %s has unsupported format %s.", device, mountlist->el[pos].format);
    182183                log_it(tmp);
    183184                if (flaws_str) {
    184                     asprintf(&tmp1, "%s%s",flaws_str, tmp);
     185                    mr_asprintf(&tmp1, "%s%s",flaws_str, tmp);
    185186                } else {
    186                     asprintf(&tmp1, "%s", tmp);
    187                 }
    188                 paranoid_free(flaws_str);
     187                    mr_asprintf(&tmp1, "%s", tmp);
     188                }
     189                mr_free(flaws_str);
    189190                flaws_str = tmp1;
    190                 paranoid_free(tmp);
     191                mr_free(tmp);
    191192                res++;
    192193            }
     
    194195            prev_sp_no = cur_sp_no;
    195196
    196             paranoid_free(device);
     197            mr_free(device);
    197198        }
    198199    }
     
    200201    npos = pos = 0;
    201202    for (curr_part_no = 1; curr_part_no < 99; curr_part_no++) {
    202         asprintf(&device, "%ss%d", drive, curr_part_no);
     203        mr_asprintf(&device, "%ss%d", drive, curr_part_no);
    203204        pos = find_device_in_mountlist(mountlist, device);
    204205        npos = 0;
    205206        for (cur_sp_no = 'a'; cur_sp_no <= 'h'; cur_sp_no++) {
    206             asprintf(&ndevice, "%ss%d%c", device, curr_part_no, cur_sp_no);
     207            mr_asprintf(&ndevice, "%ss%d%c", device, curr_part_no, cur_sp_no);
    207208            if (find_device_in_mountlist(mountlist, ndevice) >= 0)
    208209                npos++;
    209             paranoid_free(ndevice);
    210         }
    211         paranoid_free(device);
     210            mr_free(ndevice);
     211        }
     212        mr_free(device);
    212213
    213214        if (((pos >= 0) || npos) && foundsome) {
    214             asprintf(&tmp, " %s has both DD and PC-style partitions.", drive);
     215            mr_asprintf(&tmp, " %s has both DD and PC-style partitions.", drive);
    215216            if (flaws_str) {
    216                 asprintf(&tmp1, "%s%s",flaws_str, tmp);
     217                mr_asprintf(&tmp1, "%s%s",flaws_str, tmp);
    217218            } else {
    218                 asprintf(&tmp1, "%s", tmp);
    219             }
    220             paranoid_free(flaws_str);
     219                mr_asprintf(&tmp1, "%s", tmp);
     220            }
     221            mr_free(flaws_str);
    221222            flaws_str = tmp1;
    222             paranoid_free(tmp);
     223            mr_free(tmp);
    223224            return ++res;       // fatal error
    224225        }
    225         // BERLIOS : useless ? asprintf(&mountpoint, mountlist->el[pos].mountpoint);
     226        // BERLIOS : useless ? mr_asprintf(&mountpoint, mountlist->el[pos].mountpoint);
    226227        if (pos > 0 && !npos) {
    227             asprintf(&device, "%ss%d", drive, curr_part_no);
     228            mr_asprintf(&device, "%ss%d", drive, curr_part_no);
    228229            /* gap in the partition list? */
    229230            if (curr_part_no - prev_part_no > 1) {
    230231                if (prev_part_no == 0) {
    231                     asprintf(&tmp, " Gap prior to %s.", device);
     232                    mr_asprintf(&tmp, " Gap prior to %s.", device);
    232233                    log_it(tmp);
    233234                    if (flaws_str) {
    234                         asprintf(&tmp1, "%s%s",flaws_str, tmp);
     235                        mr_asprintf(&tmp1, "%s%s",flaws_str, tmp);
    235236                    } else {
    236                         asprintf(&tmp1, "%s", tmp);
     237                        mr_asprintf(&tmp1, "%s", tmp);
    237238                    }
    238                     paranoid_free(flaws_str);
     239                    mr_free(flaws_str);
    239240                    flaws_str = tmp1;
    240                     paranoid_free(tmp);
     241                    mr_free(tmp);
    241242                    res++;
    242243                } else if (curr_part_no > 5
    243244                           || (curr_part_no <= 4 && prev_part_no > 0)) {
    244                     asprintf(&tmp, " Gap between %ss%d and %d.", drive,
     245                    mr_asprintf(&tmp, " Gap between %ss%d and %d.", drive,
    245246                             prev_part_no, curr_part_no);
    246247                    log_it(tmp);
    247248                    if (flaws_str) {
    248                         asprintf(&tmp1, "%s%s",flaws_str, tmp);
     249                        mr_asprintf(&tmp1, "%s%s",flaws_str, tmp);
    249250                    } else {
    250                         asprintf(&tmp1, "%s", tmp);
     251                        mr_asprintf(&tmp1, "%s", tmp);
    251252                    }
    252                     paranoid_free(flaws_str);
     253                    mr_free(flaws_str);
    253254                    flaws_str = tmp1;
    254                     paranoid_free(tmp);
     255                    mr_free(tmp);
    255256                    res++;
    256257                }
     
    261262            if ((curr_part_no >= 5 && prev_part_no == 4)
    262263                && (strcmp(part_table_fmt, "MBR") == 0)) {
    263                 asprintf(&tmp, " Partition %ss4 is occupied.", drive);
     264                mr_asprintf(&tmp, " Partition %ss4 is occupied.", drive);
    264265                log_it(tmp);
    265266                if (flaws_str) {
    266                     asprintf(&tmp1, "%s%s",flaws_str, tmp);
     267                    mr_asprintf(&tmp1, "%s%s",flaws_str, tmp);
    267268                } else {
    268                     asprintf(&tmp1, "%s", tmp);
    269                 }
    270                 paranoid_free(flaws_str);
     269                    mr_asprintf(&tmp1, "%s", tmp);
     270                }
     271                mr_free(flaws_str);
    271272                flaws_str = tmp1;
    272                 paranoid_free(tmp);
     273                mr_free(tmp);
    273274                res++;
    274275            }
     
    281282            }
    282283            if (device_copies > 1) {
    283                 asprintf(&tmp, " %s %s's.", number_to_text(device_copies),
     284                mr_asprintf(&tmp, " %s %s's.", number_to_text(device_copies),
    284285                         device);
    285286                if (!strstr(flaws_str, tmp)) {
    286287                    log_it(tmp);
    287288                    if (flaws_str) {
    288                         asprintf(&tmp1, "%s%s",flaws_str, tmp);
     289                        mr_asprintf(&tmp1, "%s%s",flaws_str, tmp);
    289290                    } else {
    290                         asprintf(&tmp1, "%s", tmp);
     291                        mr_asprintf(&tmp1, "%s", tmp);
    291292                    }
    292                     paranoid_free(flaws_str);
     293                    mr_free(flaws_str);
    293294                    flaws_str = tmp1;
    294295                    res++;
    295296                }
    296                 paranoid_free(tmp);
     297                mr_free(tmp);
    297298            }
    298299            /* silly partition size? */
    299300            if (mountlist->el[pos].size < 8192
    300301                && strcmp(mountlist->el[pos].mountpoint, "lvm")) {
    301                 asprintf(&tmp, " %s is tiny!", device);
     302                mr_asprintf(&tmp, " %s is tiny!", device);
    302303                log_it(tmp);
    303304                if (flaws_str) {
    304                     asprintf(&tmp1, "%s%s",flaws_str, tmp);
     305                    mr_asprintf(&tmp1, "%s%s",flaws_str, tmp);
    305306                } else {
    306                     asprintf(&tmp1, "%s", tmp);
    307                 }
    308                 paranoid_free(flaws_str);
     307                    mr_asprintf(&tmp1, "%s", tmp);
     308                }
     309                mr_free(flaws_str);
    309310                flaws_str = tmp1;
    310                 paranoid_free(tmp);
     311                mr_free(tmp);
    311312                res++;
    312313            }
     
    318319                && strcmp(mountlist->el[pos].mountpoint, "none")
    319320                && mountlist->el[pos].mountpoint[0] != '/') {
    320                 asprintf(&tmp, " %s has a weird mountpoint.", device);
     321                mr_asprintf(&tmp, " %s has a weird mountpoint.", device);
    321322                log_it(tmp);
    322323                if (flaws_str) {
    323                     asprintf(&tmp1, "%s%s",flaws_str, tmp);
     324                    mr_asprintf(&tmp1, "%s%s",flaws_str, tmp);
    324325                } else {
    325                     asprintf(&tmp1, "%s", tmp);
    326                 }
    327                 paranoid_free(flaws_str);
     326                    mr_asprintf(&tmp1, "%s", tmp);
     327                }
     328                mr_free(flaws_str);
    328329                flaws_str = tmp1;
    329                 paranoid_free(tmp);
     330                mr_free(tmp);
    330331                res++;
    331332            }
    332333            /* is format sensible? */
    333334            if (!is_this_a_valid_disk_format(mountlist->el[pos].format)) {
    334                 asprintf(&tmp, " %s has unsupported format %s.", device, mountlist->el[pos].format);
     335                mr_asprintf(&tmp, " %s has unsupported format %s.", device, mountlist->el[pos].format);
    335336                log_it(tmp);
    336337                if (flaws_str) {
    337                     asprintf(&tmp1, "%s%s",flaws_str, tmp);
     338                    mr_asprintf(&tmp1, "%s%s",flaws_str, tmp);
    338339                } else {
    339                     asprintf(&tmp1, "%s", tmp);
    340                 }
    341                 paranoid_free(flaws_str);
     340                    mr_asprintf(&tmp1, "%s", tmp);
     341                }
     342                mr_free(flaws_str);
    342343                flaws_str = tmp1;
    343                 paranoid_free(tmp);
     344                mr_free(tmp);
    344345                res++;
    345346            }
    346             paranoid_free(device);
     347            mr_free(device);
    347348        } else {
    348349            /* Check subpartitions */
    349350            for (cur_sp_no = 'a'; cur_sp_no < 'z'; ++cur_sp_no) {
    350                 asprintf(&device, "%ss%d%c", drive, curr_part_no,
     351                mr_asprintf(&device, "%ss%d%c", drive, curr_part_no,
    351352                         cur_sp_no);
    352353                pos = find_device_in_mountlist(mountlist, device);
     
    354355                    continue;
    355356                }
    356                 // BERLIOS : useless ? asprintf(&mountpoint, mountlist->el[pos].mountpoint);
     357                // BERLIOS : useless ? mr_asprintf(&mountpoint, mountlist->el[pos].mountpoint);
    357358                /* is it too big? */
    358359                if (curr_part_no > 'h') {
    359                     asprintf(&tmp,
     360                    mr_asprintf(&tmp,
    360361                             " Can only have up to 'h' in disklabel.");
    361362                    log_it(tmp);
    362363                    if (flaws_str) {
    363                         asprintf(&tmp1, "%s%s",flaws_str, tmp);
     364                        mr_asprintf(&tmp1, "%s%s",flaws_str, tmp);
    364365                    } else {
    365                         asprintf(&tmp1, "%s", tmp);
     366                        mr_asprintf(&tmp1, "%s", tmp);
    366367                    }
    367                     paranoid_free(flaws_str);
     368                    mr_free(flaws_str);
    368369                    flaws_str = tmp1;
    369                     paranoid_free(tmp);
     370                    mr_free(tmp);
    370371                    res++;
    371372                }
     
    378379                }
    379380                if (device_copies > 1) {
    380                     asprintf(&tmp, " %s %s's.",
     381                    mr_asprintf(&tmp, " %s %s's.",
    381382                             number_to_text(device_copies), device);
    382383                    if (!strstr(flaws_str, tmp)) {
    383384                        log_it(tmp);
    384385                        if (flaws_str) {
    385                             asprintf(&tmp1, "%s%s",flaws_str, tmp);
     386                            mr_asprintf(&tmp1, "%s%s",flaws_str, tmp);
    386387                        } else {
    387                             asprintf(&tmp1, "%s", tmp);
     388                            mr_asprintf(&tmp1, "%s", tmp);
    388389                        }
    389                         paranoid_free(flaws_str);
     390                        mr_free(flaws_str);
    390391                        flaws_str = tmp1;
    391392                        res++;
    392393                    }
    393                     paranoid_free(tmp);
     394                    mr_free(tmp);
    394395                }
    395396                /* silly partition size? */
    396397                if (mountlist->el[pos].size < 8192
    397398                    && strcmp(mountlist->el[pos].mountpoint, "lvm")) {
    398                     asprintf(&tmp, " %s is tiny!", device);
     399                    mr_asprintf(&tmp, " %s is tiny!", device);
    399400                    log_it(tmp);
    400401                    if (flaws_str) {
    401                         asprintf(&tmp1, "%s%s",flaws_str, tmp);
     402                        mr_asprintf(&tmp1, "%s%s",flaws_str, tmp);
    402403                    } else {
    403                         asprintf(&tmp1, "%s", tmp);
     404                        mr_asprintf(&tmp1, "%s", tmp);
    404405                    }
    405                     paranoid_free(flaws_str);
     406                    mr_free(flaws_str);
    406407                    flaws_str = tmp1;
    407                     paranoid_free(tmp);
     408                    mr_free(tmp);
    408409                    res++;
    409410                }
     
    415416                    && strcmp(mountlist->el[pos].mountpoint, "none")
    416417                    && mountlist->el[pos].mountpoint[0] != '/') {
    417                     asprintf(&tmp, " %s has a weird mountpoint.", device);
     418                    mr_asprintf(&tmp, " %s has a weird mountpoint.", device);
    418419                    log_it(tmp);
    419420                    if (flaws_str) {
    420                         asprintf(&tmp1, "%s%s",flaws_str, tmp);
     421                        mr_asprintf(&tmp1, "%s%s",flaws_str, tmp);
    421422                    } else {
    422                         asprintf(&tmp1, "%s", tmp);
     423                        mr_asprintf(&tmp1, "%s", tmp);
    423424                    }
    424                     paranoid_free(flaws_str);
     425                    mr_free(flaws_str);
    425426                    flaws_str = tmp1;
    426                     paranoid_free(tmp);
     427                    mr_free(tmp);
    427428                    res++;
    428429                }
     
    430431                if (!is_this_a_valid_disk_format
    431432                    (mountlist->el[pos].format)) {
    432                     asprintf(&tmp, " %s has unsupported format %s.", device, mountlist->el[pos].format);
     433                    mr_asprintf(&tmp, " %s has unsupported format %s.", device, mountlist->el[pos].format);
    433434                    log_it(tmp);
    434435                    if (flaws_str) {
    435                         asprintf(&tmp1, "%s%s",flaws_str, tmp);
     436                        mr_asprintf(&tmp1, "%s%s",flaws_str, tmp);
    436437                    } else {
    437                         asprintf(&tmp1, "%s", tmp);
     438                        mr_asprintf(&tmp1, "%s", tmp);
    438439                    }
    439                     paranoid_free(flaws_str);
     440                    mr_free(flaws_str);
    440441                    flaws_str = tmp1;
    441                     paranoid_free(tmp);
     442                    mr_free(tmp);
    442443                    res++;
    443444                }
    444445                amount_allocated += mountlist->el[pos].size / 1024;
    445446                prev_sp_no = cur_sp_no;
    446                 paranoid_free(device);
     447                mr_free(device);
    447448            }
    448449        }
     
    456457    if (amount_allocated > physical_drive_size) // Used to be +1, but what if you're 1 MB too high?
    457458    {
    458         asprintf(&tmp, " %ld MB over-allocated on %s.",
     459        mr_asprintf(&tmp, " %ld MB over-allocated on %s.",
    459460                 amount_allocated - physical_drive_size, drive);
    460461        log_it(tmp);
    461462        if (flaws_str) {
    462             asprintf(&tmp1, "%s%s",flaws_str, tmp);
     463            mr_asprintf(&tmp1, "%s%s",flaws_str, tmp);
    463464        } else {
    464             asprintf(&tmp1, "%s", tmp);
    465         }
    466         paranoid_free(flaws_str);
     465            mr_asprintf(&tmp1, "%s", tmp);
     466        }
     467        mr_free(flaws_str);
    467468        flaws_str = tmp1;
    468         paranoid_free(tmp);
     469        mr_free(tmp);
    469470        res++;
    470471    } else if (amount_allocated < physical_drive_size - 1) {    /* NOT AN ERROR, JUST A WARNING :-) */
    471         asprintf(&tmp, " %ld MB unallocated on %s.",
     472        mr_asprintf(&tmp, " %ld MB unallocated on %s.",
    472473                 physical_drive_size - amount_allocated, drive);
    473474        log_it(tmp);
    474475        if (flaws_str) {
    475             asprintf(&tmp1, "%s%s",flaws_str, tmp);
     476            mr_asprintf(&tmp1, "%s%s",flaws_str, tmp);
    476477        } else {
    477             asprintf(&tmp1, "%s", tmp);
    478         }
    479         paranoid_free(flaws_str);
     478            mr_asprintf(&tmp1, "%s", tmp);
     479        }
     480        mr_free(flaws_str);
    480481        flaws_str = tmp1;
    481         paranoid_free(tmp);
     482        mr_free(tmp);
    482483    }
    483484    if (res) {
     
    525526
    526527    if (physical_drive_size < 0) {
    527         asprintf(&tmp, " %s does not exist.", drive);
     528        mr_asprintf(&tmp, " %s does not exist.", drive);
    528529        if (flaws_str) {
    529             asprintf(&tmp1, "%s%s",flaws_str, tmp);
     530            mr_asprintf(&tmp1, "%s%s",flaws_str, tmp);
    530531        } else {
    531             asprintf(&tmp1, "%s", tmp);
    532         }
    533         paranoid_free(flaws_str);
     532            mr_asprintf(&tmp1, "%s", tmp);
     533        }
     534        mr_free(flaws_str);
    534535        flaws_str = tmp1;
    535536        res++;
    536537        log_msg(1, tmp);
    537         paranoid_free(tmp);
     538        mr_free(tmp);
    538539        return (FALSE);
    539540    } else {
    540         asprintf(&tmp, "%s is %ld MB", drive, physical_drive_size);
     541        mr_asprintf(&tmp, "%s is %ld MB", drive, physical_drive_size);
    541542        log_it(tmp);
    542         paranoid_free(tmp);
     543        mr_free(tmp);
    543544    }
    544545
    545546    for (curr_part_no = 1; curr_part_no < 99; curr_part_no++) {
    546         asprintf(&device, "%s%d", drive, curr_part_no);
     547        mr_asprintf(&device, "%s%d", drive, curr_part_no);
    547548        pos = find_device_in_mountlist(mountlist, device);
    548549        if (pos < 0) {
     
    550551        }
    551552        if (physical_drive_size < 0) {
    552             asprintf(&tmp, " %s refers to non-existent hardware.", device);
     553            mr_asprintf(&tmp, " %s refers to non-existent hardware.", device);
    553554            if (flaws_str) {
    554                 asprintf(&tmp1, "%s%s",flaws_str, tmp);
     555                mr_asprintf(&tmp1, "%s%s",flaws_str, tmp);
    555556            } else {
    556                 asprintf(&tmp1, "%s", tmp);
    557             }
    558             paranoid_free(flaws_str);
     557                mr_asprintf(&tmp1, "%s", tmp);
     558            }
     559            mr_free(flaws_str);
    559560            flaws_str = tmp1;
    560561            res++;
    561             paranoid_free(tmp);
     562            mr_free(tmp);
    562563            continue;
    563564        }
     
    566567        if (curr_part_no - prev_part_no > 1) {
    567568            if (prev_part_no == 0) {
    568                 asprintf(&tmp, " Gap prior to %s.", device);
     569                mr_asprintf(&tmp, " Gap prior to %s.", device);
    569570                log_it(tmp);
    570571                if (flaws_str) {
    571                     asprintf(&tmp1, "%s%s",flaws_str, tmp);
     572                    mr_asprintf(&tmp1, "%s%s",flaws_str, tmp);
    572573                } else {
    573                     asprintf(&tmp1, "%s", tmp);
    574                 }
    575                 paranoid_free(flaws_str);
     574                    mr_asprintf(&tmp1, "%s", tmp);
     575                }
     576                mr_free(flaws_str);
    576577                flaws_str = tmp1;
    577                 paranoid_free(tmp);
     578                mr_free(tmp);
    578579                res++;
    579580            } else if (curr_part_no > 5
    580581                       || (curr_part_no <= 4 && prev_part_no > 0)) {
    581                 asprintf(&tmp, " Gap between %s%d and %d.", drive,
     582                mr_asprintf(&tmp, " Gap between %s%d and %d.", drive,
    582583                         prev_part_no, curr_part_no);
    583584                log_it(tmp);
    584585                if (flaws_str) {
    585                     asprintf(&tmp1, "%s%s",flaws_str, tmp);
     586                    mr_asprintf(&tmp1, "%s%s",flaws_str, tmp);
    586587                } else {
    587                     asprintf(&tmp1, "%s", tmp);
    588                 }
    589                 paranoid_free(flaws_str);
     588                    mr_asprintf(&tmp1, "%s", tmp);
     589                }
     590                mr_free(flaws_str);
    590591                flaws_str = tmp1;
    591                 paranoid_free(tmp);
     592                mr_free(tmp);
    592593                res++;
    593594            }
     
    598599        if ((curr_part_no >= 5 && prev_part_no == 4)
    599600            && (strcmp(part_table_fmt, "MBR") == 0)) {
    600             asprintf(&tmp, " Partition %s4 is occupied.", drive);
     601            mr_asprintf(&tmp, " Partition %s4 is occupied.", drive);
    601602            log_it(tmp);
    602603            if (flaws_str) {
    603                 asprintf(&tmp1, "%s%s",flaws_str, tmp);
     604                mr_asprintf(&tmp1, "%s%s",flaws_str, tmp);
    604605            } else {
    605                 asprintf(&tmp1, "%s", tmp);
    606             }
    607             paranoid_free(flaws_str);
     606                mr_asprintf(&tmp1, "%s", tmp);
     607            }
     608            mr_free(flaws_str);
    608609            flaws_str = tmp1;
    609             paranoid_free(tmp);
     610            mr_free(tmp);
    610611            res++;
    611612        }
    612         paranoid_free(part_table_fmt);
     613        mr_free(part_table_fmt);
    613614
    614615        /* does partition /dev/hdNX exist more than once in the mountlist? */
     
    620621        }
    621622        if (device_copies > 1) {
    622             asprintf(&tmp, " %s %s's.", number_to_text(device_copies),
     623            mr_asprintf(&tmp, " %s %s's.", number_to_text(device_copies),
    623624                     device);
    624625            if (!strstr(flaws_str, tmp)) {
    625626                log_it(tmp);
    626627                if (flaws_str) {
    627                     asprintf(&tmp1, "%s%s",flaws_str, tmp);
     628                    mr_asprintf(&tmp1, "%s%s",flaws_str, tmp);
    628629                } else {
    629                     asprintf(&tmp1, "%s", tmp);
    630                 }
    631                 paranoid_free(flaws_str);
     630                    mr_asprintf(&tmp1, "%s", tmp);
     631                }
     632                mr_free(flaws_str);
    632633                flaws_str = tmp1;
    633634                res++;
    634635            }
    635             paranoid_free(tmp);
     636            mr_free(tmp);
    636637        }
    637638        /* silly partition size? */
    638639        if (mountlist->el[pos].size < 8192
    639640            && strcmp(mountlist->el[pos].mountpoint, "lvm")) {
    640             asprintf(&tmp, " %s is tiny!", device);
     641            mr_asprintf(&tmp, " %s is tiny!", device);
    641642            log_it(tmp);
    642643            if (flaws_str) {
    643                 asprintf(&tmp1, "%s%s",flaws_str, tmp);
     644                mr_asprintf(&tmp1, "%s%s",flaws_str, tmp);
    644645            } else {
    645                 asprintf(&tmp1, "%s", tmp);
    646             }
    647             paranoid_free(flaws_str);
     646                mr_asprintf(&tmp1, "%s", tmp);
     647            }
     648            mr_free(flaws_str);
    648649            flaws_str = tmp1;
    649             paranoid_free(tmp);
     650            mr_free(tmp);
    650651            res++;
    651652        }
     
    656657            && strcmp(mountlist->el[pos].mountpoint, "image")
    657658            && mountlist->el[pos].mountpoint[0] != '/') {
    658             asprintf(&tmp, " %s has a weird mountpoint.", device);
     659            mr_asprintf(&tmp, " %s has a weird mountpoint.", device);
    659660            log_it(tmp);
    660661            if (flaws_str) {
    661                 asprintf(&tmp1, "%s%s",flaws_str, tmp);
     662                mr_asprintf(&tmp1, "%s%s",flaws_str, tmp);
    662663            } else {
    663                 asprintf(&tmp1, "%s", tmp);
    664             }
    665             paranoid_free(flaws_str);
     664                mr_asprintf(&tmp1, "%s", tmp);
     665            }
     666            mr_free(flaws_str);
    666667            flaws_str = tmp1;
    667             paranoid_free(tmp);
     668            mr_free(tmp);
    668669            res++;
    669670        }
    670671        /* is format sensible? */
    671672        if (!is_this_a_valid_disk_format(mountlist->el[pos].format)) {
    672             asprintf(&tmp, " %s has unsupported format %s.", device, mountlist->el[pos].format);
     673            mr_asprintf(&tmp, " %s has unsupported format %s.", device, mountlist->el[pos].format);
    673674            log_it(tmp);
    674675            if (flaws_str) {
    675                 asprintf(&tmp1, "%s%s",flaws_str, tmp);
     676                mr_asprintf(&tmp1, "%s%s",flaws_str, tmp);
    676677            } else {
    677                 asprintf(&tmp1, "%s", tmp);
    678             }
    679             paranoid_free(flaws_str);
     678                mr_asprintf(&tmp1, "%s", tmp);
     679            }
     680            mr_free(flaws_str);
    680681            flaws_str = tmp1;
    681             paranoid_free(tmp);
     682            mr_free(tmp);
    682683            res++;
    683684        }
     
    685686        amount_allocated += mountlist->el[pos].size / 1024;
    686687        prev_part_no = curr_part_no;
    687         paranoid_free(device);
     688        mr_free(device);
    688689    }
    689690
    690691    /* Over-allocated the disk? Unallocated space on disk? */
    691692    if (amount_allocated > physical_drive_size + 1) {
    692         asprintf(&tmp, " %ld MB over-allocated on %s.",
     693        mr_asprintf(&tmp, " %ld MB over-allocated on %s.",
    693694                 amount_allocated - physical_drive_size, drive);
    694695        log_it(tmp);
    695696        if (flaws_str) {
    696             asprintf(&tmp1, "%s%s",flaws_str, tmp);
     697            mr_asprintf(&tmp1, "%s%s",flaws_str, tmp);
    697698        } else {
    698             asprintf(&tmp1, "%s", tmp);
    699         }
    700         paranoid_free(flaws_str);
     699            mr_asprintf(&tmp1, "%s", tmp);
     700        }
     701        mr_free(flaws_str);
    701702        flaws_str = tmp1;
    702         paranoid_free(tmp);
     703        mr_free(tmp);
    703704        res++;
    704705    } else if (amount_allocated < physical_drive_size - 1) {    /* NOT AN ERROR, JUST A WARNING :-) */
    705         asprintf(&tmp, " %ld MB unallocated on %s.",
     706        mr_asprintf(&tmp, " %ld MB unallocated on %s.",
    706707                 physical_drive_size - amount_allocated, drive);
    707708        log_it(tmp);
    708709        if (flaws_str) {
    709             asprintf(&tmp1, "%s%s",flaws_str, tmp);
     710            mr_asprintf(&tmp1, "%s%s",flaws_str, tmp);
    710711        } else {
    711             asprintf(&tmp1, "%s", tmp);
    712         }
    713         paranoid_free(flaws_str);
     712            mr_asprintf(&tmp1, "%s", tmp);
     713        }
     714        mr_free(flaws_str);
    714715        flaws_str = tmp1;
    715         paranoid_free(tmp);
     716        mr_free(tmp);
    716717    }
    717718
     
    755756    assert(mountlist != NULL);
    756757
    757     asprintf(&flaws_str, " ");
     758    mr_asprintf(&flaws_str, " ");
    758759
    759760    make_list_of_drives_in_mountlist(mountlist, drivelist);
     
    765766            (drivelist->el[i].device,
    766767             DONT_KNOW_HOW_TO_EVALUATE_THIS_DEVICE_TYPE)) {
    767             asprintf(&tmp, " Not evaluating %s (I don't know how yet)",
     768            mr_asprintf(&tmp, " Not evaluating %s (I don't know how yet)",
    768769                     drivelist->el[i].device);
    769770            log_it(tmp);
     
    775776            }
    776777        }
    777         asprintf(&tmp1, "%s%s", flaws_str, tmp);
    778         paranoid_free(tmp);
    779         paranoid_free(flaws_str);
     778        mr_asprintf(&tmp1, "%s%s", flaws_str, tmp);
     779        mr_free(tmp);
     780        mr_free(flaws_str);
    780781        flaws_str = tmp1;
    781782    }
     
    841842
    842843    for (currline = 0; currline < mountlist->entries; currline++) {
    843         asprintf(&curr_mountpoint, mountlist->el[currline].mountpoint);
     844        mr_asprintf(&curr_mountpoint, mountlist->el[currline].mountpoint);
    844845        for (i = 0, copies = 0, last_copy = -1; i < mountlist->entries;
    845846             i++) {
     
    853854        if (copies > 1 && last_copy == currline
    854855            && strcmp(curr_mountpoint, "raid")) {
    855             asprintf(&tmp, " %s %s's.", number_to_text(copies),
     856            mr_asprintf(&tmp, " %s %s's.", number_to_text(copies),
    856857                     curr_mountpoint);
    857858            log_it(tmp);
    858             asprintf(&tmp1, "%s%s",flaws_str, tmp);
    859             paranoid_free(flaws_str);
     859            mr_asprintf(&tmp1, "%s%s",flaws_str, tmp);
     860            mr_free(flaws_str);
    860861            flaws_str = tmp1;
    861             paranoid_free(tmp);
     862            mr_free(tmp);
    862863            res++;
    863864        }
    864         paranoid_free(curr_mountpoint);
     865        mr_free(curr_mountpoint);
    865866    }
    866867    return (res);
     
    895896    for (lino = 0, noof_drives = 0; lino < mountlist->entries; lino++) {
    896897
    897         asprintf(&drive, mountlist->el[lino].device);
     898        mr_asprintf(&drive, mountlist->el[lino].device);
    898899        if (!strncmp(drive, RAID_DEVICE_STUB, strlen(RAID_DEVICE_STUB))) {
    899             asprintf(&tmp,
     900            mr_asprintf(&tmp,
    900901                     "Not putting %s in list of drives: it's a virtual drive",
    901902                     drive);
    902903            log_msg(8, tmp);
    903             paranoid_free(tmp);
     904            mr_free(tmp);
    904905            continue;
    905906        }
     
    907908        size = mountlist->el[lino].size;
    908909        if (size == 0) {
    909             asprintf(&tmp,
     910            mr_asprintf(&tmp,
    910911                     "Not putting %s in list of drives: it has zero size (maybe an LVM volume)",
    911912                     drive);
    912913            log_msg(8, tmp);
    913             paranoid_free(tmp);
     914            mr_free(tmp);
    914915            continue;
    915916        }
     
    926927*/
    927928
    928         asprintf(&tmp,
     929        mr_asprintf(&tmp,
    929930                 "Putting %s with size %lli in list of drives",
    930931                 drive, size);
    931932        log_msg(8, tmp);
    932         paranoid_free(tmp);
     933        mr_free(tmp);
    933934
    934935        (void) truncate_to_drive_name(drive);
     
    940941            strcpy(drivelist->el[noof_drives++].device, drive);
    941942        }
    942         paranoid_free(drive);
     943        mr_free(drive);
    943944
    944945    }
     
    988989                       (void *) &mountlist->el[i],
    989990                       sizeof(struct mountlist_line));
    990                 asprintf(&tmp,
     991                mr_asprintf(&tmp,
    991992                         "%s is available; user may choose to add it to raid device",
    992993                         output_list->el[items - 1].device);
    993994                log_it(tmp);
    994                 paranoid_free(tmp);
     995                mr_free(tmp);
    995996            }
    996997        }
     
    10581059        log_it("Unable to open mountlist - '%s'", fname);
    10591060        log_to_screen(_("Cannot open mountlist"));
    1060         paranoid_free(siz);
     1061        mr_free(siz);
    10611062        return (1);
    10621063    }
    10631064    items = 0;
    1064     (void) getline(&incoming, &n, fin);
     1065    mr_getline(&incoming, &n, fin);
    10651066    log_it("Loading mountlist...");
    10661067    while (!feof(fin)) {
     
    10911092                    "Ignoring %s in mountlist - not loading that line :) ",
    10921093                    mountlist->el[items].device);
    1093             (void) getline(&incoming, &n, fin);
     1094            mr_getline(&incoming, &n, fin);
    10941095            continue;
    10951096        }
     
    11071108            if (j < items) {
    11081109                strcat(mountlist->el[items].device, "_dup");
    1109                 asprintf(&tmp,
     1110                mr_asprintf(&tmp,
    11101111                         "Duplicate entry in mountlist - renaming to %s",
    11111112                         mountlist->el[items].device);
    11121113                log_it(tmp);
    1113                 paranoid_free(tmp);
    1114             }
    1115             asprintf(&tmp, mountlist->el[items].device);
     1114                mr_free(tmp);
     1115            }
     1116            mr_asprintf(&tmp, mountlist->el[items].device);
    11161117            if (strstr(tmp, "/dev/md/")) {
    11171118                log_it("format_device() --- Contracting %s", tmp);
     
    11261127                strcpy(mountlist->el[items].device, tmp);
    11271128            }
    1128             paranoid_free(tmp);
    1129 
    1130             asprintf(&tmp,
     1129            mr_free(tmp);
     1130
     1131            mr_asprintf(&tmp,
    11311132                     "%s %s %s %lld %s",
    11321133                     mountlist->el[items].device,
     
    11371138
    11381139            log_it(tmp);
    1139             paranoid_free(tmp);
     1140            mr_free(tmp);
    11401141            items++;
    11411142        }
    1142         (void) getline(&incoming, &n, fin);
     1143        mr_getline(&incoming, &n, fin);
    11431144    }
    11441145    paranoid_fclose(fin);
    1145     paranoid_free(incoming);
     1146    mr_free(incoming);
    11461147    mountlist->entries = items;
    11471148
    11481149    log_it("Mountlist loaded successfully.");
    1149     asprintf(&tmp, "%d entries in mountlist", items);
     1150    mr_asprintf(&tmp, "%d entries in mountlist", items);
    11501151    log_it(tmp);
    1151     paranoid_free(tmp);
    1152 
    1153     paranoid_free(siz);
     1152    mr_free(tmp);
     1153
     1154    mr_free(siz);
    11541155    return (0);
    11551156}
     
    12641265    assert(b >= 0);
    12651266
    1266     asprintf(&device, mountlist->el[a].device);
    1267     asprintf(&mountpoint, mountlist->el[a].mountpoint);
    1268     asprintf(&format, mountlist->el[a].format);
     1267    mr_asprintf(&device, mountlist->el[a].device);
     1268    mr_asprintf(&mountpoint, mountlist->el[a].mountpoint);
     1269    mr_asprintf(&format, mountlist->el[a].format);
    12691270
    12701271    size = mountlist->el[a].size;
  • trunk/mondo/src/common/libmondo-raid.c

    r839 r900  
    99
    1010#include "my-stuff.h"
    11 #include "mr_string.h"
     11#include "mr_str.h"
    1212#include "mondostructures.h"
    1313#include "newt-specific-EXT.h"
     
    1616#include "libmondo-string-EXT.h"
    1717#include "libmondo-raid.h"
    18 #include "mr_string.h"
     18#include "mr_mem.h"
    1919
    2020#ifdef __FreeBSD__
     
    4949
    5050    if (raidno == -1) {
    51         asprintf(&command,
     51        mr_asprintf(&command,
    5252                 "grep \"linear\" /proc/mdstat > /dev/null 2> /dev/null");
    5353    } else {
    54         asprintf(&command,
     54        mr_asprintf(&command,
    5555                 "grep \"raid%d\" /proc/mdstat > /dev/null 2> /dev/null",
    5656                 raidno);
     
    5858    log_it("Is raid %d registered? Command = '%s'", raidno, command);
    5959    res = system(command);
    60     paranoid_free(command);
     60    mr_free(command);
    6161    if (res) {
    6262        return (FALSE);
     
    185185    assert(label != NULL);
    186186
    187     asprintf(&sz_value, "%d", value);
    188     asprintf(&sz_label,label);
     187    mr_asprintf(&sz_value, "%d", value);
     188    mr_asprintf(&sz_label,label);
    189189    raidrec->additional_vars.el[lino].value = sz_value;
    190190    raidrec->additional_vars.el[lino].label = sz_label;
     
    320320        switch (raidrec->plex[i].raidlevel) {
    321321        case -1:
    322             asprintf(&org, "%s", "concat");
     322            mr_asprintf(&org, "%s", "concat");
    323323            break;
    324324        case 0:
    325             asprintf(&org, "%s", "striped");
     325            mr_asprintf(&org, "%s", "striped");
    326326            break;
    327327        case 5:
    328             asprintf(&org, "%s", "raid5");
     328            mr_asprintf(&org, "%s", "raid5");
    329329            break;
    330330        }
    331331        fprintf(fout, "  plex org %s", org);
    332         paranoid_free(org);
     332        mr_free(org);
    333333
    334334        if (raidrec->plex[i].raidlevel != -1) {
     
    418418    }
    419419
    420     for (getline(&incoming, &n, fin); !feof(fin);
    421          getline(&incoming, &n, fin)) {
     420    for (mr_getline(&incoming, &n, fin); !feof(fin);
     421         mr_getline(&incoming, &n, fin)) {
    422422        strip_spaces(incoming);
    423423        p = strchr(incoming, ' ');
     
    433433        return (0);
    434434    }
    435     paranoid_free(incoming);
     435    mr_free(incoming);
    436436    return (1);
    437437}
     
    563563    fclose(fin);
    564564    log_it("Raidtab loaded successfully.");
    565     asprintf(&tmp1, "%d RAID devices in raidtab", raidlist->entries);
     565    mr_asprintf(&tmp1, "%d RAID devices in raidtab", raidlist->entries);
    566566    log_it(tmp1);
    567     paranoid_free(tmp1);
     567    mr_free(tmp1);
    568568    return (0);
    569569}
     
    700700        }
    701701        if (!disklist) {
    702             asprintf(&tmp,
     702            mr_asprintf(&tmp,
    703703                     "Ignoring '%s %s' pair of disk %s", labelB, valueB,
    704704                     label);
    705705            log_it(tmp);
    706             paranoid_free(tmp);
     706            mr_free(tmp);
    707707        } else {
    708708            index = atoi(valueB);
    709709            add_disk_to_raid_device(disklist, value, index);
    710710        }
    711         paranoid_free(labelB);
    712         paranoid_free(valueB);
     711        mr_free(labelB);
     712        mr_free(valueB);
    713713    } else {
    714714        v = raidrec->additional_vars.entries;
     
    773773    int lastpos = 0;
    774774
    775     getline(&line, &n, f);
     775    mr_getline(&line, &n, f);
    776776    if (feof(f)) {
    777777        log_it("[GNVCL] Uh... I reached the EOF.");
     
    933933
    934934  FILE   *fin;
    935   int    res = 0, row, i, index_min;
     935  int    row, i, index_min;
    936936  int lastpos = 0;
    937937  size_t len = 0;
     
    952952  row = 1;
    953953  // skip first output row - contains registered RAID levels
    954   res = getline(&string, &len, fin);
     954  mr_getline(&string, &len, fin);
    955955  // parse the rest
    956956  while ( !feof_unlocked(fin) ) {
    957     res = getline(&string, &len, fin);
    958     if (res <= 0) break;
     957    mr_getline(&string, &len, fin);
    959958    // trim leading spaces
    960959    pos = string;
    961960    while (*pos == ' ') pos++;
    962     asprintf(&strtmp, pos);
    963     paranoid_alloc(string,strtmp);
    964     paranoid_free(strtmp);
     961    mr_asprintf(&strtmp, pos);
     962    mr_allocstr(string,strtmp);
     963    mr_free(strtmp);
    965964    // if we have newline after only spaces, this is a blank line, update
    966965    // counters, otherwise do normal parsing
     
    981980    token = mr_strtok (string, delims, &lastpos);
    982981    // get RAID device name
    983     asprintf(&strtmp,"%s%s", device_prefix, token);
     982    mr_asprintf(&strtmp,"%s%s", device_prefix, token);
    984983    raidlist->el[raidlist->entries].raid_device = strtmp;
    985     paranoid_free(token);
     984    mr_free(token);
    986985    // skip ':' and status
    987986    token = mr_strtok (string, delims, &lastpos);
    988     paranoid_free(token);
     987    mr_free(token);
    989988    token = mr_strtok (string, delims, &lastpos);
    990989    if (!strcmp(token, "inactive")) {
    991990      log_msg(1, "RAID device '%s' inactive.\n",
    992991         raidlist->el[raidlist->entries].raid_device);
    993       paranoid_free(string);
    994       paranoid_free(token);
     992      mr_free(string);
     993      mr_free(token);
    995994      return 1;
    996995    }
    997     paranoid_free(token);
     996    mr_free(token);
    998997
    999998    // get RAID level
     
    10171016    } else {
    10181017      log_msg(1, "Unknown RAID level '%s'.\n", token);
    1019       paranoid_free(string);
    1020       paranoid_free(token);
     1018      mr_free(string);
     1019      mr_free(token);
    10211020      return 1;
    10221021    }
    1023     paranoid_free(token);
     1022    mr_free(token);
    10241023
    10251024    // get RAID devices (type, index, device)
     
    10391038      case ' ': // normal data disks
    10401039        raidlist->el[raidlist->entries].data_disks.el[raidlist->el[raidlist->entries].data_disks.entries].index = atoi(pos + 1);
    1041         asprintf(&strtmp,"%s%s", device_prefix, token);
     1040        mr_asprintf(&strtmp,"%s%s", device_prefix, token);
    10421041        strcpy(raidlist->el[raidlist->entries].data_disks.el[raidlist->el[raidlist->entries].data_disks.entries].device, strtmp);
    1043         paranoid_free(strtmp);
     1042        mr_free(strtmp);
    10441043        raidlist->el[raidlist->entries].data_disks.entries++;
    10451044        break;
    10461045      case 'S': // spare disks
    10471046        raidlist->el[raidlist->entries].spare_disks.el[raidlist->el[raidlist->entries].spare_disks.entries].index = atoi(pos + 1);
    1048         asprintf(&strtmp,"%s%s", device_prefix, token);
     1047        mr_asprintf(&strtmp,"%s%s", device_prefix, token);
    10491048        strcpy(raidlist->el[raidlist->entries].spare_disks.el[raidlist->el[raidlist->entries].spare_disks.entries].device, strtmp);
    1050         paranoid_free(strtmp);
     1049        mr_free(strtmp);
    10511050        raidlist->el[raidlist->entries].spare_disks.entries++;
    10521051        break;
    10531052      case 'F': // failed disks
    10541053        raidlist->el[raidlist->entries].failed_disks.el[raidlist->el[raidlist->entries].failed_disks.entries].index = atoi(pos + 1);
    1055         asprintf(&strtmp,"%s%s", device_prefix, token);
     1054        mr_asprintf(&strtmp,"%s%s", device_prefix, token);
    10561055        strcpy(raidlist->el[raidlist->entries].failed_disks.el[raidlist->el[raidlist->entries].failed_disks.entries].device, strtmp);
    1057         paranoid_free(strtmp);
     1056        mr_free(strtmp);
    10581057        raidlist->el[raidlist->entries].failed_disks.entries++;
    10591058        log_it("At least one failed disk found in RAID array.\n");
     
    10611060      default: // error
    10621061        log_msg(1, "Unknown device type '%c'\n", type);
    1063         paranoid_free(string);
    1064         paranoid_free(token);
     1062        mr_free(string);
     1063        mr_free(token);
    10651064        return 1;
    10661065        break;
    10671066      }
    1068       paranoid_free(token);
     1067      mr_free(token);
    10691068    }
    10701069
     
    11191118        if (pos < string) {
    11201119          log_it("String underflow!\n");
    1121           paranoid_free(string);
     1120          mr_free(string);
    11221121          return 1;
    11231122        }
     
    11441143        if (pos < string) {
    11451144          printf("ERROR: String underflow!\n");
    1146           paranoid_free(string);
     1145          mr_free(string);
    11471146          return 1;
    11481147        }
     
    11611160  fclose(fin);
    11621161  // free string
    1163   paranoid_free(string);
     1162  mr_free(string);
    11641163  // return success
    11651164  return 0;
  • trunk/mondo/src/common/libmondo-stream.c

    r783 r900  
    2222#include "libmondo-tools-EXT.h"
    2323#include "libmondo-fifo-EXT.h"
     24#include "mr_mem.h"
    2425
    2526#define EXTRA_TAPE_CHECKSUMS
     
    126127        eject_device(bkpinfo->media_device);
    127128    }
    128     paranoid_free(blk);
    129     paranoid_free(g_tapecatalog);
     129    mr_free(blk);
     130    mr_free((void *)g_tapecatalog);
    130131    return (retval);
    131132}
     
    180181               g_tapecatalog->el[i].tape_posK);
    181182    }
    182     paranoid_free(blk);
    183     paranoid_free(g_tapecatalog);
     183    mr_free(blk);
     184    mr_free((void *)g_tapecatalog);
    184185    return (retval);
    185186}
     
    192193    int res;
    193194
    194     asprintf(&command, "mt -f %s status", dev);
     195    mr_asprintf(&command, "mt -f %s status", dev);
    195196    res = run_program_and_log_output(command, 1);
    196     paranoid_free(command);
     197    mr_free(command);
    197198    if (res) {
    198199        return (FALSE);
     
    224225    tmp = find_home_of_exe("cdrecord");
    225226    if (tmp) {
    226         asprintf(&cdr_exe, "cdrecord");
    227     } else {
    228         asprintf(&cdr_exe, "dvdrecord");
    229     }
    230     paranoid_free(tmp);
    231 
    232     asprintf(&command, "%s -scanbus 2> /dev/null | grep -i tape | wc -l",
     227        mr_asprintf(&cdr_exe, "cdrecord");
     228    } else {
     229        mr_asprintf(&cdr_exe, "dvdrecord");
     230    }
     231    mr_free(tmp);
     232
     233    mr_asprintf(&command, "%s -scanbus 2> /dev/null | grep -i tape | wc -l",
    233234             cdr_exe);
    234235    tmp = call_program_and_get_last_line_of_output(command);
    235     paranoid_free(command);
     236    mr_free(command);
    236237
    237238    if (atoi(tmp) != 1) {
    238239        log_it
    239240            ("Either too few or too many tape streamers for me to detect...");
    240         asprintf(&dev, VANILLA_SCSI_TAPE"0");
    241         paranoid_free(tmp);
    242         paranoid_free(cdr_exe);
     241        mr_asprintf(&dev, VANILLA_SCSI_TAPE"0");
     242        mr_free(tmp);
     243        mr_free(cdr_exe);
    243244        return 1;
    244245    }
    245     paranoid_free(tmp);
    246 
    247     asprintf(&command,
     246    mr_free(tmp);
     247
     248    mr_asprintf(&command,
    248249             "%s -scanbus 2> /dev/null | tr -s '\t' ' ' | grep \"[0-9]*,[0-9]*,[0-9]*\" | grep -v \"[0-9]*) \\*\" | grep -i TAPE | cut -d' ' -f2 | head -n1",
    249250             cdr_exe);
    250251    tmp = call_program_and_get_last_line_of_output(command);
    251     paranoid_free(command);
     252    mr_free(command);
    252253    if (strlen(tmp) < 2) {
    253254        log_it("Could not find tape device");
    254         paranoid_free(tmp);
    255         paranoid_free(cdr_exe);
     255        mr_free(tmp);
     256        mr_free(cdr_exe);
    256257        return 1;
    257258    }
    258     paranoid_free(tmp);
    259 
    260     asprintf(&command,
     259    mr_free(tmp);
     260
     261    mr_asprintf(&command,
    261262             "%s -scanbus 2> /dev/null | tr -s '\t' ' ' | grep \"[0-9]*,[0-9]*,[0-9]*\" | grep -v \"[0-9]*) \\*\" | grep -i TAPE | cut -d' ' -f3 | cut -d')' -f1 | head -n1",
    262263             cdr_exe);
    263     paranoid_free(cdr_exe);
     264    mr_free(cdr_exe);
    264265
    265266    tmp = call_program_and_get_last_line_of_output(command);
    266     paranoid_free(command);
    267 
    268     asprintf(&dev, VANILLA_SCSI_TAPE"%s", tmp);
    269     paranoid_free(tmp);
     267    mr_free(command);
     268
     269    mr_asprintf(&dev, VANILLA_SCSI_TAPE"%s", tmp);
     270    mr_free(tmp);
    270271
    271272    if (!mt_says_tape_exists(dev)) {
    272         paranoid_free(dev);
    273 
    274         asprintf(&dev, ALT_TAPE"%s", tmp);
     273        mr_free(dev);
     274
     275        mr_asprintf(&dev, ALT_TAPE"%s", tmp);
    275276        if (!mt_says_tape_exists(dev)) {
    276277            log_it("Cannot openin %s", dev);
    277             paranoid_free(dev);
    278 
    279             asprintf(&dev, VANILLA_SCSI_TAPE"0");
     278            mr_free(dev);
     279
     280            mr_asprintf(&dev, VANILLA_SCSI_TAPE"0");
    280281            if (!mt_says_tape_exists(dev)) {
    281282                log_it("Cannot openin %s", dev);
    282                 paranoid_free(dev);
    283 
    284                 asprintf(&dev, "/dev/osst0");
     283                mr_free(dev);
     284
     285                mr_asprintf(&dev, "/dev/osst0");
    285286                if (!mt_says_tape_exists(dev)) {
    286287                    res++;
     
    303304    } else {
    304305        log_it("Turning %s", dev);
    305         paranoid_free(tmp);
    306         asprintf(&tmp1,
     306        mr_free(tmp);
     307        mr_asprintf(&tmp1,
    307308                 (strrchr(dev, '/') != NULL) ? strrchr(dev, '/') : dev);
    308         paranoid_free(dev);
    309         asprintf(&dev, "/dev/os%s", tmp1);
    310         paranoid_free(tmp1);
     309        mr_free(dev);
     310        mr_asprintf(&dev, "/dev/os%s", tmp1);
     311        mr_free(tmp1);
    311312
    312313        log_it("...into %s", dev);
     
    321322
    322323    if (res) {
    323         paranoid_free(tmp);
     324        mr_free(tmp);
    324325        return (res);
    325326    }
     
    327328    if (strlen(tmp) < 2) {
    328329        log_it("Warning - size of tape unknown");
    329         paranoid_free(tmp);
     330        mr_free(tmp);
    330331        return (0);
    331332    } else {
     
    352353        fatal_error("Wrong order, sunshine.");
    353354    }
    354     paranoid_free(fname);
     355    mr_free(fname);
    355356    fname = (char *)&res;
    356357    read_file_from_stream_to_file(bkpinfo, xattr_fname, *ptmp_size);
     
    364365        fatal_error("Wrong order, sunshine.");
    365366    }
    366     paranoid_free(fname);
     367    mr_free(fname);
    367368    fname = (char *)&res;
    368369    if (*pctrl_chr != BLK_START_EXAT_FILE) {
     
    425426    if (g_current_media_number != tapeno) {
    426427        //      log_it("g_current_media_number = %d", g_current_media_number);
    427         asprintf(&tmp,
     428        mr_asprintf(&tmp,
    428429                 _("When the tape drive goes quiet, please insert volume %d in this series."),
    429430                 tapeno);
    430431        popup_and_OK(tmp);
    431         paranoid_free(tmp);
     432        mr_free(tmp);
    432433        open_evalcall_form(_("Waiting while the tape drive settles"));
    433434    } else {
     
    482483
    483484    bufsize_K = (long long) (1024LL * (1 + g_tape_buffer_size_MB));
    484     asprintf(&tmpdir, "%s/tmpfs/backcatalog", td);
     485    mr_asprintf(&tmpdir, "%s/tmpfs/backcatalog", td);
    485486    if (strstr(latest_fname, ".afio.") || strstr(latest_fname, ".star.")) {
    486487        type = fileset;
     
    493494    }
    494495    mkdir(tmpdir, 0x700);
    495     asprintf(&command, "cp -f %s %s", latest_fname, tmpdir);
     496    mr_asprintf(&command, "cp -f %s %s", latest_fname, tmpdir);
    496497    if (run_program_and_log_output(command, 6)) {
    497498        log_it("Warning - failed to copy %s to backcatalog at %s",
    498499               latest_fname, tmpdir);
    499500    }
    500     paranoid_free(command);
     501    mr_free(command);
    501502
    502503    last = g_tapecatalog->entries - 1;
     
    522523
    523524    for (i = curr - 1; i >= 0 && curr - i < 10; i--) {
    524         asprintf(&old_fname, "%s/%s", tmpdir, g_tapecatalog->el[i].fname);
     525        mr_asprintf(&old_fname, "%s/%s", tmpdir, g_tapecatalog->el[i].fname);
    525526        unlink(old_fname);
    526         paranoid_free(old_fname);
    527     }
    528     paranoid_free(tmpdir);
     527        mr_free(old_fname);
     528    }
     529    mr_free(tmpdir);
    529530    return (0);
    530531}
     
    554555        return (0);
    555556    }
    556     asprintf(&tmp, "mt -f %s setblk %ld", tapedev,
     557    mr_asprintf(&tmp, "mt -f %s setblk %ld", tapedev,
    557558             internal_tape_block_size);
    558559    res = run_program_and_log_output(tmp, 3);
    559     paranoid_free(tmp);
     560    mr_free(tmp);
    560561    return (res);
    561562}
     
    605606    }
    606607    insist_on_this_tape_number(1);
    607     asprintf(&outfname, "%s/tmp/all.tar.gz", bkpinfo->tmpdir);
     608    mr_asprintf(&outfname, "%s/tmp/all.tar.gz", bkpinfo->tmpdir);
    608609    make_hole_for_file(outfname);
    609610
     
    649650    }
    650651    paranoid_fclose(fout);
    651     paranoid_free(datablock);
     652    mr_free(datablock);
    652653    /* find initial blocks */
    653654    res = read_header_block_from_stream(&size, NULL, &ctrl_chr);
     
    665666    (void) getcwd(old_cwd, MAX_STR_LEN);
    666667    chdir(bkpinfo->tmpdir);
    667     asprintf(&tmp, "tar -zxf %s tmp/mondo-restore.cfg 2> /dev/null",
     668    mr_asprintf(&tmp, "tar -zxf %s tmp/mondo-restore.cfg 2> /dev/null",
    668669             outfname);
    669670    paranoid_system(tmp);
    670     paranoid_free(tmp);
     671    mr_free(tmp);
    671672    paranoid_system("cp -f tmp/mondo-restore.cfg . 2> /dev/null");
    672673    chdir(old_cwd);
    673674    unlink(outfname);
    674     paranoid_free(outfname);
     675    mr_free(outfname);
    675676    return (retval);
    676677}
     
    692693
    693694    /*  add 'dummy' if testing */
    694     asprintf(&command,
     695    mr_asprintf(&command,
    695696             "cdrecord -eject dev=%s speed=%d fs=24m -waiti - >> %s 2>> %s",
    696697             cddev, speed, MONDO_LOGFILE, MONDO_LOGFILE);
     
    706707    /*  log_it("Let's see what happens, shall we?"); */
    707708    g_tape_stream = popen(command, "w");
    708     paranoid_free(command);
     709    mr_free(command);
    709710    if (g_tape_stream) {
    710711        return (0);
     
    852853    res = read_header_block_from_stream(&temp_size, temp_fname, &ctrl_chr);
    853854    if (orig_size != temp_size && orig_size != -1) {
    854         asprintf(&tmp,
     855        mr_asprintf(&tmp,
    855856                 "output file's size should be %ld K but is apparently %ld K",
    856857                 (long) size >> 10, (long) temp_size >> 10);
    857858        log_to_screen(tmp);
    858         paranoid_free(tmp);
     859        mr_free(tmp);
    859860    }
    860861    if (ctrl_chr != BLK_START_FILE) {
     
    862863        return (1);
    863864    }
    864     asprintf(&tmp, "Reading file from tape; writing to '%s'; %ld KB",
     865    mr_asprintf(&tmp, "Reading file from tape; writing to '%s'; %ld KB",
    865866             outfname, (long) size >> 10);
    866867    log_to_screen(tmp);
    867     paranoid_free(tmp);
     868    mr_free(tmp);
    868869
    869870    if (foutstream) {
     
    921922    log_msg(6, ".......................... Should be %lld", orig_size);
    922923    g_tape_posK += total_read_from_tape_for_this_file / 1024;
    923     asprintf(&actual_cksum, "%04x%04x", crc16, crctt);
     924    mr_asprintf(&actual_cksum, "%04x%04x", crc16, crctt);
    924925    if (foutstream) {           /*log_it("Finished writing to foutstream"); */
    925926    } else {
     
    932933    }
    933934    if (strcmp(temp_cksum, actual_cksum)) {
    934         asprintf(&tmp, _("actual cksum=%s; recorded cksum=%s"), actual_cksum,
     935        mr_asprintf(&tmp, _("actual cksum=%s; recorded cksum=%s"), actual_cksum,
    935936                 temp_cksum);
    936937        log_to_screen(tmp);
    937         paranoid_free(tmp);
    938 
    939         asprintf(&tmp, _("%s (%ld K) is corrupt on tape"), temp_fname,
     938        mr_free(tmp);
     939
     940        mr_asprintf(&tmp, _("%s (%ld K) is corrupt on tape"), temp_fname,
    940941                 (long) orig_size >> 10);
    941942        log_to_screen(tmp);
    942         paranoid_free(tmp);
     943        mr_free(tmp);
    943944        retval++;
    944945    }
    945     paranoid_free(actual_cksum);
    946     paranoid_free(datablock);
    947     paranoid_free(temp_fname);
    948     paranoid_free(temp_cksum);
     946    mr_free(actual_cksum);
     947    mr_free(datablock);
     948    mr_free(temp_fname);
     949    mr_free(temp_cksum);
    949950    return (retval);
    950951}
     
    992993     * something (allocate) */
    993994    if (filename != NULL) {
    994         asprintf(&filename, tempblock + 1000);
     995        mr_asprintf(&filename, tempblock + 1000);
    995996    }
    996997    if (*pcontrol_char == BLK_ABORTED_BACKUP) {
     
    10091010            marker_to_string(*pcontrol_char), tempblock + 1000,
    10101011            (long) (*plen) >> 10);
    1011     paranoid_free(tempblock);
     1012    mr_free(tempblock);
    10121013    return (retval);
    10131014}
     
    11331134        wrong_marker(BLK_START_AN_AFIO_OR_SLICE, ctrl_chr);
    11341135        log_msg(3, "Still trying to re-sync w/ tape");
    1135         paranoid_free(temp_fname);
     1136        mr_free(temp_fname);
    11361137        temp_fname = (char *)&res;
    11371138    }
     
    11481149        /* Do not desallocate when the while condition is met */
    11491150        if (ctrl_chr != BLK_START_FILE) {
    1150             paranoid_free(temp_fname);
     1151            mr_free(temp_fname);
    11511152            temp_fname = (char *)&res;
    11521153        }
     
    11741175        }
    11751176
    1176         paranoid_free(temp_fname);
     1177        mr_free(temp_fname);
    11771178        temp_fname = (char *)&res;
    11781179        res = read_header_block_from_stream(&temp_size, NULL, &ctrl_chr);
     
    12111212    log_msg(2, "Reading %s (it matches %s)", temp_fname,
    12121213            the_file_I_was_reading);
    1213     paranoid_free(temp_fname);
    1214     paranoid_free(datablock);
     1214    mr_free(temp_fname);
     1215    mr_free(datablock);
    12151216    return (0);
    12161217}
     
    12811282    }
    12821283    if (bkpinfo->backup_media_type == cdstream) {
    1283         asprintf(&command,
     1284        mr_asprintf(&command,
    12841285                 "cdrecord -eject dev=%s speed=%d fs=24m -waiti - >> %s 2>> %s",
    12851286                 bkpinfo->media_device, bkpinfo->cdrw_speed, MONDO_LOGFILE,
     
    12891290        log_it("Let's see what happens, shall we?");
    12901291        g_tape_stream = popen(command, "w");
    1291         paranoid_free(command);
     1292        mr_free(command);
    12921293        if (!g_tape_stream) {
    12931294            log_to_screen(_("Failed to openout to cdstream (fifo)"));
     
    13321333    last = g_tapecatalog->entries - 1;
    13331334    for (i = 0; i <= last; i++) {
    1334         asprintf(&fname, "%s/tmpfs/backcatalog/%s", bkpinfo->tmpdir,
     1335        mr_asprintf(&fname, "%s/tmpfs/backcatalog/%s", bkpinfo->tmpdir,
    13351336                 g_tapecatalog->el[i].fname);
    13361337        if (!does_file_exist(fname)) {
     
    13511352            }
    13521353        }
    1353         paranoid_free(fname);
     1354        mr_free(fname);
    13541355    }
    13551356    log_msg(2, "Finished writing back catalog to tape");
     
    13851386    log_it("Data disks = %s", fname);
    13861387    if (!does_file_exist(fname)) {
    1387         asprintf(&tmp, _("Cannot find %s"), fname);
     1388        mr_asprintf(&tmp, _("Cannot find %s"), fname);
    13881389        log_to_screen(tmp);
    1389         paranoid_free(tmp);
     1390        mr_free(tmp);
    13901391        return (1);
    13911392    }
     
    14791480        p++;
    14801481    }
    1481     asprintf(&tmp, "Writing file '%s' to tape (%ld KB)", p,
     1482    mr_asprintf(&tmp, "Writing file '%s' to tape (%ld KB)", p,
    14821483             (long) filesize >> 10);
    14831484    log_it(tmp);
    1484     paranoid_free(tmp);
     1485    mr_free(tmp);
    14851486
    14861487    write_header_block_to_stream(filesize, infile_basename,
     
    15221523    }
    15231524    paranoid_fclose(fin);
    1524     asprintf(&checksum, "%04x%04x", crc16, crctt);
     1525    mr_asprintf(&checksum, "%04x%04x", crc16, crctt);
    15251526    /* BERLIOS: what does it do ??? */
    15261527    write_header_block_to_stream((off_t)g_current_media_number, checksum,
    15271528                                 BLK_STOP_FILE);
    1528     paranoid_free(checksum);
     1529    mr_free(checksum);
    15291530//  log_it("File '%s' written to tape.", infile);
    15301531    return (retval);
     
    15821583        fwrite(tempblock, 1, (size_t) TAPE_BLOCK_SIZE,
    15831584               g_tape_stream) / 1024;
    1584     asprintf(&tmp, "%s (fname=%s, size=%ld K)",
     1585    mr_asprintf(&tmp, "%s (fname=%s, size=%ld K)",
    15851586             marker_to_string(control_char), p,
    15861587             (long) length_of_incoming_file >> 10);
    15871588    log_msg(6, tmp);
    1588     paranoid_free(tmp);
     1589    mr_free(tmp);
    15891590    return (0);
    15901591}
     
    16031604
    16041605    /*@ end vars *************************************************** */
    1605     asprintf(&tmp, _("Wrong marker! (Should be %s, is actually %s)"),
     1606    mr_asprintf(&tmp, _("Wrong marker! (Should be %s, is actually %s)"),
    16061607             marker_to_string(should_be), marker_to_string(it_is));
    16071608    log_to_screen(tmp);
    1608     paranoid_free(tmp);
     1609    mr_free(tmp);
    16091610}
    16101611
  • trunk/mondo/src/common/libmondo-string.c

    r863 r900  
    1515#include "libmondo-tools-EXT.h"
    1616#include <math.h>
     17#include "mr_mem.h"
    1718
    1819/*@unused@*/
     
    4243    assert(partno >= 0);
    4344
    44     asprintf(&partition, "%s", drive);
     45    mr_asprintf(&partition, "%s", drive);
    4546    p = partition;
    4647    /* is this a devfs device path? */
     
    5556            p = partition;
    5657#ifdef BSD
    57             asprintf(&partition, "%ss", p);
     58            mr_asprintf(&partition, "%ss", p);
    5859#else
    5960            /* format /dev/cciss/c0d0 */
    60             asprintf(&partition, "%sp", p);
     61            mr_asprintf(&partition, "%sp", p);
    6162#endif
    62             paranoid_free(p);
     63            mr_free(p);
    6364        }
    6465    }
    6566    p = partition;
    66     asprintf(&partition, "%s%d", p, partno);
    67     paranoid_free(p);
     67    mr_asprintf(&partition, "%s%d", p, partno);
     68    mr_free(p);
    6869    return (partition);
    6970}
     
    9293    }
    9394    for (p = in_out; *p == ' '; p++);
    94     asprintf(&scratch, p);
     95    mr_asprintf(&scratch, p);
    9596    strip_spaces (scratch);
    9697    len = (int) strlen(scratch);
     
    101102    }
    102103    in_out[i] = '\0';
    103     asprintf(&out, "%s%s", in_out, scratch);
    104     paranoid_free(scratch);
     104    mr_asprintf(&out, "%s%s", in_out, scratch);
     105    mr_free(scratch);
    105106    in_out = out;
    106107    for (i = x + len ; i < width - 1; i++) {
     
    120121    bool end = FALSE;
    121122
    122     asprintf(&sav, sin);
     123    mr_asprintf(&sav, sin);
    123124    p = sav;
    124125    while ((*p != '\0') && (! end)) {
     
    129130                                    // build the new string by recursion
    130131            turn_wildcard_chars_into_literal_chars(q,p);
    131             asprintf(&sout, "%s\\%c%s", sav, r, q);
    132             paranoid_free(q);
    133             paranoid_free(sav);
     132            mr_asprintf(&sout, "%s\\%c%s", sav, r, q);
     133            mr_free(q);
     134            mr_free(sav);
    134135            end = TRUE;
    135136        }
     
    160161    assert(disklist != NULL);
    161162
    162     asprintf(&output, "%-24s %8d", disklist->el[lino].device,
     163    mr_asprintf(&output, "%-24s %8d", disklist->el[lino].device,
    163164             disklist->el[lino].index);
    164165    return (output);
     
    188189        fatal_error("Please use integers only. No decimal points.");
    189190    }
    190     asprintf(&tmp, "%s", incoming);
     191    mr_asprintf(&tmp, "%s", incoming);
    191192    i = (int) strlen(tmp);
    192193    if (tmp[i - 1] == 'B' || tmp[i - 1] == 'b') {
     
    197198    tmp[i] = '\0';
    198199    outval = atol(tmp);
    199     paranoid_free(tmp);
     200    mr_free(tmp);
    200201
    201202    if (ch == 'g' || ch == 'G') {
     
    214215        fatal_error("Integer overflow.");
    215216    } else if (ch != 'm' && ch != 'M') {
    216         asprintf(&tmp, "Re: parameter '%s' - bad multiplier ('%c')",
     217        mr_asprintf(&tmp, "Re: parameter '%s' - bad multiplier ('%c')",
    217218                 incoming, ch);
    218219        fatal_error(tmp);
     
    240241    assert(width > 2);
    241242
    242     asprintf(&output, "%s", incoming);
     243    mr_asprintf(&output, "%s", incoming);
    243244    for (i = (int) strlen(output); i < width; i++) {
    244245        output[i] = ' ';
     
    268269    switch (marker) {
    269270    case BLK_START_OF_BACKUP:
    270         asprintf(&outstr, "%s", "BLK_START_OF_BACKUP");
     271        mr_asprintf(&outstr, "%s", "BLK_START_OF_BACKUP");
    271272        break;
    272273    case BLK_START_OF_TAPE:
    273         asprintf(&outstr, "%s", "BLK_START_OF_TAPE");
     274        mr_asprintf(&outstr, "%s", "BLK_START_OF_TAPE");
    274275        break;
    275276    case BLK_START_AN_AFIO_OR_SLICE:
    276         asprintf(&outstr, "%s", "BLK_START_AN_AFIO_OR_SLICE");
     277        mr_asprintf(&outstr, "%s", "BLK_START_AN_AFIO_OR_SLICE");
    277278        break;
    278279    case BLK_STOP_AN_AFIO_OR_SLICE:
    279         asprintf(&outstr, "%s", "BLK_STOP_AN_AFIO_OR_SLICE");
     280        mr_asprintf(&outstr, "%s", "BLK_STOP_AN_AFIO_OR_SLICE");
    280281        break;
    281282    case BLK_START_AFIOBALLS:
    282         asprintf(&outstr, "%s", "BLK_START_AFIOBALLS");
     283        mr_asprintf(&outstr, "%s", "BLK_START_AFIOBALLS");
    283284        break;
    284285    case BLK_STOP_AFIOBALLS:
    285         asprintf(&outstr, "%s", "BLK_STOP_AFIOBALLS");
     286        mr_asprintf(&outstr, "%s", "BLK_STOP_AFIOBALLS");
    286287        break;
    287288    case BLK_STOP_BIGGIEFILES:
    288         asprintf(&outstr, "%s", "BLK_STOP_BIGGIEFILES");
     289        mr_asprintf(&outstr, "%s", "BLK_STOP_BIGGIEFILES");
    289290        break;
    290291    case BLK_START_A_NORMBIGGIE:
    291         asprintf(&outstr, "%s", "BLK_START_A_NORMBIGGIE");
     292        mr_asprintf(&outstr, "%s", "BLK_START_A_NORMBIGGIE");
    292293        break;
    293294    case BLK_START_A_PIHBIGGIE:
    294         asprintf(&outstr, "%s", "BLK_START_A_PIHBIGGIE");
     295        mr_asprintf(&outstr, "%s", "BLK_START_A_PIHBIGGIE");
    295296        break;
    296297    case BLK_START_EXTENDED_ATTRIBUTES:
    297         asprintf(&outstr, "%s", "BLK_START_EXTENDED_ATTRIBUTES");
     298        mr_asprintf(&outstr, "%s", "BLK_START_EXTENDED_ATTRIBUTES");
    298299        break;
    299300    case BLK_STOP_EXTENDED_ATTRIBUTES:
    300         asprintf(&outstr, "%s", "BLK_STOP_EXTENDED_ATTRIBUTES");
     301        mr_asprintf(&outstr, "%s", "BLK_STOP_EXTENDED_ATTRIBUTES");
    301302        break;
    302303    case BLK_START_EXAT_FILE:
    303         asprintf(&outstr, "%s", "BLK_START_EXAT_FILE");
     304        mr_asprintf(&outstr, "%s", "BLK_START_EXAT_FILE");
    304305        break;
    305306    case BLK_STOP_EXAT_FILE:
    306         asprintf(&outstr, "%s", "BLK_STOP_EXAT_FILE");
     307        mr_asprintf(&outstr, "%s", "BLK_STOP_EXAT_FILE");
    307308        break;
    308309    case BLK_START_BIGGIEFILES:
    309         asprintf(&outstr, "%s", "BLK_START_BIGGIEFILES");
     310        mr_asprintf(&outstr, "%s", "BLK_START_BIGGIEFILES");
    310311        break;
    311312    case BLK_STOP_A_BIGGIE:
    312         asprintf(&outstr, "%s", "BLK_STOP_A_BIGGIE");
     313        mr_asprintf(&outstr, "%s", "BLK_STOP_A_BIGGIE");
    313314        break;
    314315    case BLK_END_OF_TAPE:
    315         asprintf(&outstr, "%s", "BLK_END_OF_TAPE");
     316        mr_asprintf(&outstr, "%s", "BLK_END_OF_TAPE");
    316317        break;
    317318    case BLK_END_OF_BACKUP:
    318         asprintf(&outstr, "%s", "BLK_END_OF_BACKUP");
     319        mr_asprintf(&outstr, "%s", "BLK_END_OF_BACKUP");
    319320        break;
    320321    case BLK_ABORTED_BACKUP:
    321         asprintf(&outstr, "%s", "BLK_ABORTED_BACKUP");
     322        mr_asprintf(&outstr, "%s", "BLK_ABORTED_BACKUP");
    322323        break;
    323324    case BLK_START_FILE:
    324         asprintf(&outstr, "%s", "BLK_START_FILE");
     325        mr_asprintf(&outstr, "%s", "BLK_START_FILE");
    325326        break;
    326327    case BLK_STOP_FILE:
    327         asprintf(&outstr, "%s", "BLK_STOP_FILE");
     328        mr_asprintf(&outstr, "%s", "BLK_STOP_FILE");
    328329        break;
    329330    default:
    330         asprintf(&outstr, "%s (%d)", "BLK_UNKNOWN", marker);
     331        mr_asprintf(&outstr, "%s (%d)", "BLK_UNKNOWN", marker);
    331332        break;
    332333    }
     
    355356    assert(mountlist != NULL);
    356357
    357     asprintf(&output, "%-24s %-24s %-10s %8lld",
     358    mr_asprintf(&output, "%-24s %-24s %-10s %8lld",
    358359             mountlist->el[lino].device, mountlist->el[lino].mountpoint,
    359360             mountlist->el[lino].format, mountlist->el[lino].size / 1024);
     
    386387        p = ' ';
    387388    }
    388     asprintf(&output, "%d %s disk%c    ", noof_disks, label, p);
     389    mr_asprintf(&output, "%d %s disk%c    ", noof_disks, label, p);
    389390    /* BERLIOS: replaced with space^^^^ here !
    390391       while (strlen(output) < 14) {
     
    413414    switch (i) {
    414415    case 0:
    415         asprintf(&output, "%s", "zero");
     416        mr_asprintf(&output, "%s", "zero");
    416417        break;
    417418    case 1:
    418         asprintf(&output, "%s", "one");
     419        mr_asprintf(&output, "%s", "one");
    419420        break;
    420421    case 2:
    421         asprintf(&output, "%s", "two");
     422        mr_asprintf(&output, "%s", "two");
    422423        break;
    423424    case 3:
    424         asprintf(&output, "%s", "three");
     425        mr_asprintf(&output, "%s", "three");
    425426        break;
    426427    case 4:
    427         asprintf(&output, "%s", "four");
     428        mr_asprintf(&output, "%s", "four");
    428429        break;
    429430    case 5:
    430         asprintf(&output, "%s", "five");
     431        mr_asprintf(&output, "%s", "five");
    431432        break;
    432433    case 6:
    433         asprintf(&output, "%s", "six");
     434        mr_asprintf(&output, "%s", "six");
    434435        break;
    435436    case 7:
    436         asprintf(&output, "%s", "seven");
     437        mr_asprintf(&output, "%s", "seven");
    437438        break;
    438439    case 8:
    439         asprintf(&output, "%s", "eight");
     440        mr_asprintf(&output, "%s", "eight");
    440441        break;
    441442    case 9:
    442         asprintf(&output, "%s", "nine");
     443        mr_asprintf(&output, "%s", "nine");
    443444    case 10:
    444         asprintf(&output, "%s", "ten");
     445        mr_asprintf(&output, "%s", "ten");
    445446    default:
    446         asprintf(&output, "%d", i);
     447        mr_asprintf(&output, "%d", i);
    447448    }
    448449    return (output);
     
    470471
    471472    strcpy(output, ip);         /* just in case the token doesn't appear in string at all */
    472     asprintf(&input, "%s", ip);
     473    mr_asprintf(&input, "%s", ip);
    473474    while (strstr(input, token)) {
    474475        strcpy(output, input);
     
    478479        p = strstr(input, token) + strlen(token);
    479480        strcat(output, p);
    480         paranoid_free(input);
    481         asprintf(&input, "%s", output);
    482     }
    483     paranoid_free(input);
     481        mr_free(input);
     482        mr_asprintf(&input, "%s", output);
     483    }
     484    mr_free(input);
    484485}
    485486
     
    512513
    513514    if (s != NULL) {
    514         asprintf(&suffix, ".%s", s);
     515        mr_asprintf(&suffix, ".%s", s);
    515516    } else {
    516         asprintf(&suffix, "%s", "");
    517     }
    518     asprintf(&output, "%s/slice-%07ld.%05ld.dat%s", path, bigfileno,
     517        mr_asprintf(&suffix, "%s", "");
     518    }
     519    mr_asprintf(&output, "%s/slice-%07ld.%05ld.dat%s", path, bigfileno,
    519520             sliceno, suffix);
    520     paranoid_free(suffix);
     521    mr_free(suffix);
    521522    return (output);
    522523}
     
    578579    }
    579580    if (strlen(flaws_str) > 0) {
    580         asprintf(&flaws_str_A, "%s", flaws_str + 1);
     581        mr_asprintf(&flaws_str_A, "%s", flaws_str + 1);
    581582    }
    582583    if (strlen(flaws_str_A) >= 74) {
    583584        for (i = 74; flaws_str_A[i] != ' '; i--);
    584         asprintf(&flaws_str_B, "%s", flaws_str_A + i + 1);
     585        mr_asprintf(&flaws_str_B, "%s", flaws_str_A + i + 1);
    585586        flaws_str_A[i] = '\0';
    586587    }
    587588    if (strlen(flaws_str_B) >= 74) {
    588589        for (i = 74; flaws_str_B[i] != ' '; i--);
    589         asprintf(&flaws_str_C, "%s", flaws_str_B + i + 1);
     590        mr_asprintf(&flaws_str_C, "%s", flaws_str_B + i + 1);
    590591        flaws_str_B[i] = '\0';
    591592    }
     
    669670
    670671    assert(input != NULL);
    671     asprintf(&output, "%s", input);
     672    mr_asprintf(&output, "%s", input);
    672673    p = strchr(input, '\"');
    673674    if (p) {
    674675        q = strchr(++p, '\"');
    675676        if (q) {
    676             paranoid_free(output);
    677             asprintf(&output, "%s", p);
     677            mr_free(output);
     678            mr_asprintf(&output, "%s", p);
    678679            *(strchr(output, '\"')) = '\0';
    679680        }
     
    706707    original_incoming_length = (int) strlen(in_out);
    707708    for (i = 0; in_out[i] <= ' ' && i < (int) strlen(in_out); i++);
    708     asprintf(&tmp, "%s", in_out + i);
     709    mr_asprintf(&tmp, "%s", in_out + i);
    709710    for (i = (int) strlen(tmp); i > 0 && tmp[i - 1] <= 32; i--);
    710711    tmp[i] = '\0';
     
    724725                in_out[i++] = ' ';
    725726            } else if (in_out[i] == '\r') {
    726                 asprintf(&tmp1, "%s", in_out + i);
     727                mr_asprintf(&tmp1, "%s", in_out + i);
    727728                strcpy(in_out, tmp1);
    728                 paranoid_free(tmp1);
     729                mr_free(tmp1);
    729730                i = -1;
    730731                continue;
     
    741742    }
    742743    in_out[i] = '\0';
    743     paranoid_free(tmp);
     744    mr_free(tmp);
    744745}
    745746
     
    760761
    761762    if (incoming[0] == '\"' && incoming[strlen(incoming) - 1] == '\"') {
    762         asprintf(&outgoing, "%s", incoming + 1);
     763        mr_asprintf(&outgoing, "%s", incoming + 1);
    763764        outgoing[strlen(outgoing) - 1] = '\0';
    764765    } else {
    765         asprintf(&outgoing, incoming);
     766        mr_asprintf(&outgoing, incoming);
    766767    }
    767768    return (outgoing);
     
    831832
    832833    if (raid_level >= 0) {
    833         asprintf(&output, " RAID %-2d ", raid_level);
     834        mr_asprintf(&output, " RAID %-2d ", raid_level);
    834835    } else {
    835         asprintf(&output, "Linear RAID");
     836        mr_asprintf(&output, "Linear RAID");
    836837    }
    837838    return (output);
     
    855856    assert_string_is_neither_NULL_nor_zerolength(fn);
    856857    if (!strncmp(fn, MNT_RESTORING, strlen(MNT_RESTORING))) {
    857         asprintf(&filename, "%s", fn + strlen(MNT_RESTORING));
     858        mr_asprintf(&filename, "%s", fn + strlen(MNT_RESTORING));
    858859    } else if (fn[0] != '/') {
    859         asprintf(&filename, "/%s", fn);
     860        mr_asprintf(&filename, "/%s", fn);
    860861    } else {
    861         asprintf(&filename, "%s", fn);
     862        mr_asprintf(&filename, "%s", fn);
    862863    }
    863864
    864865    if (!strncmp(filename, "/var/", 5)) {
    865866        sev = 2;
    866         asprintf(&reason,
     867        mr_asprintf(&reason,
    867868                 _("/var's contents will change regularly, inevitably."));
    868869    }
    869870    if (!strncmp(filename, "/home", 5)) {
    870871        sev = 2;
    871         asprintf(&reason,
     872        mr_asprintf(&reason,
    872873                 _("It's in your /home partiton. Therefore, it is important."));
    873874    }
    874875    if (!strncmp(filename, "/usr/", 5)) {
    875876        sev = 3;
    876         asprintf(&reason,
     877        mr_asprintf(&reason,
    877878                 _("You may have installed/removed software during the backup."));
    878879    }
    879880    if (!strncmp(filename, "/etc/", 5)) {
    880881        sev = 3;
    881         asprintf(&reason,
     882        mr_asprintf(&reason,
    882883                 _("Do not edit config files while backing up your PC."));
    883884    }
     
    885886        || !strcmp(filename, "/etc/mtab")) {
    886887        sev = 1;
    887         asprintf(&reason, _("This file changes all the time. It's OK."));
     888        mr_asprintf(&reason, _("This file changes all the time. It's OK."));
    888889    }
    889890    if (!strncmp(filename, "/root/", 6)) {
    890891        sev = 3;
    891         asprintf(&reason,
     892        mr_asprintf(&reason,
    892893                 _("Were you compiling/editing something in /root?"));
    893894    }
    894895    if (!strncmp(filename, "/root/.", 7)) {
    895896        sev = 2;
    896         asprintf(&reason, _("Temp or 'dot' files changed in /root."));
     897        mr_asprintf(&reason, _("Temp or 'dot' files changed in /root."));
    897898    }
    898899    if (!strncmp(filename, "/var/lib/", 9)) {
    899900        sev = 2;
    900         asprintf(&reason, _("Did you add/remove software during backing?"));
     901        mr_asprintf(&reason, _("Did you add/remove software during backing?"));
    901902    }
    902903    if (!strncmp(filename, "/var/lib/rpm", 12)) {
    903904        sev = 3;
    904         asprintf(&reason, _("Did you add/remove software during backing?"));
     905        mr_asprintf(&reason, _("Did you add/remove software during backing?"));
    905906    }
    906907    if (!strncmp(filename, "/var/lib/slocate", 16)) {
    907908        sev = 1;
    908         asprintf(&reason,
     909        mr_asprintf(&reason,
    909910                 _("The 'update' daemon ran during backup. This does not affect the integrity of your backup."));
    910911    }
     
    913914        || !strcmp(filename + strlen(filename) - 4, ".log")) {
    914915        sev = 1;
    915         asprintf(&reason,
     916        mr_asprintf(&reason,
    916917                 _("Log files change frequently as the computer runs. Fret not."));
    917918    }
    918919    if (!strncmp(filename, "/var/spool", 10)) {
    919920        sev = 1;
    920         asprintf(&reason,
     921        mr_asprintf(&reason,
    921922                 _("Background processes or printers were active. This does not affect the integrity of your backup."));
    922923    }
    923924    if (!strncmp(filename, "/var/spool/mail", 10)) {
    924925        sev = 2;
    925         asprintf(&reason, _("Mail was sent/received during backup."));
     926        mr_asprintf(&reason, _("Mail was sent/received during backup."));
    926927    }
    927928    if (filename[strlen(filename) - 1] == '~') {
    928929        sev = 1;
    929         asprintf(&reason,
     930        mr_asprintf(&reason,
    930931                 _("Backup copy of another file which was modified recently."));
    931932    }
    932933    if (strstr(filename, "cache")) {
    933934        sev = 1;
    934         asprintf(&reason,
     935        mr_asprintf(&reason,
    935936                 _("Part of a cache of data. Caches change from time to time. Don't worry."));
    936937    }
     
    940941        || strstr(filename, "/.Xauthority")) {
    941942        sev = 1;
    942         asprintf(&reason,
     943        mr_asprintf(&reason,
    943944                 "Temporary file (a lockfile, perhaps) used by software such as X or KDE to register its presence.");
    944945    }
    945     paranoid_free(filename);
     946    mr_free(filename);
    946947
    947948    if (sev == 0) {
    948949        sev = 3;
    949         asprintf(&reason,
     950        mr_asprintf(&reason,
    950951                 _("Changed since backup. Consider running a differential backup in a day or two."));
    951952    }
     
    10051006
    10061007    if (bkpinfo->media_size[g_current_media_number] <= 0) {
    1007         asprintf(&outstr, _("Volume %d: %'lld kilobytes archived so far"),
     1008        mr_asprintf(&outstr, _("Volume %d: %'lld kilobytes archived so far"),
    10081009                 g_current_media_number, g_tape_posK);
    10091010
     
    10161017            (int) (g_tape_posK / 10 /
    10171018                   bkpinfo->media_size[g_current_media_number]);
    1018         asprintf(&prepstr, _("Volume %d: ["), g_current_media_number);
     1019        mr_asprintf(&prepstr, _("Volume %d: ["), g_current_media_number);
    10191020    } else {
    10201021        percentage =
    10211022            (int) (space_occupied_by_cd(bkpinfo->scratchdir) * 100 / 1024 /
    10221023                   bkpinfo->media_size[g_current_media_number]);
    1023         asprintf(&prepstr, "%s %d: [",
     1024        mr_asprintf(&prepstr, "%s %d: [",
    10241025                 bkpinfo->backup_media_string,
    10251026                 g_current_media_number);
     
    10461047    /*
    10471048       log_it("percentage: %d", percentage);
    1048        asprintf(&outstr, "%s%s%s] %3d%% used", prepstr, tmp1, tmp2, percentage);
     1049       mr_asprintf(&outstr, "%s%s%s] %3d%% used", prepstr, tmp1, tmp2, percentage);
    10491050     */
    1050     asprintf(&outstr, _("%s%s%s] %3d percent used"), prepstr, tmp1, tmp2,
     1051    mr_asprintf(&outstr, _("%s%s%s] %3d percent used"), prepstr, tmp1, tmp2,
    10511052             percentage);
    1052     paranoid_free(prepstr);
    1053     paranoid_free(tmp1);
    1054     paranoid_free(tmp2);
     1053    mr_free(prepstr);
     1054    mr_free(tmp1);
     1055    mr_free(tmp2);
    10551056    return (outstr);
    10561057}
  • trunk/mondo/src/common/libmondo-tools.c

    r783 r900  
    2121#include <arpa/inet.h>
    2222#endif
     23#include "mr_mem.h"
    2324
    2425/*@unused@*/
     
    169170    char *tmp;
    170171
    171     asprintf(&tmp,
     172    mr_asprintf(&tmp,
    172173             "for i in `find /root /home -type d -name Desktop -maxdepth 2`; do \
    173174file=$i/.directory; if [ -f \"$file\" ] ; then mv -f $file $file.old ; \
     
    175176else { print $0;};}' $file.old  > $file ; fi ; done");
    176177    run_program_and_log_output(tmp, 5);
    177     paranoid_free(tmp);
     178    mr_free(tmp);
    178179}
    179180
     
    190191    char *home_sz = NULL;
    191192
    192     asprintf(&home_sz, MONDO_SHARE);
     193    mr_asprintf(&home_sz, MONDO_SHARE);
    193194    return (home_sz);
    194195}
     
    369370    if (bkpinfo->backup_media_type == tape) {
    370371        log_msg(1, "Bar");
    371         asprintf(&tmp, "mt -f %s status", bkpinfo->media_device);
     372        mr_asprintf(&tmp, "mt -f %s status", bkpinfo->media_device);
    372373        log_msg(1, "tmp = '%s'", tmp);
    373374        if (run_program_and_log_output(tmp, 3)) {
     
    375376                ("Unable to open tape device. If you haven't specified it with -d, do so. If you already have, check your parameter. I think it's wrong.");
    376377        }
    377         paranoid_free(tmp);
     378        mr_free(tmp);
    378379    }
    379380    make_hole_for_dir(bkpinfo->scratchdir);
     
    385386    run_program_and_log_output("cat /etc/*-release", 5);
    386387    run_program_and_log_output("cat /etc/*issue*", 5);
    387     asprintf(&g_tmpfs_mountpt, "%s/tmpfs", bkpinfo->tmpdir);
    388     asprintf(&command, "mkdir -p %s", g_tmpfs_mountpt);
     388    mr_asprintf(&g_tmpfs_mountpt, "%s/tmpfs", bkpinfo->tmpdir);
     389    mr_asprintf(&command, "mkdir -p %s", g_tmpfs_mountpt);
    389390    paranoid_system(command);
    390     paranoid_free(command);
     391    mr_free(command);
    391392    rdsiz_MB = PPCFG_RAMDISK_SIZE + g_tape_buffer_size_MB;
    392393#ifdef __FreeBSD__
     
    394395             ("vmstat | tail -1 | tr -s ' ' | cut -d' ' -f6");
    395396    avm += atol(tmp);
    396     paranoid_free(tmp);
     397    mr_free(tmp);
    397398    tmp = call_program_and_get_last_line_of_output
    398399             ("swapinfo | grep -v Device | tr -s ' ' | cut -d' ' -f4 | tr '\n' '+' | sed 's/+$//' | bc");
    399400    avm += atol(tmp);
    400     paranoid_free(tmp);
    401     asprintf(&command, "mdmfs -s %d%c md9 %s", rdsiz_MB, 'm',
     401    mr_free(tmp);
     402    mr_asprintf(&command, "mdmfs -s %d%c md9 %s", rdsiz_MB, 'm',
    402403             g_tmpfs_mountpt);
    403404#else
     
    405406             ("free | grep \":\" | tr -s ' ' '\t' | cut -f2 | head -n1");
    406407    avm += atol(tmp);
    407     paranoid_free(tmp);
    408     asprintf(&command, "mount /dev/shm -t tmpfs %s -o size=%d%c",
     408    mr_free(tmp);
     409    mr_asprintf(&command, "mount /dev/shm -t tmpfs %s -o size=%d%c",
    409410             g_tmpfs_mountpt, rdsiz_MB, 'm');
    410411    run_program_and_log_output("cat /proc/cpuinfo", 5);
     
    416417    if (avm / 1024 > rdsiz_MB * 3) {
    417418        if (run_program_and_log_output(command, 5)) {
    418             paranoid_free(g_tmpfs_mountpt);
     419            mr_free(g_tmpfs_mountpt);
    419420            log_it("Failed to mount tmpfs");
    420421        } else {
     
    422423        }
    423424    } else {
    424         paranoid_free(g_tmpfs_mountpt);
     425        mr_free(g_tmpfs_mountpt);
    425426        log_it("It doesn't seem you have enough swap to use tmpfs. Fine.");
    426427    }
    427     paranoid_free(command);
     428    mr_free(command);
    428429
    429430    if (bkpinfo->use_lzo) {
    430         paranoid_alloc(bkpinfo->zip_exe, "lzop");
    431         paranoid_alloc(bkpinfo->zip_suffix, "lzo");
     431        mr_allocstr(bkpinfo->zip_exe, "lzop");
     432        mr_allocstr(bkpinfo->zip_suffix, "lzo");
    432433    } else if (bkpinfo->compression_level != 0) {
    433         paranoid_alloc(bkpinfo->zip_exe, "bzip2");
    434         paranoid_alloc(bkpinfo->zip_suffix, "bz2");
     434        mr_allocstr(bkpinfo->zip_exe, "bzip2");
     435        mr_allocstr(bkpinfo->zip_suffix, "bz2");
    435436    } else {
    436437        bkpinfo->zip_exe = NULL;
     
    445446            fatal_error("Please install growisofs.");
    446447        }
    447         paranoid_free(tmp);
     448        mr_free(tmp);
    448449
    449450        if (bkpinfo->nonbootable_backup) {
    450             asprintf(&mondo_mkisofs_sz, MONDO_GROWISOFS_NONBOOT);
     451            mr_asprintf(&mondo_mkisofs_sz, MONDO_GROWISOFS_NONBOOT);
    451452        } else if
    452453#ifdef __FreeBSD__
     
    457458#ifdef __IA64__
    458459    {
    459         asprintf(&mondo_mkisofs_sz, MONDO_GROWISOFS_REGULAR_ELILO);
     460        mr_asprintf(&mondo_mkisofs_sz, MONDO_GROWISOFS_REGULAR_ELILO);
    460461    }
    461462#else
    462463    {
    463         asprintf(&mondo_mkisofs_sz, MONDO_GROWISOFS_REGULAR_LILO);
     464        mr_asprintf(&mondo_mkisofs_sz, MONDO_GROWISOFS_REGULAR_LILO);
    464465    }
    465466#endif
    466467        else
    467468        {
    468             asprintf(&mondo_mkisofs_sz, MONDO_GROWISOFS_REGULAR_SYSLINUX);
     469            mr_asprintf(&mondo_mkisofs_sz, MONDO_GROWISOFS_REGULAR_SYSLINUX);
    469470        }
    470471        if (bkpinfo->manual_cd_tray) {
     
    472473            // -m isn't supported by growisofs, BTW...
    473474        } else {
    474             asprintf(&bkpinfo->call_make_iso,
     475            mr_asprintf(&bkpinfo->call_make_iso,
    475476                    "%s %s -Z %s . 2>> _ERR_",
    476477                    mondo_mkisofs_sz, "", bkpinfo->media_device);
    477478        }
    478         paranoid_free(mondo_mkisofs_sz);
     479        mr_free(mondo_mkisofs_sz);
    479480
    480481        if (getenv ("SUDO_COMMAND")) {
    481             asprintf(&command, "strings `which growisofs` | grep -c SUDO_COMMAND");
     482            mr_asprintf(&command, "strings `which growisofs` | grep -c SUDO_COMMAND");
    482483            tmp = call_program_and_get_last_line_of_output(command);
    483484            if (!strcmp(tmp, "1")) {
     
    485486                fatal_error("Can't write DVDs as sudo because growisofs doesn't support this - see the growisofs manpage for details.");
    486487            }       
    487             paranoid_free(tmp);
    488             paranoid_free(command);
     488            mr_free(tmp);
     489            mr_free(command);
    489490        }
    490491        log_msg(2, "call_make_iso (DVD res) is ... %s",
     
    496497        || bkpinfo->backup_media_type == cdr) {
    497498        if (!bkpinfo->manual_cd_tray) {
    498             asprintf(&extra_cdrom_params, "-waiti ");
     499            mr_asprintf(&extra_cdrom_params, "-waiti ");
    499500        }
    500501        if (bkpinfo->backup_media_type == cdrw) {
    501502            if (extra_cdrom_params != NULL) {
    502                 asprintf(&tmp, extra_cdrom_params);
    503                 paranoid_free(extra_cdrom_params);
    504                 asprintf(&extra_cdrom_params, "%s blank=fast ", tmp);
     503                mr_asprintf(&tmp, extra_cdrom_params);
     504                mr_free(extra_cdrom_params);
     505                mr_asprintf(&extra_cdrom_params, "%s blank=fast ", tmp);
    505506            } else {
    506                 asprintf(&extra_cdrom_params, "blank=fast ");
     507                mr_asprintf(&extra_cdrom_params, "blank=fast ");
    507508            }
    508509        }
     
    510511        tmp1 = find_home_of_exe("dvdrecord");
    511512        if (tmp) {
    512             asprintf(&cdr_exe, "cdrecord");
     513            mr_asprintf(&cdr_exe, "cdrecord");
    513514        } else if (tmp1) {
    514             asprintf(&cdr_exe, "dvdrecord");
     515            mr_asprintf(&cdr_exe, "dvdrecord");
    515516        } else {
    516517            fatal_error("Please install either cdrecord or dvdrecord.");
    517518        }
    518         paranoid_free(tmp);
    519         paranoid_free(tmp1);
     519        mr_free(tmp);
     520        mr_free(tmp1);
    520521
    521522        if (bkpinfo->nonbootable_backup) {
    522             asprintf(&mondo_mkisofs_sz, "%s -r -p MondoRescue -publisher www.mondorescue.org -A Mondo_Rescue_GPL_Version -V _CD#_", bkpinfo->mr_conf->mondo_iso_creation_cmd);
     523            mr_asprintf(&mondo_mkisofs_sz, "%s -r -p MondoRescue -publisher www.mondorescue.org -A Mondo_Rescue_GPL_Version -V _CD#_", bkpinfo->mr_conf->mondo_iso_creation_cmd);
    523524        } else if
    524525#ifdef __FreeBSD__
     
    529530#ifdef __IA64__
    530531    {
    531         asprintf(&mondo_mkisofs_sz, MONDO_MKISOFS_REGULAR_ELILO);
     532        mr_asprintf(&mondo_mkisofs_sz, MONDO_MKISOFS_REGULAR_ELILO);
    532533    }
    533534#else
    534535    {
    535         asprintf(&mondo_mkisofs_sz, MONDO_MKISOFS_REGULAR_LILO);
     536        mr_asprintf(&mondo_mkisofs_sz, MONDO_MKISOFS_REGULAR_LILO);
    536537    }
    537538#endif
    538539        else
    539540        {
    540             asprintf(&mondo_mkisofs_sz, MONDO_MKISOFS_REGULAR_SYSLINUX);
     541            mr_asprintf(&mondo_mkisofs_sz, MONDO_MKISOFS_REGULAR_SYSLINUX);
    541542        }
    542543        if (bkpinfo->manual_cd_tray) {
    543544            if (bkpinfo->call_before_iso == NULL) {
    544                 asprintf(&bkpinfo->call_before_iso,
     545                mr_asprintf(&bkpinfo->call_before_iso,
    545546                        "%s -o %s/temporary.iso . 2>> _ERR_",
    546547                        mondo_mkisofs_sz, bkpinfo->tmpdir);
    547548            } else {
    548                 asprintf(&call_before_iso_user, bkpinfo->call_before_iso);
    549                 asprintf(&bkpinfo->call_before_iso,
     549                mr_asprintf(&call_before_iso_user, bkpinfo->call_before_iso);
     550                mr_asprintf(&bkpinfo->call_before_iso,
    550551                                    "( %s -o %s/temporary.iso . 2>> _ERR_ ; %s )",
    551552                        mondo_mkisofs_sz, bkpinfo->tmpdir, call_before_iso_user);
    552                 paranoid_free(call_before_iso_user);
     553                mr_free(call_before_iso_user);
    553554            }
    554555            log_it("bkpinfo->call_before_iso = %s", bkpinfo->call_before_iso);
    555             asprintf(&bkpinfo->call_make_iso,
     556            mr_asprintf(&bkpinfo->call_make_iso,
    556557                    "%s %s -v %s fs=4m dev=%s speed=%d %s/temporary.iso",
    557558                    cdr_exe, (bkpinfo->please_dont_eject) ? " " : "-eject",
     
    559560                    bkpinfo->cdrw_speed, bkpinfo->tmpdir);
    560561        } else {
    561             asprintf(&bkpinfo->call_make_iso,
     562            mr_asprintf(&bkpinfo->call_make_iso,
    562563                    "%s . 2>> _ERR_ | %s %s %s fs=4m dev=%s speed=%d -",
    563564                    mondo_mkisofs_sz, cdr_exe,
     
    566567                    bkpinfo->cdrw_speed);
    567568        }
    568         paranoid_free(mondo_mkisofs_sz);
    569         paranoid_free(cdr_exe);
    570         paranoid_free(extra_cdrom_params);
     569        mr_free(mondo_mkisofs_sz);
     570        mr_free(cdr_exe);
     571        mr_free(extra_cdrom_params);
    571572    }                           // end of CD code
    572573
     
    581582
    582583        log_it("isodir = %s", bkpinfo->isodir);
    583         asprintf(&command, "df -P %s | tail -n1 | cut -d' ' -f1",
     584        mr_asprintf(&command, "df -P %s | tail -n1 | cut -d' ' -f1",
    584585                 bkpinfo->isodir);
    585586        log_it("command = %s", command);
    586587        tmp = call_program_and_get_last_line_of_output(command);
    587         paranoid_free(command);
     588        mr_free(command);
    588589        log_it("res of it = %s", tmp);
    589         asprintf(&tmp1, "%s/ISO-DEV", bkpinfo->tmpdir);
     590        mr_asprintf(&tmp1, "%s/ISO-DEV", bkpinfo->tmpdir);
    590591        write_one_liner_data_file(tmp1, tmp);
    591         paranoid_free(tmp1);
    592 
    593         asprintf(&command, "mount | grep -w %s | tail -n1 | cut -d' ' -f3",
     592        mr_free(tmp1);
     593
     594        mr_asprintf(&command, "mount | grep -w %s | tail -n1 | cut -d' ' -f3",
    594595                 tmp);
    595         paranoid_free(tmp);
     596        mr_free(tmp);
    596597        log_it("command = %s", command);
    597598        tmp = call_program_and_get_last_line_of_output(command);
    598         paranoid_free(command);
     599        mr_free(command);
    599600        log_it("res of it = %s", tmp);
    600601
    601         asprintf(&tmp1, "%s/ISO-MNT", bkpinfo->tmpdir);
     602        mr_asprintf(&tmp1, "%s/ISO-MNT", bkpinfo->tmpdir);
    602603        write_one_liner_data_file(tmp1, tmp);
    603         paranoid_free(tmp1);
     604        mr_free(tmp1);
    604605
    605606        log_it("isomnt: %s, %d", tmp, strlen(tmp));
    606607        if (strlen(bkpinfo->isodir) < strlen(tmp)) {
    607             asprintf(&iso_path, " ");
     608            mr_asprintf(&iso_path, " ");
    608609        } else {
    609             asprintf(&iso_path, "%s", bkpinfo->isodir + strlen(tmp));
    610         }
    611         paranoid_free(tmp);
    612 
    613         asprintf(&tmp, "%s/ISODIR", bkpinfo->tmpdir);
     610            mr_asprintf(&iso_path, "%s", bkpinfo->isodir + strlen(tmp));
     611        }
     612        mr_free(tmp);
     613
     614        mr_asprintf(&tmp, "%s/ISODIR", bkpinfo->tmpdir);
    614615        write_one_liner_data_file(tmp, iso_path);
    615         paranoid_free(tmp);
     616        mr_free(tmp);
    616617        log_it("isodir: %s", iso_path);
    617         paranoid_free(iso_path);
    618         asprintf(&tmp, "%s/ISO-PREFIX", bkpinfo->tmpdir);
     618        mr_free(iso_path);
     619        mr_asprintf(&tmp, "%s/ISO-PREFIX", bkpinfo->tmpdir);
    619620        write_one_liner_data_file(tmp, bkpinfo->prefix);
    620621        log_it("iso-prefix: %s",  bkpinfo->prefix);
    621         paranoid_free(tmp);
     622        mr_free(tmp);
    622623/* End patch */
    623624    }                           // end of iso code
    624625
    625626    if (bkpinfo->backup_media_type == nfs) {
    626         asprintf(&hostname, bkpinfo->nfs_mount);
     627        mr_asprintf(&hostname, bkpinfo->nfs_mount);
    627628        colon = strchr(hostname, ':');
    628629        if (!colon) {
     
    639640                retval++;
    640641            } else {
    641                 asprintf(&ip_address, "%s%s", inet_ntoa((struct in_addr)
     642                mr_asprintf(&ip_address, "%s%s", inet_ntoa((struct in_addr)
    642643                                                        *((struct in_addr
    643644                                                           *) hent->
    644645                                                          h_addr)),
    645646                         strchr(bkpinfo->nfs_mount, ':'));
    646                 paranoid_alloc(bkpinfo->nfs_mount, ip_address);
    647                 paranoid_free(ip_address);
     647                mr_allocstr(bkpinfo->nfs_mount, ip_address);
     648                mr_free(ip_address);
    648649            }
    649650        }
    650651        store_nfs_config(bkpinfo);
    651         paranoid_free(hostname);
     652        mr_free(hostname);
    652653    }
    653654
     
    656657        fprintf(stderr, "Type 'man mondoarchive' for help.\n");
    657658    }
    658     asprintf(&tmp, "%s", MONDO_TMPISOS);
     659    mr_asprintf(&tmp, "%s", MONDO_TMPISOS);
    659660    if (does_file_exist(tmp)) {
    660661        unlink(tmp);
    661662    }
    662     paranoid_free(tmp);
     663    mr_free(tmp);
    663664
    664665    if (strlen(bkpinfo->tmpdir) < 2 || strlen(bkpinfo->scratchdir) < 2) {
     
    668669    if (bkpinfo->include_paths == NULL) {
    669670        //      fatal_error ("Why no backup path?");
    670         asprintf(&bkpinfo->include_paths, "/");
     671        mr_asprintf(&bkpinfo->include_paths, "/");
    671672    }
    672673    chmod(bkpinfo->scratchdir, 0700);
    673674    chmod(bkpinfo->tmpdir, 0700);
    674675    g_backup_media_type = bkpinfo->backup_media_type;
    675     paranoid_alloc(g_backup_media_string,bkpinfo->backup_media_string);
     676    mr_allocstr(g_backup_media_string,bkpinfo->backup_media_string);
    676677    return (retval);
    677678}
     
    716717    g_current_media_number = 1;
    717718    bkpinfo->postnuke_tarball = NULL;
    718     paranoid_free(bkpinfo->nfs_mount);
     719    mr_free(bkpinfo->nfs_mount);
    719720    return (res);
    720721}
     
    746747    }
    747748
    748     paranoid_free(bkpinfo->media_device);
    749     paranoid_free(bkpinfo->boot_device);
    750     paranoid_free(bkpinfo->zip_exe);
    751     paranoid_free(bkpinfo->zip_suffix);
    752     paranoid_free(bkpinfo->restore_path);
     749    mr_free(bkpinfo->media_device);
     750    mr_free(bkpinfo->boot_device);
     751    mr_free(bkpinfo->zip_exe);
     752    mr_free(bkpinfo->zip_suffix);
     753    mr_free(bkpinfo->restore_path);
    753754    bkpinfo->use_lzo = FALSE;
    754755    bkpinfo->verify_data = FALSE;
     
    758759        (am_I_in_disaster_recovery_mode()? TRUE : FALSE);
    759760    if (bkpinfo->disaster_recovery) {
    760         paranoid_alloc(bkpinfo->isodir, "/");
     761        mr_allocstr(bkpinfo->isodir, "/");
    761762    } else {
    762         paranoid_alloc(bkpinfo->isodir, "/var/cache/mondo/iso");
    763     }
    764     paranoid_alloc(bkpinfo->prefix, STD_PREFIX);
    765 
    766     paranoid_free(bkpinfo->scratchdir);
     763        mr_allocstr(bkpinfo->isodir, "/var/cache/mondo/iso");
     764    }
     765    mr_allocstr(bkpinfo->prefix, STD_PREFIX);
     766
     767    mr_free(bkpinfo->scratchdir);
    767768    bkpinfo->make_filelist = TRUE;  // unless -J supplied to mondoarchive
    768     paranoid_free(bkpinfo->tmpdir);
    769     asprintf(&bkpinfo->tmpdir, "/tmp/tmpfs/mondo.tmp.%d", (int) (random() % 32768));    // for mondorestore
     769    mr_free(bkpinfo->tmpdir);
     770    mr_asprintf(&bkpinfo->tmpdir, "/tmp/tmpfs/mondo.tmp.%d", (int) (random() % 32768)); // for mondorestore
    770771    bkpinfo->optimal_set_size = 0;
    771772    bkpinfo->backup_media_type = none;
    772     paranoid_free(bkpinfo->backup_media_string);
    773     paranoid_alloc(bkpinfo->include_paths, "/");
    774     paranoid_free(bkpinfo->exclude_paths);
    775     paranoid_free(bkpinfo->call_before_iso);
    776     paranoid_free(bkpinfo->call_make_iso);
    777     paranoid_free(bkpinfo->call_burn_iso);
    778     paranoid_free(bkpinfo->call_after_iso);
    779     paranoid_free(bkpinfo->image_devs);
    780     paranoid_free(bkpinfo->postnuke_tarball);
    781     paranoid_free(bkpinfo->kernel_path);
    782     paranoid_free(bkpinfo->nfs_mount);
    783     paranoid_free(bkpinfo->nfs_remote_dir);
     773    mr_free(bkpinfo->backup_media_string);
     774    mr_allocstr(bkpinfo->include_paths, "/");
     775    mr_free(bkpinfo->exclude_paths);
     776    mr_free(bkpinfo->call_before_iso);
     777    mr_free(bkpinfo->call_make_iso);
     778    mr_free(bkpinfo->call_burn_iso);
     779    mr_free(bkpinfo->call_after_iso);
     780    mr_free(bkpinfo->image_devs);
     781    mr_free(bkpinfo->postnuke_tarball);
     782    mr_free(bkpinfo->kernel_path);
     783    mr_free(bkpinfo->nfs_mount);
     784    mr_free(bkpinfo->nfs_remote_dir);
    784785    bkpinfo->wipe_media_first = FALSE;
    785786    bkpinfo->differential = FALSE;
     
    805806    assert_string_is_neither_NULL_nor_zerolength(partition);
    806807
    807     asprintf(&command, "df -m -P %s &> /dev/null", partition);
     808    mr_asprintf(&command, "df -m -P %s &> /dev/null", partition);
    808809    if (system(command)) {
    809810        return (-1);
    810811    }                           // partition does not exist
    811     paranoid_free(command);
    812 
    813     asprintf(&command, "df -m -P %s | tail -n1 | tr -s ' ' '\t' | cut -f4",
     812    mr_free(command);
     813
     814    mr_asprintf(&command, "df -m -P %s | tail -n1 | tr -s ' ' '\t' | cut -f4",
    814815             partition);
    815816    out_sz = call_program_and_get_last_line_of_output(command);
    816     paranoid_free(command);
     817    mr_free(command);
    817818    if (strlen(out_sz) == 0) {
    818819        return (-1);
    819820    }                           // error within df, probably
    820821    res = atol(out_sz);
    821     paranoid_free(out_sz);
     822    mr_free(out_sz);
    822823    return (res);
    823824}
     
    868869            (_("WARNING! You have very little RAM. Please upgrade to 64MB or more."));
    869870    }
    870     paranoid_free(tmp);
     871    mr_free(tmp);
    871872#endif
    872873
     
    929930            log_to_screen(_("Please install ms-sys just in case."));
    930931        }
    931         paranoid_free(tmp);
     932        mr_free(tmp);
    932933#endif
    933934    }
     
    937938        whine_if_not_found("cmp");
    938939    }
    939     paranoid_free(tmp);
     940    mr_free(tmp);
    940941
    941942    run_program_and_log_output
     
    958959        }
    959960    }
    960     paranoid_free(tmp);
     961    mr_free(tmp);
    961962#ifndef __FreeBSD__
    962963    if (!does_file_exist("/etc/modules.conf")) {
     
    10411042
    10421043    if (!does_file_exist(config_file)) {
    1043         asprintf(&tmp, "(read_cfg_var) Cannot find %s config file",
     1044        mr_asprintf(&tmp, "(read_cfg_var) Cannot find %s config file",
    10441045                 config_file);
    10451046        log_to_screen(tmp);
    1046         paranoid_free(tmp);
     1047        mr_free(tmp);
    10471048        value = NULL;
    10481049        return (1);
     
    10541055        return (0);
    10551056    */ } else {
    1056         asprintf(&command, "grep '%s .*' %s| cut -d' ' -f2,3,4,5",
     1057        mr_asprintf(&command, "grep '%s .*' %s| cut -d' ' -f2,3,4,5",
    10571058                label, config_file);
    10581059        value = call_program_and_get_last_line_of_output(command);
    1059         paranoid_free(command);
     1060        mr_free(command);
    10601061        if (strlen(value) == 0) {
    10611062            return (1);
     
    11081109    log_msg(1, "Started sub");
    11091110    log_msg(4, "Setting command to something");
    1110     asprintf(&command,
     1111    mr_asprintf(&command,
    11111112             "grep -v \":\" /etc/fstab | grep -vx \"#.*\" | grep -w \"/boot\" | tr -s ' ' '\t' | cut -f1 | head -n1");
    11121113    log_msg(4, "Cool. Command = '%s'", command);
    11131114    tmp = call_program_and_get_last_line_of_output(command);
    1114     paranoid_free(command);
     1115    mr_free(command);
    11151116
    11161117    log_msg(4, "tmp = '%s'", tmp);
     
    11191120        if (strstr(tmp, "LABEL=")) {
    11201121            if (!run_program_and_log_output("mount /boot", 5)) {
    1121                 paranoid_free(g_boot_mountpt);
    1122                 asprintf(&g_boot_mountpt, "/boot");
     1122                mr_free(g_boot_mountpt);
     1123                mr_asprintf(&g_boot_mountpt, "/boot");
    11231124                log_msg(1, "Mounted /boot");
    11241125            } else {
     
    11261127            }
    11271128        } else {
    1128             asprintf(&command, "mount | grep -w \"%s\"", tmp);
     1129            mr_asprintf(&command, "mount | grep -w \"%s\"", tmp);
    11291130            log_msg(3, "command = %s", command);
    11301131            if (run_program_and_log_output(command, 5)) {
    1131                 paranoid_free(g_boot_mountpt);
    1132                 asprintf(&g_boot_mountpt, tmp);
    1133                 asprintf(&tmp1,
     1132                mr_free(g_boot_mountpt);
     1133                mr_asprintf(&g_boot_mountpt, tmp);
     1134                mr_asprintf(&tmp1,
    11341135                         "%s (your /boot partition) is not mounted. I'll mount it before backing up",
    11351136                         g_boot_mountpt);
    11361137                log_it(tmp1);
    1137                 paranoid_free(tmp1);
    1138 
    1139                 asprintf(&tmp1, "mount %s", g_boot_mountpt);
     1138                mr_free(tmp1);
     1139
     1140                mr_asprintf(&tmp1, "mount %s", g_boot_mountpt);
    11401141                if (run_program_and_log_output(tmp1, 5)) {
    11411142                    /* BERLIOS: Useless ???
    1142                     paranoid_free(g_boot_mountpt);
    1143                     asprintf(&g_boot_mountpt, " ");
     1143                    mr_free(g_boot_mountpt);
     1144                    mr_asprintf(&g_boot_mountpt, " ");
    11441145                    */
    11451146                    log_msg(1, "Plan B");
    11461147                    if (!run_program_and_log_output("mount /boot", 5)) {
    1147                         paranoid_free(g_boot_mountpt);
    1148                         asprintf(&g_boot_mountpt, "/boot");
     1148                        mr_free(g_boot_mountpt);
     1149                        mr_asprintf(&g_boot_mountpt, "/boot");
    11491150                        log_msg(1, "Plan B worked");
    11501151                    } else {
     
    11531154                    }
    11541155                }
    1155                 paranoid_free(tmp1);
     1156                mr_free(tmp1);
    11561157            }
    1157             paranoid_free(command);
    1158         }
    1159     }
    1160     paranoid_free(tmp);
     1158            mr_free(command);
     1159        }
     1160    }
     1161    mr_free(tmp);
    11611162    log_msg(1, "Ended sub");
    11621163}
     
    11721173    log_msg(3, "starting");
    11731174    if (g_boot_mountpt != NULL) {
    1174         asprintf(&tmp, "umount %s", g_boot_mountpt);
     1175        mr_asprintf(&tmp, "umount %s", g_boot_mountpt);
    11751176        if (run_program_and_log_output(tmp, 5)) {
    11761177            log_it("WARNING - unable to unmount /boot");
    11771178        }
    1178         paranoid_free(tmp);
     1179        mr_free(tmp);
    11791180    }
    11801181    log_msg(3, "leaving");
     
    12051206
    12061207    if (!does_file_exist(config_file)) {
    1207         asprintf(&tmp, "(write_cfg_file) Cannot find %s config file",
     1208        mr_asprintf(&tmp, "(write_cfg_file) Cannot find %s config file",
    12081209                 config_file);
    12091210        log_to_screen(tmp);
    1210         paranoid_free(tmp);
     1211        mr_free(tmp);
    12111212        return (1);
    12121213    }
     
    12141215             ("mktemp -q /tmp/mojo-jojo.blah.XXXXXX");
    12151216    if (does_file_exist(config_file)) {
    1216         asprintf(&command, "grep -vx '%s .*' %s > %s",
     1217        mr_asprintf(&command, "grep -vx '%s .*' %s > %s",
    12171218                label, config_file, tempfile);
    12181219        paranoid_system(command);
    1219         paranoid_free(command);
    1220     }
    1221     asprintf(&command, "echo \"%s %s\" >> %s", label, value, tempfile);
     1220        mr_free(command);
     1221    }
     1222    mr_asprintf(&command, "echo \"%s %s\" >> %s", label, value, tempfile);
    12221223    paranoid_system(command);
    1223     paranoid_free(command);
    1224 
    1225     asprintf(&command, "mv -f %s %s", tempfile, config_file);
     1224    mr_free(command);
     1225
     1226    mr_asprintf(&command, "mv -f %s %s", tempfile, config_file);
    12261227    paranoid_system(command);
    1227     paranoid_free(command);
     1228    mr_free(command);
    12281229    unlink(tempfile);
    1229     paranoid_free(tempfile);
     1230    mr_free(tempfile);
    12301231    return (0);
    12311232}
     
    12431244    } else {
    12441245        iamhere("Freeing globals");
    1245         paranoid_free(g_boot_mountpt);
    1246         paranoid_free(g_mondo_home);
    1247         paranoid_free(g_tmpfs_mountpt);
    1248         paranoid_free(g_erase_tmpdir_and_scratchdir);
    1249         paranoid_free(g_serial_string);
    1250         paranoid_free(g_magicdev_command);
     1246        mr_free(g_boot_mountpt);
     1247        mr_free(g_mondo_home);
     1248        mr_free(g_tmpfs_mountpt);
     1249        mr_free(g_erase_tmpdir_and_scratchdir);
     1250        mr_free(g_serial_string);
     1251        mr_free(g_magicdev_command);
    12511252    }
    12521253}
     
    12951296
    12961297    if (!g_magicdev_command) {
    1297         asprintf(&tmp, "%s &", g_magicdev_command);
     1298        mr_asprintf(&tmp, "%s &", g_magicdev_command);
    12981299        paranoid_system(tmp);
    1299         paranoid_free(tmp);
     1300        mr_free(tmp);
    13001301    }
    13011302}
  • trunk/mondo/src/common/libmondo-verify.c

    r783 r900  
    1818#include "libmondo-devices-EXT.h"
    1919#include "libmondo-tools-EXT.h"
     20#include "mr_mem.h"
    2021
    2122/*@unused@*/
     
    6061    assert_string_is_neither_NULL_nor_zerolength(stderr_fname);
    6162
    62     asprintf(&afio_found_changes, "%s.afio", ignorefiles_fname);
     63    mr_asprintf(&afio_found_changes, "%s.afio", ignorefiles_fname);
    6364    sync();
    6465
     
    6970
    7071    log_msg(1, "Now scanning log file for 'afio: ' stuff");
    71     asprintf(&command,
     72    mr_asprintf(&command,
    7273             "grep \"afio: \" %s | sed 's/afio: //' | grep -vx \"/dev/.*\" >> %s",
    7374             stderr_fname, afio_found_changes);
    7475    log_msg(2, command);
    7576    res = system(command);
    76     paranoid_free(command);
     77    mr_free(command);
    7778    if (res) {
    7879        log_msg(2, "Warning - failed to think");
     
    8081
    8182    log_msg(1, "Now scanning log file for 'star: ' stuff");
    82     asprintf(&command,
     83    mr_asprintf(&command,
    8384             "grep \"star: \" %s | sed 's/star: //' | grep -vx \"/dev/.*\" >> %s",
    8485             stderr_fname, afio_found_changes);
    8586    log_msg(2, command);
    8687    res = system(command);
    87     paranoid_free(command);
     88    mr_free(command);
    8889    if (res) {
    8990        log_msg(2, "Warning - failed to think");
     
    9192//  exclude_nonexistent_files (afio_found_changes);
    9293    afio_diffs = count_lines_in_file(afio_found_changes);
    93     asprintf(&command,
     94    mr_asprintf(&command,
    9495             "sort %s %s %s | uniq -c | awk '{ if ($1==\"2\") {print $2;};}' | grep -v \"incheckentry xwait()\" > %s",
    9596             ignorefiles_fname, afio_found_changes, afio_found_changes,
     
    9798    log_msg(2, command);
    9899    paranoid_system(command);
    99     paranoid_free(command);
    100     paranoid_free(afio_found_changes);
     100    mr_free(command);
     101    mr_free(afio_found_changes);
    101102    return (afio_diffs);
    102103}
     
    145146        } else {
    146147            retval++;
    147             asprintf(&tmp, "Warning - missing set(s) between %d and %d\n",
     148            mr_asprintf(&tmp, "Warning - missing set(s) between %d and %d\n",
    148149                     g_last_afioball_number, set_number - 1);
    149150            log_to_screen(tmp);
    150             paranoid_free(tmp);
    151         }
    152     }
    153     asprintf(&tmp, "Verifying %s #%d's tarballs",
     151            mr_free(tmp);
     152        }
     153    }
     154    mr_asprintf(&tmp, "Verifying %s #%d's tarballs",
    154155             bkpinfo->backup_media_string,
    155156             g_current_media_number);
    156157    open_evalcall_form(tmp);
    157     paranoid_free(tmp);
     158    mr_free(tmp);
    158159
    159160    for (total_sets = set_number;
     
    234235    if (bkpinfo->compression_level > 0) {
    235236        if (bkpinfo->use_lzo) {
    236             asprintf(&sz_exe, "lzop");
     237            mr_asprintf(&sz_exe, "lzop");
    237238        } else {
    238             asprintf(&sz_exe, "bzip2");
     239            mr_asprintf(&sz_exe, "bzip2");
    239240        }
    240241    } else {
    241         asprintf(&sz_exe, " ");
     242        mr_asprintf(&sz_exe, " ");
    242243    }
    243244
    244245    iamhere("before vsbf");
    245     asprintf(&tmp, "Verifying %s#%d's big files",
     246    mr_asprintf(&tmp, "Verifying %s#%d's big files",
    246247             bkpinfo->backup_media_string,
    247248             g_current_media_number);
    248249    open_evalcall_form(tmp);
    249     paranoid_free(tmp);
     250    mr_free(tmp);
    250251
    251252    iamhere("after vsbf");
    252     asprintf(&mountpoint, "%s/archives", mtpt);
     253    mr_asprintf(&mountpoint, "%s/archives", mtpt);
    253254    if (last_bigfile_num == -1) {
    254255        bigfile_num = 0;
     
    279280                paranoid_fclose(fin);
    280281            }
    281             asprintf(&tmp2, "%s/%s", bkpinfo->restore_path,
     282            mr_asprintf(&tmp2, "%s/%s", bkpinfo->restore_path,
    282283                     biggiestruct.filename);
    283284            log_msg(2, "Opening biggiefile #%ld - '%s'", bigfile_num, tmp2);
     
    286287                retval++;
    287288            }
    288             paranoid_free(tmp2);
     289            mr_free(tmp2);
    289290
    290291            slice_num++;
     
    299300                    g_current_media_number, bigfile_num, slice_num);
    300301            if (bkpinfo->compression_level > 0) {
    301                 asprintf(&command, "%s -dc %s 2>> %s", sz_exe, tmp, MONDO_LOGFILE);
     302                mr_asprintf(&command, "%s -dc %s 2>> %s", sz_exe, tmp, MONDO_LOGFILE);
    302303            } else {
    303                 asprintf(&command, "cat %s", tmp);
     304                mr_asprintf(&command, "cat %s", tmp);
    304305            }
    305306            if ((pin = popen(command, "r"))) {
     
    339340                }
    340341            }
    341             paranoid_free(command);
     342            mr_free(command);
    342343            slice_num++;
    343344        }
    344345    }
    345     paranoid_free(tmp);
    346     paranoid_free(tmp1);
    347     paranoid_free(mountpoint);
    348     paranoid_free(sz_exe);
     346    mr_free(tmp);
     347    mr_free(tmp1);
     348    mr_free(mountpoint);
     349    mr_free(sz_exe);
    349350
    350351    last_bigfile_num = bigfile_num;
     
    355356    close_evalcall_form();
    356357    if (bufblkA) {
    357         paranoid_free(bufblkA);
     358        mr_free(bufblkA);
    358359    }
    359360    if (bufblkB) {
    360         paranoid_free(bufblkB);
     361        mr_free(bufblkB);
    361362    }
    362363    return (0);
     
    397398
    398399    /*  chdir("/"); */
    399     asprintf(&outlog, "%s/afio.log", bkpinfo->tmpdir);
     400    mr_asprintf(&outlog, "%s/afio.log", bkpinfo->tmpdir);
    400401
    401402    /* if programmer forgot to say which compression thingy to use then find out */
     
    403404        && strcmp(bkpinfo->zip_suffix, "lzo")) {
    404405        log_msg(2, "OK, I'm going to start using lzop.");
    405         paranoid_alloc(bkpinfo->zip_exe, "lzop");
    406         paranoid_alloc(bkpinfo->zip_suffix, "lzo");
     406        mr_allocstr(bkpinfo->zip_exe, "lzop");
     407        mr_allocstr(bkpinfo->zip_suffix, "lzo");
    407408        bkpinfo->use_lzo = TRUE;
    408409    }
     
    410411        && strcmp(bkpinfo->zip_suffix, "bz2")) {
    411412        log_msg(2, "OK, I'm going to start using bzip2.");
    412         paranoid_alloc(bkpinfo->zip_exe, "bzip2");
    413         paranoid_alloc(bkpinfo->zip_suffix, "bz2");
     413        mr_allocstr(bkpinfo->zip_exe, "bzip2");
     414        mr_allocstr(bkpinfo->zip_suffix, "bz2");
    414415        bkpinfo->use_lzo = FALSE;
    415416    }
     
    418419        bkpinfo->use_star = TRUE;
    419420        if (strstr(tarball_fname, ".bz2"))
    420             asprintf(&command,
     421            mr_asprintf(&command,
    421422                     "star -diff diffopts=mode,size,data file=%s %s >> %s 2>> %s",
    422423                     tarball_fname,
     
    425426    } else {
    426427        bkpinfo->use_star = FALSE;
    427         asprintf(&command, "afio -r -P %s -Z %s >> %s 2>> %s",
     428        mr_asprintf(&command, "afio -r -P %s -Z %s >> %s 2>> %s",
    428429                 bkpinfo->zip_exe, tarball_fname, outlog, outlog);
    429430    }
    430431    log_msg(6, "command=%s", command);
    431432    paranoid_system(command);
    432     paranoid_free(command);
     433    mr_free(command);
    433434
    434435    if (length_of_file(outlog) < 10) {
    435         asprintf(&command, "cat %s >> %s", outlog, MONDO_LOGFILE);
     436        mr_asprintf(&command, "cat %s >> %s", outlog, MONDO_LOGFILE);
    436437    } else {
    437         asprintf(&command, "cut -d':' -f%d %s | sort -u",
     438        mr_asprintf(&command, "cut -d':' -f%d %s | sort -u",
    438439                 (bkpinfo->use_star) ? 1 : 2, outlog);
    439440        pin = popen(command, "r");
    440441        if (pin) {
    441             for (getline(&tmp, &n, pin); !feof(pin);
    442                  getline(&tmp, &n, pin)) {
     442            for (mr_getline(&tmp, &n, pin); !feof(pin);
     443                 mr_getline(&tmp, &n, pin)) {
    443444                if (bkpinfo->use_star) {
    444445                    if (!strstr(tmp, "diffopts=")) {
     
    467468            }
    468469            paranoid_pclose(pin);
    469             paranoid_free(tmp);
     470            mr_free(tmp);
    470471        } else {
    471472            log_OS_error(command);
    472473        }
    473474    }
    474     paranoid_free(outlog);
    475     paranoid_free(command);
     475    mr_free(outlog);
     476    mr_free(command);
    476477
    477478    /*  chdir(old_pwd); */
     
    545546        p++;
    546547    }
    547     asprintf(&tmp, "mkdir -p %s/tmpfs", bkpinfo->tmpdir);
     548    mr_asprintf(&tmp, "mkdir -p %s/tmpfs", bkpinfo->tmpdir);
    548549    paranoid_system(tmp);
    549     paranoid_free(tmp);
    550 
    551     asprintf(&tarball_fname, "%s/tmpfs/temporary-%s", bkpinfo->tmpdir, p);
     550    mr_free(tmp);
     551
     552    mr_asprintf(&tarball_fname, "%s/tmpfs/temporary-%s", bkpinfo->tmpdir, p);
    552553    /* BERLIOS : useless
    553        asprintf(&tmp, "Temporarily copying file from tape to '%s'",
     554       mr_asprintf(&tmp, "Temporarily copying file from tape to '%s'",
    554555       tarball_fname);
    555556       log_it(tmp);
    556        paranoid_free(tmp);
     557       mr_free(tmp);
    557558     */
    558559    read_file_from_stream_to_file(bkpinfo, tarball_fname, size);
    559560    res = verify_a_tarball(bkpinfo, tarball_fname);
    560561    if (res) {
    561         asprintf(&tmp,
     562        mr_asprintf(&tmp,
    562563                 "Afioball '%s' no longer matches your live filesystem",
    563564                 p);
    564565        log_msg(0, tmp);
    565         paranoid_free(tmp);
     566        mr_free(tmp);
    566567        retval++;
    567568    }
    568569    unlink(tarball_fname);
    569     paranoid_free(tarball_fname);
     570    mr_free(tarball_fname);
    570571    return (retval);
    571572}
     
    612613        p++;
    613614    }
    614     asprintf(&test_file, "%s/temporary-%s", bkpinfo->tmpdir, p);
    615     asprintf(&tmp,
     615    mr_asprintf(&test_file, "%s/temporary-%s", bkpinfo->tmpdir, p);
     616    mr_asprintf(&tmp,
    616617             "Temporarily copying biggiefile %s's slices from tape to '%s'",
    617618             p, test_file);
    618619    log_it(tmp);
    619     paranoid_free(tmp);
     620    mr_free(tmp);
    620621    for (res =
    621622         read_header_block_from_stream(&slice_siz, slice_fnam, &ctrl_chr);
     
    629630        res = read_file_from_stream_to_file(bkpinfo, test_file, slice_siz);
    630631        unlink(test_file);
    631         paranoid_free(slice_fnam);
     632        mr_free(slice_fnam);
    632633        slice_fnam = (char *) &res;
    633634        res =
     
    640641        current_slice_number++;
    641642        retval += res;
    642         paranoid_free(slice_fnam);
     643        mr_free(slice_fnam);
    643644        slice_fnam = (char *) &res;
    644645    }
    645     paranoid_free(test_file);
    646 
    647     asprintf(&biggie_cksum, slice_fnam);
    648     paranoid_free(slice_fnam);
     646    mr_free(test_file);
     647
     648    mr_asprintf(&biggie_cksum, slice_fnam);
     649    mr_free(slice_fnam);
    649650
    650651    if (biggie_cksum[0] != '\0') {
    651652        orig_cksum = calc_checksum_of_file(biggie_fname);
    652653        if (strcmp(biggie_cksum, orig_cksum)) {
    653             asprintf(&tmp, "orig cksum=%s; curr cksum=%s", biggie_cksum,
     654            mr_asprintf(&tmp, "orig cksum=%s; curr cksum=%s", biggie_cksum,
    654655                     orig_cksum);
    655656            log_msg(2, tmp);
    656             paranoid_free(tmp);
    657 
    658             asprintf(&tmp, _("%s has changed on live filesystem"),
     657            mr_free(tmp);
     658
     659            mr_asprintf(&tmp, _("%s has changed on live filesystem"),
    659660                     biggie_fname);
    660661            log_to_screen(tmp);
    661             paranoid_free(tmp);
    662 
    663             asprintf(&tmp, "echo \"%s\" >> /tmp/biggies.changed",
     662            mr_free(tmp);
     663
     664            mr_asprintf(&tmp, "echo \"%s\" >> /tmp/biggies.changed",
    664665                     biggie_fname);
    665666            system(tmp);
    666             paranoid_free(tmp);
    667         }
    668         paranoid_free(orig_cksum);
    669     }
    670     paranoid_free(biggie_cksum);
     667            mr_free(tmp);
     668        }
     669        mr_free(orig_cksum);
     670    }
     671    mr_free(biggie_cksum);
    671672
    672673    return (retval);
     
    702703    assert(bkpinfo != NULL);
    703704
    704     asprintf(&curr_xattr_list_fname, XATTR_BIGGLST_FNAME_RAW_SZ,
     705    mr_asprintf(&curr_xattr_list_fname, XATTR_BIGGLST_FNAME_RAW_SZ,
    705706             bkpinfo->tmpdir);
    706     asprintf(&curr_acl_list_fname, ACL_BIGGLST_FNAME_RAW_SZ,
     707    mr_asprintf(&curr_acl_list_fname, ACL_BIGGLST_FNAME_RAW_SZ,
    707708             bkpinfo->tmpdir);
    708709    log_to_screen(_("Verifying regular archives on tape"));
     
    726727        wrong_marker(BLK_START_AFIOBALLS, ctrl_chr);
    727728    }
    728     paranoid_free(curr_xattr_list_fname);
    729     paranoid_free(curr_acl_list_fname);
     729    mr_free(curr_xattr_list_fname);
     730    mr_free(curr_acl_list_fname);
    730731
    731732    for (res = read_header_block_from_stream(&size, fname, &ctrl_chr);
    732733         ctrl_chr != BLK_STOP_AFIOBALLS;
    733734         res = read_header_block_from_stream(&size, fname, &ctrl_chr)) {
    734         asprintf(&curr_xattr_list_fname, XATTR_LIST_FNAME_RAW_SZ,
     735        mr_asprintf(&curr_xattr_list_fname, XATTR_LIST_FNAME_RAW_SZ,
    735736                 bkpinfo->tmpdir, current_afioball_number);
    736         asprintf(&curr_acl_list_fname, ACL_LIST_FNAME_RAW_SZ,
     737        mr_asprintf(&curr_acl_list_fname, ACL_LIST_FNAME_RAW_SZ,
    737738                 bkpinfo->tmpdir, current_afioball_number);
    738739        if (ctrl_chr == BLK_START_EXTENDED_ATTRIBUTES) {
    739740            iamhere("Reading EXAT files from tape");
    740             paranoid_free(fname);
     741            mr_free(fname);
    741742            fname = (char *) &res;
    742743            res =
     
    745746                                          curr_acl_list_fname);
    746747        }
    747         paranoid_free(curr_xattr_list_fname);
    748         paranoid_free(curr_acl_list_fname);
     748        mr_free(curr_xattr_list_fname);
     749        mr_free(curr_acl_list_fname);
    749750
    750751        if (ctrl_chr != BLK_START_AN_AFIO_OR_SLICE) {
    751752            wrong_marker(BLK_START_AN_AFIO_OR_SLICE, ctrl_chr);
    752753        }
    753         asprintf(&tmp, "Verifying fileset #%ld", current_afioball_number);
     754        mr_asprintf(&tmp, "Verifying fileset #%ld", current_afioball_number);
    754755        /*log_it(tmp); */
    755756        update_progress_form(tmp);
    756         paranoid_free(tmp);
     757        mr_free(tmp);
    757758
    758759        res = verify_an_afioball_from_stream(bkpinfo, fname, size);
    759760        if (res) {
    760             asprintf(&tmp, _("Afioball %ld differs from live filesystem"),
     761            mr_asprintf(&tmp, _("Afioball %ld differs from live filesystem"),
    761762                     current_afioball_number);
    762763            log_to_screen(tmp);
    763             paranoid_free(tmp);
     764            mr_free(tmp);
    764765        }
    765766        retval += res;
    766767        current_afioball_number++;
    767768        g_current_progress++;
    768         paranoid_free(fname);
     769        mr_free(fname);
    769770        fname = (char *) &res;
    770771        res = read_header_block_from_stream(&size, fname, &ctrl_chr);
     
    772773            wrong_marker(BLK_STOP_AN_AFIO_OR_SLICE, ctrl_chr);
    773774        }
    774         paranoid_free(fname);
     775        mr_free(fname);
    775776        fname = (char *) &res;
    776777    }
    777778    log_msg(1, "All done with afioballs");
    778779    close_progress_form();
    779     paranoid_free(fname);
     780    mr_free(fname);
    780781    return (retval);
    781782}
     
    816817    assert(bkpinfo != NULL);
    817818
    818     asprintf(&curr_xattr_list_fname, XATTR_BIGGLST_FNAME_RAW_SZ,
     819    mr_asprintf(&curr_xattr_list_fname, XATTR_BIGGLST_FNAME_RAW_SZ,
    819820             bkpinfo->tmpdir);
    820     asprintf(&curr_acl_list_fname, ACL_BIGGLST_FNAME_RAW_SZ,
     821    mr_asprintf(&curr_acl_list_fname, ACL_BIGGLST_FNAME_RAW_SZ,
    821822             bkpinfo->tmpdir);
    822     asprintf(&comment, "Verifying all bigfiles.");
     823    mr_asprintf(&comment, "Verifying all bigfiles.");
    823824    log_to_screen(comment);
    824825    res = read_header_block_from_stream(&size, orig_fname, &ctrl_chr);
     
    826827        if (ctrl_chr == BLK_START_EXTENDED_ATTRIBUTES) {
    827828            iamhere("Grabbing the EXAT biggiefiles");
    828             paranoid_free(orig_fname);
     829            mr_free(orig_fname);
    829830            orig_fname = (char *) &ctrl_chr;
    830831            res =
     
    834835        }
    835836    }
    836     paranoid_free(curr_xattr_list_fname);
    837     paranoid_free(curr_acl_list_fname);
    838     paranoid_free(orig_fname);
     837    mr_free(curr_xattr_list_fname);
     838    mr_free(curr_acl_list_fname);
     839    mr_free(orig_fname);
    839840    orig_fname = (char *) &ctrl_chr;
    840841
     
    847848                       _("Please wait. This may take some time."), "",
    848849                       noof_biggiefiles);
    849     paranoid_free(comment);
     850    mr_free(comment);
    850851
    851852    for (res = read_header_block_from_stream(&size, orig_fname, &ctrl_chr);
     
    863864            p++;
    864865        }
    865         asprintf(&comment, _("Verifying bigfile #%ld (%ld K)"),
     866        mr_asprintf(&comment, _("Verifying bigfile #%ld (%ld K)"),
    866867                 current_biggiefile_number, (long) size >> 10);
    867868        update_progress_form(comment);
    868         paranoid_free(comment);
    869 
    870         asprintf(&logical_fname, "%s/%s", bkpinfo->restore_path,
     869        mr_free(comment);
     870
     871        mr_asprintf(&logical_fname, "%s/%s", bkpinfo->restore_path,
    871872                 orig_fname);
    872873        res =
    873874            verify_a_biggiefile_from_stream(bkpinfo, logical_fname, size);
    874         paranoid_free(logical_fname);
     875        mr_free(logical_fname);
    875876        retval += res;
    876877        current_biggiefile_number++;
    877878        g_current_progress++;
    878         paranoid_free(orig_fname);
     879        mr_free(orig_fname);
    879880        orig_fname = (char *) &ctrl_chr;
    880881    }
     
    922923    assert(bkpinfo != NULL);
    923924
    924     asprintf(&mountpoint, "%s/cdrom", bkpinfo->tmpdir);
    925     asprintf(&fname, "%s/%s/%s-%d.iso", bkpinfo->isodir, bkpinfo->nfs_remote_dir,
     925    mr_asprintf(&mountpoint, "%s/cdrom", bkpinfo->tmpdir);
     926    mr_asprintf(&fname, "%s/%s/%s-%d.iso", bkpinfo->isodir, bkpinfo->nfs_remote_dir,
    926927             bkpinfo->prefix, g_current_media_number);
    927928
     
    929930    sync();
    930931    if (!does_file_exist(fname)) {
    931         asprintf(&tmp,
     932        mr_asprintf(&tmp,
    932933                 "%s not found; assuming you backed up to CD; verifying CD...",
    933934                 fname);
    934935        log_msg(2, tmp);
    935         paranoid_free(tmp);
     936        mr_free(tmp);
    936937
    937938        if (bkpinfo->manual_cd_tray) {
     
    943944        }
    944945    } else {
    945         asprintf(&tmp, "%s found; verifying ISO...", fname);
     946        mr_asprintf(&tmp, "%s found; verifying ISO...", fname);
    946947        log_to_screen(tmp);
    947         paranoid_free(tmp);
     948        mr_free(tmp);
    948949#ifdef __FreeBSD__
    949950        ret = 0;
     
    951952        mddevice = make_vn(fname);
    952953        if (ret) {
    953             asprintf(&tmp, _("make_vn of %s failed; unable to verify ISO\n"),
     954            mr_asprintf(&tmp, _("make_vn of %s failed; unable to verify ISO\n"),
    954955                     fname);
    955956            log_to_screen(tmp);
    956             paranoid_free(tmp);
     957            mr_free(tmp);
    957958            return (1);
    958959        }
    959         asprintf(&command, "mount_cd9660 %s %s", mddevice, mountpoint);
     960        mr_asprintf(&command, "mount_cd9660 %s %s", mddevice, mountpoint);
    960961#else
    961         asprintf(&command, "mount -o loop,ro -t iso9660 %s %s", fname,
     962        mr_asprintf(&command, "mount -o loop,ro -t iso9660 %s %s", fname,
    962963                 mountpoint);
    963964#endif
    964965        if (run_program_and_log_output(command, FALSE)) {
    965             asprintf(&tmp, _("%s failed; unable to mount ISO image\n"),
     966            mr_asprintf(&tmp, _("%s failed; unable to mount ISO image\n"),
    966967                     command);
    967968            log_to_screen(tmp);
    968             paranoid_free(tmp);
     969            mr_free(tmp);
    969970            return (1);
    970971        }
    971         paranoid_free(command);
     972        mr_free(command);
    972973    }
    973974    log_msg(2, "OK, I've mounted the ISO/CD\n");
    974     asprintf(&tmp, "%s/archives/NOT-THE-LAST", mountpoint);
     975    mr_asprintf(&tmp, "%s/archives/NOT-THE-LAST", mountpoint);
    975976    if (!does_file_exist(tmp)) {
    976977        log_msg
     
    984985*/
    985986    }
    986     paranoid_free(tmp);
     987    mr_free(tmp);
    987988
    988989    verify_afioballs_on_CD(bkpinfo, mountpoint);
     
    992993#ifdef __FreeBSD__
    993994    ret = 0;
    994     asprintf(&command, "umount %s", mountpoint);
     995    mr_asprintf(&command, "umount %s", mountpoint);
    995996    ret += system(command);
    996997
     
    998999    if (ret)
    9991000#else
    1000     asprintf(&command, "umount %s", mountpoint);
     1001    mr_asprintf(&command, "umount %s", mountpoint);
    10011002
    10021003    if (system(command))
    10031004#endif
    10041005    {
    1005         asprintf(&tmp, "%s failed; unable to unmount ISO image\n",
     1006        mr_asprintf(&tmp, "%s failed; unable to unmount ISO image\n",
    10061007                 command);
    10071008        log_to_screen(tmp);
    1008         paranoid_free(tmp);
     1009        mr_free(tmp);
    10091010        retval++;
    10101011    } else {
    10111012        log_msg(2, "OK, I've unmounted the ISO file\n");
    10121013    }
    1013     paranoid_free(command);
    1014     paranoid_free(mountpoint);
     1014    mr_free(command);
     1015    mr_free(mountpoint);
    10151016
    10161017    if (!does_file_exist(fname)) {
    1017         asprintf(&command, "umount %s", bkpinfo->media_device);
     1018        mr_asprintf(&command, "umount %s", bkpinfo->media_device);
    10181019        run_program_and_log_output(command, 2);
    1019         paranoid_free(command);
     1020        mr_free(command);
    10201021
    10211022        if (!bkpinfo->please_dont_eject
     
    10241025        }
    10251026    }
    1026     paranoid_free(fname);
     1027    mr_free(fname);
    10271028    return (retval);
    10281029}
     
    10681069    paranoid_system
    10691070        ("rm -f /tmp/biggies.changed /tmp/changed.files.[0-9]* 2> /dev/null");
    1070     asprintf(&changed_files_fname, "/tmp/changed.files.%d",
     1071    mr_asprintf(&changed_files_fname, "/tmp/changed.files.%d",
    10711072             (int) (random() % 32767));
    1072     asprintf(&tmp,
     1073    mr_asprintf(&tmp,
    10731074             "grep -x \"%s:.*\" %s | cut -d'\"' -f2 | sort -u | awk '{print \"/\"$0;};' | tr -s '/' '/' | grep -v \"(total of\" | grep -v \"incheckentry.*xwait\" | grep -vx \"/afio:.*\" | grep -vx \"dev/.*\"  > %s",
    10741075             (bkpinfo->use_star) ? "star" : "afio", MONDO_LOGFILE,
     
    10861087        }
    10871088    }
    1088     paranoid_free(tmp);
    1089 
    1090     asprintf(&tmp, "cat /tmp/biggies.changed >> %s", changed_files_fname);
     1089    mr_free(tmp);
     1090
     1091    mr_asprintf(&tmp, "cat /tmp/biggies.changed >> %s", changed_files_fname);
    10911092    paranoid_system(tmp);
    1092     paranoid_free(tmp);
     1093    mr_free(tmp);
    10931094
    10941095    diffs = count_lines_in_file(changed_files_fname);
    10951096    if (diffs > 0) {
    1096         asprintf(&tmp, "cp -f %s %s", changed_files_fname,
     1097        mr_asprintf(&tmp, "cp -f %s %s", changed_files_fname,
    10971098                 "/tmp/changed.files");
    10981099        run_program_and_log_output(tmp, FALSE);
    1099         paranoid_free(tmp);
    1100 
    1101         asprintf(&tmp,
     1100        mr_free(tmp);
     1101
     1102        mr_asprintf(&tmp,
    11021103                 "%ld files differed from live filesystem; type less %s or less %s to see",
    11031104                 diffs, changed_files_fname, "/tmp/changed.files");
    11041105        log_msg(0, tmp);
    1105         paranoid_free(tmp);
     1106        mr_free(tmp);
    11061107
    11071108        log_to_screen
     
    11111112        //      retval++;
    11121113    }
    1113     paranoid_free(changed_files_fname);
     1114    mr_free(changed_files_fname);
    11141115    return (retval);
    11151116}
     
    11331134    assert(bkpinfo != NULL);
    11341135    assert_string_is_neither_NULL_nor_zerolength(mountpoint);
    1135     asprintf(&output, "%s/archives/%d.star.%s", mountpoint, setno,
     1136    mr_asprintf(&output, "%s/archives/%d.star.%s", mountpoint, setno,
    11361137             bkpinfo->zip_suffix);
    11371138    if (!does_file_exist(output)) {
    1138         paranoid_free(output);
    1139         asprintf(&output, "%s/archives/%d.afio.%s", mountpoint, setno,
     1139        mr_free(output);
     1140        mr_asprintf(&output, "%s/archives/%d.afio.%s", mountpoint, setno,
    11401141                 bkpinfo->zip_suffix);
    11411142    }
  • trunk/mondo/src/common/mondostructures.h

    r783 r900  
    773773    int mindi_ia64_boot_size;
    774774    char *mondo_iso_creation_cmd;
    775 };
     775    char *mondo_logfile;
     776};
  • trunk/mondo/src/common/mr_string.c

    r863 r900  
    11/*
    2  * mr_string.c - New generation of string handling functions
     2 * $Id$
     3 *
     4 * New generation of string handling functions
    35 */
    46
     
    98100
    99101    return retstr;
    100 
    101102}
  • trunk/mondo/src/common/newt-specific.c

    r838 r900  
    2626#include "libmondo-fork-EXT.h"
    2727#include "newt-specific-EXT.h"
     28#include "mr_mem.h"
    2829
    2930/*@unused@*/
     
    116117                    ("---promptdialogYN---1--- %s\r\n---promptdialogYN---Q--- [yes] [no] ---\r\n--> ",
    117118                     prompt);
    118                 (void) getline(&tmp, &n, stdin);
     119                mr_getline(&tmp, &n, stdin);
    119120                if (tmp[strlen(tmp) - 1] == '\n')
    120121                    tmp[strlen(tmp) - 1] = '\0';
     
    125126                }
    126127                if (strstr(_("yesYES"), tmp)) {
    127                     paranoid_free(tmp);
     128                    mr_free(tmp);
    128129                    return (TRUE);
    129130                } else if (strstr(_("NOno"), tmp)) {
    130                     paranoid_free(tmp);
     131                    mr_free(tmp);
    131132                    return (FALSE);
    132133                } else {
     
    161162                ("---promptdialogOKC---1--- %s\r\n---promptdialogOKC---Q--- [OK] [Cancel] ---\r\n--> ",
    162163                 prompt);
    163             (void) getline(&tmp, &n, stdin);
     164            mr_getline(&tmp, &n, stdin);
    164165            if (tmp[strlen(tmp) - 1] == '\n')
    165166                tmp[strlen(tmp) - 1] = '\0';
     
    170171            }
    171172            if (strstr(_("okOKOkYESyes"), tmp)) {
    172                 paranoid_free(tmp);
     173                mr_free(tmp);
    173174                return (TRUE);
    174175            } else {
    175                 paranoid_free(tmp);
     176                mr_free(tmp);
    176177                return (FALSE);
    177178            }
     
    243244    char *tmp = NULL;
    244245
    245     asprintf(&tmp,"kill `ps %s | grep \" %s \" | awk '{print $1;}' | grep -vx \"\\?\"`", ps_options, str);
     246    mr_asprintf(&tmp,"kill `ps %s | grep \" %s \" | awk '{print $1;}' | grep -vx \"\\?\"`", ps_options, str);
    246247run_program_and_log_output(tmp, TRUE);
    247     paranoid_free(tmp);
     248    mr_free(tmp);
    248249}
    249250
     
    264265        /*@ end vars **************************************************** */
    265266
    266         asprintf(&fatalstr, "-------FATAL ERROR---------");
     267        mr_asprintf(&fatalstr, "-------FATAL ERROR---------");
    267268        set_signals(FALSE);     // link to external func
    268269        g_exiting = TRUE;
     
    297298        sync();
    298299        if (g_tmpfs_mountpt != NULL) {
    299             asprintf(&tmp, "umount %s", g_tmpfs_mountpt);
     300            mr_asprintf(&tmp, "umount %s", g_tmpfs_mountpt);
    300301            chdir("/");
    301302            for (i = 0; i < 10 && run_program_and_log_output(tmp, 5); i++) {
     
    304305                run_program_and_log_output(tmp, 5);
    305306            }
    306             paranoid_free(tmp);
     307            mr_free(tmp);
    307308        }
    308309
     
    312313
    313314        if (g_selfmounted_isodir) {
    314             asprintf(&command, "umount %s", g_selfmounted_isodir);
     315            mr_asprintf(&command, "umount %s", g_selfmounted_isodir);
    315316            run_program_and_log_output(command, 5);
    316             asprintf(&command, "rmdir %s", g_selfmounted_isodir);
     317            mr_asprintf(&command, "rmdir %s", g_selfmounted_isodir);
    317318            run_program_and_log_output(command, 5);
    318             paranoid_free(g_selfmounted_isodir);
     319            mr_free(g_selfmounted_isodir);
    319320        }
    320321
     
    322323            log_msg(0, fatalstr);
    323324            log_msg(0, error_string);
    324             //      popup_and_OK (error_string);
    325325            newtFinished();
    326326        }
    327327
    328         system
    329             ("gzip -9c "MONDO_LOGFILE" > /tmp/MA.log.gz 2> /dev/null");
    330328        printf
    331329                (_("If you require technical support, please contact the mailing list.\n"));
     
    334332                (_("The list's members can help you, if you attach that file to your e-mail.\n"));
    335333        printf(_("Log file: %s\n"), MONDO_LOGFILE);
    336         if (does_file_exist("/tmp/MA.log.gz")) {
    337             printf
    338                 (_("FYI, I have gzipped the log and saved it to /tmp/MA.log.gz\n"));
    339         }
    340334        printf(_("Mondo has aborted.\n"));
    341335        register_pid(0, "mondo");   // finish() does this too, FYI
     
    357351     finish(int signal) {
    358352        char *command = NULL;
    359 
    360         /*  if (signal==0) { popup_and_OK("Please press <enter> to quit."); } */
    361 
    362         /* newtPopHelpLine(); */
    363353
    364354        register_pid(0, "mondo");
     
    371361        }
    372362        if (g_selfmounted_isodir) {
    373             asprintf(&command, "umount %s", g_selfmounted_isodir);
     363            mr_asprintf(&command, "umount %s", g_selfmounted_isodir);
    374364            run_program_and_log_output(command, 1);
    375             asprintf(&command, "rmdir %s", g_selfmounted_isodir);
     365            mr_asprintf(&command, "rmdir %s", g_selfmounted_isodir);
    376366            run_program_and_log_output(command, 1);
    377             paranoid_free(g_selfmounted_isodir);
    378         }
    379 //  iamhere("foo");
    380         /* system("clear"); */
    381 //  iamhere("About to call newtFinished");
     367            mr_free(g_selfmounted_isodir);
     368        }
    382369        if (!g_text_mode) {
    383370            if (does_file_exist("/THIS-IS-A-RAMDISK")) {
     
    389376            }
    390377        }
    391 //  system("clear");
    392 //  iamhere("Finished calling newtFinished");
    393378        printf(_("Execution run ended; result=%d\n"), signal);
    394379        printf(_("Type 'less %s' to see the output log\n"), MONDO_LOGFILE);
     
    428413        }
    429414        if (grep_for_me[0] != '\0') {
    430             asprintf(&command, "grep '%s' %s | tail -n%d",
     415            mr_asprintf(&command, "grep '%s' %s | tail -n%d",
    431416                     grep_for_me, filename, g_noof_log_lines);
    432417        } else {
    433             asprintf(&command, "tail -n%d %s", g_noof_log_lines, filename);
     418            mr_asprintf(&command, "tail -n%d %s", g_noof_log_lines, filename);
    434419        }
    435420        fin = popen(command, "r");
     
    440425                for (;
    441426                    strlen(err_log_lines[i]) < 2 && !feof(fin);) {
    442                     getline(&(err_log_lines[i]), &n, fin);
     427                    mr_getline(&(err_log_lines[i]), &n, fin);
    443428                    strip_spaces(err_log_lines[i]);
    444429                    if (!strncmp(err_log_lines[i], "root:", 5)) {
    445                         asprintf(&tmp, "%s", err_log_lines[i] + 6);
    446                         paranoid_free(err_log_lines[i]);
     430                        mr_asprintf(&tmp, "%s", err_log_lines[i] + 6);
     431                        mr_free(err_log_lines[i]);
    447432                        err_log_lines[i] = tmp;
    448433                    }
     
    455440        }
    456441        refresh_log_screen();
    457         paranoid_free(command);
     442        mr_free(command);
    458443    }
    459444
     
    477462
    478463        va_start(args, fmt);
    479         vasprintf(&output, fmt, args);
     464        mr_vasprintf(&output, fmt, args);
    480465        log_msg(0, output);
    481466        if (strlen(output) > 80) {
     
    489474
    490475        if (err_log_lines) {
    491             paranoid_free(err_log_lines[0]);
     476            mr_free(err_log_lines[0]);
    492477            for (i = 1; i < g_noof_log_lines; i++) {
    493478                err_log_lines[i - 1] = err_log_lines[i];
     
    549534
    550535        assert(ttl != NULL);
    551         asprintf(&title, ttl);
     536        mr_asprintf(&title, ttl);
    552537        // BERLIOS: We need to unallocate it somewhere
    553         asprintf(&g_isoform_header_str, title);
     538        mr_asprintf(&g_isoform_header_str, title);
    554539        //  center_string (title, 80);
    555540        if (g_text_mode) {
    556541            log_msg(0, title);
    557542        } else {
    558             asprintf(&tmp, title);
     543            mr_asprintf(&tmp, title);
    559544            /* BERLIOS: center_string is now broken replace it ! */
    560545            //center_string(tmp, 80);
    561546            newtPushHelpLine(tmp);
    562             paranoid_free(tmp);
     547            mr_free(tmp);
    563548        }
    564549        /* BERLIOS: center_string is now broken replace it ! */
     
    581566        }
    582567        update_evalcall_form(0);
    583         paranoid_free(title);
     568        mr_free(title);
    584569    }
    585570
     
    613598        assert(b3 != NULL);
    614599
    615         asprintf(&blurb1, b1);
    616         asprintf(&blurb2, b2);
    617         asprintf(&blurb3, b3);
    618         asprintf(&b1c, b1);
     600        mr_asprintf(&blurb1, b1);
     601        mr_asprintf(&blurb2, b2);
     602        mr_asprintf(&blurb3, b3);
     603        mr_asprintf(&b1c, b1);
    619604        /* BERLIOS: center_string is now broken replace it ! */
    620605        //center_string(b1c, 80);
     
    627612        g_current_progress = 0;
    628613        // BERLIOS: We need to unallocate them
    629         asprintf(&g_blurb_str_1, blurb1);
    630         asprintf(&g_blurb_str_2, blurb3);
    631         asprintf(&g_blurb_str_3, blurb2);
     614        mr_asprintf(&g_blurb_str_1, blurb1);
     615        mr_asprintf(&g_blurb_str_2, blurb3);
     616        mr_asprintf(&g_blurb_str_3, blurb2);
    632617        if (g_text_mode) {
    633618            log_msg(0, blurb1);
     
    651636        }
    652637        update_progress_form_full(blurb1, blurb2, blurb3);
    653         paranoid_free(b1c);
    654         paranoid_free(blurb1);
    655         paranoid_free(blurb2);
    656         paranoid_free(blurb3);
     638        mr_free(b1c);
     639        mr_free(blurb1);
     640        mr_free(blurb2);
     641        mr_free(blurb3);
    657642    }
    658643
     
    710695                ("---promptstring---1--- %s\r\n---promptstring---2--- %s\r\n---promptstring---Q---\r\n-->  ",
    711696                 title, b);
    712             paranoid_free(output);
    713             (void) getline(&output, &n, stdin);
     697            mr_free(output);
     698            mr_getline(&output, &n, stdin);
    714699            if (output[strlen(output) - 1] == '\n')
    715700                output[strlen(output) - 1] = '\0';
    716701            return (ret);
    717702        }
    718         asprintf(&blurb, b);
     703        mr_asprintf(&blurb, b);
    719704        text = newtTextboxReflowed(2, 1, blurb, 48, 5, 5, 0);
    720705
     
    732717        //center_string(blurb, 80);
    733718        newtPushHelpLine(blurb);
    734         paranoid_free(blurb);
     719        mr_free(blurb);
    735720
    736721        b_res = newtRunForm(myForm);
     
    741726            // Copy entry_value before destroying the form
    742727            // clearing potentially output before
    743             paranoid_alloc(output,*entry_value);
     728            mr_allocstr(output,*entry_value);
    744729        }
    745730        newtFormDestroy(myForm);
     
    779764                printf("%s (%s or %s) --> ", p, button1, button2);
    780765            }
    781             for (asprintf(&tmp, " ");
     766            for (mr_asprintf(&tmp, " ");
    782767                 strcmp(tmp, button1) && (strlen(button2) == 0
    783768                                          || strcmp(tmp, button2));) {
    784769                printf("--> ");
    785                 paranoid_free(tmp);
    786                 (void) getline(&tmp, &n, stdin);
     770                mr_free(tmp);
     771                mr_getline(&tmp, &n, stdin);
    787772            }
    788773            if (!strcmp(tmp, button1)) {
    789                 paranoid_free(tmp);
     774                mr_free(tmp);
    790775                return (TRUE);
    791776            } else {
    792                 paranoid_free(tmp);
     777                mr_free(tmp);
    793778                return (FALSE);
    794779            }
    795780        }
    796781
    797         asprintf(&prompt, p);
     782        mr_asprintf(&prompt, p);
    798783        text = newtTextboxReflowed(1, 1, prompt, 40, 5, 5, 0);
    799784        b_1 =
     
    816801        //center_string(prompt, 80);
    817802        newtPushHelpLine(prompt);
    818         paranoid_free(prompt);
     803        mr_free(prompt);
    819804        b_res = newtRunForm(myForm);
    820805        newtPopHelpLine();
     
    943928            || percentage > g_isoform_old_progress) {
    944929            g_isoform_old_progress = percentage;
    945             asprintf(&timeline_str,
     930            mr_asprintf(&timeline_str,
    946931                     _("%2ld:%02ld taken            %2ld:%02ld remaining"),
    947932                     time_taken / 60, time_taken % 60, time_remaining / 60,
     
    968953                *p = '\0';
    969954
    970                 asprintf(&pcline_str, " Working%s%s %c", tmp1, tmp2,
     955                mr_asprintf(&pcline_str, " Working%s%s %c", tmp1, tmp2,
    971956                         special_dot_char(g_mysterious_dot_counter));
    972                 paranoid_free(tmp1);
    973                 paranoid_free(tmp2);
     957                mr_free(tmp1);
     958                mr_free(tmp2);
    974959            } else {
    975                 asprintf(&pcline_str,
     960                mr_asprintf(&pcline_str,
    976961                         _(" %3d%% done              %3d%% to go"),
    977962                         percentage, 100 - percentage);
     
    992977
    993978                if (percentage >= 3) {
    994                     asprintf(&taskprogress,
     979                    mr_asprintf(&taskprogress,
    995980                             "TASK:  [%s%s] %3d%% done; %2ld:%02ld to go",
    996981                             tmp1, tmp2, percentage, time_remaining / 60,
     
    1000985                    printf("---evalcall---2--- %s\r\n", taskprogress);
    1001986                    printf("---evalcall---E---\r\n");
    1002                     paranoid_free(taskprogress);
     987                    mr_free(taskprogress);
    1003988                }
    1004989            } else {
     
    1010995                }
    1011996            }
    1012             paranoid_free(timeline_str);
    1013             paranoid_free(pcline_str);
     997            mr_free(timeline_str);
     998            mr_free(pcline_str);
    1014999        }
    10151000        if (!g_text_mode) {
     
    10321017            return;
    10331018        }
    1034         paranoid_free(g_blurb_str_2);
    1035         asprintf(&g_blurb_str_2, blurb3);
     1019        mr_free(g_blurb_str_2);
     1020        mr_asprintf(&g_blurb_str_2, blurb3);
    10361021        update_progress_form_full(g_blurb_str_1, g_blurb_str_2,
    10371022                                  g_blurb_str_3);
     
    10811066        } else {
    10821067            if (g_current_progress > g_maximum_progress) {
    1083                 asprintf(&tmp,
     1068                mr_asprintf(&tmp,
    10841069                         "update_progress_form_full(%s,%s,%s) --- g_current_progress=%ld; g_maximum_progress=%ld",
    10851070                         blurb1, blurb2, blurb3, g_current_progress,
    10861071                         g_maximum_progress);
    10871072                log_msg(0, tmp);
    1088                 paranoid_free(tmp);
     1073                mr_free(tmp);
    10891074                g_current_progress = g_maximum_progress;
    10901075            }
     
    11081093        /* BERLIOS/ Is it useful here ? */
    11091094        //g_mysterious_dot_counter = (g_mysterious_dot_counter + 1) % 27;
    1110         asprintf(&timeline_str,
     1095        mr_asprintf(&timeline_str,
    11111096                 "%2ld:%02ld taken               %2ld:%02ld remaining  ",
    11121097                 time_taken / 60, time_taken % 60, time_remaining / 60,
    11131098                 time_remaining % 60);
    1114         asprintf(&percentline_str,
     1099        mr_asprintf(&percentline_str,
    11151100                 " %3d%% done                 %3d%% to go", percentage,
    11161101                 100 - percentage);
     
    11381123                log_msg(2, _("percentage = %d"), percentage);
    11391124            }
    1140             asprintf(&taskprogress,
     1125            mr_asprintf(&taskprogress,
    11411126                     _("TASK:  [%s%s] %3d%% done; %2ld:%02ld to go"), tmp1,
    11421127                     tmp2, percentage, time_remaining / 60,
     
    11441129
    11451130            printf(_("---progress-form---4--- %s\r\n"), taskprogress);
    1146             paranoid_free(taskprogress);
     1131            mr_free(taskprogress);
    11471132        } else {
    11481133            /* BERLIOS: center_string is now broken replace it ! */
     
    11621147            newtRefresh();
    11631148        }
    1164         paranoid_free(percentline_str);
    1165         paranoid_free(timeline_str);
     1149        mr_free(percentline_str);
     1150        mr_free(timeline_str);
    11661151    }
    11671152
     
    12141199                }
    12151200                printf(")\n--> ");
    1216                 (void) getline(&outstr, &n, stdin);
     1201                mr_getline(&outstr, &n, stdin);
    12171202                strip_spaces(outstr);
    12181203                for (i = 0; possible_responses[i]; i++) {
     
    12221207                }
    12231208            }
    1224             paranoid_free(outstr);
     1209            mr_free(outstr);
    12251210            return (backup_type);
    12261211        }
    12271212        newtDrawRootText(18, 0, WELCOME_STRING);
    12281213        if (restoring) {
    1229             asprintf(&title_sz,
     1214            mr_asprintf(&title_sz,
    12301215                     _("Please choose the backup media from which you want to read data."));
    1231             asprintf(&minimsg_sz, _("Read from:"));
    1232         } else {
    1233             asprintf(&title_sz,
     1216            mr_asprintf(&minimsg_sz, _("Read from:"));
     1217        } else {
     1218            mr_asprintf(&title_sz,
    12341219                     _("Please choose the backup media to which you want to archive data."));
    1235             asprintf(&minimsg_sz, _("Backup to:"));
     1220            mr_asprintf(&minimsg_sz, _("Backup to:"));
    12361221        }
    12371222        newtPushHelpLine(title_sz);
    1238         paranoid_free(title_sz);
     1223        mr_free(title_sz);
    12391224
    12401225        //  newtOpenWindow (23, 3, 34, 17, minimsg_sz);
    12411226        newtCenteredWindow(34, 17, minimsg_sz);
    1242         paranoid_free(minimsg_sz);
     1227        mr_free(minimsg_sz);
    12431228
    12441229        b1 = newtButton(1, 1, _("CD-R disks "));
     
    13631348                break;
    13641349            }
    1365             (void) getline(&tmp, &n, fin);
     1350            mr_getline(&tmp, &n, fin);
    13661351            i = (int) strlen(tmp);
    13671352            if (i < 2) {
     
    13851370            filelist->el[filelist->entries].severity =
    13861371                severity_of_difference(tmp, reason);
    1387             paranoid_free(reason);
     1372            mr_free(reason);
    13881373            strcpy(filelist->el[filelist->entries].filename, tmp);
    13891374            if (feof(fin)) {
     
    13941379        if (filelist->entries >= ARBITRARY_MAXIMUM) {
    13951380            log_to_screen(_("Arbitrary limits suck, man!"));
    1396             paranoid_free(tmp);
     1381            mr_free(tmp);
    13971382            return (1);
    13981383        }
    1399         paranoid_free(tmp);
     1384        mr_free(tmp);
    14001385
    14011386        for (done = FALSE; !done;) {
     
    14421427        assert(flentry != NULL);
    14431428        if (flentry->severity == 0) {
    1444             asprintf(&comment, "0     %93s", flentry->filename);
     1429            mr_asprintf(&comment, "0     %93s", flentry->filename);
    14451430        } else if (flentry->severity == 1) {
    1446             asprintf(&comment, "low   %93s", flentry->filename);
     1431            mr_asprintf(&comment, "low   %93s", flentry->filename);
    14471432        } else if (flentry->severity == 2) {
    1448             asprintf(&comment, "med   %93s", flentry->filename);
    1449         } else {
    1450             asprintf(&comment, "high  %93s", flentry->filename);
     1433            mr_asprintf(&comment, "med   %93s", flentry->filename);
     1434        } else {
     1435            mr_asprintf(&comment, "high  %93s", flentry->filename);
    14511436        }
    14521437        iamhere("leaving");
     
    15251510                                   keylist[i]);
    15261511        }
    1527         asprintf(&differ_sz,
     1512        mr_asprintf(&differ_sz,
    15281513                 _("  %ld files differ. Hit 'Select' to pick a file. Hit 'Close' to quit the list."),
    15291514                 i);
    15301515        newtPushHelpLine(differ_sz);
    1531         paranoid_free(differ_sz);
     1516        mr_free(differ_sz);
    15321517
    15331518        bClose = newtCompactButton(10, 15, _(" Close  "));
    15341519        bSelect = newtCompactButton(30, 15, _(" Select "));
    1535         asprintf(&tmp, "%-10s               %-20s", _("Priority"),
     1520        mr_asprintf(&tmp, "%-10s               %-20s", _("Priority"),
    15361521                 _("Filename"));
    15371522        headerMsg = newtLabel(2, 1, tmp);
    1538         paranoid_free(tmp);
     1523        mr_free(tmp);
    15391524
    15401525        newtOpenWindow(5, 4, 70, 16, _("Non-matching files"));
     
    15581543                        severity_of_difference(filelist->el[currline].
    15591544                                               filename, reason);
    1560                         asprintf(&tmp, "%s --- %s",
     1545                        mr_asprintf(&tmp, "%s --- %s",
    15611546                                 filelist->el[currline].filename, reason);
    15621547                        popup_and_OK(tmp);
    1563                         paranoid_free(tmp);
    1564                         paranoid_free(reason);
     1548                        mr_free(tmp);
     1549                        mr_free(reason);
    15651550                    }
    15661551                }
  • trunk/mondo/src/include/mr_str.h

    r895 r900  
    1 /* mr_string.h
    2  *
     1/*
    32 * $Id$
    43 *
    5  *     Header file of mr_string: a set of function manipulating strings
     4 *     Header file of mr_str.c: a set of function manipulating strings
    65 *     Provided under the GPL v2
    76 */
    87
    9 #ifndef MR_STRING_H
    10 #define MR_STRING_H
     8#ifndef MR_STR_H
     9#define MR_STR_H
    1110
    1211/* functions (public methods) */
     
    1514extern char *mr_stresc(char *instr, char *toesc, const char escchr);
    1615
    17 #endif                          /* MR_STRING_H */
     16#endif                          /* MR_STR_H */
  • trunk/mondo/src/include/my-stuff.h

    r849 r900  
    294294 */
    295295#define paranoid_system(x) {if(system(x)) log_msg(4, x); }
    296 
    297 /**
    298  * Free @p x and set it to NULL.
    299  */
    300 #define paranoid_free(x) {if ((x) != NULL) free(x); (x)=NULL;}
    301296
    302297/**
  • trunk/mondo/src/lib/Makefile.am

    r826 r900  
    77noinst_LIBRARIES = libmr.a
    88
    9 libmr_a_SOURCES  = mr_conf.c mr_string.c
     9libmr_a_SOURCES  = mr_conf.c mr_str.c mr_mem.c mr_err.c mr_msg.c
  • trunk/mondo/src/lib/mr_conf.c

    r852 r900  
    1717#include <string.h>
    1818
    19 #include "my-stuff.h"
    20 
    21 /* BERLIOS: instead of this declaration, we need a good include structure */
    22 extern void (*log_debug_msg) (int debug_level, const char *szFile,
    23                               const char *szFunction, int nLine,
    24                               const char *fmt, ...);
     19#include "mr_msg.h"
     20#include "mr_mem.h"
     21#include "mr_gettext.h"
    2522
    2623/* error flags */
     
    7976static FILE *CONF = NULL;       /* Configuration file FD */
    8077
    81 /*if output all error and warnin messages*/
     78/*if output all error and warning messages*/
    8279static int mr_conf_flags = MRCONF_FLAG_VERBOSE;
    8380
     
    9592int mr_conf_open(const char *filename) {
    9693    size_t length;              /*length of the buffer/file */
     94    size_t res = 0;
    9795
    9896    /* check if mr_conf is already opened? */
     
    126124    /*reading file in buffer (skip all 0 characters) */
    127125
    128     (void) fread(buffer, sizeof(char), length, CONF);
     126    res = fread(buffer, sizeof(char), length, CONF);
    129127    buffer[length] = (char) 0;  /*finalize the string */
    130128
     
    146144        mr_conf_error_msg(MRCONF_CLOSE_BUT_NOT_OPEN, NULL);
    147145    }
    148     paranoid_free(buffer);
     146    mr_free(buffer);
    149147    fclose(CONF);
    150148
     
    215213/*
    216214  reads string outstr after string str in the current file (between
    217   "..."), not more than maxlength simbols: cannot check if outstr has
     215  "..."), not more than maxlength symbols: cannot check if outstr has
    218216  enough length! It must be at least maxlength+1 ! Returns number of
    219217  read chars
     
    233231        return(p);
    234232    }
    235     asprintf(&q, p);
     233    mr_asprintf(&q, p);
    236234
    237235    /* trunk at first \n */
     
    252250
    253251    ret[i] = (char) 0;      /*and set its length */
    254     paranoid_free(q);
     252    mr_free(q);
    255253
    256254    return ret;
     
    299297    tmp_buf[k] = (char) 0;      /*and set its length */
    300298
    301     paranoid_free(buffer);
     299    mr_free(buffer);
    302300    /*copy filtered data to the buffer */
    303301    buffer = tmp_buf;
     
    339337        switch (error_code) {
    340338        case MRCONF_BAD_FILE:
    341             log_msg(4, "%s %s %s\n", MRCONF_STR_ERROR, MRCONF_STR_BAD_FILE,
     339            mr_msg(0,"%s %s %s\n", MRCONF_STR_ERROR, MRCONF_STR_BAD_FILE,
    342340                   add_line);
    343341            break;
    344342
    345343        case MRCONF_ALLOC_FAILED:
    346             log_msg(4, "%s %s\n", MRCONF_STR_ERROR, MRCONF_STR_ALLOC_FAILED);
     344            mr_msg(0,"%s %s\n", MRCONF_STR_ERROR, MRCONF_STR_ALLOC_FAILED);
    347345            break;
    348346
    349347        case MRCONF_READING_FAILED:
    350             log_msg(4, "%s %s\n", MRCONF_STR_ERROR, MRCONF_STR_READING_FAILED);
     348            mr_msg(0,"%s %s\n", MRCONF_STR_ERROR, MRCONF_STR_READING_FAILED);
    351349            break;
    352350
    353351        case MRCONF_FIELD_NOT_FOUND:
    354             log_msg(4, "%s %s \"%s\"\n", MRCONF_STR_ERROR,
    355                    MRCONF_STR_FIELD_NOT_FOUND, add_line);
    356             log_msg(4, "%s %s\n", MRCONF_STR_WARNING, MRCONF_STR_SET_TO_ZERO);
     352            mr_msg(1,"%s %s \"%s\"\n", MRCONF_STR_ERROR, MRCONF_STR_FIELD_NOT_FOUND, add_line);
     353            mr_msg(1,"%s %s\n", MRCONF_STR_WARNING, MRCONF_STR_SET_TO_ZERO);
    357354            break;
    358355
    359356        case MRCONF_FIELD_NO_VALUE:
    360             log_msg(4, "%s %s \"%s\"\n", MRCONF_STR_ERROR,
    361                    MRCONF_STR_FIELD_NO_VALUE, add_line);
    362             log_msg(4, "%s %s\n", MRCONF_STR_WARNING, MRCONF_STR_IGNORE);
     357            mr_msg(1,"%s %s \"%s\"\n", MRCONF_STR_ERROR, MRCONF_STR_FIELD_NO_VALUE, add_line);
     358            mr_msg(1,"%s %s\n", MRCONF_STR_WARNING, MRCONF_STR_IGNORE);
    363359            break;
    364360
    365361        case MRCONF_CLOSE_BUT_NOT_OPEN:
    366             log_msg(4, "%s %s\n", MRCONF_STR_WARNING,
    367                    MRCONF_STR_CLOSE_BUT_NOT_OPEN);
     362            mr_msg(0,"%s %s\n", MRCONF_STR_WARNING, MRCONF_STR_CLOSE_BUT_NOT_OPEN);
    368363            break;
    369364
    370365        case MRCONF_CALL_BUT_NOT_OPEN:
    371             log_msg(4, "%s %s\n", MRCONF_STR_WARNING,
    372                    MRCONF_STR_CALL_BUT_NOT_OPEN);
     366            mr_msg(0,"%s %s\n", MRCONF_STR_WARNING, MRCONF_STR_CALL_BUT_NOT_OPEN);
    373367            break;
    374368
    375369        case MRCONF_OPEN_OPENED:
    376             log_msg(4, "%s %s\n", MRCONF_STR_ERROR, MRCONF_STR_OPEN_OPENED);
     370            mr_msg(0,"%s %s\n", MRCONF_STR_ERROR, MRCONF_STR_OPEN_OPENED);
    377371            break;
    378372
    379373        default:
    380             log_msg(4, "%s %s\n", MRCONF_STR_ERROR, MRCONF_STR_DEFAULT_ERROR);
    381             break;
    382         }
    383     }
    384 }
     374            mr_msg(1,"%s %s\n", MRCONF_STR_ERROR, MRCONF_STR_DEFAULT_ERROR);
     375            break;
     376        }
     377    }
     378}
  • trunk/mondo/src/mondoarchive/Makefile.am

    r867 r900  
     1## $Id$
    12##
    23## Process with Automake to generate Makefile.in
  • trunk/mondo/src/mondoarchive/main.c

    r815 r900  
    2121#include "../common/libmondo.h"
    2222#include "mondo-cli-EXT.h"
     23
     24#include "mr_mem.h"
    2325
    2426// for CVS
     
    185187
    186188    /* make sure PATH environmental variable allows access to mkfs, fdisk, etc. */
    187     asprintf(&tmp, "/sbin:/usr/sbin:%s:/usr/local/sbin", getenv("PATH"));
     189    mr_asprintf(&tmp, "/sbin:/usr/sbin:%s:/usr/local/sbin", getenv("PATH"));
    188190    setenv("PATH", tmp, 1);
    189     paranoid_free(tmp);
     191    mr_free(tmp);
    190192
    191193    /* Add the ARCH environment variable for ia64 purposes */
     
    236238        turn_wildcard_chars_into_literal_chars(tmp, argv[2]);
    237239        printf("in=%s; out=%s\n", argv[2], tmp);
    238         paranoid_free(tmp);
     240        mr_free(tmp);
    239241        finish(1);
    240242    }
     
    268270            printf(_("CD-RW is at %s\n"), tmp);
    269271        }
    270         paranoid_free(tmp);
     272        mr_free(tmp);
    271273
    272274        if ((tmp = find_cdrom_device(FALSE)) == NULL) {
     
    275277            printf(_("CD-ROM is at %s\n"), tmp);
    276278        }
    277         paranoid_free(tmp);
     279        mr_free(tmp);
    278280        finish(0);
    279281    }
     
    288290            printf(_("DVD is at %s\n"), tmp);
    289291        }
    290         paranoid_free(tmp);
     292        mr_free(tmp);
    291293        finish(0);
    292294    }
     
    345347        retval += res;
    346348        if (res) {
    347             asprintf(&say_at_end,
     349            mr_asprintf(&say_at_end,
    348350                   _("Data archived. Please check the logs, just as a precaution. "));
    349351        } else {
    350             asprintf(&say_at_end, _("Data archived OK. "));
     352            mr_asprintf(&say_at_end, _("Data archived OK. "));
    351353        }
    352354    }
     
    356358        res = verify_data(bkpinfo);
    357359        if (res < 0) {
    358             asprintf(&say_at_end, _("%d difference%c found."), -res,
     360            mr_asprintf(&say_at_end, _("%d difference%c found."), -res,
    359361                    (-res != 1) ? 's' : ' ');
    360362            res = 0;
     
    399401    }
    400402    log_to_screen(say_at_end);
    401     paranoid_free(say_at_end);
    402 
    403     asprintf(&tmp, "umount %s/tmpfs", bkpinfo->tmpdir);
     403    mr_free(say_at_end);
     404
     405    mr_asprintf(&tmp, "umount %s/tmpfs", bkpinfo->tmpdir);
    404406    run_program_and_log_output(tmp, TRUE);
    405     paranoid_free(tmp);
    406 
    407     asprintf(&g_erase_tmpdir_and_scratchdir, "rm -Rf %s %s", bkpinfo->tmpdir,
     407    mr_free(tmp);
     408
     409    mr_asprintf(&g_erase_tmpdir_and_scratchdir, "rm -Rf %s %s", bkpinfo->tmpdir,
    408410            bkpinfo->scratchdir);
    409411    run_program_and_log_output(g_erase_tmpdir_and_scratchdir, TRUE);
     
    424426    system(g_erase_tmpdir_and_scratchdir);
    425427    free_libmondo_global_strings();
    426     paranoid_free(bkpinfo);
     428    mr_free((void *)bkpinfo);
    427429
    428430    unlink("/tmp/filelist.full");
  • trunk/mondo/src/mondoarchive/mondo-cli.c

    r815 r900  
    1414#include <pthread.h>
    1515#endif
     16#include "mr_mem.h"
    1617
    1718extern int g_loglevel;
     
    8283    for (i = 0; i < 128; i++) {
    8384        if (flag_set[i]) {
    84             asprintf(&tmp, "-%c %s", i, flag_val[i]);
     85            mr_asprintf(&tmp, "-%c %s", i, flag_val[i]);
    8586            log_msg(3, tmp);
    86             paranoid_free(tmp);
     87            mr_free(tmp);
    8788        }
    8889    }
    8990//    }
    90     asprintf(&tmp, "rm -Rf %s/mondo.tmp.*", bkpinfo->tmpdir);
     91    mr_asprintf(&tmp, "rm -Rf %s/mondo.tmp.*", bkpinfo->tmpdir);
    9192    paranoid_system(tmp);
    92     paranoid_free(tmp);
    93 
    94     asprintf(&tmp, "rm -Rf %s/mondo.scratch.*", bkpinfo->scratchdir);
     93    mr_free(tmp);
     94
     95    mr_asprintf(&tmp, "rm -Rf %s/mondo.scratch.*", bkpinfo->scratchdir);
    9596    paranoid_system(tmp);
    96     paranoid_free(tmp);
     97    mr_free(tmp);
    9798
    9899    /* BERLIOS : Useless ???
     
    103104    */
    104105
    105     asprintf(&tmp, "mkdir -p %s/tmpfs", bkpinfo->tmpdir);
     106    mr_asprintf(&tmp, "mkdir -p %s/tmpfs", bkpinfo->tmpdir);
    106107    paranoid_system(tmp);
    107     paranoid_free(tmp);
    108 
    109     asprintf(&tmp, "mkdir -p %s", bkpinfo->scratchdir);
     108    mr_free(tmp);
     109
     110    mr_asprintf(&tmp, "mkdir -p %s", bkpinfo->scratchdir);
    110111    paranoid_system(tmp);
    111     paranoid_free(tmp);
     112    mr_free(tmp);
    112113
    113114    if (bkpinfo->nfs_mount != NULL) {
     
    139140    for (j = 1, p = value; j < MAX_NOOF_MEDIA && strchr(p, ',');
    140141         j++, p = strchr(p, ',') + 1) {
    141         asprintf(&tmp, p);
     142        mr_asprintf(&tmp, p);
    142143        q = strchr(tmp, ',');
    143144        if (q != NULL) {
     
    145146        }
    146147        bkpinfo->media_size[j] = friendly_sizestr_to_sizelong(tmp);
    147         paranoid_free(tmp);
    148 
    149         asprintf(&comment, "media_size[%d] = %ld", j,
     148        mr_free(tmp);
     149
     150        mr_asprintf(&comment, "media_size[%d] = %ld", j,
    150151                bkpinfo->media_size[j]);
    151152        log_msg(3, comment);
    152         paranoid_free(comment);
     153        mr_free(comment);
    153154    }
    154155    for (; j <= MAX_NOOF_MEDIA; j++) {
     
    245246        }
    246247    }
    247     paranoid_free(tmp);
     248    mr_free(tmp);
    248249
    249250    if (flag_set['R']) {
     
    257258        }
    258259    }
    259     paranoid_free(tmp1);
     260    mr_free(tmp1);
    260261
    261262    if (flag_set['W']) {
     
    276277            bkpinfo->include_paths = NULL;
    277278        }
    278         asprintf(&tmp1, flag_val['I']);
     279        mr_asprintf(&tmp1, flag_val['I']);
    279280        p = tmp1;
    280281        q = tmp1;
     
    298299            }
    299300        }
    300         paranoid_free(tmp1);
     301        mr_free(tmp1);
    301302
    302303        if (bkpinfo->include_paths == NULL) {
    303             asprintf(&tmp1, "%s", flag_val['I']);
     304            mr_asprintf(&tmp1, "%s", flag_val['I']);
    304305        } else {
    305             asprintf(&tmp1, "%s %s", bkpinfo->include_paths, flag_val['I']);
    306         }
    307         paranoid_alloc(bkpinfo->include_paths,tmp1);
    308         paranoid_free(tmp1);
     306            mr_asprintf(&tmp1, "%s %s", bkpinfo->include_paths, flag_val['I']);
     307        }
     308        mr_allocstr(bkpinfo->include_paths,tmp1);
     309        mr_free(tmp1);
    309310
    310311        log_msg(1, "include_paths is now '%s'", bkpinfo->include_paths);
     
    328329        }
    329330        bkpinfo->make_filelist = FALSE;
    330         paranoid_alloc(bkpinfo->include_paths, flag_val['J']);
     331        mr_allocstr(bkpinfo->include_paths, flag_val['J']);
    331332    }
    332333
     
    384385        }
    385386        flag_set['d'] = TRUE;
    386         paranoid_free(tmp); // allocation from find_tape_device_and_size
    387 
    388         asprintf(&tmp,
     387        mr_free(tmp); // allocation from find_tape_device_and_size
     388
     389        mr_asprintf(&tmp,
    389390                _("You didn't specify a tape streamer device. I'm assuming %s"),
    390391                flag_val['d']);
    391392        log_to_screen(tmp);
    392         paranoid_free(tmp);
     393        mr_free(tmp);
    393394        percent = 0;
    394395    }
     
    412413        }
    413414        if (!flag_set['s']) {
    414             asprintf(&flag_val['s'], "%dm", DEFAULT_DVD_DISK_SIZE); // 4.7 salesman's GB = 4.482 real GB = 4582 MB
     415            mr_asprintf(&flag_val['s'], "%dm", DEFAULT_DVD_DISK_SIZE);  // 4.7 salesman's GB = 4.482 real GB = 4582 MB
    415416            log_to_screen
    416417                (_("You did not specify a size (-s) for DVD. I'm guessing %s."),
     
    454455    }
    455456    if (flag_set['n']) {
    456         paranoid_alloc(bkpinfo->nfs_mount,flag_val['n']);
     457        mr_allocstr(bkpinfo->nfs_mount,flag_val['n']);
    457458        if (!flag_set['d']) {
    458             paranoid_alloc(bkpinfo->nfs_remote_dir,"/");
    459         }
    460         asprintf(&tmp, "mount | grep -x \"%s .*\" | cut -d' ' -f3",
     459            mr_allocstr(bkpinfo->nfs_remote_dir,"/");
     460        }
     461        mr_asprintf(&tmp, "mount | grep -x \"%s .*\" | cut -d' ' -f3",
    461462                bkpinfo->nfs_mount);
    462         paranoid_free(bkpinfo->isodir);
     463        mr_free(bkpinfo->isodir);
    463464        bkpinfo->isodir = call_program_and_get_last_line_of_output(tmp);
    464         paranoid_free(tmp);
     465        mr_free(tmp);
    465466
    466467        if (strlen(bkpinfo->isodir) < 3) {
     
    503504
    504505    if (flag_set['E']) {
    505         asprintf(&tmp1, flag_val['E']);
     506        mr_asprintf(&tmp1, flag_val['E']);
    506507        p = tmp1;
    507508        q = tmp1;
     
    531532            }
    532533        }
    533         paranoid_free(tmp1);
     534        mr_free(tmp1);
    534535
    535536        if (bkpinfo->exclude_paths == NULL) {
    536             asprintf(&tmp1, "%s", flag_val['E']);
     537            mr_asprintf(&tmp1, "%s", flag_val['E']);
    537538        } else {
    538             asprintf(&tmp1, "%s %s", bkpinfo->exclude_paths, flag_val['E']);
    539         }
    540         paranoid_alloc(bkpinfo->exclude_paths,tmp1);
    541         paranoid_free(tmp1);
     539            mr_asprintf(&tmp1, "%s %s", bkpinfo->exclude_paths, flag_val['E']);
     540        }
     541        mr_allocstr(bkpinfo->exclude_paths,tmp1);
     542        mr_free(tmp1);
    542543    }
    543544
     
    550551        psz = list_of_NFS_mounts_only();
    551552        if (bkpinfo->exclude_paths != NULL) {
    552             asprintf(&tmp1, "%s %s", bkpinfo->exclude_paths, psz);
     553            mr_asprintf(&tmp1, "%s %s", bkpinfo->exclude_paths, psz);
    553554        } else {
    554             asprintf(&tmp1, "%s", psz);
    555         }
    556         paranoid_free(psz);
    557         paranoid_alloc(bkpinfo->exclude_paths, tmp1);
    558         paranoid_free(tmp1);
     555            mr_asprintf(&tmp1, "%s", psz);
     556        }
     557        mr_free(psz);
     558        mr_allocstr(bkpinfo->exclude_paths, tmp1);
     559        mr_free(tmp1);
    559560
    560561        log_msg(3, "-N means we're now excluding %s",
     
    563564
    564565    if (flag_set['b']) {
    565         asprintf(&psz, flag_val['b']);
     566        mr_asprintf(&psz, flag_val['b']);
    566567        log_msg(1, "psz = '%s'", psz);
    567568        if (psz[strlen(psz) - 1] == 'k') {
     
    571572            itbs = atol(psz);
    572573        }
    573         paranoid_free(psz);
     574        mr_free(psz);
    574575
    575576        log_msg(1, "'%s' --> %ld", flag_val['b'], itbs);
     
    592593
    593594    if (flag_set['x']) {
    594         paranoid_alloc(bkpinfo->image_devs,flag_val['x']);
     595        mr_allocstr(bkpinfo->image_devs,flag_val['x']);
    595596        if (run_program_and_log_output("which ntfsclone", 2)) {
    596597            fatal_error("Please install ntfsprogs package/tarball.");
     
    604605    if (flag_set['k']) {
    605606        if (strcasecmp(flag_val['k'], "FAILSAFE")) {
    606             paranoid_alloc(bkpinfo->kernel_path,"FAILSAFE");
     607            mr_allocstr(bkpinfo->kernel_path,"FAILSAFE");
    607608
    608609            if (!does_file_exist(bkpinfo->kernel_path)) {
    609610                retval++;
    610                 asprintf(&tmp,
     611                mr_asprintf(&tmp,
    611612                    _("You specified kernel '%s', which does not exist\n"),
    612613                    bkpinfo->kernel_path);
    613614                log_to_screen(tmp);
    614                 paranoid_free(tmp);
     615                mr_free(tmp);
    615616            }
    616617        } else {
    617             paranoid_alloc(bkpinfo->kernel_path,flag_val['k']);
     618            mr_allocstr(bkpinfo->kernel_path,flag_val['k']);
    618619        }
    619620    }
    620621
    621622    if (flag_set['p']) {
    622         paranoid_alloc(bkpinfo->prefix,flag_val['p']);
     623        mr_allocstr(bkpinfo->prefix,flag_val['p']);
    623624    }
    624625
    625626    if (flag_set['d']) {        /* backup directory (if ISO/NFS) */
    626627        if (flag_set['i']) {
    627             paranoid_alloc(bkpinfo->isodir,flag_val['d']);
    628             asprintf(&tmp, "ls -l %s", bkpinfo->isodir);
     628            mr_allocstr(bkpinfo->isodir,flag_val['d']);
     629            mr_asprintf(&tmp, "ls -l %s", bkpinfo->isodir);
    629630            if (run_program_and_log_output(tmp, FALSE)) {
    630631                fatal_error
    631632                    ("output folder does not exist - please create it");
    632633            }
    633             paranoid_free(tmp);
     634            mr_free(tmp);
    634635        } else if (flag_set['n']) {
    635             paranoid_alloc(bkpinfo->nfs_remote_dir,flag_val['d']);
     636            mr_allocstr(bkpinfo->nfs_remote_dir,flag_val['d']);
    636637        } else {                /* backup device (if tape/CD-R/CD-RW) */
    637638
    638             paranoid_alloc(bkpinfo->media_device, flag_val['d']);
     639            mr_allocstr(bkpinfo->media_device, flag_val['d']);
    639640        }
    640641    }
    641642
    642643    if (flag_set['n']) {
    643         asprintf(&tmp, "echo hi > %s/%s/.dummy.txt", bkpinfo->isodir,
     644        mr_asprintf(&tmp, "echo hi > %s/%s/.dummy.txt", bkpinfo->isodir,
    644645                bkpinfo->nfs_remote_dir);
    645646        if (run_program_and_log_output(tmp, FALSE)) {
    646647            retval++;
    647             paranoid_free(tmp);
    648             asprintf(&tmp,
     648            mr_free(tmp);
     649            mr_asprintf(&tmp,
    649650                    _("Are you sure directory '%s' exists in remote dir '%s'?\nIf so, do you have rights to write to it?\n"),
    650651                    bkpinfo->nfs_remote_dir, bkpinfo->nfs_mount);
    651652            log_to_screen(tmp);
    652653        }
    653         paranoid_free(tmp);
     654        mr_free(tmp);
    654655    }
    655656
     
    664665            }
    665666        } else if ((tmp = find_cdrw_device()) ==  NULL) {
    666             paranoid_alloc(bkpinfo->media_device, tmp);
    667             paranoid_free(tmp);
     667            mr_allocstr(bkpinfo->media_device, tmp);
     668            mr_free(tmp);
    668669            retval++;
    669670            log_to_screen
     
    671672        } else {
    672673            flag_set['d'] = TRUE;
    673             asprintf(&flag_val['d'], bkpinfo->media_device);
     674            mr_asprintf(&flag_val['d'], bkpinfo->media_device);
    674675        }
    675676    }
     
    689690    j = (int) random() % 32768;
    690691    if (flag_set['S']) {
    691         asprintf(&tmp, "%s/mondo.scratch.%d", flag_val['S'], j);
    692         paranoid_free(bkpinfo->scratchdir);
     692        mr_asprintf(&tmp, "%s/mondo.scratch.%d", flag_val['S'], j);
     693        mr_free(bkpinfo->scratchdir);
    693694        bkpinfo->scratchdir = tmp;
    694695    }
    695696    if (flag_set['T']) {
    696         asprintf(&tmp, "%s/mondo.tmp.%d", flag_val['T'], j);
    697         paranoid_free(bkpinfo->tmpdir);
     697        mr_asprintf(&tmp, "%s/mondo.tmp.%d", flag_val['T'], j);
     698        mr_free(bkpinfo->tmpdir);
    698699        bkpinfo->tmpdir = tmp;
    699         asprintf(&tmp, "touch %s/.foo.dat", flag_val['T']);
     700        mr_asprintf(&tmp, "touch %s/.foo.dat", flag_val['T']);
    700701        if (run_program_and_log_output(tmp, 1)) {
    701702            retval++;
     
    704705            fatal_error("I cannot write to the tempdir you specified.");
    705706        }
    706         paranoid_free(tmp);
    707 
    708         asprintf(&tmp, "ln -sf %s/.foo.dat %s/.bar.dat", flag_val['T'],
     707        mr_free(tmp);
     708
     709        mr_asprintf(&tmp, "ln -sf %s/.foo.dat %s/.bar.dat", flag_val['T'],
    709710                flag_val['T']);
    710711        if (run_program_and_log_output(tmp, 1)) {
     
    714715            fatal_error("I cannot write to the tempdir you specified.");
    715716        }
    716         paranoid_free(tmp);
     717        mr_free(tmp);
    717718    }
    718719
    719720    if (flag_set['A']) {
    720         paranoid_alloc(bkpinfo->call_after_iso,flag_val['A']);
     721        mr_allocstr(bkpinfo->call_after_iso,flag_val['A']);
    721722    }
    722723    if (flag_set['B']) {
    723         paranoid_alloc(bkpinfo->call_before_iso,flag_val['B']);
     724        mr_allocstr(bkpinfo->call_before_iso,flag_val['B']);
    724725    }
    725726    if (flag_set['F']) {
     
    753754    if (flag_set['f']) {
    754755        tmp = resolve_softlinks_to_get_to_actual_device_file(flag_val['f']);
    755         paranoid_alloc(bkpinfo->boot_device,tmp);
     756        mr_allocstr(bkpinfo->boot_device,tmp);
    756757    }
    757758    if (flag_set['Q']) {
     
    763764        log_msg(3, "boot loader is %c, residing at %s", i, tmp);
    764765        printf(_("boot loader is %c, residing at %s\n"), i, tmp);
    765         paranoid_free(tmp);
     766        mr_free(tmp);
    766767        finish(0);
    767768    }
    768     paranoid_free(tmp);
     769    mr_free(tmp);
    769770
    770771    if (flag_set['P']) {
    771         paranoid_alloc(bkpinfo->postnuke_tarball,flag_val['P']);
     772        mr_allocstr(bkpinfo->postnuke_tarball,flag_val['P']);
    772773    }
    773774
     
    883884            if (flag_set[optopt]) {
    884885                bad_switches = TRUE;
    885                 asprintf(&tmp, _("Switch -%c previously defined as %s\n"), opt,
     886                mr_asprintf(&tmp, _("Switch -%c previously defined as %s\n"), opt,
    886887                        flag_val[i]);
    887888                log_to_screen(tmp);
    888                 paranoid_free(tmp);
     889                mr_free(tmp);
    889890            } else {
    890891                flag_set[opt] = TRUE;
     
    900901                        if (strchr(flag_val[opt], '/')
    901902                            && flag_val[opt][0] != '/') {
    902                             asprintf(&tmp,
     903                            mr_asprintf(&tmp,
    903904                                    _("-%c flag --- must be absolute path --- '%s' isn't absolute"),
    904905                                    opt, flag_val[opt]);
    905906                            log_to_screen(tmp);
    906                             paranoid_free(tmp);
     907                            mr_free(tmp);
    907908                            bad_switches = TRUE;
    908909                        }
    909910                    }
    910                     asprintf(&flag_val[opt], optarg);
     911                    mr_asprintf(&flag_val[opt], optarg);
    911912                }
    912913            }
     
    915916    for (i = optind; i < argc; i++) {
    916917        bad_switches = TRUE;
    917         asprintf(&tmp, _("Invalid arg -- %s\n"), argv[i]);
     918        mr_asprintf(&tmp, _("Invalid arg -- %s\n"), argv[i]);
    918919        log_to_screen(tmp);
    919         paranoid_free(tmp);
     920        mr_free(tmp);
    920921    }
    921922    return (bad_switches);
     
    946947    switch (sig) {
    947948    case SIGINT:
    948         asprintf(&tmp, _("SIGINT signal received from OS"));
    949         asprintf(&tmp2, _("You interrupted me :-)"));
     949        mr_asprintf(&tmp, _("SIGINT signal received from OS"));
     950        mr_asprintf(&tmp2, _("You interrupted me :-)"));
    950951        break;
    951952    case SIGKILL:
    952         asprintf(&tmp, _("SIGKILL signal received from OS"));
    953         asprintf(&tmp2,
     953        mr_asprintf(&tmp, _("SIGKILL signal received from OS"));
     954        mr_asprintf(&tmp2,
    954955               _("I seriously have no clue how this signal even got to me. Something's wrong with your system."));
    955956        break;
    956957    case SIGTERM:
    957         asprintf(&tmp, _("SIGTERM signal received from OS"));
    958         asprintf(&tmp2, _("Got terminate signal"));
     958        mr_asprintf(&tmp, _("SIGTERM signal received from OS"));
     959        mr_asprintf(&tmp2, _("Got terminate signal"));
    959960        break;
    960961    case SIGHUP:
    961         asprintf(&tmp, _("SIGHUP signal received from OS"));
    962         asprintf(&tmp2, _("Hangup on line"));
     962        mr_asprintf(&tmp, _("SIGHUP signal received from OS"));
     963        mr_asprintf(&tmp2, _("Hangup on line"));
    963964        break;
    964965    case SIGSEGV:
    965         asprintf(&tmp, _("SIGSEGV signal received from OS"));
    966         asprintf(&tmp2,
     966        mr_asprintf(&tmp, _("SIGSEGV signal received from OS"));
     967        mr_asprintf(&tmp2,
    967968               _("Internal programming error. Please send a backtrace as well as your log."));
    968969        break;
    969970    case SIGPIPE:
    970         asprintf(&tmp, _("SIGPIPE signal received from OS"));
    971         asprintf(&tmp2, _("Pipe was broken"));
     971        mr_asprintf(&tmp, _("SIGPIPE signal received from OS"));
     972        mr_asprintf(&tmp2, _("Pipe was broken"));
    972973        break;
    973974    case SIGABRT:
    974         asprintf(&tmp, _("SIGABRT signal received from OS"));
    975         asprintf(&tmp2,
     975        mr_asprintf(&tmp, _("SIGABRT signal received from OS"));
     976        mr_asprintf(&tmp2,
    976977                _("Abort - probably failed assertion. I'm sleeping for a few seconds so you can read the message."));
    977978        break;
    978979    default:
    979         asprintf(&tmp, _("(Unknown)"));
    980         asprintf(&tmp2, _("(Unknown)"));
     980        mr_asprintf(&tmp, _("(Unknown)"));
     981        mr_asprintf(&tmp2, _("(Unknown)"));
    981982    }
    982983
    983984    log_to_screen(tmp);
    984985    log_to_screen(tmp2);
    985     paranoid_free(tmp);
    986     paranoid_free(tmp2);
     986    mr_free(tmp);
     987    mr_free(tmp2);
    987988    if (sig == SIGABRT) {
    988989        sleep(10);
  • trunk/mondo/src/mondorestore/Makefile.am

    r867 r900  
     1## $Id$
    12##
    23## Process with Automake to generate Makefile.in
     
    1415mondorestore_SOURCES  = mondo-prep.c mondo-restore.c mondo-rstr-newt.c \
    1516                        mondo-rstr-compare.c mondo-rstr-tools.c
    16 mondorestore_LDADD    = ${top_builddir}/src/common/libmondo.a  ${top_builddir}/src/lib/libmr.a @MONDORESTORE_STATIC@
    17 
    18 
     17mondorestore_LDADD    = ${top_builddir}/src/common/libmondo.a ${top_builddir}/src/lib/libmr.a @MONDORESTORE_STATIC@
  • trunk/mondo/src/mondorestore/mondo-prep.c

    r783 r900  
    1919#include <math.h>
    2020#include <unistd.h>
     21#include "mr_mem.h"
    2122
    2223
     
    6364        make_list_of_drives_in_mountlist(mountlist, drivelist);
    6465        for (lino = 0; lino < drivelist->entries; lino++) {
    65             asprintf(&command,
     66            mr_asprintf(&command,
    6667                     "dd if=%s bs=512 count=1 2> /dev/null | grep \"%s\"",
    6768                     drivelist->el[lino].device, MONDO_WAS_HERE);
     
    6970                log_msg(1, "Found MONDO_WAS_HERE marker on drive#%d (%s)",
    7071                        lino, drivelist->el[lino].device);
    71                 paranoid_free(command);
     72                mr_free(command);
    7273                break;
    7374            }
    74             paranoid_free(command);
     75            mr_free(command);
    7576        }
    7677
     
    8687            log_to_screen("Please hit 'Enter' to reboot.");
    8788            for (lino = 0; lino < drivelist->entries; lino++) {
    88                 asprintf(&buf, "%s\n", MONDO_WAS_HERE);
     89                mr_asprintf(&buf, "%s\n", MONDO_WAS_HERE);
    8990                fout = fopen(drivelist->el[lino].device, "w+");
    9091                if (!fout) {
     
    101102                    fclose(fout);
    102103                }
    103                 paranoid_free(buf);
     104                mr_free(buf);
    104105            }
    105106            sync();
     
    201202    if (tmp)    // found it :) cool
    202203    {
    203         asprintf(&lvscan_sz, "lvm lvscan");
    204         asprintf(&lvremove_sz, "lvm lvremove");
    205         asprintf(&vgscan_sz, "lvm vgscan");
    206         asprintf(&pvscan_sz, "lvm pvscan");
    207         asprintf(&vgchange_sz, "lvm vgchange");
    208         asprintf(&vgremove_sz, "lvm vgremove");
     204        mr_asprintf(&lvscan_sz, "lvm lvscan");
     205        mr_asprintf(&lvremove_sz, "lvm lvremove");
     206        mr_asprintf(&vgscan_sz, "lvm vgscan");
     207        mr_asprintf(&pvscan_sz, "lvm pvscan");
     208        mr_asprintf(&vgchange_sz, "lvm vgchange");
     209        mr_asprintf(&vgremove_sz, "lvm vgremove");
    209210    } else {
    210         asprintf(&lvscan_sz, "lvscan");
    211         asprintf(&lvremove_sz, "lvremove");
    212         asprintf(&vgscan_sz, "vgscan");
    213         asprintf(&pvscan_sz, "pvscan");
    214         asprintf(&vgchange_sz, "vgchange");
    215         asprintf(&vgremove_sz, "vgremove");
    216     }
    217     paranoid_free(tmp);
    218 
    219     asprintf(&command,
     211        mr_asprintf(&lvscan_sz, "lvscan");
     212        mr_asprintf(&lvremove_sz, "lvremove");
     213        mr_asprintf(&vgscan_sz, "vgscan");
     214        mr_asprintf(&pvscan_sz, "pvscan");
     215        mr_asprintf(&vgchange_sz, "vgchange");
     216        mr_asprintf(&vgremove_sz, "vgremove");
     217    }
     218    mr_free(tmp);
     219
     220    mr_asprintf(&command,
    220221            "for i in `%s | cut -d\"'\" -f2 | sort -r` ; do echo \"Shutting down lv $i\" >> "
    221222            MONDO_LOGFILE "; %s -f $i; done", lvscan_sz, lvremove_sz);
    222     paranoid_free(lvscan_sz);
    223     paranoid_free(lvremove_sz);
     223    mr_free(lvscan_sz);
     224    mr_free(lvremove_sz);
    224225
    225226    run_program_and_log_output(command, 5);
    226     paranoid_free(command);
     227    mr_free(command);
    227228
    228229    sleep(1);
    229     asprintf(&command,
     230    mr_asprintf(&command,
    230231            "for i in `%s | grep -i lvm | cut -d'\"' -f2` ; do %s -a n $i ; %s $i; echo \"Shutting down vg $i\" >> "
    231232            MONDO_LOGFILE "; done", vgscan_sz, vgchange_sz, vgremove_sz);
    232     paranoid_free(vgchange_sz);
    233     paranoid_free(vgremove_sz);
     233    mr_free(vgchange_sz);
     234    mr_free(vgremove_sz);
    234235
    235236    run_program_and_log_output(command, 5);
    236     paranoid_free(command);
     237    mr_free(command);
    237238
    238239    if (just_erase_existing_volumes) {
     
    250251    log_msg(1, "OK, rewound i-want-my-lvm. Doing funky stuff...");
    251252    rewind(fin);
    252     for (getline(&incoming, &n1, fin); !feof(fin); getline(&incoming, &n1, fin)) {
     253    for (mr_getline(&incoming, &n1, fin); !feof(fin); mr_getline(&incoming, &n1, fin)) {
    253254        fgetpos(fin, &orig_pos);
    254255        /* we want to execute lines begining with a # */
     
    264265        if ((p = strstr(incoming, "vgcreate"))) {
    265266            // include next line(s) if they end in /dev (cos we've got a broken i-want-my-lvm)
    266             for (getline(&tmp, &n, fin); !feof(fin); getline(&tmp, &n, fin)) {
     267            for (mr_getline(&tmp, &n, fin); !feof(fin); mr_getline(&tmp, &n, fin)) {
    267268                if (tmp[0] == '#') {
    268269                    fsetpos(fin, &orig_pos);
     
    270271                } else {
    271272                    fgetpos(fin, &orig_pos);
    272                     asprintf(&tmp1, "%s%s", incoming, tmp);
    273                     paranoid_free(incoming);
     273                    mr_asprintf(&tmp1, "%s%s", incoming, tmp);
     274                    mr_free(incoming);
    274275                    incoming = tmp1;
    275276                }
    276277            }
    277             paranoid_free(tmp);
     278            mr_free(tmp);
    278279
    279280            for (q = incoming; *q != '\0'; q++) {
     
    282283                }
    283284            }
    284             asprintf(&tmp1, p + strlen("vgcreate") + 1);
     285            mr_asprintf(&tmp1, p + strlen("vgcreate") + 1);
    285286            for (q = tmp1; *q > 32; q++);
    286287            *q = '\0';
    287288            log_msg(1, "Deleting old entries at /dev/%s", tmp1);
    288             asprintf(&tmp, "rm -Rf /dev/%s", tmp1);
    289             paranoid_free(tmp1);
     289            mr_asprintf(&tmp, "rm -Rf /dev/%s", tmp1);
     290            mr_free(tmp1);
    290291
    291292            run_program_and_log_output(tmp, 1);
    292             paranoid_free(tmp);
     293            mr_free(tmp);
    293294
    294295            run_program_and_log_output(vgscan_sz, 1);
     
    299300        }
    300301        for (p = incoming + 1; *p == ' '; p++);
    301         paranoid_alloc(command,p);
     302        mr_allocstr(command,p);
    302303        for (p = command; *p != '\0'; p++);
    303304        for (; *(p - 1) < 32; p--);
     
    333334            extents = atol(p);
    334335            log_msg(5, "p='%s' --> extents=%ld", p, extents);
    335             paranoid_free(tmp);
     336            mr_free(tmp);
    336337
    337338            p = strstr(command, "-L");
     
    384385            retval++;
    385386        }
    386         asprintf(&tmp, "echo \"%s\" >> /tmp/out.sh", command);
     387        mr_asprintf(&tmp, "echo \"%s\" >> /tmp/out.sh", command);
    387388        system(tmp);
    388         paranoid_free(tmp);
     389        mr_free(tmp);
    389390        sleep(1);
    390391    }
    391392    paranoid_fclose(fin);
    392     paranoid_free(vgscan_sz);
    393     paranoid_free(pvscan_sz);
    394     paranoid_free(command);
    395     paranoid_free(incoming);
     393    mr_free(vgscan_sz);
     394    mr_free(pvscan_sz);
     395    mr_free(command);
     396    mr_free(incoming);
    396397
    397398    log_msg(1, "Closed i-want-my-lvm. Finished doing funky stuff.");
     
    460461                finish(1);
    461462            }
    462             for (getline(&incoming, &n, fin); !feof(fin)
     463            for (mr_getline(&incoming, &n, fin); !feof(fin)
    463464                 && !strstr(incoming, old_mountlist->el[lino].device);
    464                  getline(&incoming, &n, fin));
     465                 mr_getline(&incoming, &n, fin));
    465466            if (!feof(fin)) {
    466                 asprintf(&tmp, "Investigating %s",
     467                mr_asprintf(&tmp, "Investigating %s",
    467468                        old_mountlist->el[lino].device);
    468469                log_it(tmp);
    469                 paranoid_free(tmp);
    470 
    471                 for (getline(&incoming, &n, fin); !feof(fin)
     470                mr_free(tmp);
     471
     472                for (mr_getline(&incoming, &n, fin); !feof(fin)
    472473                     && !strstr(incoming, "raiddev");
    473                      getline(&incoming, &n, fin)) {
     474                     mr_getline(&incoming, &n, fin)) {
    474475                    if (strstr(incoming, OSSWAP("device", "drive"))
    475476                        && !strchr(incoming, '#')) {
     
    478479                        *p = '\0';
    479480                        for (p--; p > incoming && *(p - 1) > 32; p--);
    480                         asprintf(&tmp, "Extrapolating %s", p);
     481                        mr_asprintf(&tmp, "Extrapolating %s", p);
    481482                        log_it(tmp);
    482                         paranoid_free(tmp);
     483                        mr_free(tmp);
    483484
    484485                        for (j = 0;
     
    499500                            new_mountlist->entries++;
    500501                        } else {
    501                             asprintf(&tmp,
     502                            mr_asprintf(&tmp,
    502503                                    "Not adding %s to mountlist: it's already there", p);
    503504                            log_it(tmp);
    504                             paranoid_free(tmp);
     505                            mr_free(tmp);
    505506                        }
    506507                    }
    507508                }
    508509            }
    509             paranoid_free(incoming);
     510            mr_free(incoming);
    510511            paranoid_fclose(fin);
    511512        } else {
     
    566567    }
    567568    // create device list from normal disks followed by spare ones
    568     asprintf(&devices, raidlist->el[i].data_disks.el[0].device);
     569    mr_asprintf(&devices, raidlist->el[i].data_disks.el[0].device);
    569570    for (j = 1; j < raidlist->el[i].data_disks.entries; j++) {
    570         asprintf(&strtmp, "%s", devices);
    571         paranoid_free(devices);
    572         asprintf(&devices, "%s %s", strtmp,
     571        mr_asprintf(&strtmp, "%s", devices);
     572        mr_free(devices);
     573        mr_asprintf(&devices, "%s %s", strtmp,
    573574                 raidlist->el[i].data_disks.el[j].device);
    574         paranoid_free(strtmp);
     575        mr_free(strtmp);
    575576    }
    576577    for (j = 0; j < raidlist->el[i].spare_disks.entries; j++) {
    577         asprintf(&strtmp, "%s", devices);
    578         paranoid_free(devices);
    579         asprintf(&devices, "%s %s", strtmp,
     578        mr_asprintf(&strtmp, "%s", devices);
     579        mr_free(devices);
     580        mr_asprintf(&devices, "%s %s", strtmp,
    580581                 raidlist->el[i].spare_disks.el[j].device);
    581         paranoid_free(strtmp);
     582        mr_free(strtmp);
    582583    }
    583584    // translate RAID level
    584585    if (raidlist->el[i].raid_level == -2) {
    585         asprintf(&level, "multipath");
     586        mr_asprintf(&level, "multipath");
    586587    } else if (raidlist->el[i].raid_level == -1) {
    587         asprintf(&level, "linear");
     588        mr_asprintf(&level, "linear");
    588589    } else {
    589         asprintf(&level, "raid%d", raidlist->el[i].raid_level);
     590        mr_asprintf(&level, "raid%d", raidlist->el[i].raid_level);
    590591    }
    591592    // create RAID device:
     
    594595    // - faulty devices ignored
    595596    // - persistent superblock always used as this is recommended
    596     asprintf(&program,
     597    mr_asprintf(&program,
    597598             "mdadm --create --force --run --auto=yes %s --level=%s --raid-devices=%d",
    598599             raidlist->el[i].raid_device, level,
    599600             raidlist->el[i].data_disks.entries);
    600601    if (raidlist->el[i].parity != -1) {
    601         asprintf(&strtmp, "%s", program);
    602         paranoid_free(program);
     602        mr_asprintf(&strtmp, "%s", program);
     603        mr_free(program);
    603604        switch (raidlist->el[i].parity) {
    604605        case 0:
    605             asprintf(&program, "%s --parity=%s", strtmp, "la");
     606            mr_asprintf(&program, "%s --parity=%s", strtmp, "la");
    606607            break;
    607608        case 1:
    608             asprintf(&program, "%s --parity=%s", strtmp, "ra");
     609            mr_asprintf(&program, "%s --parity=%s", strtmp, "ra");
    609610            break;
    610611        case 2:
    611             asprintf(&program, "%s --parity=%s", strtmp, "ls");
     612            mr_asprintf(&program, "%s --parity=%s", strtmp, "ls");
    612613            break;
    613614        case 3:
    614             asprintf(&program, "%s --parity=%s", strtmp, "rs");
     615            mr_asprintf(&program, "%s --parity=%s", strtmp, "rs");
    615616            break;
    616617        default:
     
    618619            break;
    619620        }
    620         paranoid_free(strtmp);
     621        mr_free(strtmp);
    621622    }
    622623    if (raidlist->el[i].chunk_size != -1) {
    623         asprintf(&strtmp, "%s", program);
    624         paranoid_free(program);
    625         asprintf(&program, "%s --chunk=%d", strtmp,
     624        mr_asprintf(&strtmp, "%s", program);
     625        mr_free(program);
     626        mr_asprintf(&program, "%s --chunk=%d", strtmp,
    626627                 raidlist->el[i].chunk_size);
    627         paranoid_free(strtmp);
     628        mr_free(strtmp);
    628629    }
    629630    if (raidlist->el[i].spare_disks.entries > 0) {
    630         asprintf(&strtmp, "%s", program);
    631         paranoid_free(program);
    632         asprintf(&program, "%s --spare-devices=%d", strtmp,
     631        mr_asprintf(&strtmp, "%s", program);
     632        mr_free(program);
     633        mr_asprintf(&program, "%s --spare-devices=%d", strtmp,
    633634                 raidlist->el[i].spare_disks.entries);
    634         paranoid_free(strtmp);
    635     }
    636     asprintf(&strtmp, "%s", program);
    637     paranoid_free(program);
    638     asprintf(&program, "%s %s", strtmp, devices);
    639     paranoid_free(strtmp);
     635        mr_free(strtmp);
     636    }
     637    mr_asprintf(&strtmp, "%s", program);
     638    mr_free(program);
     639    mr_asprintf(&program, "%s %s", strtmp, devices);
     640    mr_free(strtmp);
    640641    res = run_program_and_log_output(program, 1);
    641642    // free memory
    642     paranoid_free(devices);
    643     paranoid_free(level);
    644     paranoid_free(program);
     643    mr_free(devices);
     644    mr_free(level);
     645    mr_free(program);
    645646    // return to calling instance
    646647    return res;
     
    687688
    688689    if (strstr(format, "raid")) {   // do not form RAID disks; do it to /dev/md* instead
    689         asprintf(&tmp, "Not formatting %s (it is a RAID disk)", device);
     690        mr_asprintf(&tmp, "Not formatting %s (it is a RAID disk)", device);
    690691        log_it(tmp);
    691         paranoid_free(tmp);
     692        mr_free(tmp);
    692693        return (0);
    693694    }
     
    699700#endif
    700701    if (strlen(format) <= 2) {
    701         asprintf(&tmp,
     702        mr_asprintf(&tmp,
    702703                "%s has a really small format type ('%s') - this is probably a hexadecimal string, which would suggest the partition is an image --- I shouldn't format it",
    703704                device, format);
    704705        log_it(tmp);
    705         paranoid_free(tmp);
     706        mr_free(tmp);
    706707        return (0);
    707708    }
    708709    if (is_this_device_mounted(device)) {
    709         asprintf(&tmp, _("%s is mounted - cannot format it       "), device);
     710        mr_asprintf(&tmp, _("%s is mounted - cannot format it       "), device);
    710711        log_to_screen(tmp);
    711         paranoid_free(tmp);
     712        mr_free(tmp);
    712713        return (1);
    713714    }
     
    736737
    737738        if (vinum_started_yet) {
    738             asprintf(&tmp,
     739            mr_asprintf(&tmp,
    739740                    _
    740741                    ("Initializing Vinum device %s (this may take a *long* time)"),
    741742                    device);
    742743            log_to_screen(tmp);
    743             paranoid_free(tmp);
     744            mr_free(tmp);
    744745
    745746            /* format raid partition */
    746             asprintf(&program,
     747            mr_asprintf(&program,
    747748                    "for plex in `vinum lv -r %s | grep '^P' | tr '\t' ' ' | tr -s ' ' | cut -d' ' -f2`; do echo $plex; done > /tmp/plexes",
    748749                    basename(device));
     
    752753                fprintf(g_fprep, "%s\n", program);
    753754            }
    754             paranoid_free(program);
     755            mr_free(program);
    755756
    756757            fin = fopen("/tmp/plexes", "r");
    757             while (getline(&line, &n, fin)) {
     758            while (mr_getline(&line, &n, fin)) {
    758759                if (strchr(line, '\n'))
    759760                    *(strchr(line, '\n')) = '\0';   // get rid of the \n on the end
    760761
    761                 asprintf(&tmp, "Initializing plex: %s", line);
     762                mr_asprintf(&tmp, "Initializing plex: %s", line);
    762763                open_evalcall_form(tmp);
    763                 paranoid_free(tmp);
    764 
    765                 asprintf(&tmp, "vinum init %s", line);
     764                mr_free(tmp);
     765
     766                mr_asprintf(&tmp, "vinum init %s", line);
    766767                system(tmp);
    767                 paranoid_free(tmp);
     768                mr_free(tmp);
    768769
    769770                while (1) {
    770                     asprintf(&tmp,
     771                    mr_asprintf(&tmp,
    771772                            "vinum lp -r %s | grep '^S' | head -1 | tr -s ' ' | cut -d: -f2 | cut -f1 | sed 's/^ //' | sed 's/I //' | sed 's/%%//'",
    772773                            line);
    773774                    pin = popen(tmp, "r");
    774                     paranoid_free(tmp);
    775 
    776                     getline(&status, &n1, pin);
     775                    mr_free(tmp);
     776
     777                    mr_getline(&status, &n1, pin);
    777778                    pclose(pin);
    778779
     
    782783                    update_evalcall_form(atoi(status));
    783784                    usleep(250000);
    784                     paranoid_free(status);
     785                    mr_free(status);
    785786                }
    786787                close_evalcall_form();
    787788            }
    788             paranoid_free(line);
     789            mr_free(line);
    789790            fclose(fin);
    790791            unlink("/tmp/plexes");
     
    792793        }
    793794#else
    794         asprintf(&tmp, _("Initializing RAID device %s"), device);
     795        mr_asprintf(&tmp, _("Initializing RAID device %s"), device);
    795796        log_to_screen(tmp);
    796         paranoid_free(tmp);
     797        mr_free(tmp);
    797798
    798799// Shouldn't be necessary.
     
    814815                    device, res);
    815816        } else {
    816             asprintf(&program, "mkraid --really-force %s", device);
     817            mr_asprintf(&program, "mkraid --really-force %s", device);
    817818            res = run_program_and_log_output(program, 1);
    818819            log_msg(1, "%s returned %d", program, res);
     
    823824                fprintf(g_fprep, "%s\n", program);
    824825            }
    825             paranoid_free(program);
     826            mr_free(program);
    826827        }
    827828        sync();
     
    842843    res = which_format_command_do_i_need(format, program);
    843844    if (strstr(program, "kludge")) {
    844         asprintf(&tmp, "%s %s /", program, device);
     845        mr_asprintf(&tmp, "%s %s /", program, device);
    845846    } else {
    846         asprintf(&tmp, "%s %s", program, device);
    847     }
    848     paranoid_free(program);
    849 
    850     asprintf(&program, "sh -c 'echo -en \"y\\ny\\ny\\n\" | %s'", tmp);
    851     paranoid_free(tmp);
    852 
    853     asprintf(&tmp, "Formatting %s as %s", device, format);
     847        mr_asprintf(&tmp, "%s %s", program, device);
     848    }
     849    mr_free(program);
     850
     851    mr_asprintf(&program, "sh -c 'echo -en \"y\\ny\\ny\\n\" | %s'", tmp);
     852    mr_free(tmp);
     853
     854    mr_asprintf(&tmp, "Formatting %s as %s", device, format);
    854855    update_progress_form(tmp);
    855856
     
    857858    if (res && strstr(program, "kludge")) {
    858859#ifdef __FreeBSD__
    859         paranoid_free(program);
    860         asprintf(&program, "newfs_msdos -F 32 %s", device);
     860        mr_free(program);
     861        mr_asprintf(&program, "newfs_msdos -F 32 %s", device);
    861862#else
    862863#ifdef __IA64__
    863864        /* For EFI partitions take fat16
    864865         * as we want to make small ones */
    865         paranoid_free(program);
    866         asprintf(&program, "mkfs -t %s -F 16 %s", format, device);
     866        mr_free(program);
     867        mr_asprintf(&program, "mkfs -t %s -F 16 %s", format, device);
    867868#else
    868         paranoid_free(program);
    869         asprintf(&program, "mkfs -t %s -F 32 %s", format, device);
     869        mr_free(program);
     870        mr_asprintf(&program, "mkfs -t %s -F 32 %s", format, device);
    870871#endif
    871872#endif
     
    875876        }
    876877    }
    877     paranoid_free(program);
     878    mr_free(program);
    878879
    879880    retval += res;
    880881    if (retval) {
    881         asprintf(&tmp1, "%s%s",tmp, _("...failed"));
     882        mr_asprintf(&tmp1, "%s%s",tmp, _("...failed"));
    882883    } else {
    883         asprintf(&tmp1, "%s%s",tmp, _("...OK"));
    884     }
    885     paranoid_free(tmp);
     884        mr_asprintf(&tmp1, "%s%s",tmp, _("...OK"));
     885    }
     886    mr_free(tmp);
    886887
    887888    log_to_screen(tmp1);
    888     paranoid_free(tmp1);
     889    mr_free(tmp1);
    889890    sync();
    890891    sleep(1);
     
    923924
    924925    assert(mountlist != NULL);
    925     asprintf(&tmp, "format_everything (mountlist, interactively = %s",
     926    mr_asprintf(&tmp, "format_everything (mountlist, interactively = %s",
    926927            (interactively) ? "true" : "false");
    927928    log_it(tmp);
    928     paranoid_free(tmp);
     929    mr_free(tmp);
    929930
    930931    mvaddstr_and_log_it(g_currentY, 0, _("Formatting partitions     "));
     
    952953            if (interactively) {
    953954                // ask user if we should format the current device
    954                 asprintf(&tmp, "Shall I format %s (%s) ?", me->device,
     955                mr_asprintf(&tmp, "Shall I format %s (%s) ?", me->device,
    955956                        me->mountpoint);
    956957                do_it = ask_me_yes_or_no(tmp);
    957                 paranoid_free(tmp);
     958                mr_free(tmp);
    958959            } else {
    959960                do_it = TRUE;
     
    10031004        me = &mountlist->el[lino];  // the current mountlist entry
    10041005        if (!strcmp(me->mountpoint, "image")) {
    1005             asprintf(&tmp, "Not formatting %s - it's an image", me->device);
     1006            mr_asprintf(&tmp, "Not formatting %s - it's an image", me->device);
    10061007            log_it(tmp);
    1007             paranoid_free(tmp);
     1008            mr_free(tmp);
    10081009        } else if (!strcmp(me->format, "raid")) {
    1009             asprintf(&tmp, "Not formatting %s - it's a raid-let",
     1010            mr_asprintf(&tmp, "Not formatting %s - it's a raid-let",
    10101011                    me->device);
    10111012            log_it(tmp);
    1012             paranoid_free(tmp);
     1013            mr_free(tmp);
    10131014            continue;
    10141015        } else if (!strcmp(me->format, "lvm")) {
    1015             asprintf(&tmp, "Not formatting %s - it's an LVM", me->device);
     1016            mr_asprintf(&tmp, "Not formatting %s - it's an LVM", me->device);
    10161017            log_it(tmp);
    1017             paranoid_free(tmp);
     1018            mr_free(tmp);
    10181019            continue;
    10191020        } else if (!strncmp(me->device, "/dev/md", 7)) {
    1020             asprintf(&tmp, "Already formatted %s - it's a soft-RAID dev",
     1021            mr_asprintf(&tmp, "Already formatted %s - it's a soft-RAID dev",
    10211022                    me->device);
    10221023            log_it(tmp);
    1023             paranoid_free(tmp);
     1024            mr_free(tmp);
    10241025            continue;
    10251026        } else if (!does_file_exist(me->device)
    10261027                   && strncmp(me->device, "/dev/hd", 7)
    10271028                   && strncmp(me->device, "/dev/sd", 7)) {
    1028             asprintf(&tmp,
     1029            mr_asprintf(&tmp,
    10291030                    "Not formatting %s yet - doesn't exist - probably an LVM",
    10301031                    me->device);
    10311032            log_it(tmp);
    1032             paranoid_free(tmp);
     1033            mr_free(tmp);
    10331034            continue;
    10341035        } else {
    10351036            if (interactively) {
    10361037                // ask user if we should format the current device
    1037                 asprintf(&tmp, "Shall I format %s (%s) ?", me->device,
     1038                mr_asprintf(&tmp, "Shall I format %s (%s) ?", me->device,
    10381039                        me->mountpoint);
    10391040                do_it = ask_me_yes_or_no(tmp);
    1040                 paranoid_free(tmp);
     1041                mr_free(tmp);
    10411042            } else {
    10421043                do_it = TRUE;
     
    10681069    }
    10691070
    1070     asprintf(&tmp, "format_everything () - %s",
     1071    mr_asprintf(&tmp, "format_everything () - %s",
    10711072            (retval) ? "failed!" : "finished successfully");
    10721073    log_it(tmp);
    1073     paranoid_free(tmp);
     1074    mr_free(tmp);
    10741075
    10751076    if (g_partition_table_locked_up > 0) {
     
    11351136
    11361137    if (devno_we_must_allow_for >= 5) {
    1137         asprintf(&tmp, "Making dummy primary %s%d", drivename, 1);
     1138        mr_asprintf(&tmp, "Making dummy primary %s%d", drivename, 1);
    11381139        log_it(tmp);
    1139         paranoid_free(tmp);
     1140        mr_free(tmp);
    11401141
    11411142        g_maximum_progress++;
     
    11511152    }
    11521153    for (; current_devno < devno_we_must_allow_for; current_devno++) {
    1153         asprintf(&tmp, "Creating dummy partition %s%d", drivename,
     1154        mr_asprintf(&tmp, "Creating dummy partition %s%d", drivename,
    11541155                current_devno);
    11551156        log_it(tmp);
    1156         paranoid_free(tmp);
     1157        mr_free(tmp);
    11571158
    11581159        g_maximum_progress++;
     
    13011302    off_t mediasize;
    13021303
    1303     asprintf(&lnamebuf, "%s", dkname);
     1304    mr_asprintf(&lnamebuf, "%s", dkname);
    13041305    if ((f = open(lnamebuf, O_RDONLY)) == -1) {
    13051306        warn("cannot open %s", lnamebuf);
    1306         paranoid_free(lnamebuf);
     1307        mr_free(lnamebuf);
    13071308        return (NULL);
    13081309    }
    1309     paranoid_free(lnamebuf);
     1310    mr_free(lnamebuf);
    13101311
    13111312    /* New world order */
     
    13891390    for (c = 'a'; c <= 'z'; ++c) {
    13901391        int idx;
    1391         asprintf(&subdev_str, "%s%c", drivename, c);
     1392        mr_asprintf(&subdev_str, "%s%c", drivename, c);
    13921393        if ((idx = find_device_in_mountlist(mountlist, subdev_str)) < 0) {
    13931394            lp->d_partitions[c - 'a'].p_size = 0;
     
    14141415                lp->d_partitions[c - 'a'].p_fstype = FS_OTHER;
    14151416        }
    1416         paranoid_free(subdev_str);
     1417        mr_free(subdev_str);
    14171418    }
    14181419
     
    14451446    display_disklabel(ftmp, lp);
    14461447    fclose(ftmp);
    1447     asprintf(&command, "disklabel -wr %s auto", canonical_name(drivename));
     1448    mr_asprintf(&command, "disklabel -wr %s auto", canonical_name(drivename));
    14481449    retval += run_program_and_log_output(command, TRUE);
    1449     paranoid_free(command);
    1450 
    1451     asprintf(&command, "disklabel -R %s /tmp/disklabel",
     1450    mr_free(command);
     1451
     1452    mr_asprintf(&command, "disklabel -R %s /tmp/disklabel",
    14521453            canonical_name(drivename));
    14531454    retval += run_program_and_log_output(command, TRUE);
    1454     paranoid_free(command);
     1455    mr_free(command);
    14551456    if (ret)
    14561457        *ret = *lp;
     
    14951496    assert_string_is_neither_NULL_nor_zerolength(drivename);
    14961497
    1497     asprintf(&tmp, "Partitioning drive %s", drivename);
     1498    mr_asprintf(&tmp, "Partitioning drive %s", drivename);
    14981499    log_it(tmp);
    1499     paranoid_free(tmp);
     1500    mr_free(tmp);
    15001501
    15011502#if __FreeBSD__
     
    15041505#else
    15051506    make_hole_for_file(FDISK_LOG);
    1506     asprintf(&tmp, "parted2fdisk %s >> %s 2>> %s", drivename, FDISK_LOG,
     1507    mr_asprintf(&tmp, "parted2fdisk %s >> %s 2>> %s", drivename, FDISK_LOG,
    15071508            FDISK_LOG);
    15081509    pout_to_fdisk = popen(tmp, "w");
    1509     paranoid_free(tmp);
     1510    mr_free(tmp);
    15101511
    15111512    if (!pout_to_fdisk) {
     
    15311532                // try DangerouslyDedicated mode
    15321533                for (c = 'a'; c <= 'z'; c++) {
    1533                     asprintf(&subdev_str, "%s%c", drivename, c);
     1534                    mr_asprintf(&subdev_str, "%s%c", drivename, c);
    15341535                    if (find_device_in_mountlist(mountlist, subdev_str) > 0) {
    15351536                        fbsd_part = TRUE;
    15361537                    }
    1537                     paranoid_free(subdev_str);
     1538                    mr_free(subdev_str);
    15381539                }
    15391540                if (fbsd_part) {
     
    15411542                                                 drivename,
    15421543                                                 0);
    1543                     asprintf(&command, "disklabel -B %s",
     1544                    mr_asprintf(&command, "disklabel -B %s",
    15441545                            basename(drivename));
    15451546                    if (system(command)) {
     
    15481549                             ("Warning! Unable to make the drive bootable."));
    15491550                    }
    1550                     paranoid_free(command);
    1551                     paranoid_free(device_str);
     1551                    mr_free(command);
     1552                    mr_free(device_str);
    15521553
    15531554                    return r;
     
    15551556            }
    15561557            for (c = 'a'; c <= 'z'; c++) {
    1557                 asprintf(&subdev_str, "%s%c", device_str, c);
     1558                mr_asprintf(&subdev_str, "%s%c", device_str, c);
    15581559                if (find_device_in_mountlist(mountlist, subdev_str) > 0) {
    15591560                    fbsd_part = TRUE;
    15601561                }
    1561                 paranoid_free(subdev_str);
     1562                mr_free(subdev_str);
    15621563            }
    15631564            // Now we check the subpartitions of the current partition.
     
    15651566                int i, line;
    15661567
    1567                 asprintf(&format, "ufs");
     1568                mr_asprintf(&format, "ufs");
    15681569                partsize = 0;
    15691570                for (i = 'a'; i < 'z'; ++i) {
    1570                     asprintf(&subdev_str, "%s%c", device_str, i);
     1571                    mr_asprintf(&subdev_str, "%s%c", device_str, i);
    15711572                    line = find_device_in_mountlist(mountlist, subdev_str);
    1572                     paranoid_free(subdev_str);
     1573                    mr_free(subdev_str);
    15731574
    15741575                    if (line > 0) {
     
    15961597            file = open(drivename, O_WRONLY);
    15971598            if (!file) {
    1598                 asprintf(&tmp,
     1599                mr_asprintf(&tmp,
    15991600                        _("Warning - unable to open %s for wiping it's partition table"),
    16001601                        drivename);
    16011602                log_to_screen(tmp);
    1602                 paranoid_free(tmp);
     1603                mr_free(tmp);
    16031604            }
    16041605
    16051606            for (i = 0; i < 512; i++) {
    16061607                if (!write(file, "\0", 1)) {
    1607                     asprintf(&tmp, _("Warning - unable to write to %s"),
     1608                    mr_asprintf(&tmp, _("Warning - unable to write to %s"),
    16081609                            drivename);
    16091610                    log_to_screen(tmp);
    1610                     paranoid_free(tmp);
     1611                    mr_free(tmp);
    16111612                }
    16121613            }
     
    16291630#endif
    16301631
    1631             asprintf(&format, mountlist->el[lino].format);
     1632            mr_asprintf(&format, mountlist->el[lino].format);
    16321633            partsize = mountlist->el[lino].size;
    16331634
     
    16401641                (_
    16411642                 ("You must leave at least one partition spare as the Extended partition."));
    1642             paranoid_free(device_str);
    1643             paranoid_free(format);
     1643            mr_free(device_str);
     1644            mr_free(format);
    16441645
    16451646            return (1);
     
    16521653#ifdef __FreeBSD__
    16531654        if ((current_devno <= 4) && fbsd_part) {
    1654             asprintf(&tmp, "disklabel -B %s", basename(device_str));
     1655            mr_asprintf(&tmp, "disklabel -B %s", basename(device_str));
    16551656            retval += label_drive_or_slice(mountlist, device_str, 0);
    16561657            if (system(tmp)) {
     
    16581659                    (_("Warning! Unable to make the slice bootable."));
    16591660            }
    1660             paranoid_free(tmp);
     1661            mr_free(tmp);
    16611662        }
    16621663#endif
     
    16641665        previous_devno = current_devno;
    16651666    }
    1666     paranoid_free(device_str);
    1667     paranoid_free(format);
     1667    mr_free(device_str);
     1668    mr_free(format);
    16681669
    16691670    if (pout_to_fdisk) {
     
    16711672        tmp1 = call_program_and_get_last_line_of_output
    16721673                ("make-me-bootable /tmp/mountlist.txt dummy");
    1673         asprintf(&tmp, "a\n%s\n", tmp1);
    1674         paranoid_free(tmp1);
     1674        mr_asprintf(&tmp, "a\n%s\n", tmp1);
     1675        mr_free(tmp1);
    16751676
    16761677        fput_string_one_char_at_a_time(pout_to_fdisk, tmp);
    1677         paranoid_free(tmp);
     1678        mr_free(tmp);
    16781679
    16791680        // close fdisk
     
    16831684        log_msg(0,
    16841685                "------------------- fdisk.log looks like this ------------------");
    1685         asprintf(&tmp, "cat %s >> %s", FDISK_LOG, MONDO_LOGFILE);
     1686        mr_asprintf(&tmp, "cat %s >> %s", FDISK_LOG, MONDO_LOGFILE);
    16861687        system(tmp);
    1687         paranoid_free(tmp);
     1688        mr_free(tmp);
    16881689
    16891690        log_msg(0,
    16901691                "------------------- end of fdisk.log... word! ------------------");
    1691         asprintf(&tmp, "tail -n6 %s | grep -F \"16: \"", FDISK_LOG);
     1692        mr_asprintf(&tmp, "tail -n6 %s | grep -F \"16: \"", FDISK_LOG);
    16921693        if (!run_program_and_log_output(tmp, 5)) {
    16931694            g_partition_table_locked_up++;
     
    16961697                 ("A flaw in the Linux kernel has locked the partition table."));
    16971698        }
    1698         paranoid_free(tmp);
     1699        mr_free(tmp);
    16991700    }
    17001701    return (retval);
     
    17391740
    17401741    if (!strncmp(drive, RAID_DEVICE_STUB, strlen(RAID_DEVICE_STUB))) {
    1741         asprintf(&tmp, "Not partitioning %s - it is a virtual drive", drive);
     1742        mr_asprintf(&tmp, "Not partitioning %s - it is a virtual drive", drive);
    17421743        log_it(tmp);
    1743         paranoid_free(tmp);
     1744        mr_free(tmp);
    17441745        return (0);
    17451746    }
    17461747    partition_name = build_partition_name(drive, partno);
    17471748    if (partsize <= 0) {
    1748         asprintf(&tmp, "Partitioning device %s (max size)", partition_name);
     1749        mr_asprintf(&tmp, "Partitioning device %s (max size)", partition_name);
    17491750    } else {
    1750         asprintf(&tmp, "Partitioning device %s (%lld MB)", partition_name,
     1751        mr_asprintf(&tmp, "Partitioning device %s (%lld MB)", partition_name,
    17511752                (long long) partsize / 1024);
    17521753    }
    17531754    update_progress_form(tmp);
    17541755    log_it(tmp);
    1755     paranoid_free(tmp);
     1756    mr_free(tmp);
    17561757
    17571758    if (is_this_device_mounted(partition_name)) {
    1758         asprintf(&tmp, _("%s is mounted, and should not be partitioned"),
     1759        mr_asprintf(&tmp, _("%s is mounted, and should not be partitioned"),
    17591760                partition_name);
    1760         paranoid_free(partition_name);
     1761        mr_free(partition_name);
    17611762
    17621763        log_to_screen(tmp);
    1763         paranoid_free(tmp);
     1764        mr_free(tmp);
    17641765        return (1);
    17651766    }
    17661767
    17671768    p = (char *) strrchr(partition_name, '/');
    1768     asprintf(&program, "parted2fdisk %s >> %s 2>> %s", drive, MONDO_LOGFILE,
     1769    mr_asprintf(&program, "parted2fdisk %s >> %s 2>> %s", drive, MONDO_LOGFILE,
    17691770            MONDO_LOGFILE);
    17701771
     
    17731774    /* make it a primary/extended/logical */
    17741775    if (partno <= 4) {
    1775         asprintf(&output,"n\np\n%d\n", partno);
     1776        mr_asprintf(&output,"n\np\n%d\n", partno);
    17761777    } else {
    17771778        /* MBR needs an extended partition if more than 4 partitions */
     
    17821783                        (_
    17831784                         ("You need to leave at least one partition free, for 'extended/logical'"));
    1784                     paranoid_free(partition_name);
    1785                     paranoid_free(program);
    1786 
    1787                     paranoid_free(output);
     1785                    mr_free(partition_name);
     1786                    mr_free(program);
     1787
     1788                    mr_free(output);
    17881789                    return (1);
    17891790                } else {
    1790                     asprintf(&output,"n\ne\n%d\n\n\n",prev_partno + 1);
     1791                    mr_asprintf(&output,"n\ne\n%d\n\n\n",prev_partno + 1);
    17911792                }
    17921793            }
    1793             asprintf(&tmp,"%sn\nl\n",output);
    1794             paranoid_free(output);
     1794            mr_asprintf(&tmp,"%sn\nl\n",output);
     1795            mr_free(output);
    17951796            output = tmp;
    17961797        } else {
    17971798            /* GPT allows more than 4 primary partitions */
    1798             asprintf(&output,"n\np\n%d\n",partno);
    1799         }
    1800     }
    1801     paranoid_free(part_table_fmt);
     1799            mr_asprintf(&output,"n\np\n%d\n",partno);
     1800        }
     1801    }
     1802    mr_free(part_table_fmt);
    18021803    /*start block (ENTER for next free blk */
    1803     asprintf(&tmp,"%s\n",output);
    1804     paranoid_free(output);
     1804    mr_asprintf(&tmp,"%s\n",output);
     1805    mr_free(output);
    18051806    output = tmp;
    18061807
     
    18101811            partsize += 512;
    18111812        }
    1812         asprintf(&tmp,"%s+%lldK", output,  (long long) (partsize));
    1813         paranoid_free(output);
     1813        mr_asprintf(&tmp,"%s+%lldK", output,  (long long) (partsize));
     1814        mr_free(output);
    18141815        output = tmp;
    18151816    }
    1816     asprintf(&tmp,"%s\n",output);
    1817     paranoid_free(output);
     1817    mr_asprintf(&tmp,"%s\n",output);
     1818    mr_free(output);
    18181819    output = tmp;
    18191820#if 0
    18201821/*
    18211822#endif
    1822     asprintf(&tmp,"PARTSIZE = +%ld",(long)partsize);
     1823    mr_asprintf(&tmp,"PARTSIZE = +%ld",(long)partsize);
    18231824    log_it(tmp);
    1824     paranoid_free(tmp);
     1825    mr_free(tmp);
    18251826
    18261827    log_it("---fdisk command---");
     
    18451846                    partno);
    18461847        }
    1847         paranoid_free(tmp);
     1848        mr_free(tmp);
    18481849
    18491850        if (!retval) {
     
    18641865        }
    18651866    } else {
    1866         asprintf(&tmp,"%sw\n\n",output);
    1867         paranoid_free(output);
     1867        mr_asprintf(&tmp,"%sw\n\n",output);
     1868        mr_free(output);
    18681869        output = tmp;
    18691870
     
    18851886                                 format, -1);
    18861887            if (res) {
    1887                 asprintf(&tmp, "Failed to vacuum-pack %s", partition_name);
     1888                mr_asprintf(&tmp, "Failed to vacuum-pack %s", partition_name);
    18881889                log_it(tmp);
    1889                 paranoid_free(tmp);
     1890                mr_free(tmp);
    18901891
    18911892                retval++;
     
    18991900                                   partsize);
    19001901            if (retval) {
    1901                 asprintf(&tmp, "Partitioned %s but failed to set its type",
     1902                mr_asprintf(&tmp, "Partitioned %s but failed to set its type",
    19021903                        partition_name);
    19031904                log_it(tmp);
    1904                 paranoid_free(tmp);
     1905                mr_free(tmp);
    19051906            } else {
    19061907                if (partsize > 0) {
    1907                     asprintf(&tmp, "Partition %s created+configured OK",
     1908                    mr_asprintf(&tmp, "Partition %s created+configured OK",
    19081909                            partition_name);
    19091910                    log_to_screen(tmp);
    1910                     paranoid_free(tmp);
     1911                    mr_free(tmp);
    19111912                } else {
    19121913                    log_it("Returning from a successful vacuum-pack");
     
    19141915            }
    19151916        } else {
    1916             asprintf(&tmp, "Failed to partition %s", partition_name);
     1917            mr_asprintf(&tmp, "Failed to partition %s", partition_name);
    19171918            if (partsize > 0) {
    19181919                log_to_screen(tmp);
     
    19201921                log_it(tmp);
    19211922            }
    1922             paranoid_free(tmp);
     1923            mr_free(tmp);
    19231924            retval++;
    19241925        }
     
    19261927    g_current_progress++;
    19271928    log_it("partition_device() --- leaving");
    1928     paranoid_free(partition_name);
    1929     paranoid_free(program);
    1930     paranoid_free(output);
     1929    mr_free(partition_name);
     1930    mr_free(program);
     1931    mr_free(output);
    19311932    return (retval);
    19321933}
     
    20142015    system("clear");
    20152016    newtResume();
    2016     paranoid_free(drivelist);
     2017    mr_free(drivelist);
    20172018    return (retval);
    20182019}
     
    20582059    p = (char *) strrchr(partition, '/');
    20592060    if (strcmp(format, "swap") == 0) {
    2060         asprintf(&partcode, "82");
     2061        mr_asprintf(&partcode, "82");
    20612062    } else if (strcmp(format, "vfat") == 0) {
    20622063        if (partsize / 1024 > 8192) {
    2063             asprintf(&partcode, "c");
     2064            mr_asprintf(&partcode, "c");
    20642065        } else {
    2065             asprintf(&partcode, "b");
     2066            mr_asprintf(&partcode, "b");
    20662067        }
    20672068    } else if (strcmp(format, "ext2") == 0
     
    20692070               || strcmp(format, "ext3") == 0 || strcmp(format, "xfs") == 0
    20702071               || strcmp(format, "jfs") == 0) {
    2071         asprintf(&partcode, "83");
     2072        mr_asprintf(&partcode, "83");
    20722073    } else if (strcmp(format, "minix") == 0) {
    2073         asprintf(&partcode, "81");
     2074        mr_asprintf(&partcode, "81");
    20742075    } else if (strcmp(format, "raid") == 0) {
    2075         asprintf(&partcode, "fd");
     2076        mr_asprintf(&partcode, "fd");
    20762077    } else if ((strcmp(format, "ufs") == 0)
    20772078               || (strcmp(format, "ffs") == 0)) {   /* raid autodetect */
    2078         asprintf(&partcode, "a5");
     2079        mr_asprintf(&partcode, "a5");
    20792080    } else if (strcmp(format, "lvm") == 0) {
    2080         asprintf(&partcode, "8e");
     2081        mr_asprintf(&partcode, "8e");
    20812082    } else if (format[0] == '\0') { /* LVM physical partition */
    2082         asprintf(&partcode, "%s", "");
     2083        mr_asprintf(&partcode, "%s", "");
    20832084    } else if (strlen(format) >= 1 && strlen(format) <= 2) {
    2084         asprintf(&partcode, format);
     2085        mr_asprintf(&partcode, format);
    20852086    } else {
    20862087        /* probably an image */
    2087         asprintf(&tmp,
     2088        mr_asprintf(&tmp,
    20882089                "Unknown format ('%s') - using supplied string anyway",
    20892090                format);
    20902091        mvaddstr_and_log_it(g_currentY++, 0, tmp);
    2091         paranoid_free(tmp);
     2092        mr_free(tmp);
    20922093#ifdef __FreeBSD__
    2093         asprintf(&partcode, format);    // was a5
     2094        mr_asprintf(&partcode, format); // was a5
    20942095#else
    2095         asprintf(&partcode, format);    // was 83
    2096 #endif
    2097     }
    2098     asprintf(&tmp, "Setting %s's type to %s (%s)", partition, format,
     2096        mr_asprintf(&partcode, format); // was 83
     2097#endif
     2098    }
     2099    mr_asprintf(&tmp, "Setting %s's type to %s (%s)", partition, format,
    20992100            partcode);
    2100     paranoid_free(partition);
     2101    mr_free(partition);
    21012102
    21022103    log_msg(1, tmp);
    2103     paranoid_free(tmp);
     2104    mr_free(tmp);
    21042105    if (partcode[0] != '\0' && strcmp(partcode, "83")) {    /* no need to set type if 83: 83 is default */
    21052106
     
    21112112                || strstr(tmp1, " (1-4)")) {
    21122113                log_msg(5, "Specifying partno (%d) - yay", partno);
    2113                 asprintf(&tmp, "%d\n", partno);
     2114                mr_asprintf(&tmp, "%d\n", partno);
    21142115                fput_string_one_char_at_a_time(pout_to_fdisk, tmp);
    2115                 paranoid_free(tmp);
    2116                 paranoid_free(tmp1);
     2116                mr_free(tmp);
     2117                mr_free(tmp1);
    21172118                tmp1 = last_line_of_file(FDISK_LOG);
    21182119                log_msg(5, "A - last line = '%s'", tmp1);
    21192120            }
    2120             paranoid_free(tmp1);
    2121 
    2122             asprintf(&tmp, "%s\n", partcode);
     2121            mr_free(tmp1);
     2122
     2123            mr_asprintf(&tmp, "%s\n", partcode);
    21232124            fput_string_one_char_at_a_time(pout_to_fdisk, tmp);
    2124             paranoid_free(tmp);
     2125            mr_free(tmp);
    21252126            tmp1 = last_line_of_file(FDISK_LOG);
    21262127            log_msg(5, "B - last line = '%s'",tmp1);
    2127             paranoid_free(tmp1);
     2128            mr_free(tmp1);
    21282129
    21292130            fput_string_one_char_at_a_time(pout_to_fdisk, "\n");
    21302131            tmp1 = last_line_of_file(FDISK_LOG);
    21312132            log_msg(5, "C - last line = '%s'",tmp1);
    2132             paranoid_free(tmp1);
     2133            mr_free(tmp1);
    21332134
    21342135            tmp = last_line_of_file(FDISK_LOG);
     
    21382139                fput_string_one_char_at_a_time(pout_to_fdisk, "\n");
    21392140            }
    2140             paranoid_free(tmp);
     2141            mr_free(tmp);
    21412142            fput_string_one_char_at_a_time(pout_to_fdisk, "p\n");
    21422143        } else {
    2143             asprintf(&output, "t\n%d\n%s\nw\n", partno, partcode);
    2144             asprintf(&command, "parted2fdisk %s >> %s 2>> %s", drive,
     2144            mr_asprintf(&output, "t\n%d\n%s\nw\n", partno, partcode);
     2145            mr_asprintf(&command, "parted2fdisk %s >> %s 2>> %s", drive,
    21452146                    MONDO_LOGFILE, MONDO_LOGFILE);
    21462147            log_msg(5, "output = '%s'", output);
     
    21562157                paranoid_pclose(fout);
    21572158            }
    2158             paranoid_free(command);
    2159             paranoid_free(output);
     2159            mr_free(command);
     2160            mr_free(output);
    21602161        }
    21612162        /* BERLIOS: Useless as command not initialized in all cases
     
    21652166        */
    21662167    }
    2167     paranoid_free(partcode);
     2168    mr_free(partcode);
    21682169
    21692170
     
    21902191        return 1;
    21912192    }
    2192     asprintf(&program, "vinum start -f %s", raid_device);
     2193    mr_asprintf(&program, "vinum start -f %s", raid_device);
    21932194#else
    2194     asprintf(&program, "raidstart %s", raid_device);
     2195    mr_asprintf(&program, "raidstart %s", raid_device);
    21952196#endif
    21962197    log_msg(1, "program = %s", program);
     
    21992200        fprintf(g_fprep, "%s\n", program);
    22002201    }
    2201     paranoid_free(program);
     2202    mr_free(program);
    22022203
    22032204    if (res) {
     
    22342235        return 1;
    22352236    }
    2236     asprintf(&program, "vinum stop -f %s", raid_device);
     2237    mr_asprintf(&program, "vinum stop -f %s", raid_device);
    22372238#else
    22382239    // use raidstop if it exists, otherwise use mdadm
    22392240    if (run_program_and_log_output("which raidstop", FALSE)) {
    2240         asprintf(&program, "mdadm -S %s", raid_device);
     2241        mr_asprintf(&program, "mdadm -S %s", raid_device);
    22412242    } else {
    2242         asprintf(&program, "raidstop %s", raid_device);
     2243        mr_asprintf(&program, "raidstop %s", raid_device);
    22432244    }
    22442245#endif
     
    22482249        fprintf(g_fprep, "%s\n", program);
    22492250    }
    2250     paranoid_free(program);
     2251    mr_free(program);
    22512252
    22522253    if (res) {
     
    23222323            return (1);
    23232324        }
    2324         for (getline(&incoming, &n, fin); !feof(fin);
    2325              getline(&incoming, &n, fin)) {
     2325        for (mr_getline(&incoming, &n, fin); !feof(fin);
     2326             mr_getline(&incoming, &n, fin)) {
    23262327            retval += stop_raid_device(incoming);
    23272328        }
     
    23322333            return (1);
    23332334        }
    2334         for (getline(&incoming, &n, fin); !feof(fin);
    2335              getline(&incoming, &n, fin)) {
     2335        for (mr_getline(&incoming, &n, fin); !feof(fin);
     2336             mr_getline(&incoming, &n, fin)) {
    23362337            for (p = incoming;
    23372338                 *p != '\0' && (*p != 'm' || *(p + 1) != 'd'
    23382339                                || !isdigit(*(p + 2))); p++);
    23392340            if (*p != '\0') {
    2340                 asprintf(&dev, "/dev/%s", p);
     2341                mr_asprintf(&dev, "/dev/%s", p);
    23412342                /* BERLIOS : 32 Hard coded value */
    23422343                for (p = dev; *p > 32; p++);
    23432344                *p = '\0';
    23442345                res = stop_raid_device(dev);
    2345                 paranoid_free(dev);
    2346             }
    2347         }
    2348 #endif
    2349         paranoid_free(incoming);
     2346                mr_free(dev);
     2347            }
     2348        }
     2349#endif
     2350        mr_free(incoming);
    23502351    }
    23512352    paranoid_fclose(fin);
     
    23812382    if (strcmp(format, "swap") == 0) {
    23822383#ifdef __FreeBSD__
    2383         asprintf(&program, "true");
     2384        mr_asprintf(&program, "true");
    23842385#else
    2385         asprintf(&program, "mkswap");
     2386        mr_asprintf(&program, "mkswap");
    23862387#endif
    23872388    } else if (strcmp(format, "vfat") == 0) {
    2388         asprintf(&program, "format-and-kludge-vfat");
     2389        mr_asprintf(&program, "format-and-kludge-vfat");
    23892390#ifndef __FreeBSD__
    23902391    } else if (strcmp(format, "reiserfs") == 0) {
    2391         asprintf(&program, "mkreiserfs -ff");
     2392        mr_asprintf(&program, "mkreiserfs -ff");
    23922393    } else if (strcmp(format, "xfs") == 0) {
    2393         asprintf(&program, "mkfs.xfs -f -q");
     2394        mr_asprintf(&program, "mkfs.xfs -f -q");
    23942395    } else if (strcmp(format, "jfs") == 0) {
    2395         asprintf(&program, "mkfs.jfs");
     2396        mr_asprintf(&program, "mkfs.jfs");
    23962397    } else if (strcmp(format, "ext3") == 0) {
    2397         asprintf(&program, "mkfs -t ext2 -F -j -q");
     2398        mr_asprintf(&program, "mkfs -t ext2 -F -j -q");
    23982399    } else if (strcmp(format, "minix") == 0) {
    2399         asprintf(&program, "mkfs.minix");
     2400        mr_asprintf(&program, "mkfs.minix");
    24002401#endif
    24012402    } else if (strcmp(format, "ext2") == 0) {
    2402         asprintf(&program, "mke2fs -F -q");
     2403        mr_asprintf(&program, "mke2fs -F -q");
    24032404    } else {
    24042405#ifdef __FreeBSD__
    2405         asprintf(&program, "newfs_%s", format);
     2406        mr_asprintf(&program, "newfs_%s", format);
    24062407#else
    2407         asprintf(&program, "mkfs -t %s -c", format);    // -c checks for bad blocks
    2408 #endif
    2409         asprintf(&tmp, "Unknown format (%s) - assuming '%s' will do", format,
     2408        mr_asprintf(&program, "mkfs -t %s -c", format); // -c checks for bad blocks
     2409#endif
     2410        mr_asprintf(&tmp, "Unknown format (%s) - assuming '%s' will do", format,
    24102411                program);
    24112412        log_it(tmp);
    2412         paranoid_free(tmp);
     2413        mr_free(tmp);
    24132414        res = 0;
    24142415    }
     
    24482449            original_size_of_drive += mountlist->el[partno].size;
    24492450        } else {
    2450             asprintf(&tmp, "Skipping %s", mountlist->el[partno].device);
     2451            mr_asprintf(&tmp, "Skipping %s", mountlist->el[partno].device);
    24512452//                      log_to_screen(tmp);
    2452             paranoid_free(tmp);
     2453            mr_free(tmp);
    24532454        }
    24542455    }
     
    25122513        return;
    25132514    }
    2514     asprintf(&tmp, _("Expanding entries to suit drive %s (%ld MB)"),
     2515    mr_asprintf(&tmp, _("Expanding entries to suit drive %s (%ld MB)"),
    25152516            drive_name, current_size_of_drive);
    25162517    log_to_screen(tmp);
    2517     paranoid_free(tmp);
     2518    mr_free(tmp);
    25182519
    25192520    drivemntlist = malloc(sizeof(struct mountlist_reference));
     
    25322533
    25332534    if (original_size_of_drive <= 0) {
    2534         asprintf(&tmp, _("Cannot resize %s's entries. Drive not found."),
     2535        mr_asprintf(&tmp, _("Cannot resize %s's entries. Drive not found."),
    25352536                drive_name);
    25362537        log_to_screen(tmp);
    2537         paranoid_free(tmp);
     2538        mr_free(tmp);
    25382539        return;
    25392540    }
    25402541    factor =
    25412542        (float) (current_size_of_drive) / (float) (original_size_of_drive);
    2542     asprintf(&tmp, "Disk %s was %ld MB; is now %ld MB; factor = %f",
     2543    mr_asprintf(&tmp, "Disk %s was %ld MB; is now %ld MB; factor = %f",
    25432544            drive_name, original_size_of_drive, current_size_of_drive,
    25442545            factor);
    25452546    log_to_screen(tmp);
    2546     paranoid_free(tmp);
     2547    mr_free(tmp);
    25472548
    25482549    lastpart = drivemntlist->entries - 1;
     
    25632564            newsizL = (long) new_size;
    25642565        }
    2565         asprintf(&tmp, _("Changing %s from %lld KB to %ld KB"),
     2566        mr_asprintf(&tmp, _("Changing %s from %lld KB to %ld KB"),
    25662567                drivemntlist->el[partno]->device,
    25672568                drivemntlist->el[partno]->size, newsizL);
    25682569        log_to_screen(tmp);
    2569         paranoid_free(tmp);
     2570        mr_free(tmp);
    25702571        drivemntlist->el[partno]->size = newsizL;
    25712572    }
    25722573    final_size = get_phys_size_of_drive(drive_name);
    2573     asprintf(&tmp, _("final_size = %ld MB"), final_size);
     2574    mr_asprintf(&tmp, _("final_size = %ld MB"), final_size);
    25742575    log_to_screen(tmp);
    2575     paranoid_free(tmp);
     2576    mr_free(tmp);
    25762577}
    25772578
     
    26132614    }
    26142615    log_to_screen(_("Mountlist adjusted to suit current hard drive(s)"));
    2615     paranoid_free(drivelist);
     2616    mr_free(drivelist);
    26162617}
    26172618
     
    26372638    log_msg(1, "Creating list of partitions for drive %s", drive_name);
    26382639
    2639     asprintf(&tmp_drive_name,drive_name);
     2640    mr_asprintf(&tmp_drive_name,drive_name);
    26402641    if (!tmp_drive_name)
    26412642        fatal_error("Out of memory");
     
    26572658        }
    26582659    }
    2659     paranoid_free(tmp_drive_name);
     2660    mr_free(tmp_drive_name);
    26602661}
    26612662
  • trunk/mondo/src/mondorestore/mondo-restore.c

    r851 r900  
    2323#include <pthread.h>
    2424#endif
     25#include "mr_mem.h"
    2526
    2627extern void twenty_seconds_til_yikes(void);
     
    160161    assert(raidlist != NULL);
    161162    if (!bkpinfo->disaster_recovery) {
    162         paranoid_alloc(g_mountlist_fname, "/tmp/mountlist.txt");
     163        mr_allocstr(g_mountlist_fname, "/tmp/mountlist.txt");
    163164        log_msg(2, "I guess you're testing edit_mountlist()");
    164165    }
     
    274275        }
    275276        if (g_ISO_restore_mode) {
    276             asprintf(&tmp, "umount %s", bkpinfo->isodir);
     277            mr_asprintf(&tmp, "umount %s", bkpinfo->isodir);
    277278            run_program_and_log_output(tmp, FALSE);
    278             paranoid_free(tmp);
     279            mr_free(tmp);
    279280        }
    280281        paranoid_MR_finish(0);
     
    386387            save_mountlist_to_disk(mountlist, g_mountlist_fname);
    387388            tmp1 = find_my_editor();
    388             asprintf(&tmp, "%s %s", tmp1, g_mountlist_fname);
    389             paranoid_free(tmp1);
     389            mr_asprintf(&tmp, "%s %s", tmp1, g_mountlist_fname);
     390            mr_free(tmp1);
    390391
    391392            res = system(tmp);
    392             paranoid_free(tmp);
     393            mr_free(tmp);
    393394            load_mountlist(mountlist, g_mountlist_fname);
    394395        } else {
     
    500501             ask_me_yes_or_no
    501502             (_("Do you want me to restore _some_ of your data?")))) {
    502         asprintf(&old_restpath,bkpinfo->restore_path);
     503        mr_asprintf(&old_restpath,bkpinfo->restore_path);
    503504        for (done = FALSE; !done;) {
    504505            unlink("/tmp/filelist.full");
     
    514515                    if (!strcmp(bkpinfo->restore_path, "/")) {
    515516                        if (!ask_me_yes_or_no(_("Are you sure?"))) {
    516                             paranoid_alloc(bkpinfo->restore_path, old_restpath);
     517                            mr_allocstr(bkpinfo->restore_path, old_restpath);
    517518                            goto gotos_suck;
    518519                        }
    519                         paranoid_alloc(bkpinfo->restore_path, "");  // so we restore to [blank]/file/name :)
     520                        mr_allocstr(bkpinfo->restore_path, ""); // so we restore to [blank]/file/name :)
    520521                    }
    521522                    log_msg(1, "Restoring subset");
     
    523524                    free_filelist(filelist);
    524525                } else {
    525                     paranoid_alloc(bkpinfo->restore_path,old_restpath);
     526                    mr_allocstr(bkpinfo->restore_path,old_restpath);
    526527                    free_filelist(filelist);
    527528                }
     
    534535            }
    535536        }
    536         paranoid_free(old_restpath);
     537        mr_free(old_restpath);
    537538    } else {
    538539        mvaddstr_and_log_it(g_currentY++,
     
    567568                            ("Using e2label to label your ext2,3 partitions"));
    568569        if (does_file_exist("/tmp/fstab.new")) {
    569             asprintf(&fstab_fname, "/tmp/fstab.new");
     570            mr_asprintf(&fstab_fname, "/tmp/fstab.new");
    570571        } else {
    571             asprintf(&fstab_fname, "/tmp/fstab");
    572         }
    573         asprintf(&tmp,
     572            mr_asprintf(&fstab_fname, "/tmp/fstab");
     573        }
     574        mr_asprintf(&tmp,
    574575                "label-partitions-as-necessary %s < %s >> %s 2>> %s",
    575576                g_mountlist_fname, fstab_fname, MONDO_LOGFILE,
    576577                MONDO_LOGFILE);
    577         paranoid_free(fstab_fname);
     578        mr_free(fstab_fname);
    578579
    579580        res = system(tmp);
    580         paranoid_free(tmp);
     581        mr_free(tmp);
    581582        if (res) {
    582583            log_to_screen
     
    679680            (strstr(tmp1,"RESTORE") == NULL)) {
    680681                /* -H option */
    681                 asprintf(&tmp,
     682                mr_asprintf(&tmp,
    682683                    _
    683684                    (" Mondo has restored your system. Please remove the backup media and reboot.\n\nPlease visit our website at http://www.mondorescue.org for more information."));
    684685                popup_and_OK(tmp);
    685                 paranoid_free(tmp);
    686         }
    687         paranoid_free(tmp1);
     686                mr_free(tmp);
     687        }
     688        mr_free(tmp1);
    688689
    689690        log_to_screen(_
     
    739740        resize_mountlist_proportionately_to_suit_new_drives(mountlist);
    740741    }
    741     paranoid_free(tmp);
     742    mr_free(tmp);
    742743
    743744    if (!evaluate_mountlist(mountlist, tmpA, tmpB, tmpC)) {
    744         asprintf(&tmp,
     745        mr_asprintf(&tmp,
    745746                _
    746747                ("Mountlist analyzed. Result: \"%s %s %s\" Switch to Interactive Mode?"),
    747748                tmpA, tmpB, tmpC);
    748749        if (ask_me_yes_or_no(tmp)) {
    749             paranoid_free(tmp);
     750            mr_free(tmp);
    750751            retval = interactive_mode(bkpinfo, mountlist, raidlist);
    751752            goto after_the_nuke;
    752753        } else {
    753             paranoid_free(tmp);
     754            mr_free(tmp);
    754755            fatal_error("Nuke Mode aborted. ");
    755756        }
     
    787788                }
    788789            }
    789             paranoid_free(tmp);
     790            mr_free(tmp);
    790791
    791792            retval += res;
     
    840841                        ("Using e2label to label your ext2,3 partitions"));
    841842
    842     asprintf(&tmp, "label-partitions-as-necessary %s < /tmp/fstab",
     843    mr_asprintf(&tmp, "label-partitions-as-necessary %s < /tmp/fstab",
    843844            g_mountlist_fname);
    844845    res = run_program_and_log_output(tmp, TRUE);
    845     paranoid_free(tmp);
     846    mr_free(tmp);
    846847
    847848    if (res) {
     
    916917    }
    917918
    918     paranoid_alloc(bkpinfo->restore_path, "/");
     919    mr_allocstr(bkpinfo->restore_path, "/");
    919920    if (!g_restoring_live_from_cd) {
    920921        popup_and_OK
     
    945946    if (filelist) {
    946947        save_filelist(filelist, "/tmp/selected-files.txt");
    947         asprintf(&old_restpath,bkpinfo->restore_path);
     948        mr_asprintf(&old_restpath,bkpinfo->restore_path);
    948949        if (popup_and_get_string(_("Restore path"),
    949950                                 _("Restore files to where? )"),
     
    953954        }
    954955        free_filelist(filelist);
    955         paranoid_alloc(bkpinfo->restore_path,old_restpath);
     956        mr_allocstr(bkpinfo->restore_path,old_restpath);
    956957    }
    957958    if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) {
     
    10341035    if (!(fin = fopen(tmp,"r"))) {
    10351036        log_to_screen(_("Cannot even open bigfile's info file"));
    1036         paranoid_free(tmp);
     1037        mr_free(tmp);
    10371038        return (pathname_of_last_file_restored);
    10381039    }
    1039     paranoid_free(tmp);
     1040    mr_free(tmp);
    10401041
    10411042    memset((void *) &biggiestruct, 0, sizeof(biggiestruct));
     
    10471048    paranoid_fclose(fin);
    10481049
    1049     asprintf(&checksum, biggiestruct.checksum);
     1050    mr_asprintf(&checksum, biggiestruct.checksum);
    10501051
    10511052    if (!checksum[0]) {
    1052         asprintf(&tmp, "Warning - bigfile %ld does not have a checksum",
     1053        mr_asprintf(&tmp, "Warning - bigfile %ld does not have a checksum",
    10531054                bigfileno + 1);
    10541055        log_msg(3, tmp);
    1055         paranoid_free(tmp);
     1056        mr_free(tmp);
    10561057        /* BERLIOS : Useless ???
    10571058        p = checksum;
    10581059        */
    10591060    }
    1060     paranoid_free(checksum);
     1061    mr_free(checksum);
    10611062
    10621063    if (!strncmp(biggiestruct.filename, "/dev/", 5))    // Whether NTFS or not :)
    10631064    {
    1064         asprintf(&outfile_fname, biggiestruct.filename);
     1065        mr_asprintf(&outfile_fname, biggiestruct.filename);
    10651066    } else {
    1066         asprintf(&outfile_fname, "%s/%s", bkpinfo->restore_path,
     1067        mr_asprintf(&outfile_fname, "%s/%s", bkpinfo->restore_path,
    10671068                biggiestruct.filename);
    10681069    }
     
    11011102                "Calling ntfsclone in background because %s is an NTFS /dev entry",
    11021103                outfile_fname);
    1103         asprintf(&ntfsprog_fifo, "/tmp/%d.%d.000", (int) (random() % 32768),
     1104        mr_asprintf(&ntfsprog_fifo, "/tmp/%d.%d.000", (int) (random() % 32768),
    11041105                (int) (random() % 32768));
    11051106        mkfifo(ntfsprog_fifo, 0x770);
     
    11251126        }
    11261127        // BERLIOS: Is it the right place ??
    1127         paranoid_free(ntfsprog_fifo);
     1128        mr_free(ntfsprog_fifo);
    11281129    } else {
    11291130        use_ntfsprog_hack = FALSE;
     
    11351136    }
    11361137
    1137     asprintf(&tmp, "Reassembling big file %ld (%s)", bigfileno + 1,
     1138    mr_asprintf(&tmp, "Reassembling big file %ld (%s)", bigfileno + 1,
    11381139            outfile_fname);
    11391140    log_msg(2, tmp);
    1140     paranoid_free(tmp);
     1141    mr_free(tmp);
    11411142
    11421143    /*
     
    11461147     */
    11471148
    1148     asprintf(&pathname_of_last_file_restored, biggiestruct.filename);
     1149    mr_asprintf(&pathname_of_last_file_restored, biggiestruct.filename);
    11491150
    11501151    log_msg(3, "file_to_openout = %s", file_to_openout);
     
    11651166                    g_current_media_number);
    11661167            g_current_media_number++;
    1167             asprintf(&tmp3,
     1168            mr_asprintf(&tmp3,
    11681169                    "Asking for %s #%d so that I may read slice #%ld\n",
    11691170                    bkpinfo->backup_media_string,
    11701171                    g_current_media_number, sliceno);
    11711172            log_msg(2, tmp3);
    1172             paranoid_free(tmp3);
    1173 
    1174             asprintf(&tmp3, _("Restoring from %s #%d"),
     1173            mr_free(tmp3);
     1174
     1175            mr_asprintf(&tmp3, _("Restoring from %s #%d"),
    11751176                    bkpinfo->backup_media_string,
    11761177                    g_current_media_number);
    11771178            log_to_screen(tmp3);
    1178             paranoid_free(tmp3);
     1179            mr_free(tmp3);
    11791180
    11801181            insist_on_this_cd_number(bkpinfo, g_current_media_number);
     
    11891190            } else {
    11901191                if (does_file_exist(tmp1)) {
    1191                     asprintf(&bzip2_command, "lzop -dc %s 2>> %s",tmp1, MONDO_LOGFILE);
     1192                    mr_asprintf(&bzip2_command, "lzop -dc %s 2>> %s",tmp1, MONDO_LOGFILE);
    11921193                } else if (does_file_exist(tmp2)) {
    1193                         asprintf(&bzip2_command, "bzip2 -dc %s 2>> %s",tmp2, MONDO_LOGFILE);
     1194                        mr_asprintf(&bzip2_command, "bzip2 -dc %s 2>> %s",tmp2, MONDO_LOGFILE);
    11941195                } else if (does_file_exist(tmp)) {
    1195                         asprintf(&bzip2_command, "%s", "");
     1196                        mr_asprintf(&bzip2_command, "%s", "");
    11961197                } else {
    11971198                    log_to_screen(_("OK, that's pretty fsck0red..."));
     
    12011202
    12021203            if (bzip2_command == NULL) {
    1203                 asprintf(&bzip2_command, "cat %s 2>> %s", tmp, MONDO_LOGFILE);
    1204             }
    1205             asprintf(&tmp3, "Working on %s #%d, file #%ld, slice #%ld ",
     1204                mr_asprintf(&bzip2_command, "cat %s 2>> %s", tmp, MONDO_LOGFILE);
     1205            }
     1206            mr_asprintf(&tmp3, "Working on %s #%d, file #%ld, slice #%ld ",
    12061207                    bkpinfo->backup_media_string,
    12071208                    g_current_media_number, bigfileno + 1, sliceno);
     
    12121213                update_progress_form(tmp3);
    12131214            }
    1214             paranoid_free(tmp3);
     1215            mr_free(tmp3);
    12151216
    12161217            if (!(fbzip2 = popen(bzip2_command, "r"))) {
    12171218                fatal_error("Can't run popen command");
    12181219            }
    1219             paranoid_free(bzip2_command);
     1220            mr_free(bzip2_command);
    12201221
    12211222            while (!feof(fbzip2)) {
     
    12231224                if (siz > 0) {
    12241225                    siz1 = fwrite(bigblk, 1, siz, fout);
    1225                     asprintf(&sz_msg, "Read %ld from fbzip2; written %ld to fout", siz, siz1);
     1226                    mr_asprintf(&sz_msg, "Read %ld from fbzip2; written %ld to fout", siz, siz1);
    12261227                    log_it(sz_msg);
    1227                     paranoid_free(sz_msg);
     1228                    mr_free(sz_msg);
    12281229                }
    12291230            }
     
    12341235            g_current_progress++;
    12351236        }
    1236         paranoid_free(tmp);
    1237         paranoid_free(tmp1);
    1238         paranoid_free(tmp2);
     1237        mr_free(tmp);
     1238        mr_free(tmp1);
     1239        mr_free(tmp2);
    12391240    }
    12401241    paranoid_fclose(fout);
     
    12431244    if (use_ntfsprog_hack) {
    12441245        log_msg(3, "Waiting for ntfsclone to finish");
    1245         asprintf(&tmp,
     1246        mr_asprintf(&tmp,
    12461247                " ps | grep \" ntfsclone \" | grep -v grep > /dev/null 2> /dev/null");
    12471248        while (system(tmp) == 0) {
    12481249            sleep(1);
    12491250        }
    1250         paranoid_free(tmp);
     1251        mr_free(tmp);
    12511252        log_it("OK, ntfsclone has really finished");
    12521253    }
     
    12601261        utime(outfile_fname, ubuf);
    12611262    }
    1262     paranoid_free(outfile_fname);
    1263     paranoid_free(bigblk);
     1263    mr_free(outfile_fname);
     1264    mr_free(bigblk);
    12641265
    12651266    return (pathname_of_last_file_restored);
     
    13291330    }
    13301331
    1331     asprintf(&pathname_of_last_file_restored, orig_bf_fname);
     1332    mr_asprintf(&pathname_of_last_file_restored, orig_bf_fname);
    13321333
    13331334    /* open out to biggiefile to be restored (or /dev/null if biggiefile is not to be restored) */
     
    13591360    if (use_ntfsprog) {
    13601361        g_loglevel = 4;
    1361         asprintf(&outfile_fname, orig_bf_fname);
     1362        mr_asprintf(&outfile_fname, orig_bf_fname);
    13621363        use_ntfsprog_hack = TRUE;
    13631364        log_msg(2,
    13641365                "Calling ntfsclone in background because %s is a /dev entry",
    13651366                outfile_fname);
    1366         asprintf(&ntfsprog_fifo, "%s/%d.%d.000",
     1367        mr_asprintf(&ntfsprog_fifo, "%s/%d.%d.000",
    13671368                bkpinfo->tmpdir,
    13681369                (int) (random() % 32768),
     
    13871388                    (long int) (pid));
    13881389        }
    1389         paranoid_free(ntfsprog_fifo);
     1390        mr_free(ntfsprog_fifo);
    13901391    } else {
    13911392        if (!strncmp(orig_bf_fname, "/dev/", 5))    // non-NTFS partition
    13921393        {
    1393             asprintf(&outfile_fname, orig_bf_fname);
     1394            mr_asprintf(&outfile_fname, orig_bf_fname);
    13941395        } else                  // biggiefile
    13951396        {
    1396             asprintf(&outfile_fname, "%s/%s", bkpinfo->restore_path,
     1397            mr_asprintf(&outfile_fname, "%s/%s", bkpinfo->restore_path,
    13971398                    orig_bf_fname);
    13981399        }
     
    14031404            make_hole_for_file(outfile_fname);
    14041405        }
    1405         asprintf(&tmp1, "Reassembling big file %ld (%s)",
     1406        mr_asprintf(&tmp1, "Reassembling big file %ld (%s)",
    14061407                biggiefile_number + 1, orig_bf_fname);
    14071408        log_msg(2, tmp1);
    1408         paranoid_free(tmp1);
     1409        mr_free(tmp1);
    14091410    }
    14101411
    14111412    if (dummy_restore) {
    1412         paranoid_free(outfile_fname);
    1413         asprintf(&outfile_fname, "/dev/null");
     1413        mr_free(outfile_fname);
     1414        mr_asprintf(&outfile_fname, "/dev/null");
    14141415    }
    14151416
    14161417    if (bkpinfo->zip_exe == NULL) {
    1417         asprintf(&command, "cat > \"%s\"", file_to_openout);
     1418        mr_asprintf(&command, "cat > \"%s\"", file_to_openout);
    14181419    } else {
    1419         asprintf(&command, "%s -dc > \"%s\" 2>> %s", bkpinfo->zip_exe,
     1420        mr_asprintf(&command, "%s -dc > \"%s\" 2>> %s", bkpinfo->zip_exe,
    14201421                file_to_openout, MONDO_LOGFILE);
    14211422    }
    1422     asprintf(&tmp1, "Pipe command = '%s'", command);
     1423    mr_asprintf(&tmp1, "Pipe command = '%s'", command);
    14231424    log_msg(3, tmp1);
    1424     paranoid_free(tmp1);
     1425    mr_free(tmp1);
    14251426
    14261427    /* restore biggiefile, one slice at a time */
     
    14281429        fatal_error("Cannot pipe out");
    14291430    }
    1430     paranoid_free(command);
     1431    mr_free(command);
    14311432
    14321433    for (res = read_header_block_from_stream(&slice_siz, tmp, &ctrl_chr);
     
    14361437            wrong_marker(BLK_START_AN_AFIO_OR_SLICE, ctrl_chr);
    14371438        }
    1438         asprintf(&tmp1, "Working on file #%ld, slice #%ld    ",
     1439        mr_asprintf(&tmp1, "Working on file #%ld, slice #%ld    ",
    14391440                biggiefile_number + 1, current_slice_number);
    14401441        log_msg(2, tmp1);
     
    14461447        strip_spaces(tmp1);
    14471448        update_progress_form(tmp1);
    1448         paranoid_free(tmp1);
     1449        mr_free(tmp1);
    14491450
    14501451        if (current_slice_number == 0) {
     
    14771478        g_current_progress++;
    14781479    }
    1479     paranoid_free(tmp);
     1480    mr_free(tmp);
    14801481    paranoid_pclose(pout);
    14811482
     
    14851486    if (use_ntfsprog_hack) {
    14861487        log_msg(3, "Waiting for ntfsclone to finish");
    1487         asprintf(&tmp,
     1488        mr_asprintf(&tmp,
    14881489                " ps | grep \" ntfsclone \" | grep -v grep > /dev/null 2> /dev/null");
    14891490        while (system(tmp) == 0) {
    14901491            sleep(1);
    14911492        }   
    1492         paranoid_free(tmp);
     1493        mr_free(tmp);
    14931494        log_msg(3, "OK, ntfsclone has really finished");
    14941495    }
     
    15051506    }
    15061507
    1507     paranoid_free(outfile_fname);
     1508    mr_free(outfile_fname);
    15081509    g_loglevel = old_loglevel;
    15091510    return (pathname_of_last_file_restored);
     
    15511552    log_msg(5, "Entering");
    15521553    use_star = (strstr(tarball_fname, ".star")) ? TRUE : FALSE;
    1553     asprintf(&command, "mkdir -p %s/tmp", MNT_RESTORING);
     1554    mr_asprintf(&command, "mkdir -p %s/tmp", MNT_RESTORING);
    15541555    run_program_and_log_output(command, 9);
    1555     paranoid_free(command);
    1556 
    1557     asprintf(&filelist_name, MNT_CDROM "/archives/filelist.%ld",
     1556    mr_free(command);
     1557
     1558    mr_asprintf(&filelist_name, MNT_CDROM "/archives/filelist.%ld",
    15581559            current_tarball_number);
    15591560    if (length_of_file(filelist_name) <= 2) {
     
    15721573        log_msg(3, "length_of_file(%s) = %llu", tarball_fname,
    15731574                length_of_file(tarball_fname));
    1574         asprintf(&tmp, "Unable to restore fileset #%ld (CD I/O error)",
     1575        mr_asprintf(&tmp, "Unable to restore fileset #%ld (CD I/O error)",
    15751576                current_tarball_number);
    15761577        log_to_screen(tmp);
    1577         paranoid_free(tmp);
     1578        mr_free(tmp);
    15781579        retval = 1;
    15791580        log_msg(5, "Leaving");
     
    15821583
    15831584    if (filelist) {
    1584         asprintf(&filelist_subset_fname, "/tmp/filelist-subset-%ld.tmp",
     1585        mr_asprintf(&filelist_subset_fname, "/tmp/filelist-subset-%ld.tmp",
    15851586                current_tarball_number);
    15861587        if ((matches =
     
    15891590                                             use_star))
    15901591            <= 0) {
    1591             asprintf(&tmp, "Skipping fileset %ld", current_tarball_number);
     1592            mr_asprintf(&tmp, "Skipping fileset %ld", current_tarball_number);
    15921593            log_msg(1, tmp);
    1593             paranoid_free(tmp);
     1594            mr_free(tmp);
    15941595        } else {
    15951596            log_msg(3, "Saved fileset %ld's subset to %s",
    15961597                    current_tarball_number, filelist_subset_fname);
    15971598        }
    1598         asprintf(&tmp, "Tarball #%ld --- %ld matches",
     1599        mr_asprintf(&tmp, "Tarball #%ld --- %ld matches",
    15991600                current_tarball_number, matches);
    16001601        log_to_screen(tmp);
    1601         paranoid_free(tmp);
     1602        mr_free(tmp);
    16021603    } else {
    16031604        filelist_subset_fname = NULL;
    16041605    }
    1605     paranoid_free(filelist_name);
     1606    mr_free(filelist_name);
    16061607
    16071608    if (filelist == NULL || matches > 0) {
    1608         asprintf(&xattr_fname, XATTR_LIST_FNAME_RAW_SZ,
     1609        mr_asprintf(&xattr_fname, XATTR_LIST_FNAME_RAW_SZ,
    16091610                MNT_CDROM "/archives", current_tarball_number);
    1610         asprintf(&acl_fname, ACL_LIST_FNAME_RAW_SZ, MNT_CDROM "/archives",
     1611        mr_asprintf(&acl_fname, ACL_LIST_FNAME_RAW_SZ, MNT_CDROM "/archives",
    16111612                current_tarball_number);
    16121613        if (strstr(tarball_fname, ".bz2")) {
    1613             asprintf(&executable, "bzip2");
     1614            mr_asprintf(&executable, "bzip2");
    16141615        } else if (strstr(tarball_fname, ".lzo")) {
    1615             asprintf(&executable, "lzop");
     1616            mr_asprintf(&executable, "lzop");
    16161617        } else {
    16171618            executable = NULL;
     
    16191620
    16201621        if (executable == NULL) {
    1621             asprintf(&tmp, "which %s > /dev/null 2> /dev/null", executable);
     1622            mr_asprintf(&tmp, "which %s > /dev/null 2> /dev/null", executable);
    16221623            if (run_program_and_log_output(tmp, FALSE)) {
    16231624                log_to_screen
     
    16261627                paranoid_MR_finish(1);
    16271628            }
    1628             paranoid_free(tmp);
    1629 
    1630             asprintf(&tmp, executable);
    1631             asprintf(&executable, "-P %s -Z", tmp);
    1632             paranoid_free(tmp);
     1629            mr_free(tmp);
     1630
     1631            mr_asprintf(&tmp, executable);
     1632            mr_asprintf(&executable, "-P %s -Z", tmp);
     1633            mr_free(tmp);
    16331634        }
    16341635#ifdef __FreeBSD__
     
    16381639#endif
    16391640
    1640         asprintf(&temp_log, "/tmp/%d.%d", (int) (random() % 32768),
     1641        mr_asprintf(&temp_log, "/tmp/%d.%d", (int) (random() % 32768),
    16411642            (int) (random() % 32768));
    16421643
    16431644        if (use_star) {
    16441645            if (strstr(tarball_fname, ".bz2")) {
    1645                 asprintf(&tmp, " -bz");
     1646                mr_asprintf(&tmp, " -bz");
    16461647            } else {
    1647                 asprintf(&tmp, "%s", "");
    1648             }
    1649             asprintf(&command,
     1648                mr_asprintf(&tmp, "%s", "");
     1649            }
     1650            mr_asprintf(&command,
    16501651                    "star -x -force-remove -U " STAR_ACL_SZ
    16511652                    " errctl= file=%s %s 2>> %s >> %s", tarball_fname, tmp, temp_log, temp_log);
    1652             paranoid_free(tmp);
     1653            mr_free(tmp);
    16531654        } else {
    16541655            if (filelist_subset_fname != NULL) {
    1655                 asprintf(&command,
     1656                mr_asprintf(&command,
    16561657                        "afio -i -M 8m -b %ld -c %ld %s -w '%s' %s 2>> %s >> %s",
    16571658                        TAPE_BLOCK_SIZE,
     
    16601661                        tarball_fname, temp_log, temp_log);
    16611662            } else {
    1662                 asprintf(&command,
     1663                mr_asprintf(&command,
    16631664                        "afio -i -b %ld -c %ld -M 8m %s %s 2>> %s >> %s",
    16641665                        TAPE_BLOCK_SIZE,
     
    16661667            }
    16671668        }
    1668         paranoid_free(executable);
     1669        mr_free(executable);
    16691670
    16701671#undef BUFSIZE
     
    16801681            }
    16811682        }
    1682         paranoid_free(command);
     1683        mr_free(command);
    16831684
    16841685        if (res && length_of_file(temp_log) < 5) {
     
    17111712        }
    17121713        if (retval) {
    1713             asprintf(&command, "cat %s >> %s", temp_log, MONDO_LOGFILE);
     1714            mr_asprintf(&command, "cat %s >> %s", temp_log, MONDO_LOGFILE);
    17141715            system(command);
    1715             paranoid_free(command);
     1716            mr_free(command);
    17161717            log_msg(2, "Errors occurred while processing fileset #%d",
    17171718                    current_tarball_number);
     
    17201721        }
    17211722        unlink(xattr_fname);
    1722         paranoid_free(xattr_fname);
     1723        mr_free(xattr_fname);
    17231724    }
    17241725    if (does_file_exist("/PAUSE")) {
     
    17311732    unlink(temp_log);
    17321733
    1733     paranoid_free(filelist_subset_fname);
    1734     paranoid_free(acl_fname);
    1735     paranoid_free(temp_log);
     1734    mr_free(filelist_subset_fname);
     1735    mr_free(acl_fname);
     1736    mr_free(temp_log);
    17361737
    17371738    log_msg(5, "Leaving");
     
    17851786    /* to do it with a file... */
    17861787    use_star = (strstr(tarball_fname, ".star")) ? TRUE : FALSE;
    1787     asprintf(&tmp,
     1788    mr_asprintf(&tmp,
    17881789            "Restoring from fileset #%ld (%ld KB) on %s #%d",
    17891790            current_tarball_number, (long) size >> 10,
     
    17911792            g_current_media_number);
    17921793    log_msg(2, tmp);
    1793     paranoid_free(tmp);
     1794    mr_free(tmp);
    17941795    run_program_and_log_output("mkdir -p " MNT_RESTORING "/tmp", FALSE);
    17951796
     
    17991800   * in afio or someting; oh darn.. OK, use tmpfs :-)                         *
    18001801   ****************************************************************************/
    1801     asprintf(&afio_fname, "/tmp/tmpfs/archive.tmp.%ld",
     1802    mr_asprintf(&afio_fname, "/tmp/tmpfs/archive.tmp.%ld",
    18021803            current_tarball_number);
    1803     asprintf(&filelist_fname, "%s/filelist.%ld", bkpinfo->tmpdir,
     1804    mr_asprintf(&filelist_fname, "%s/filelist.%ld", bkpinfo->tmpdir,
    18041805            current_tarball_number);
    1805     asprintf(&filelist_subset_fname, "%s/filelist-subset-%ld.tmp",
     1806    mr_asprintf(&filelist_subset_fname, "%s/filelist-subset-%ld.tmp",
    18061807            bkpinfo->tmpdir, current_tarball_number);
    18071808    res = read_file_from_stream_to_file(bkpinfo, afio_fname, size);
     
    18141815    if (bkpinfo->compression_level != 0) {
    18151816        if (bkpinfo->use_star) {
    1816             asprintf(&executable, " -bz");
     1817            mr_asprintf(&executable, " -bz");
    18171818        } else {
    1818             asprintf(&executable, "-P %s -Z", bkpinfo->zip_exe);
     1819            mr_asprintf(&executable, "-P %s -Z", bkpinfo->zip_exe);
    18191820        }
    18201821    }
     
    18271828        if (strstr(tarball_fname, ".star.")) {
    18281829            use_star = TRUE;
    1829             asprintf(&command, "star -t file=%s %s > %s 2>> %s", afio_fname, executable, filelist_fname, MONDO_LOGFILE);
     1830            mr_asprintf(&command, "star -t file=%s %s > %s 2>> %s", afio_fname, executable, filelist_fname, MONDO_LOGFILE);
    18301831        } else {
    18311832            use_star = FALSE;
    1832             asprintf(&command, "afio -t -M 8m -b %ld %s %s > %s 2>> %s", TAPE_BLOCK_SIZE,
     1833            mr_asprintf(&command, "afio -t -M 8m -b %ld %s %s > %s 2>> %s", TAPE_BLOCK_SIZE,
    18331834                    executable, afio_fname, filelist_fname, MONDO_LOGFILE);
    18341835        }
     
    18371838            log_msg(4, "Warning - error occurred while retrieving TOC");
    18381839        }
    1839         paranoid_free(command);
     1840        mr_free(command);
    18401841        if ((matches =
    18411842             save_filelist_entries_in_common(filelist_fname, filelist,
     
    18471848                        current_tarball_number);
    18481849            }
    1849             asprintf(&tmp, "Skipping fileset %ld", current_tarball_number);
     1850            mr_asprintf(&tmp, "Skipping fileset %ld", current_tarball_number);
    18501851            log_msg(2, tmp);
    1851             paranoid_free(tmp);
     1852            mr_free(tmp);
    18521853            restore_this_fileset = FALSE;
    18531854        } else {
     
    18591860    }
    18601861    unlink(filelist_fname);
    1861     paranoid_free(filelist_fname);
     1862    mr_free(filelist_fname);
    18621863
    18631864// Concoct the call to star/afio to restore files
     
    18651866        // star
    18661867        if (filelist) {
    1867             asprintf(&command, "star -x file=%s %s list=%s 2>> %s", afio_fname, executable,
     1868            mr_asprintf(&command, "star -x file=%s %s list=%s 2>> %s", afio_fname, executable,
    18681869                    filelist_subset_fname,MONDO_LOGFILE);
    18691870        } else {
    1870             asprintf(&command,"star -x file=%s %s 2>> %s", afio_fname, executable,MONDO_LOGFILE);
     1871            mr_asprintf(&command,"star -x file=%s %s 2>> %s", afio_fname, executable,MONDO_LOGFILE);
    18711872        }
    18721873    } else {
    18731874        // afio
    18741875        if (filelist) {
    1875             asprintf(&command, "afio -i -M 8m -b %ld %s -w %s %s 2>> %s", TAPE_BLOCK_SIZE, executable, filelist_subset_fname,afio_fname,MONDO_LOGFILE);
     1876            mr_asprintf(&command, "afio -i -M 8m -b %ld %s -w %s %s 2>> %s", TAPE_BLOCK_SIZE, executable, filelist_subset_fname,afio_fname,MONDO_LOGFILE);
    18761877        } else {
    1877             asprintf(&command, "afio -i -M 8m -b %ld %s %s 2>> %s", TAPE_BLOCK_SIZE, executable,afio_fname,MONDO_LOGFILE);
    1878         }
    1879     }
    1880     paranoid_free(executable);
     1878            mr_asprintf(&command, "afio -i -M 8m -b %ld %s %s 2>> %s", TAPE_BLOCK_SIZE, executable,afio_fname,MONDO_LOGFILE);
     1879        }
     1880    }
     1881    mr_free(executable);
    18811882
    18821883    // Call if IF there are files to restore (selectively/unconditionally)
     
    19051906        log_msg(1, "NOT CALLING '%s'", command);
    19061907    }
    1907     paranoid_free(command);
     1908    mr_free(command);
    19081909
    19091910    if (does_file_exist("/PAUSE") && current_tarball_number >= 50) {
     
    19151916    unlink(afio_fname);
    19161917
    1917     paranoid_free(filelist_subset_fname);
    1918     paranoid_free(afio_fname);
     1918    mr_free(filelist_subset_fname);
     1919    mr_free(afio_fname);
    19191920    return (retval);
    19201921}
     
    19521953    assert(bkpinfo != NULL);
    19531954
    1954     asprintf(&biggies_whose_EXATs_we_should_set,
     1955    mr_asprintf(&biggies_whose_EXATs_we_should_set,
    19551956            "%s/biggies-whose-EXATs-we-should-set", bkpinfo->tmpdir);
    19561957    if (!(fbw = fopen(biggies_whose_EXATs_we_should_set, "w"))) {
     
    19611962    read_cfg_var(g_mondo_cfg_file, "total-slices", tmp);
    19621963    total_slices = atol(tmp);
    1963     paranoid_free(tmp);
    1964 
    1965     asprintf(&tmp, _("Reassembling large files      "));
     1964    mr_free(tmp);
     1965
     1966    mr_asprintf(&tmp, _("Reassembling large files      "));
    19661967    mvaddstr_and_log_it(g_currentY, 0, tmp);
    1967     paranoid_free(tmp);
     1968    mr_free(tmp);
    19681969
    19691970    if (length_of_file(BIGGIELIST) < 6) {
     
    19771978        return (0);
    19781979    }
    1979     asprintf(&tmp, "OK, there are %ld biggiefiles in the archives",
     1980    mr_asprintf(&tmp, "OK, there are %ld biggiefiles in the archives",
    19801981            noof_biggiefiles);
    19811982    log_msg(2, tmp);
    1982     paranoid_free(tmp);
     1983    mr_free(tmp);
    19831984
    19841985    open_progress_form(_("Reassembling large files"),
     
    19981999            tmp1 = slice_fname(bigfileno + 1, 0, ARCHIVES_PATH, "");
    19992000            log_msg(3, "Slicename would have been %s", tmp1);
    2000             paranoid_free(tmp1);
     2001            mr_free(tmp1);
    20012002
    20022003            // I'm not positive 'just_changed_cds' is even necessary...
     
    20082009                insist_on_this_cd_number(bkpinfo,
    20092010                                         ++g_current_media_number);
    2010                 asprintf(&tmp, _("Restoring from %s #%d"),
     2011                mr_asprintf(&tmp, _("Restoring from %s #%d"),
    20112012                        bkpinfo->backup_media_string,
    20122013                        g_current_media_number);
    20132014                log_to_screen(tmp);
    2014                 paranoid_free(tmp);
     2015                mr_free(tmp);
    20152016
    20162017                just_changed_cds = TRUE;
     
    20232024        } else {
    20242025            just_changed_cds = FALSE;
    2025             asprintf(&tmp, _("Restoring big file %ld"), bigfileno + 1);
     2026            mr_asprintf(&tmp, _("Restoring big file %ld"), bigfileno + 1);
    20262027            update_progress_form(tmp);
    2027             paranoid_free(tmp);
     2028            mr_free(tmp);
    20282029
    20292030            pathname_of_last_biggie_restored =
     
    20332034                fprintf(fbw, "%s\n", pathname_of_last_biggie_restored);
    20342035            }
    2035             paranoid_free(pathname_of_last_biggie_restored);
     2036            mr_free(pathname_of_last_biggie_restored);
    20362037            retval += res;
    20372038            bigfileno++;
    20382039
    20392040        }
    2040         paranoid_free(tmp);
     2041        mr_free(tmp);
    20412042    }
    20422043
    20432044    if (fbw) {
    20442045        fclose(fbw);
    2045         asprintf(&acl_fname, ACL_BIGGLST_FNAME_RAW_SZ, ARCHIVES_PATH);
    2046         asprintf(&xattr_fname, XATTR_BIGGLST_FNAME_RAW_SZ, ARCHIVES_PATH);
     2046        mr_asprintf(&acl_fname, ACL_BIGGLST_FNAME_RAW_SZ, ARCHIVES_PATH);
     2047        mr_asprintf(&xattr_fname, XATTR_BIGGLST_FNAME_RAW_SZ, ARCHIVES_PATH);
    20472048        tmp = find_home_of_exe("setfacl");
    20482049        if (length_of_file(acl_fname) > 0 && tmp) {
    20492050            set_acl_list(biggies_whose_EXATs_we_should_set, acl_fname);
    20502051        }
    2051         paranoid_free(tmp);
     2052        mr_free(tmp);
    20522053
    20532054        tmp = find_home_of_exe("setfattr");
     
    20552056            set_fattr_list(biggies_whose_EXATs_we_should_set, xattr_fname);
    20562057        }
    2057         paranoid_free(tmp);
    2058         paranoid_free(acl_fname);
    2059         paranoid_free(xattr_fname);
    2060     }
    2061     paranoid_free(biggies_whose_EXATs_we_should_set);
     2058        mr_free(tmp);
     2059        mr_free(acl_fname);
     2060        mr_free(xattr_fname);
     2061    }
     2062    mr_free(biggies_whose_EXATs_we_should_set);
    20622063
    20632064    if (does_file_exist("/PAUSE")) {
     
    21172118    read_cfg_var(g_mondo_cfg_file, "last-filelist-number", tmp);
    21182119    max_val = atol(tmp) + 1;
    2119     paranoid_free(tmp);
    2120 
    2121     asprintf(&progress_str, _("Restoring from %s #%d"),
     2120    mr_free(tmp);
     2121
     2122    mr_asprintf(&progress_str, _("Restoring from %s #%d"),
    21222123            bkpinfo->backup_media_string,
    21232124            g_current_media_number);
     
    21312132        update_progress_form(progress_str);
    21322133
    2133         asprintf(&tarball_fname, MNT_CDROM "/archives/%ld.afio.bz2",
     2134        mr_asprintf(&tarball_fname, MNT_CDROM "/archives/%ld.afio.bz2",
    21342135                current_tarball_number);
    21352136        if (!does_file_exist(tarball_fname)) {
    2136             paranoid_free(tarball_fname);
    2137             asprintf(&tarball_fname, MNT_CDROM "/archives/%ld.afio.lzo",
     2137            mr_free(tarball_fname);
     2138            mr_asprintf(&tarball_fname, MNT_CDROM "/archives/%ld.afio.lzo",
    21382139                    current_tarball_number);
    21392140        }
    21402141        if (!does_file_exist(tarball_fname)) {
    2141             paranoid_free(tarball_fname);
    2142             asprintf(&tarball_fname, MNT_CDROM "/archives/%ld.afio.",
     2142            mr_free(tarball_fname);
     2143            mr_asprintf(&tarball_fname, MNT_CDROM "/archives/%ld.afio.",
    21432144                    current_tarball_number);
    21442145        }
    21452146        if (!does_file_exist(tarball_fname)) {
    2146             paranoid_free(tarball_fname);
    2147             asprintf(&tarball_fname, MNT_CDROM "/archives/%ld.star.bz2",
     2147            mr_free(tarball_fname);
     2148            mr_asprintf(&tarball_fname, MNT_CDROM "/archives/%ld.star.bz2",
    21482149                    current_tarball_number);
    21492150        }
    21502151        if (!does_file_exist(tarball_fname)) {
    2151             paranoid_free(tarball_fname);
    2152             asprintf(&tarball_fname, MNT_CDROM "/archives/%ld.star.",
     2152            mr_free(tarball_fname);
     2153            mr_asprintf(&tarball_fname, MNT_CDROM "/archives/%ld.star.",
    21532154                    current_tarball_number);
    21542155        }
    21552156        if (!does_file_exist(tarball_fname)) {
    2156             paranoid_free(tarball_fname);
     2157            mr_free(tarball_fname);
    21572158            if (current_tarball_number == 0) {
    21582159                log_to_screen
     
    21682169            }
    21692170            g_current_media_number++;
    2170             paranoid_free(progress_str);
    2171             asprintf(&progress_str, _("Restoring from %s #%d"),
     2171            mr_free(progress_str);
     2172            mr_asprintf(&progress_str, _("Restoring from %s #%d"),
    21722173                    bkpinfo->backup_media_string,
    21732174                    g_current_media_number);
    21742175            log_to_screen(progress_str);
    21752176        } else {
    2176             paranoid_free(progress_str);
    2177             asprintf(&progress_str,
     2177            mr_free(progress_str);
     2178            mr_asprintf(&progress_str,
    21782179                    _("Restoring from fileset #%ld on %s #%d"),
    21792180                    current_tarball_number,
     
    21892190            }
    21902191            if (res) {
    2191                 asprintf(&tmp1, _("reported errors"));
     2192                mr_asprintf(&tmp1, _("reported errors"));
    21922193            } else {
    2193                 asprintf(&tmp1, _("succeeded"));
    2194             }
    2195             asprintf(&tmp, _("%s #%d, fileset #%ld - restore %s"),
     2194                mr_asprintf(&tmp1, _("succeeded"));
     2195            }
     2196            mr_asprintf(&tmp, _("%s #%d, fileset #%ld - restore %s"),
    21962197                    bkpinfo->backup_media_string,
    21972198                    g_current_media_number, current_tarball_number,tmp1);
    2198             paranoid_free(tmp1);
     2199            mr_free(tmp1);
    21992200           
    22002201            if (attempts > 1) {
    2201                 asprintf(&tmp1, _(" (%d attempts) - review logs"), attempts);
    2202             }
    2203             asprintf(&comment, "%s%s", tmp, tmp1);
    2204             paranoid_free(tmp);
    2205             paranoid_free(tmp1);
     2202                mr_asprintf(&tmp1, _(" (%d attempts) - review logs"), attempts);
     2203            }
     2204            mr_asprintf(&comment, "%s%s", tmp, tmp1);
     2205            mr_free(tmp);
     2206            mr_free(tmp1);
    22062207            if (attempts > 1) {
    22072208                log_to_screen(comment);
    22082209            }
    2209             paranoid_free(comment);
     2210            mr_free(comment);
    22102211
    22112212            retval += res;
     
    22132214            g_current_progress++;
    22142215        }
    2215         paranoid_free(tarball_fname);
    2216     }
    2217     paranoid_free(progress_str);
     2216        mr_free(tarball_fname);
     2217    }
     2218    mr_free(progress_str);
    22182219    close_progress_form();
    22192220
     
    22652266    read_cfg_var(g_mondo_cfg_file, "total-slices", tmp);
    22662267    total_slices = atol(tmp);
    2267     paranoid_free(tmp);
    2268 
    2269     asprintf(&tmp, "Reassembling large files      ");
    2270     asprintf(&xattr_fname, XATTR_BIGGLST_FNAME_RAW_SZ, bkpinfo->tmpdir);
    2271     asprintf(&acl_fname, ACL_BIGGLST_FNAME_RAW_SZ, bkpinfo->tmpdir);
     2268    mr_free(tmp);
     2269
     2270    mr_asprintf(&tmp, "Reassembling large files      ");
     2271    mr_asprintf(&xattr_fname, XATTR_BIGGLST_FNAME_RAW_SZ, bkpinfo->tmpdir);
     2272    mr_asprintf(&acl_fname, ACL_BIGGLST_FNAME_RAW_SZ, bkpinfo->tmpdir);
    22722273    mvaddstr_and_log_it(g_currentY, 0, tmp);
    2273     paranoid_free(tmp);
    2274 
    2275     asprintf(&biggies_whose_EXATs_we_should_set,
     2274    mr_free(tmp);
     2275
     2276    mr_asprintf(&biggies_whose_EXATs_we_should_set,
    22762277            "%s/biggies-whose-EXATs-we-should-set", bkpinfo->tmpdir);
    22772278    if (!(fbw = fopen(biggies_whose_EXATs_we_should_set, "w"))) {
     
    22902291
    22912292    noof_biggiefiles = atol(biggie_fname);
    2292     asprintf(&tmp, "OK, there are %ld biggiefiles in the archives",
     2293    mr_asprintf(&tmp, "OK, there are %ld biggiefiles in the archives",
    22932294            noof_biggiefiles);
    22942295    log_msg(2, tmp);
    2295     paranoid_free(tmp);
     2296    mr_free(tmp);
    22962297
    22972298    open_progress_form(_("Reassembling large files"),
     
    23192320        }
    23202321        */
    2321         asprintf(&tmp, _("Restoring big file %ld (%lld K)"),
     2322        mr_asprintf(&tmp, _("Restoring big file %ld (%lld K)"),
    23222323                current_bigfile_number + 1, biggie_size / 1024);
    23232324        update_progress_form(tmp);
    2324         paranoid_free(tmp);
     2325        mr_free(tmp);
    23252326
    23262327        pathname_of_last_biggie_restored = restore_a_biggiefile_from_stream(bkpinfo, biggie_fname,
     
    23322333            fprintf(fbw, "%s\n", pathname_of_last_biggie_restored);
    23332334        }
    2334         paranoid_free(pathname_of_last_biggie_restored);
     2335        mr_free(pathname_of_last_biggie_restored);
    23352336
    23362337        retval += res;
     
    23402341    if (current_bigfile_number != noof_biggiefiles
    23412342        && noof_biggiefiles != 0) {
    2342         asprintf(&tmp, "Warning - bigfileno=%ld but noof_biggiefiles=%ld\n",
     2343        mr_asprintf(&tmp, "Warning - bigfileno=%ld but noof_biggiefiles=%ld\n",
    23432344                current_bigfile_number, noof_biggiefiles);
    23442345    } else {
    2345         asprintf(&tmp,
     2346        mr_asprintf(&tmp,
    23462347                "%ld biggiefiles in biggielist.txt; %ld biggiefiles processed today.",
    23472348                noof_biggiefiles, current_bigfile_number);
    23482349    }
    23492350    log_msg(1, tmp);
    2350     paranoid_free(tmp);
     2351    mr_free(tmp);
    23512352
    23522353    if (fbw) {
     
    23702371        }
    23712372    }
    2372     paranoid_free(xattr_fname);
    2373     paranoid_free(acl_fname);
    2374     paranoid_free(biggies_whose_EXATs_we_should_set);
     2373    mr_free(xattr_fname);
     2374    mr_free(acl_fname);
     2375    mr_free(biggies_whose_EXATs_we_should_set);
    23752376
    23762377    if (does_file_exist("/PAUSE")) {
     
    23862387        mvaddstr_and_log_it(g_currentY++, 74, _("Done."));
    23872388    }
    2388     paranoid_free(biggie_fname);
     2389    mr_free(biggie_fname);
    23892390    return (retval);
    23902391}
     
    24282429    read_cfg_var(g_mondo_cfg_file, "last-filelist-number", tmp);
    24292430    max_val = atol(tmp) + 1;
    2430     paranoid_free(tmp);
     2431    mr_free(tmp);
    24312432
    24322433    chdir(bkpinfo->restore_path);   /* I don't know why this is needed _here_ but it seems to be. -HR, 02/04/2002 */
     
    24342435    run_program_and_log_output("pwd", 5);
    24352436
    2436     asprintf(&progress_str, _("Restoring from media #%d"),
     2437    mr_asprintf(&progress_str, _("Restoring from media #%d"),
    24372438            g_current_media_number);
    24382439    log_to_screen(progress_str);
     
    24562457    while (ctrl_chr != BLK_STOP_AFIOBALLS) {
    24572458        update_progress_form(progress_str);
    2458         asprintf(&xattr_fname, "%s/xattr-subset-%ld.tmp", bkpinfo->tmpdir,
     2459        mr_asprintf(&xattr_fname, "%s/xattr-subset-%ld.tmp", bkpinfo->tmpdir,
    24592460                current_afioball_number);
    2460         asprintf(&acl_fname, "%s/acl-subset-%ld.tmp", bkpinfo->tmpdir,
     2461        mr_asprintf(&acl_fname, "%s/acl-subset-%ld.tmp", bkpinfo->tmpdir,
    24612462                current_afioball_number);
    24622463        unlink(xattr_fname);
     
    24732474        }
    24742475        /* BERLIOS: useless ?
    2475         asprintf(&tmp,
     2476        mr_asprintf(&tmp,
    24762477                _("Restoring from fileset #%ld (name=%s, size=%ld K)"),
    24772478                current_afioball_number, tmp_fname, (long) tmp_size >> 10);
     
    24842485        retval += res;
    24852486        if (res) {
    2486             asprintf(&tmp, _("Fileset %ld - errors occurred"),
     2487            mr_asprintf(&tmp, _("Fileset %ld - errors occurred"),
    24872488                    current_afioball_number);
    24882489            log_to_screen(tmp);
    2489             paranoid_free(tmp);
     2490            mr_free(tmp);
    24902491        }
    24912492        res =
     
    24982499        g_current_progress++;
    24992500
    2500         paranoid_free(progress_str);
    2501         asprintf(&progress_str, _("Restoring from fileset #%ld on %s #%d"),
     2501        mr_free(progress_str);
     2502        mr_asprintf(&progress_str, _("Restoring from fileset #%ld on %s #%d"),
    25022503                current_afioball_number,
    25032504                bkpinfo->backup_media_string,
     
    25072508        unlink(xattr_fname);
    25082509        unlink(acl_fname);
    2509         paranoid_free(xattr_fname);
    2510         paranoid_free(acl_fname);
     2510        mr_free(xattr_fname);
     2511        mr_free(acl_fname);
    25112512    }                           // next
    2512     paranoid_free(progress_str);
    2513     paranoid_free(tmp_fname);
     2513    mr_free(progress_str);
     2514    mr_free(tmp_fname);
    25142515
    25152516    log_msg(1, "All done with afioballs");
     
    25552556    /* BERLIOS: should test return value, or better change the function */
    25562557    getcwd(cwd, MAX_STR_LEN - 1);
    2557     asprintf(&tmp, "mkdir -p %s", bkpinfo->restore_path);
     2558    mr_asprintf(&tmp, "mkdir -p %s", bkpinfo->restore_path);
    25582559    run_program_and_log_output(tmp, FALSE);
    2559     paranoid_free(tmp);
     2560    mr_free(tmp);
    25602561
    25612562    log_msg(1, "Changing dir to %s", bkpinfo->restore_path);
     
    25722573        newtRefresh();
    25732574    }
    2574     paranoid_free(tmp);
     2575    mr_free(tmp);
    25752576
    25762577    mvaddstr_and_log_it(g_currentY, 0,
     
    26132614    kill_petris();
    26142615    log_msg(2, "restore_everything() --- leaving");
    2615     paranoid_free(cwd);
    2616     paranoid_free(newpath);
     2616    mr_free(cwd);
     2617    mr_free(newpath);
    26172618    return (resA + resB);
    26182619}
     
    27152716        g_text_mode = FALSE;
    27162717    }                           // newt :-)
    2717     paranoid_free(tmp);
     2718    mr_free(tmp);
    27182719
    27192720    if (!
     
    27322733
    27332734    g_mondo_home = call_program_and_get_last_line_of_output("which mondorestore");
    2734     paranoid_alloc(g_tmpfs_mountpt, "/tmp/tmpfs");
     2735    mr_allocstr(g_tmpfs_mountpt, "/tmp/tmpfs");
    27352736    make_hole_for_dir(g_tmpfs_mountpt);
    27362737    g_current_media_number = 1; // precaution
     
    27572758
    27582759/* Backup original mountlist.txt */
    2759     asprintf(&tmp, "%s.orig", g_mountlist_fname);
     2760    mr_asprintf(&tmp, "%s.orig", g_mountlist_fname);
    27602761    if (!does_file_exist(g_mountlist_fname)) {
    27612762        log_msg(2,
     
    27632764                __LINE__, g_mountlist_fname);
    27642765    } else if (!does_file_exist(tmp)) {
    2765         paranoid_free(tmp);
    2766         asprintf(&tmp, "cp -f %s %s.orig", g_mountlist_fname,
     2766        mr_free(tmp);
     2767        mr_asprintf(&tmp, "cp -f %s %s.orig", g_mountlist_fname,
    27672768                g_mountlist_fname);
    27682769        run_program_and_log_output(tmp, FALSE);
    27692770    }
    2770     paranoid_free(tmp);
     2771    mr_free(tmp);
    27712772
    27722773/* Init directories */
    27732774    make_hole_for_dir(bkpinfo->tmpdir);
    2774     asprintf(&tmp, "mkdir -p %s", bkpinfo->tmpdir);
     2775    mr_asprintf(&tmp, "mkdir -p %s", bkpinfo->tmpdir);
    27752776    run_program_and_log_output(tmp, FALSE);
    2776     paranoid_free(tmp);
     2777    mr_free(tmp);
    27772778
    27782779    make_hole_for_dir("/var/log");
     
    28052806        load_raidtab_into_raidlist(raidlist, RAIDTAB_FNAME);
    28062807        if (!does_file_exist(g_mountlist_fname)) {
    2807             paranoid_alloc(g_mountlist_fname, "/tmp/mountlist.txt");
     2808            mr_allocstr(g_mountlist_fname, "/tmp/mountlist.txt");
    28082809        }
    28092810        res = let_user_edit_the_mountlist(bkpinfo, mountlist, raidlist);
     
    28322833        bkpinfo->compression_level = 1;
    28332834        g_current_media_number = 2;
    2834         paranoid_alloc(bkpinfo->restore_path, "/tmp/TESTING");
     2835        mr_allocstr(bkpinfo->restore_path, "/tmp/TESTING");
    28352836        bkpinfo->backup_media_type = dvd;
    2836         paranoid_free(bkpinfo->backup_media_string);
     2837        mr_free(bkpinfo->backup_media_string);
    28372838        bkpinfo->backup_media_string = bkptype_to_string(bkpinfo->backup_media_type);
    28382839        open_progress_form(_("Reassembling /dev/hda1"),
     
    28592860//      finish(0);
    28602861//      toggle_path_selection (filelist, "/root/stuff", TRUE);
    2861         asprintf(&a, argv[3]);
    2862         asprintf(&b, argv[4]);
     2862        mr_asprintf(&a, argv[3]);
     2863        mr_asprintf(&b, argv[4]);
    28632864
    28642865        res = save_filelist_entries_in_common(a, filelist, b, FALSE);
    28652866        free_filelist(filelist);
    2866         paranoid_free(a);
    2867         paranoid_free(b);
     2867        mr_free(a);
     2868        mr_free(b);
    28682869        printf("res = %d", res);
    28692870        finish(0);
     
    29442945        log_msg(2, "Still here. Yay.");
    29452946        if (strlen(bkpinfo->tmpdir) > 0) {
    2946             asprintf(&tmp, "rm -Rf %s/*", bkpinfo->tmpdir);
     2947            mr_asprintf(&tmp, "rm -Rf %s/*", bkpinfo->tmpdir);
    29472948            run_program_and_log_output(tmp, FALSE);
    2948             paranoid_free(tmp);
     2949            mr_free(tmp);
    29492950        }
    29502951        unmount_boot_if_necessary();    /* for Gentoo users */
     
    29602961
    29612962        iamhere("About to call load_mountlist and load_raidtab");
    2962         paranoid_alloc(bkpinfo->restore_path, MNT_RESTORING);
     2963        mr_allocstr(bkpinfo->restore_path, MNT_RESTORING);
    29632964        read_cfg_file_into_bkpinfo(g_mondo_cfg_file, bkpinfo);
    29642965        retval = load_mountlist(mountlist, g_mountlist_fname);
     
    29732974                && !is_this_device_mounted(bkpinfo->nfs_mount)) {
    29742975                log_msg(1, "Mounting nfs dir");
    2975                 paranoid_alloc(bkpinfo->isodir, "/tmp/isodir");
     2976                mr_allocstr(bkpinfo->isodir, "/tmp/isodir");
    29762977                run_program_and_log_output("mkdir -p /tmp/isodir", 5);
    2977                 asprintf(&tmp, "mount %s -t nfs -o nolock /tmp/isodir",
     2978                mr_asprintf(&tmp, "mount %s -t nfs -o nolock /tmp/isodir",
    29782979                        bkpinfo->nfs_mount);
    29792980                run_program_and_log_output(tmp, 1);
    2980                 paranoid_free(tmp);
     2981                mr_free(tmp);
    29812982            }
    29822983        }
     
    29952996            log_msg(0, "Partitioning only.");
    29962997            load_raidtab_into_raidlist(raidlist, RAIDTAB_FNAME);
    2997             paranoid_alloc(g_mountlist_fname, "/tmp/mountlist.txt");
     2998            mr_allocstr(g_mountlist_fname, "/tmp/mountlist.txt");
    29982999            load_mountlist(mountlist, g_mountlist_fname);
    29993000            res = partition_everything(mountlist);
     
    30043005            log_msg(0, "Formatting only.");
    30053006            load_raidtab_into_raidlist(raidlist, RAIDTAB_FNAME);
    3006             paranoid_alloc(g_mountlist_fname, "/tmp/mountlist.txt");
     3007            mr_allocstr(g_mountlist_fname, "/tmp/mountlist.txt");
    30073008            load_mountlist(mountlist, g_mountlist_fname);
    30083009            res = format_everything(mountlist, FALSE, raidlist);
     
    30133014            log_msg(0, "Stopping LVM and RAID");
    30143015            load_raidtab_into_raidlist(raidlist, RAIDTAB_FNAME);
    3015             paranoid_alloc(g_mountlist_fname, "/tmp/mountlist.txt");
     3016            mr_allocstr(g_mountlist_fname, "/tmp/mountlist.txt");
    30163017            load_mountlist(mountlist, g_mountlist_fname);
    30173018            res = do_my_funky_lvm_stuff(TRUE, FALSE);
     
    31393140    unlink("/tmp/mondo-run-prog.tmp");
    31403141    set_signals(FALSE);
    3141     asprintf(&tmp, "rm -Rf %s", bkpinfo->tmpdir);
     3142    mr_asprintf(&tmp, "rm -Rf %s", bkpinfo->tmpdir);
    31423143    run_program_and_log_output(tmp, FALSE);
    3143     paranoid_free(tmp);
     3144    mr_free(tmp);
    31443145
    31453146    log_to_screen
    31463147        (_
    31473148         ("Restore log copied to /tmp/mondo-restore.log on your hard disk"));
    3148     asprintf(&tmp,
     3149    mr_asprintf(&tmp,
    31493150            _
    31503151            ("Mondo-restore is exiting (retval=%d)                                      "),
    31513152            retval);
    31523153    log_to_screen(tmp);
    3153     paranoid_free(tmp);
    3154 
    3155     asprintf(&tmp, "umount %s", bkpinfo->isodir);
     3154    mr_free(tmp);
     3155
     3156    mr_asprintf(&tmp, "umount %s", bkpinfo->isodir);
    31563157    run_program_and_log_output(tmp, 5);
    3157     paranoid_free(tmp);
    3158 
    3159     paranoid_free(mountlist);
    3160     paranoid_free(raidlist);
     3158    mr_free(tmp);
     3159
     3160    mr_free(mountlist);
     3161    mr_free(raidlist);
    31613162    if (am_I_in_disaster_recovery_mode()) {
    31623163        run_program_and_log_output("mount / -o remount,rw", 2);
  • trunk/mondo/src/mondorestore/mondo-rstr-compare.c

    r783 r900  
    1414#include <pthread.h>
    1515#endif
     16#include "mr_mem.h"
    1617
    1718void popup_changelist_from_file(char *);
     
    6162    }
    6263    if (!(fin = fopen(tmp1, "r"))) {
    63         asprintf(&tmp, _("Cannot open bigfile %ld (%s)'s info file"),
     64        mr_asprintf(&tmp, _("Cannot open bigfile %ld (%s)'s info file"),
    6465                bigfileno + 1, tmp);
    6566        log_to_screen(tmp);
    66         paranoid_free(tmp);
    67         paranoid_free(tmp1);
     67        mr_free(tmp);
     68        mr_free(tmp1);
    6869        return (1);
    6970    }
    70     paranoid_free(tmp1);
     71    mr_free(tmp1);
    7172
    7273    fread((void *) &biggiestruct, 1, sizeof(biggiestruct), fin);
    7374    paranoid_fclose(fin);
    7475
    75     asprintf(&checksum, biggiestruct.checksum);
    76     asprintf(&bigfile_fname, biggiestruct.filename);
     76    mr_asprintf(&checksum, biggiestruct.checksum);
     77    mr_asprintf(&bigfile_fname, biggiestruct.filename);
    7778
    7879    log_msg(2, "biggiestruct.filename = %s", bigfile_fname);
     
    8081
    8182    if (!g_text_mode) {
    82         asprintf(&tmp, _("Comparing %s"), bigfile_fname);
     83        mr_asprintf(&tmp, _("Comparing %s"), bigfile_fname);
    8384        newtDrawRootText(0, 22, tmp);
    8485        newtRefresh();
    85         paranoid_free(tmp);
     86        mr_free(tmp);
    8687    }
    8788    /* BERLIOS: Useless ?
     
    9394        return(0);
    9495    } else {
    95         asprintf(&command,
     96        mr_asprintf(&command,
    9697                "md5sum \"%s%s\" > /tmp/md5sum.txt 2> /tmp/errors.txt",
    9798                MNT_RESTORING, bigfile_fname);
     
    101102    if (system(command)) {
    102103        log_OS_error("Warning - command failed");
    103         paranoid_free(command);
    104         paranoid_free(bigfile_fname);
     104        mr_free(command);
     105        mr_free(bigfile_fname);
    105106        return (1);
    106107    } else {
    107         paranoid_free(command);
     108        mr_free(command);
    108109        if (!(fin = fopen("/tmp/md5sum.txt", "r"))) {
    109110            log_msg(2, "Unable to open /tmp/md5sum.txt; can't get live checksum");
    110             paranoid_free(bigfile_fname);
     111            mr_free(bigfile_fname);
    111112            return (1);
    112113        } else {
    113             getline(&original_cksum, &n, fin);
     114            mr_getline(&original_cksum, &n, fin);
    114115            paranoid_fclose(fin);
    115116            for (i = strlen(original_cksum);
     
    128129        retval++;
    129130    }
    130     paranoid_free(original_cksum);
    131     paranoid_free(checksum);
     131    mr_free(original_cksum);
     132    mr_free(checksum);
    132133
    133134    if (retval) {
     
    138139        paranoid_fclose(fout);
    139140    }
    140     paranoid_free(bigfile_fname);
     141    mr_free(bigfile_fname);
    141142
    142143    return (retval);
     
    181182                       noof_biggiefiles);
    182183    for (bigfileno = 0; bigfileno < noof_biggiefiles; bigfileno++) {
    183         asprintf(&tmp, "Comparing big file #%ld", bigfileno + 1);
     184        mr_asprintf(&tmp, "Comparing big file #%ld", bigfileno + 1);
    184185        log_msg(1, tmp);
    185186        update_progress_form(tmp);
    186         paranoid_free(tmp);
     187        mr_free(tmp);
    187188        res = compare_a_biggiefile(bkpinfo, bigfileno);
    188189        retval += res;
     
    232233    use_star = (strstr(tarball_fname, ".star")) ? TRUE : FALSE;
    233234    assert_string_is_neither_NULL_nor_zerolength(tarball_fname);
    234     asprintf(&filelist_name, MNT_CDROM "/archives/filelist.%d",
     235    mr_asprintf(&filelist_name, MNT_CDROM "/archives/filelist.%d",
    235236            current_tarball_number);
    236237
    237238    noof_lines = count_lines_in_file(filelist_name);
    238     paranoid_free(filelist_name);
     239    mr_free(filelist_name);
    239240
    240241    if (strstr(tarball_fname, ".bz2")) {
    241         asprintf(&compressor_exe, "bzip2");
     242        mr_asprintf(&compressor_exe, "bzip2");
    242243    } else if (strstr(tarball_fname, ".lzo")) {
    243         asprintf(&compressor_exe, "lzop");
     244        mr_asprintf(&compressor_exe, "lzop");
    244245    } else {
    245246        compressor_exe = NULL;
     
    247248
    248249    if (use_star) {
    249         asprintf(&archiver_exe, "star -bz");
    250     } else {
    251         asprintf(&archiver_exe, "afio");
     250        mr_asprintf(&archiver_exe, "star -bz");
     251    } else {
     252        mr_asprintf(&archiver_exe, "afio");
    252253    }
    253254
     
    257258            fatal_error("(compare_a_tarball) Compression program missing");
    258259        }
    259         paranoid_free(tmp);
     260        mr_free(tmp);
    260261
    261262        if (use_star) {
     
    266267        } else {
    267268            tmp = compressor_exe;
    268             asprintf(&compressor_exe, "-P %s -Z", tmp);
    269             paranoid_free(tmp);
     269            mr_asprintf(&compressor_exe, "-P %s -Z", tmp);
     270            mr_free(tmp);
    270271        }
    271272    }
     
    278279#endif
    279280
    280     asprintf(&logfile, "/tmp/afio.log.%d", current_tarball_number);
     281    mr_asprintf(&logfile, "/tmp/afio.log.%d", current_tarball_number);
    281282    if (use_star)               // doesn't use compressor_exe
    282283    {
    283         asprintf(&command,
     284        mr_asprintf(&command,
    284285                "%s -diff H=star file=%s >> %s 2>> %s",
    285286                archiver_exe, tarball_fname, logfile, logfile);
    286287    } else {
    287         asprintf(&command,
     288        mr_asprintf(&command,
    288289                "%s -r -b %ld -M 16m -c %ld %s %s >> %s 2>> %s",
    289290                archiver_exe,
     
    292293    }
    293294#undef BUFSIZE
    294     paranoid_free(archiver_exe);
    295     paranoid_free(compressor_exe);
     295    mr_free(archiver_exe);
     296    mr_free(compressor_exe);
    296297
    297298    res = system(command);
     
    300301        log_OS_error(command);
    301302    }
    302     paranoid_free(command);
     303    mr_free(command);
    303304
    304305    if (length_of_file(logfile) > 5) {
    305         asprintf(&command,
     306        mr_asprintf(&command,
    306307                "sed s/': \\\"'/\\|/ %s | sed s/'\\\": '/\\|/ | cut -d'|' -f2 | sort -u | grep -vx \"dev/.*\" >> /tmp/changed.txt",
    307308                logfile);
    308309        system(command);
    309         paranoid_free(command);
     310        mr_free(command);
    310311        archiver_errors = count_lines_in_file(logfile);
    311312    } else {
     
    314315
    315316    if (archiver_errors) {
    316         asprintf(&tmp,
     317        mr_asprintf(&tmp,
    317318                "Differences found while processing fileset #%d       ",
    318319                current_tarball_number);
    319320        log_msg(1, tmp);
    320         paranoid_free(tmp);
     321        mr_free(tmp);
    321322    }
    322323    unlink(logfile);
    323     paranoid_free(logfile);
     324    mr_free(logfile);
    324325    return (retval);
    325326}
     
    353354
    354355    max_val = atol(tmp);
    355     paranoid_free(tmp);
    356 
    357     asprintf(&progress_str, _("Comparing with %s #%d "),
     356    mr_free(tmp);
     357
     358    mr_asprintf(&progress_str, _("Comparing with %s #%d "),
    358359            bkpinfo->backup_media_string,
    359360            g_current_media_number);
     
    369370        insist_on_this_cd_number(bkpinfo, g_current_media_number);
    370371        update_progress_form(progress_str);
    371         asprintf(&tarball_fname,
     372        mr_asprintf(&tarball_fname,
    372373                MNT_CDROM "/archives/%d.afio.bz2", current_tarball_number);
    373374
    374375        if (!does_file_exist(tarball_fname)) {
    375             paranoid_free(tarball_fname);
    376             asprintf(&tarball_fname, MNT_CDROM "/archives/%d.afio.lzo",
     376            mr_free(tarball_fname);
     377            mr_asprintf(&tarball_fname, MNT_CDROM "/archives/%d.afio.lzo",
    377378                    current_tarball_number);
    378379        }
    379380        if (!does_file_exist(tarball_fname)) {
    380             paranoid_free(tarball_fname);
    381             asprintf(&tarball_fname, MNT_CDROM "/archives/%d.afio.",
     381            mr_free(tarball_fname);
     382            mr_asprintf(&tarball_fname, MNT_CDROM "/archives/%d.afio.",
    382383                    current_tarball_number);
    383384        }
    384385        if (!does_file_exist(tarball_fname)) {
    385             paranoid_free(tarball_fname);
    386             asprintf(&tarball_fname, MNT_CDROM "/archives/%d.star.bz2",
     386            mr_free(tarball_fname);
     387            mr_asprintf(&tarball_fname, MNT_CDROM "/archives/%d.star.bz2",
    387388                    current_tarball_number);
    388389        }
    389390        if (!does_file_exist(tarball_fname)) {
    390             paranoid_free(tarball_fname);
    391             asprintf(&tarball_fname, MNT_CDROM "/archives/%d.star.",
     391            mr_free(tarball_fname);
     392            mr_asprintf(&tarball_fname, MNT_CDROM "/archives/%d.star.",
    392393                    current_tarball_number);
    393394        }
     
    398399                == 0) {
    399400                log_msg(2, "OK, I think I'm done with tarballs...");
    400                 paranoid_free(tarball_fname);
     401                mr_free(tarball_fname);
    401402                break;
    402403            }
    403404            log_msg(2, "OK, I think it's time for another CD...");
    404405            g_current_media_number++;
    405             paranoid_free(progress_str);
    406             asprintf(&progress_str, _("Comparing with %s #%d "),
     406            mr_free(progress_str);
     407            mr_asprintf(&progress_str, _("Comparing with %s #%d "),
    407408                    bkpinfo->backup_media_string,
    408409                    g_current_media_number);
     
    410411        } else {
    411412            res = compare_a_tarball(tarball_fname, current_tarball_number);
    412             paranoid_free(tarball_fname);
     413            mr_free(tarball_fname);
    413414
    414415            g_current_progress++;
     
    416417        }
    417418    }
    418     paranoid_free(progress_str);
     419    mr_free(progress_str);
    419420    close_progress_form();
    420421
     
    470471    noof_changed_files = count_lines_in_file("/tmp/changed.txt");
    471472    if (noof_changed_files) {
    472         asprintf(&tmp, _("%ld files do not match the backup            "),
     473        mr_asprintf(&tmp, _("%ld files do not match the backup            "),
    473474                noof_changed_files);
    474475        //      mvaddstr_and_log_it( g_currentY++, 0, tmp );
    475476        log_to_screen(tmp);
    476         paranoid_free(tmp);
    477 
    478         asprintf(&command, "cat /tmp/changed.txt >> %s", MONDO_LOGFILE);
     477        mr_free(tmp);
     478
     479        mr_asprintf(&command, "cat /tmp/changed.txt >> %s", MONDO_LOGFILE);
    479480        paranoid_system(command);
    480         paranoid_free(command);
    481     } else {
    482         asprintf(&tmp, _("All files match the backup                     "));
     481        mr_free(command);
     482    } else {
     483        mr_asprintf(&tmp, _("All files match the backup                     "));
    483484        mvaddstr_and_log_it(g_currentY++, 0, tmp);
    484485        log_to_screen(tmp);
    485         paranoid_free(tmp);
    486     }
    487 
    488     paranoid_free(cwd);
    489     paranoid_free(new);
     486        mr_free(tmp);
     487    }
     488
     489    mr_free(cwd);
     490    mr_free(new);
    490491
    491492    return (resA + resB);
     
    573574        } else {
    574575            q = count_lines_in_file("/tmp/changed.files");
    575             asprintf(&tmp, _("%ld significant difference%s found."), q,
     576            mr_asprintf(&tmp, _("%ld significant difference%s found."), q,
    576577                    (q != 1) ? "s" : "");
    577578            mvaddstr_and_log_it(g_currentY++, 0, tmp);
    578579            log_to_screen(tmp);
    579             paranoid_free(tmp);
    580 
    581             asprintf(&tmp,
     580            mr_free(tmp);
     581
     582            mr_asprintf(&tmp,
    582583                   _("Type 'less /tmp/changed.files' for a list of non-matching files"));
    583584            mvaddstr_and_log_it(g_currentY++, 0, tmp);
    584585            log_to_screen(tmp);
    585             paranoid_free(tmp);
     586            mr_free(tmp);
    586587
    587588            log_msg(2, "calling popup_changelist_from_file()");
     
    624625    chdir(bkpinfo->restore_path);
    625626
    626     asprintf(&command, "cp -f /tmp/LAST-FILELIST-NUMBER %s/tmp",
     627    mr_asprintf(&command, "cp -f /tmp/LAST-FILELIST-NUMBER %s/tmp",
    627628            bkpinfo->restore_path);
    628629    run_program_and_log_output(command, FALSE);
    629     paranoid_free(command);
     630    mr_free(command);
    630631    mvaddstr_and_log_it(g_currentY,
    631632                        0, _("Verifying archives against filesystem"));
     
    633634    if (bkpinfo->disaster_recovery
    634635        && does_file_exist("/tmp/CDROM-LIVES-HERE")) {
    635         paranoid_free(bkpinfo->media_device);
     636        mr_free(bkpinfo->media_device);
    636637        // last_line_of_file allocates the string
    637638        bkpinfo->media_device = last_line_of_file("/tmp/CDROM-LIVES-HERE");
    638639    } else {
    639         paranoid_free(bkpinfo->media_device);
     640        mr_free(bkpinfo->media_device);
    640641        // find_cdrom_device allocates the string
    641642        bkpinfo->media_device = find_cdrom_device(FALSE);
     
    653654
    654655    mvaddstr_and_log_it(g_currentY++, 74, _("Done."));
    655     paranoid_free(dir);
     656    mr_free(dir);
    656657    return (res);
    657658}
     
    684685    getcwd(dir, MAX_STR_LEN);
    685686    chdir(bkpinfo->restore_path);
    686     asprintf(&command, "cp -f /tmp/LAST-FILELIST-NUMBER %s/tmp",
     687    mr_asprintf(&command, "cp -f /tmp/LAST-FILELIST-NUMBER %s/tmp",
    687688            bkpinfo->restore_path);
    688689    run_program_and_log_output(command, FALSE);
    689     paranoid_free(command);
     690    mr_free(command);
    690691
    691692    mvaddstr_and_log_it(g_currentY,
     
    698699        mvaddstr_and_log_it(g_currentY++, 74, _("Done."));
    699700    }
    700     paranoid_free(dir);
     701    mr_free(dir);
    701702    return (res);
    702703}
  • trunk/mondo/src/mondorestore/mondo-rstr-newt.c

    r783 r900  
    1616
    1717#include "mondo-rstr-newt.h"
     18#include "mr_mem.h"
    1819
    1920/**
     
    7879        (_
    7980         ("   Add one of the following unallocated RAID partitions to this RAID device."));
    80     asprintf(&tmp, "%-26s %s", _("Device"), _("Size"));
     81    mr_asprintf(&tmp, "%-26s %s", _("Device"), _("Size"));
    8182    headerMsg = newtLabel(1, 1, tmp);
    82     paranoid_free(tmp);
     83    mr_free(tmp);
    8384
    8485    partitionsListbox =
     
    167168    assert(keylist != NULL);
    168169
    169     asprintf(&device_str, "/dev/");
    170     asprintf(&mountpoint_str, "/");
     170    mr_asprintf(&device_str, "/dev/");
     171    mr_asprintf(&mountpoint_str, "/");
    171172#ifdef __FreeBSD__
    172     asprintf(&format_str, "ufs");
     173    mr_asprintf(&format_str, "ufs");
    173174#else
    174     asprintf(&format_str, "ext2");
     175    mr_asprintf(&format_str, "ext2");
    175176#endif
    176177    newtOpenWindow(20, 5, 48, 10, _("Add entry"));
     
    199200        b_res = newtRunForm(myForm);
    200201
    201         paranoid_free(device_str);
    202         asprintf(&device_str, device_here);
     202        mr_free(device_str);
     203        mr_asprintf(&device_str, device_here);
    203204        strip_spaces(device_str);
    204205
    205         paranoid_free(format_str);
    206         asprintf(&format_str, format_here);
     206        mr_free(format_str);
     207        mr_asprintf(&format_str, format_here);
    207208        strip_spaces(format_str);
    208209
    209         paranoid_free(mountpoint_str);
    210         asprintf(&mountpoint_str, mountpoint_here);
     210        mr_free(mountpoint_str);
     211        mr_asprintf(&mountpoint_str, mountpoint_here);
    211212        strip_spaces(mountpoint_str);
    212213
    213         paranoid_free(size_str);
    214         asprintf(&size_str, size_here);
     214        mr_free(size_str);
     215        mr_asprintf(&size_str, size_here);
    215216        strip_spaces(size_str);
    216217
     
    234235        return;
    235236    }
    236     asprintf(&drive_to_add, device_str);
     237    mr_asprintf(&drive_to_add, device_str);
    237238    for (i = strlen(drive_to_add); isdigit(drive_to_add[i - 1]); i--);
    238239    num_to_add = atoi(drive_to_add + i);
    239240    drive_to_add[i] = '\0';
    240     paranoid_free(drive_to_add);
     241    mr_free(drive_to_add);
    241242
    242243    currline = mountlist->entries;
    243244    strcpy(mountlist->el[currline].device, device_str);
    244245    strcpy(mountlist->el[currline].mountpoint, mountpoint_str);
    245     paranoid_free(mountpoint_str);
     246    mr_free(mountpoint_str);
    246247
    247248    strcpy(mountlist->el[currline].format, format_str);
    248     paranoid_free(format_str);
     249    mr_free(format_str);
    249250
    250251    mountlist->el[currline].size = atol(size_str) * 1024;
    251     paranoid_free(size_str);
     252    mr_free(size_str);
    252253
    253254    mountlist->entries++;
     
    256257                                    device_str);
    257258    }
    258     paranoid_free(device_str);
     259    mr_free(device_str);
    259260    redraw_mountlist(mountlist, keylist, listbox);
    260261}
     
    296297        }
    297298    }
    298     paranoid_free(sz_out);
     299    mr_free(sz_out);
    299300}
    300301#endif
     
    335336         && strcmp(raidlist->el[i].volname, basename(raid_device)); i++);
    336337    if (i == raidlist->entries) {
    337         asprintf(&tmp,
     338        mr_asprintf(&tmp,
    338339                 "Cannot calc size of raid device %s - cannot find it in raidlist",
    339340                 raid_device);
    340341        log_it(tmp);
    341         paranoid_free(tmp);
     342        mr_free(tmp);
    342343        return (0);             // Isn't this more sensible than 999999999? If the raid dev !exists,
    343344        // then it has no size, right?
     
    351352        int k = 0, l = 0;
    352353        for (k = 0; k < raidrec->plex[j].subdisks; ++k) {
    353             asprintf(&devname, raidrec->plex[j].sd[k].which_device);
     354            mr_asprintf(&devname, raidrec->plex[j].sd[k].which_device);
    354355            for (l = 0; l < raidlist->disks.entries; ++l) {
    355356                if (!strcmp(devname, raidlist->disks.el[l].name)) {
     
    379380                }
    380381            }
    381             paranoid_free(devname);
     382            mr_free(devname);
    382383        }
    383384
     
    400401    }
    401402
    402     asprintf(&tmp, "I have calculated %s's real size to be %ld",
     403    mr_asprintf(&tmp, "I have calculated %s's real size to be %ld",
    403404             raid_device, (long) smallest_plex);
    404405    log_it(tmp);
    405     paranoid_free(tmp);
     406    mr_free(tmp);
    406407    return (smallest_plex);
    407408#else
     
    431432         && strcmp(raidlist->el[i].raid_device, raid_device); i++);
    432433    if (i == raidlist->entries) {
    433         asprintf(&tmp,
     434        mr_asprintf(&tmp,
    434435                 "Cannot calc size of raid device %s - cannot find it in raidlist",
    435436                 raid_device);
    436437        log_it(tmp);
    437         paranoid_free(tmp);
     438        mr_free(tmp);
    438439        return (999999999);
    439440    }
     
    458459        total_size = smallest_partition * (noof_partitions - 1);
    459460    }
    460     asprintf(&tmp, "I have calculated %s's real size to be %ld",
     461    mr_asprintf(&tmp, "I have calculated %s's real size to be %ld",
    461462             raid_device, (long) total_size);
    462463    log_it(tmp);
    463     paranoid_free(tmp);
     464    mr_free(tmp);
    464465    return (total_size);
    465466#endif
     
    487488    char *sz = NULL;
    488489
    489     asprintf(&prompt,
     490    mr_asprintf(&prompt,
    490491             _
    491492             ("Please enter the RAID level you want. (concat, striped, raid5)"));
    492493    if (raidrec->raidlevel == -1) {
    493         asprintf(&tmp, "concat");
     494        mr_asprintf(&tmp, "concat");
    494495    } else if (raidrec->raidlevel == 0) {
    495         asprintf(&tmp, "striped");
     496        mr_asprintf(&tmp, "striped");
    496497    } else {
    497         asprintf(&tmp, "raid%i", raidrec->raidlevel);
     498        mr_asprintf(&tmp, "raid%i", raidrec->raidlevel);
    498499    }
    499500    for (out = 999; out == 999;) {
     
    504505        /* BERLIOS: Useless ???
    505506        if (tmp[0] == '[' && tmp[strlen(tmp) - 1] == ']') {
    506             asprintf(&sz, tmp);
     507            mr_asprintf(&sz, tmp);
    507508            strncpy(tmp, sz + 1, strlen(sz) - 2);
    508509            tmp[strlen(sz) - 2] = '\0';
    509             paranoid_free(sz);
     510            mr_free(sz);
    510511        }
    511512        */
     
    518519        }
    519520        log_it(tmp);
    520         paranoid_free(tmp);
     521        mr_free(tmp);
    521522        if (is_this_raid_personality_registered(out)) {
    522523            log_it
     
    530531        }
    531532    }
    532     paranoid_free(prompt);
     533    mr_free(prompt);
    533534    raidrec->raidlevel = out;
    534535#else
     
    544545        ("grep Pers /proc/mdstat > /tmp/raid-personalities.txt 2> /dev/null");
    545546    personalities = last_line_of_file("/tmp/raid-personalities.txt");
    546     asprintf(&prompt, _("Please enter the RAID level you want. %s"),
     547    mr_asprintf(&prompt, _("Please enter the RAID level you want. %s"),
    547548             personalities);
    548     paranoid_free(personalities);
     549    mr_free(personalities);
    549550
    550551    if (raidrec->raid_level == -1) {
    551         asprintf(&tmp, "linear");
     552        mr_asprintf(&tmp, "linear");
    552553    } else {
    553         asprintf(&tmp, "%d", raidrec->raid_level);
     554        mr_asprintf(&tmp, "%d", raidrec->raid_level);
    554555    }
    555556    for (out = 999;
     
    563564        /* BERLIOS: Useless ???
    564565        if (tmp[0] == '[' && tmp[strlen(tmp) - 1] == ']') {
    565             asprintf(&sz, tmp);
    566             paranoid_free(tmp);
    567 
    568             asprintf(&tmp, sz + 1);
     566            mr_asprintf(&sz, tmp);
     567            mr_free(tmp);
     568
     569            mr_asprintf(&tmp, sz + 1);
    569570            tmp[strlen(sz) - 2] = '\0';
    570             paranoid_free(sz);
     571            mr_free(sz);
    571572        }
    572573        */
     
    591592        }
    592593    }
    593     paranoid_free(tmp);
    594     paranoid_free(prompt);
     594    mr_free(tmp);
     595    mr_free(prompt);
    595596    raidrec->raid_level = out;
    596597#endif
     
    659660    assert_string_is_neither_NULL_nor_zerolength(raid_device);
    660661
    661     asprintf(&tmp, _("Delete %s from RAID device %s - are you sure?"),
     662    mr_asprintf(&tmp, _("Delete %s from RAID device %s - are you sure?"),
    662663             disklist->el[currline].device, raid_device);
    663664    if (!ask_me_yes_or_no(tmp)) {
    664         paranoid_free(tmp);
     665        mr_free(tmp);
    665666        return;
    666667    }
    667     paranoid_free(tmp);
     668    mr_free(tmp);
    668669    for (pos = currline; pos < disklist->entries - 1; pos++) {
    669670        /* memcpy((void*)&disklist->el[pos], (void*)&disklist->el[pos+1], sizeof(struct s_disk)); */
     
    707708                                                  device);
    708709    if (pos >= 0) {
    709         asprintf(&tmp,
     710        mr_asprintf(&tmp,
    710711                 _("Cannot delete %s: it is in use by RAID device %s"),
    711712                 mountlist->el[currline].device,
    712713                 raidlist->el[pos].OSSWAP(raid_device, volname));
    713714        popup_and_OK(tmp);
    714         paranoid_free(tmp);
     715        mr_free(tmp);
    715716        return;
    716717    }
    717     asprintf(&tmp, _("Delete %s - are you sure?"),
     718    mr_asprintf(&tmp, _("Delete %s - are you sure?"),
    718719             mountlist->el[currline].device);
    719720    if (!ask_me_yes_or_no(tmp)) {
    720         paranoid_free(tmp);
     721        mr_free(tmp);
    721722        return;
    722723    }
    723     paranoid_free(tmp);
     724    mr_free(tmp);
    724725
    725726    if (strstr(mountlist->el[currline].device, RAID_DEVICE_STUB)) {
    726         asprintf(&device, mountlist->el[currline].device);
     727        mr_asprintf(&device, mountlist->el[currline].device);
    727728        delete_raidlist_entry(mountlist, raidlist, device);
    728729        for (currline = 0;
     
    732733            if (currline == mountlist->entries) {
    733734                log_it("Dev is gone. I can't delete it. Ho-hum");
    734                 paranoid_free(device);
     735                mr_free(device);
    735736                return;
    736737            }
    737         paranoid_free(device);
     738        mr_free(device);
    738739    }
    739740    memcpy((void *) &mountlist->el[currline],
     
    775776        return;
    776777    }
    777     asprintf(&tmp,
     778    mr_asprintf(&tmp,
    778779             _("Do you want me to delete %s's partitions, too?"), device);
    779780    delete_partitions_too = ask_me_yes_or_no(tmp);
     
    820821        items--;
    821822    }
    822     paranoid_free(tmp);
     823    mr_free(tmp);
    823824
    824825    raidlist->entries = items;
     
    845846
    846847    av = &raidrec->additional_vars;
    847     asprintf(&tmp, _("Delete %s - are you sure?"), av->el[lino].label);
     848    mr_asprintf(&tmp, _("Delete %s - are you sure?"), av->el[lino].label);
    848849    if (ask_me_yes_or_no(tmp)) {
    849850        if (!strcmp(av->el[lino].label, "persistent-superblock")
    850851            || !strcmp(av->el[lino].label, "chunk-size")) {
    851             paranoid_free(tmp);
    852             asprintf(&tmp, _("%s must not be deleted. It would be bad."),
     852            mr_free(tmp);
     853            mr_asprintf(&tmp, _("%s must not be deleted. It would be bad."),
    853854                     av->el[lino].label);
    854855            popup_and_OK(tmp);
    855856        } else {
    856             paranoid_free(av->el[lino].label);
    857             paranoid_free(av->el[lino].value);
     857            mr_free(av->el[lino].label);
     858            mr_free(av->el[lino].value);
    858859            memcpy((void *) &av->el[lino], (void *) &av->el[av->entries--],
    859860                   sizeof(struct raid_var_line));
     
    864865        }
    865866    }
    866     paranoid_free(tmp);
     867    mr_free(tmp);
    867868}
    868869#endif
     
    924925                if (!warned_already) {
    925926                    warned_already = TRUE;
    926                     asprintf(&tmp,
     927                    mr_asprintf(&tmp,
    927928                             _
    928929                             ("Too many lines. Displaying first %d entries only. Close a directory to see more."),
    929930                             ARBITRARY_MAXIMUM);
    930931                    popup_and_OK(tmp);
    931                     paranoid_free(tmp);
     932                    mr_free(tmp);
    932933                }
    933934            } else {
     
    948949                (g_strings_of_flist_window[i],
    949950                 g_strings_of_flist_window[i - 1]) < 0) {
    950                 asprintf(&tmp, g_strings_of_flist_window[i]);
     951                mr_asprintf(&tmp, g_strings_of_flist_window[i]);
    951952                strcpy(g_strings_of_flist_window[i],
    952953                       g_strings_of_flist_window[i - 1]);
    953954                strcpy(g_strings_of_flist_window[i - 1], tmp);
    954                 paranoid_free(tmp);
     955                mr_free(tmp);
    955956
    956957                dummybool = g_is_path_selected[i];
     
    963964        newtListboxClear(listbox);
    964965        for (i = 0; i < lines_in_flist_window; i++) {
    965             asprintf(&tmp, "%c%c %-80s",
     966            mr_asprintf(&tmp, "%c%c %-80s",
    966967                     (g_is_path_selected[i] ? '*' : ' '),
    967968                     (g_is_path_expanded[i] ? '+' : '-'),
     
    973974            keylist[i] = (void *) i;
    974975            newtListboxAppendEntry(listbox, tmp, keylist[i]);
    975             paranoid_free(tmp);
     976            mr_free(tmp);
    976977        }
    977978        return (lines_in_flist_window);
     
    12231224    memcpy((void *) &bkp_raidlist, (void *) raidlist,
    12241225           sizeof(struct raidlist_itself));
    1225     asprintf(&device_str, mountlist->el[currline].device);
    1226     asprintf(&device_used_to_be, mountlist->el[currline].device);
    1227     asprintf(&mountpoint_str, mountlist->el[currline].mountpoint);
    1228     asprintf(&mountpt_used_to_be, mountlist->el[currline].mountpoint);
    1229     asprintf(&format_str, mountlist->el[currline].format);
    1230     asprintf(&size_str, "%lld", mountlist->el[currline].size / 1024);
     1226    mr_asprintf(&device_str, mountlist->el[currline].device);
     1227    mr_asprintf(&device_used_to_be, mountlist->el[currline].device);
     1228    mr_asprintf(&mountpoint_str, mountlist->el[currline].mountpoint);
     1229    mr_asprintf(&mountpt_used_to_be, mountlist->el[currline].mountpoint);
     1230    mr_asprintf(&format_str, mountlist->el[currline].format);
     1231    mr_asprintf(&size_str, "%lld", mountlist->el[currline].size / 1024);
    12311232
    12321233    newtOpenWindow(20, 5, 48, 10, "Edit entry");
     
    12371238    deviceComp =
    12381239        newtEntry(14, 1, device_str, 30, (void *) &device_here, 0);
    1239     paranoid_free(device_str);
     1240    mr_free(device_str);
    12401241
    12411242    mountpointComp =
    12421243        newtEntry(14, 2, mountpoint_str, 30, (void *) &mountpoint_here, 0);
    1243     paranoid_free(mountpoint_str);
     1244    mr_free(mountpoint_str);
    12441245
    12451246    formatComp =
    12461247        newtEntry(14, 4, format_str, 15, (void *) &format_here, 0);
    1247     paranoid_free(format_str);
     1248    mr_free(format_str);
    12481249
    12491250    if (strstr(mountlist->el[currline].device, RAID_DEVICE_STUB)
     
    12531254        sizeComp = newtEntry(14, 3, size_str, 10, (void *) &size_here, 0);
    12541255    }
    1255     paranoid_free(size_str);
     1256    mr_free(size_str);
    12561257
    12571258    bOK = newtButton(2, 6, _("  OK  "));
     
    12701271        b_res = newtRunForm(myForm);
    12711272
    1272         paranoid_free(device_str);
    1273         asprintf(&device_str, device_here);
     1273        mr_free(device_str);
     1274        mr_asprintf(&device_str, device_here);
    12741275        strip_spaces(device_str);
    12751276
    1276         paranoid_free(mountpoint_str);
    1277         asprintf(&mountpoint_str, mountpoint_here);
     1277        mr_free(mountpoint_str);
     1278        mr_asprintf(&mountpoint_str, mountpoint_here);
    12781279        strip_spaces(mountpoint_str);
    12791280
    1280         paranoid_free(format_str);
    1281         asprintf(&format_str, format_here);
    1282         paranoid_free(format_here);
     1281        mr_free(format_str);
     1282        mr_asprintf(&format_str, format_here);
     1283        mr_free(format_here);
    12831284        strip_spaces(format_str);
    12841285        if (b_res == bOK && strstr(device_str, RAID_DEVICE_STUB)
     
    12951296            continue;
    12961297        }
    1297         paranoid_free(mountpt_used_to_be);
     1298        mr_free(mountpt_used_to_be);
    12981299
    12991300        if (!strstr(mountlist->el[currline].device, RAID_DEVICE_STUB)
    13001301            && strcmp(mountlist->el[currline].mountpoint, "image")) {
    1301             asprintf(&size_str, size_here);
     1302            mr_asprintf(&size_str, size_here);
    13021303            strip_spaces(size_str);
    13031304        } else {
    1304             asprintf(&size_str, "%ld",
     1305            mr_asprintf(&size_str, "%ld",
    13051306                    calculate_raid_device_size(mountlist, raidlist,
    13061307                                               mountlist->el[currline].
     
    13081309            newtLabelSetText(sizeComp, size_str);
    13091310        }
    1310         paranoid_free(size_here);
     1311        mr_free(size_here);
    13111312
    13121313        /* do not let user click RAID button if user has changed device_str */
     
    13251326                                                 device);
    13261327                if (j < 0) {
    1327                     asprintf(&tmp,
     1328                    mr_asprintf(&tmp,
    13281329                            _
    13291330                            ("/etc/raidtab does not have an entry for %s; please delete it and add it again"),
    13301331                            mountlist->el[currline].device);
    13311332                    popup_and_OK(tmp);
    1332                     paranoid_free(tmp);
     1333                    mr_free(tmp);
    13331334                } else {
    13341335                    log_it(_("edit_raidlist_entry - calling"));
     
    13391340        }
    13401341    }
    1341     paranoid_free(device_here);
    1342     paranoid_free(mountpoint_here);
     1342    mr_free(device_here);
     1343    mr_free(mountpoint_here);
    13431344
    13441345    newtFormDestroy(myForm);
     
    13521353    strcpy(mountlist->el[currline].device, device_str);
    13531354    strcpy(mountlist->el[currline].mountpoint, mountpoint_str);
    1354     paranoid_free(mountpoint_str);
     1355    mr_free(mountpoint_str);
    13551356
    13561357    strcpy(mountlist->el[currline].format, format_str);
    1357     paranoid_free(format_str);
     1358    mr_free(format_str);
    13581359
    13591360    if (strcmp(mountlist->el[currline].mountpoint, "image")) {
     
    13661367        }
    13671368    }
    1368     paranoid_free(size_str);
     1369    mr_free(size_str);
    13691370
    13701371    newtListboxSetEntry(listbox, (long) keylist[currline],
     
    13971398#endif
    13981399    redraw_mountlist(mountlist, keylist, listbox);
    1399     paranoid_free(device_str);
    1400     paranoid_free(device_used_to_be);
     1400    mr_free(device_str);
     1401    mr_free(device_used_to_be);
    14011402}
    14021403
     
    15161517    memcpy((void *) &bkp_raidrec, (void *) raidrec,
    15171518           sizeof(struct vinum_volume));
    1518     asprintf(&title_of_editraidForm_window, _("Plexes on %s"),
     1519    mr_asprintf(&title_of_editraidForm_window, _("Plexes on %s"),
    15191520            raidrec->volname);
    15201521    newtPushHelpLine(_("   Please select a plex to edit"));
    15211522    newtOpenWindow(13, 5, 54, 15, title_of_editraidForm_window);
    1522     paranoid_free(title_of_editraidForm_window);
     1523    mr_free(title_of_editraidForm_window);
    15231524
    15241525    for (;;) {
    1525         asprintf(&headerstr, "%-14s %-8s  %11s  %8s", _("Plex"), _("Level",) _("Stripe Size"), _("Subdisks"));
     1526        mr_asprintf(&headerstr, "%-14s %-8s  %11s  %8s", _("Plex"), _("Level",) _("Stripe Size"), _("Subdisks"));
    15261527
    15271528        bOK = newtCompactButton(2, 13, _("  OK  "));
     
    15341535            newtListbox(2, 3, 9, NEWT_FLAG_SCROLL | NEWT_FLAG_RETURNEXIT);
    15351536        plexesHeader = newtLabel(2, 2, headerstr);
    1536         paranoid_free(headerstr);
     1537        mr_free(headerstr);
    15371538
    15381539        editraidForm = newtForm(NULL, NULL, 0);
     
    15441545                switch (raidrec->plex[i].raidlevel) {
    15451546                case -1:
    1546                     asprintf(&raidlevel, "concat");
     1547                    mr_asprintf(&raidlevel, "concat");
    15471548                    break;
    15481549                case 0:
    1549                     asprintf(&raidlevel, "striped");
     1550                    mr_asprintf(&raidlevel, "striped");
    15501551                    break;
    15511552                case 5:
    1552                     asprintf(&raidlevel, "raid5");
     1553                    mr_asprintf(&raidlevel, "raid5");
    15531554                    break;
    15541555                default:
    1555                     asprintf(&raidlevel, "raid%i",
     1556                    mr_asprintf(&raidlevel, "raid%i",
    15561557                            raidrec->plex[i].raidlevel);
    15571558                    break;
     
    15591560
    15601561                if (raidrec->plex[i].raidlevel == -1) {
    1561                     asprintf(&chunksize, "N/A");
     1562                    mr_asprintf(&chunksize, "N/A");
    15621563                } else {
    1563                     asprintf(&chunksize, "%dk", raidrec->plex[i].stripesize);
     1564                    mr_asprintf(&chunksize, "%dk", raidrec->plex[i].stripesize);
    15641565                }
    1565                 asprintf(&pname, "%s.p%i", raidrec->volname, i);
    1566                 asprintf(&entry, "%-14s %-8s  %11s  %8d",
     1566                mr_asprintf(&pname, "%s.p%i", raidrec->volname, i);
     1567                mr_asprintf(&entry, "%-14s %-8s  %11s  %8d",
    15671568                         pname, raidlevel, chunksize,
    15681569                         raidrec->plex[i].subdisks);
    1569                 paranoid_free(pname);
    1570                 paranoid_free(chunksize);
    1571                 paranoid_free(raidlevel);
     1570                mr_free(pname);
     1571                mr_free(chunksize);
     1572                mr_free(raidlevel);
    15721573                newtListboxAppendEntry(plexesListbox, entry, keylist[i]);
    1573                 paranoid_free(entry);
     1574                mr_free(entry);
    15741575            }
    15751576        }
     
    15921593
    15931594        if (b_res == bDelete) {
    1594             asprintf(&msg, _("Are you sure you want to delete %s.p%i?"),
     1595            mr_asprintf(&msg, _("Are you sure you want to delete %s.p%i?"),
    15951596                    raidrec->volname, currline2);
    15961597            if (ask_me_yes_or_no(msg)) {
     
    16011602                raidrec->plexes--;
    16021603            }
    1603             paranoid_free(msg);
     1604            mr_free(msg);
    16041605            continue;
    16051606        }
     
    16591660    memcpy((void *) bkp_raidrec, (void *) raidrec,
    16601661           sizeof(struct raid_device_record));
    1661     asprintf(&title_of_editraidForm_window, _("Edit %s"), raidrec->raid_device);
     1662    mr_asprintf(&title_of_editraidForm_window, _("Edit %s"), raidrec->raid_device);
    16621663    log_msg(2, "Opening newt window");
    16631664    newtOpenWindow(20, 5, 40, 14, title_of_editraidForm_window);
    1664     paranoid_free(title_of_editraidForm_window);
     1665    mr_free(title_of_editraidForm_window);
    16651666
    16661667    for (;;) {
    16671668        log_msg(2, "Main loop");
    1668         asprintf(&sz_raid_level,
     1669        mr_asprintf(&sz_raid_level,
    16691670               turn_raid_level_number_to_string(raidrec->raid_level));
    1670         asprintf(&sz_data_disks,
     1671        mr_asprintf(&sz_data_disks,
    16711672               number_of_disks_as_string(raidrec->data_disks.entries,
    16721673                                         _("data")));
    1673         asprintf(&sz_spare_disks,
     1674        mr_asprintf(&sz_spare_disks,
    16741675               number_of_disks_as_string(raidrec->spare_disks.entries,
    16751676                                         _("spare")));
    1676         asprintf(&sz_parity_disks,
     1677        mr_asprintf(&sz_parity_disks,
    16771678               number_of_disks_as_string(raidrec->parity_disks.entries,
    16781679                                         _("parity")));
    1679         asprintf(&sz_failed_disks,
     1680        mr_asprintf(&sz_failed_disks,
    16801681               number_of_disks_as_string(raidrec->failed_disks.entries,
    16811682                                         _("failed")));
     
    16851686        bSelectFailed = newtButton(20, 5, sz_failed_disks);
    16861687        bChangeRaid = newtButton(1, 9, sz_raid_level);
    1687         paranoid_free(sz_raid_level);
    1688         paranoid_free(sz_data_disks);
    1689         paranoid_free(sz_spare_disks);
    1690         paranoid_free(sz_parity_disks);
    1691         paranoid_free(sz_failed_disks);
     1688        mr_free(sz_raid_level);
     1689        mr_free(sz_data_disks);
     1690        mr_free(sz_spare_disks);
     1691        mr_free(sz_parity_disks);
     1692        mr_free(sz_failed_disks);
    16921693
    16931694        bOK = newtButton(16 + (raidrec->raid_level == -1), 9, _("  OK  "));
     
    17351736        calculate_raid_device_size(mountlist, raidlist,
    17361737                                   raidrec->raid_device);
    1737     paranoid_free(bkp_raidrec);
     1738    mr_free(bkp_raidrec);
    17381739#endif
    17391740}
     
    17921793    memcpy((void *) &bkp_raidrec, (void *) raidrec,
    17931794           sizeof(struct vinum_plex));
    1794     asprintf(&title_of_editraidForm_window, "%s.p%i",
     1795    mr_asprintf(&title_of_editraidForm_window, "%s.p%i",
    17951796            raidlist->el[currline].volname, currline2);
    17961797    newtPushHelpLine
     
    17981799         ("   Please select a subdisk to edit, or edit this plex's parameters"));
    17991800    newtOpenWindow(13, 3, 54, 18, title_of_editraidForm_window);
    1800     paranoid_free(title_of_editraidForm_window);
     1801    mr_free(title_of_editraidForm_window);
    18011802
    18021803    for (;;) {
    18031804        switch (raidrec->raidlevel) {
    18041805        case -1:
    1805             asprintf(&tmp, "concat");
     1806            mr_asprintf(&tmp, "concat");
    18061807            break;
    18071808        case 0:
    1808             asprintf(&tmp, "striped");
     1809            mr_asprintf(&tmp, "striped");
    18091810            break;
    18101811        case 5:
    1811             asprintf(&tmp, "raid5");
     1812            mr_asprintf(&tmp, "raid5");
    18121813            break;
    18131814        default:
    1814             asprintf(&tmp, _("unknown (%i)"), raidrec->raidlevel);
     1815            mr_asprintf(&tmp, _("unknown (%i)"), raidrec->raidlevel);
    18151816            break;
    18161817        }
    18171818        bLevel = newtCompactButton(2, 2, _(" RAID level "));
    18181819        sLevel = newtLabel(19, 2, tmp);
    1819         paranoid_free(tmp);
     1820        mr_free(tmp);
    18201821
    18211822        if (raidrec->raidlevel >= 0) {
    1822             asprintf(&tmp, "%ik", raidrec->stripesize);
     1823            mr_asprintf(&tmp, "%ik", raidrec->stripesize);
    18231824            bStripeSize = newtCompactButton(2, 4, _(" Stripe size "));
    18241825        } else {
    1825             asprintf(&tmp, "N/A");
     1826            mr_asprintf(&tmp, "N/A");
    18261827            bStripeSize = newtLabel(2, 4, _("Stripe size:"));
    18271828        }
    18281829        sStripeSize = newtLabel(19, 4, tmp);
    1829         paranoid_free(tmp);
     1830        mr_free(tmp);
    18301831
    18311832        bOK = newtCompactButton(2, 16, _("  OK  "));
     
    18541855            keylist[i] = (void *) i;
    18551856            if (i < raidrec->subdisks) {
    1856                 asprintf(&entry, "%-17s",
     1857                mr_asprintf(&entry, "%-17s",
    18571858                         find_dev_entry_for_raid_device_name(raidlist,
    18581859                                                             raidrec->
     
    18601861                                                             which_device));
    18611862                newtListboxAppendEntry(allocListbox, entry, keylist[i]);
    1862                 paranoid_free(entry);
     1863                mr_free(entry);
    18631864            }
    18641865            if (i < unallocparts->entries) {
    1865                 asprintf(&entry, "%-17s", unallocparts->el[i].device);
     1866                mr_asprintf(&entry, "%-17s", unallocparts->el[i].device);
    18661867                newtListboxAppendEntry(unallocListbox, entry, keylist[i]);
    1867                 paranoid_free(entry);
     1868                mr_free(entry);
    18681869            }
    18691870        }
     
    19151916            choose_raid_level(raidrec);
    19161917        } else if (b_res == bStripeSize) {
    1917             asprintf(&tmp, "%i", raidrec->stripesize);
     1918            mr_asprintf(&tmp, "%i", raidrec->stripesize);
    19181919            if (popup_and_get_string
    19191920                (_("Stripe size"),
     
    19211922                raidrec->stripesize = atoi(tmp);
    19221923            }
    1923             paranoid_free(tmp);
     1924            mr_free(tmp);
    19241925        } else if ((b_res == bAlloc) || (b_res == unallocListbox)) {
    19251926            if (currline_u <= unallocparts->entries)
     
    19691970    assert(lino >= 0);
    19701971
    1971     asprintf(&sz_out, raidrec->additional_vars.el[lino].value);
    1972     asprintf(&header, _("Edit %s"), raidrec->additional_vars.el[lino].label);
    1973     asprintf(&comment, _("Please set %s's value (currently '%s')"),
     1972    mr_asprintf(&sz_out, raidrec->additional_vars.el[lino].value);
     1973    mr_asprintf(&header, _("Edit %s"), raidrec->additional_vars.el[lino].label);
     1974    mr_asprintf(&comment, _("Please set %s's value (currently '%s')"),
    19741975            raidrec->additional_vars.el[lino].label, sz_out);
    19751976    if (popup_and_get_string(header, comment, sz_out)) {
    1976         paranoid_free(raidrec->additional_vars.el[lino].value);
     1977        mr_free(raidrec->additional_vars.el[lino].value);
    19771978        raidrec->additional_vars.el[lino].value = sz_out;
    19781979    }
    1979     paranoid_free(header);
    1980     paranoid_free(comment);
     1980    mr_free(header);
     1981    mr_free(comment);
    19811982}
    19821983#endif
     
    20432044    bCancel = newtCompactButton(i += 12, 17, _("Cancel"));
    20442045    bOK = newtCompactButton(i += 12, 17, _("  OK  "));
    2045     asprintf(&tmp, "%-24s %-24s %-8s  %s", _("Device"), _("Mountpoint"),
     2046    mr_asprintf(&tmp, "%-24s %-24s %-8s  %s", _("Device"), _("Mountpoint"),
    20462047            _("Format"), _("Size (MB)"));
    20472048    headerMsg = newtLabel(2, 1, tmp);
     
    20642065        newtLabelSetText(flawsLabelC, flaws_str_C);
    20652066
    2066         paranoid_free(flaws_str_A);
    2067         paranoid_free(flaws_str_B);
    2068         paranoid_free(flaws_str_C);
     2067        mr_free(flaws_str_A);
     2068        mr_free(flaws_str_B);
     2069        mr_free(flaws_str_C);
    20692070
    20702071        b_res = newtRunForm(myForm);
     
    21962197    memcpy((void *) &bkp_raidrec, (void *) raidrec,
    21972198           sizeof(struct raid_device_record));
    2198     asprintf(&title_of_window, "Additional variables");
     2199    mr_asprintf(&title_of_window, "Additional variables");
    21992200    newtPushHelpLine
    22002201        (_
     
    22112212    bCancel = newtCompactButton(i += 9, 9, _("Cancel"));
    22122213    newtOpenWindow(17, 7, 46, 10, title_of_window);
    2213     paranoid_free(title_of_window);
     2214    mr_free(title_of_window);
    22142215
    22152216    myForm = newtForm(NULL, NULL, 0);
     
    23062307#ifdef __FreeBSD__
    23072308    for (i = 0; i < raidlist->entries; i++) {
    2308         asprintf(&vdev, "/dev/vinum/%s", raidlist->el[i].volname);
     2309        mr_asprintf(&vdev, "/dev/vinum/%s", raidlist->el[i].volname);
    23092310        if (!strcmp(device, vdev)) {
    2310             paranoid_free(vdev);
     2311            mr_free(vdev);
    23112312            break;
    23122313        }
    2313         paranoid_free(vdev);
     2314        mr_free(vdev);
    23142315    }
    23152316#else
     
    23442345    // log_it("%d - AAA - isodir_path = %s", isodir_path);
    23452346    if (isodir_device == NULL) {
    2346         asprintf(&isodir_device, "/dev/");
     2347        mr_asprintf(&isodir_device, "/dev/");
    23472348    }
    23482349    if (isodir_path == NULL) {
    2349         asprintf(&isodir_path, "/");
     2350        mr_asprintf(&isodir_path, "/");
    23502351    }
    23512352    if (does_file_exist("/tmp/NFS-SERVER-PATH")) {
    2352         paranoid_free(isodir_device);
     2353        mr_free(isodir_device);
    23532354        isodir_device = last_line_of_file("/tmp/NFS-SERVER-MOUNT");
    2354         asprintf(&isodir_format, "nfs");
    2355         paranoid_free(isodir_path);
     2355        mr_asprintf(&isodir_format, "nfs");
     2356        mr_free(isodir_path);
    23562357        isodir_path = last_line_of_file("/tmp/NFS-SERVER-PATH");
    23572358    }
     
    24152416    raidrec = &raidlist->el[pos_in_raidlist];
    24162417    initialize_raidrec(raidrec);
    2417     asprintf(&raidrec->OSSWAP(raid_device, volname),
     2418    mr_asprintf(&raidrec->OSSWAP(raid_device, volname),
    24182419           OSSWAP(device, basename(device)));
    24192420#ifndef __FreeBSD__
     
    25732574    }
    25742575    for (i = 0; i < unallocated_raid_partitions->entries; i++) {
    2575         asprintf(&tmp, "%-22s %8lld",
     2576        mr_asprintf(&tmp, "%-22s %8lld",
    25762577                unallocated_raid_partitions->el[i].device,
    25772578                unallocated_raid_partitions->el[i].size / 1024);
    25782579        newtListboxAppendEntry(listbox, tmp, keylist[i]);
    2579         paranoid_free(tmp);
     2580        mr_free(tmp);
    25802581    }
    25812582}
     
    26102611    }
    26112612    for (i = 0; i < additional_vars->entries; i++) {
    2612         asprintf(&tmp, "%-32s %-8s", additional_vars->el[i].label,
     2613        mr_asprintf(&tmp, "%-32s %-8s", additional_vars->el[i].label,
    26132614                additional_vars->el[i].value);
    26142615        newtListboxAppendEntry(listbox, tmp, keylist[i]);
    2615         paranoid_free(tmp);
     2616        mr_free(tmp);
    26162617    }
    26172618}
     
    26832684    pos = which_raid_device_is_using_this_partition(raidlist, old_dev);
    26842685    if (pos < 0) {
    2685         asprintf(&tmp, "No need to rejig %s in raidlist: it's not listed.",
     2686        mr_asprintf(&tmp, "No need to rejig %s in raidlist: it's not listed.",
    26862687                old_dev);
    26872688        log_it(tmp);
    2688         paranoid_free(tmp);
     2689        mr_free(tmp);
    26892690    } else {
    26902691        if ((j =
     
    27182719#endif
    27192720        else {
    2720             asprintf(&tmp,
     2721            mr_asprintf(&tmp,
    27212722                    "%s is supposed to be listed in this raid dev but it's not...",
    27222723                    old_dev);
    27232724            log_it(tmp);
    2724             paranoid_free(tmp);
     2725            mr_free(tmp);
    27252726        }
    27262727    }
     
    28332834
    28342835    iamhere("Post-malloc");
    2835     asprintf(&help_text,
     2836    mr_asprintf(&help_text,
    28362837           _
    28372838           ("   Edit this RAID device's list of partitions. Choose OK or Cancel when done."));
    2838     asprintf(&header_text, "%-24s    %s", _("Device"), _("Index"));
    2839     asprintf(&title_of_window, _("%s contains..."), raidrec->raid_device);
     2839    mr_asprintf(&header_text, "%-24s    %s", _("Device"), _("Index"));
     2840    mr_asprintf(&title_of_window, _("%s contains..."), raidrec->raid_device);
    28402841    newtPushHelpLine(help_text);
    2841     paranoid_free(help_text);
     2842    mr_free(help_text);
    28422843    for (b_res = (newtComponent) 12345; b_res != bOK && b_res != bCancel;) {
    28432844        headerMsg = newtLabel(1, 1, header_text);
     
    28962897                    redraw_disklist(disklist, keylist, partitionsListbox);
    28972898                } else {
    2898                     asprintf(&tmp, _("%s's index is %d. What should it be?"),
     2899                    mr_asprintf(&tmp, _("%s's index is %d. What should it be?"),
    28992900                            raidrec->raid_device,
    29002901                            disklist->el[currline].index);
    2901                     asprintf(&sz_res, "%d", disklist->el[currline].index);
     2902                    mr_asprintf(&sz_res, "%d", disklist->el[currline].index);
    29022903                    if (popup_and_get_string
    29032904                        (_("Set index"), tmp, sz_res)) {
    29042905                        disklist->el[currline].index = atoi(sz_res);
    29052906                    }
    2906                     paranoid_free(tmp);
    2907                     paranoid_free(sz_res);
     2907                    mr_free(tmp);
     2908                    mr_free(sz_res);
    29082909                    redraw_disklist(disklist, keylist, partitionsListbox);
    29092910                }
     
    29132914        newtPopWindow();
    29142915    }
    2915     paranoid_free(title_of_window);
    2916     paranoid_free(header_text);
     2916    mr_free(title_of_window);
     2917    mr_free(header_text);
    29172918
    29182919    newtPopHelpLine();
     
    29252926               sizeof(struct list_of_disks));
    29262927    }
    2927     paranoid_free(bkp_raidrec);
    2928     paranoid_free(bkp_disklist);
    2929     paranoid_free(bkp_raidlist);
    2930     paranoid_free(unallocated_raid_partitions);
     2928    mr_free(bkp_raidrec);
     2929    mr_free(bkp_disklist);
     2930    mr_free(bkp_raidlist);
     2931    mr_free(unallocated_raid_partitions);
    29312932}
    29322933#endif
     
    29602961                (_
    29612962                 ("Which mode - (A)utomatic, (I)nteractive, \n(C)ompare only, or (E)xit to shell?\n--> "));
    2962             getline(&tmp, &n, stdin);
    2963         }
    2964         paranoid_free(tmp);
     2963            mr_getline(&tmp, &n, stdin);
     2964        }
     2965        mr_free(tmp);
    29652966        return (output);
    29662967    }
  • trunk/mondo/src/mondorestore/mondo-rstr-tools.c

    r808 r900  
    1313#include <pthread.h>
    1414#endif
     15#include "mr_mem.h"
    1516
    1617extern bool g_sigpipe_caught;
     
    5253void free_MR_global_filenames()
    5354{
    54     paranoid_free(g_biggielist_txt);
    55     paranoid_free(g_filelist_full);
    56     paranoid_free(g_filelist_imagedevs);
    57     paranoid_free(g_imagedevs_restthese);
    58     paranoid_free(g_mondo_cfg_file);
    59     paranoid_free(g_mountlist_fname);
    60     paranoid_free(g_mondo_home);
    61     paranoid_free(g_tmpfs_mountpt);
    62     paranoid_free(g_isodir_device);
    63     paranoid_free(g_isodir_format);
     55    mr_free(g_biggielist_txt);
     56    mr_free(g_filelist_full);
     57    mr_free(g_filelist_imagedevs);
     58    mr_free(g_imagedevs_restthese);
     59    mr_free(g_mondo_cfg_file);
     60    mr_free(g_mountlist_fname);
     61    mr_free(g_mondo_home);
     62    mr_free(g_tmpfs_mountpt);
     63    mr_free(g_isodir_device);
     64    mr_free(g_isodir_format);
    6465
    6566}
     
    9495        fatal_error("Cannot openin outfname");
    9596    }
    96     for (getline(&incoming, &n, fin);
    97          !feof(fin); getline(&incoming, &n, fin)) {
     97    for (mr_getline(&incoming, &n, fin);
     98         !feof(fin); mr_getline(&incoming, &n, fin)) {
    9899        strip_spaces(incoming);
    99100
     
    102103        }
    103104
    104         asprintf(&question,
     105        mr_asprintf(&question,
    105106                 _("Should I restore the image of %s ?"), incoming);
    106107
     
    108109            fprintf(fout, "%s\n", incoming);
    109110        }
    110         paranoid_free(question);
     111        mr_free(question);
    111112    }
    112113
    113114  /*** free memory ***********/
    114     paranoid_free(incoming);
     115    mr_free(incoming);
    115116
    116117    paranoid_fclose(fout);
     
    147148    assert_string_is_neither_NULL_nor_zerolength(output_cfg_file);
    148149    assert_string_is_neither_NULL_nor_zerolength(output_mountlist_file);
    149     asprintf(&mountpt, "%s/mount.bootdisk", bkpinfo->tmpdir);
    150     asprintf(&command, "mkdir -p %s", mountpt);
     150    mr_asprintf(&mountpt, "%s/mount.bootdisk", bkpinfo->tmpdir);
     151    mr_asprintf(&command, "mkdir -p %s", mountpt);
    151152    run_program_and_log_output(command, FALSE);
    152     paranoid_free(command);
    153 
    154     asprintf(&command, "gzip -dc %s > %s/mindi.rd 2> /dev/null",
     153    mr_free(command);
     154
     155    mr_asprintf(&command, "gzip -dc %s > %s/mindi.rd 2> /dev/null",
    155156            ramdisk_fname, bkpinfo->tmpdir);
    156157    run_program_and_log_output(command, FALSE);
    157     paranoid_free(command);
    158 
    159     asprintf(&command, "umount %s", mountpt);
     158    mr_free(command);
     159
     160    mr_asprintf(&command, "umount %s", mountpt);
    160161    run_program_and_log_output(command, FALSE);
    161     paranoid_free(command);
    162 
    163     asprintf(&command, "mount -o loop %s/mindi.rd -t ext2 %s",
     162    mr_free(command);
     163
     164    mr_asprintf(&command, "mount -o loop %s/mindi.rd -t ext2 %s",
    164165            bkpinfo->tmpdir, mountpt);
    165166    run_program_and_log_output(command, FALSE);
    166     paranoid_free(command);
    167 
    168     asprintf(&command, "mkdir -p %s/tmp", bkpinfo->tmpdir);
     167    mr_free(command);
     168
     169    mr_asprintf(&command, "mkdir -p %s/tmp", bkpinfo->tmpdir);
    169170    run_program_and_log_output(command, FALSE);
    170     paranoid_free(command);
    171 
    172     asprintf(&command, "cp -f %s/%s %s",    // %s/%s becomes {mountpt}/tmp/m*ndo-restore.cfg
     171    mr_free(command);
     172
     173    mr_asprintf(&command, "cp -f %s/%s %s", // %s/%s becomes {mountpt}/tmp/m*ndo-restore.cfg
    173174            mountpt, g_mondo_cfg_file, output_cfg_file);
    174175    run_program_and_log_output(command, FALSE);
    175     paranoid_free(command);
    176 
    177     asprintf(&orig_fname, "%s/%s", mountpt, g_mountlist_fname);
     176    mr_free(command);
     177
     178    mr_asprintf(&orig_fname, "%s/%s", mountpt, g_mountlist_fname);
    178179    if (does_file_exist(orig_fname)) {
    179         asprintf(&command, "cp -f %s %s", orig_fname, output_mountlist_file);
     180        mr_asprintf(&command, "cp -f %s %s", orig_fname, output_mountlist_file);
    180181        run_program_and_log_output(command, FALSE);
    181         paranoid_free(command);
    182     }
    183     asprintf(&command, "umount %s", mountpt);
    184     paranoid_free(mountpt);
     182        mr_free(command);
     183    }
     184    mr_asprintf(&command, "umount %s", mountpt);
     185    mr_free(mountpt);
    185186
    186187    run_program_and_log_output(command, FALSE);
    187     paranoid_free(command);
     188    mr_free(command);
    188189
    189190    if (!does_file_exist(output_cfg_file)
     
    196197        retval = 0;
    197198    }
    198     paranoid_free(orig_fname);
     199    mr_free(orig_fname);
    199200    return (retval);
    200201}
     
    240241
    241242    if (strncmp(preamble, f, strlen(preamble)) == 0) {
    242         asprintf(&file, f + strlen(preamble));
    243     } else {
    244         asprintf(&file, f);
     243        mr_asprintf(&file, f + strlen(preamble));
     244    } else {
     245        mr_asprintf(&file, f);
    245246    }
    246247    if (file[0] == '/' && file[1] == '/') {
    247         asprintf(&tmp, file);
    248         paranoid_free(file);
    249         asprintf(&file, tmp + 1);
    250         paranoid_free(tmp);
    251     }
    252     asprintf(&tmp,
     248        mr_asprintf(&tmp, file);
     249        mr_free(file);
     250        mr_asprintf(&file, tmp + 1);
     251        mr_free(tmp);
     252    }
     253    mr_asprintf(&tmp,
    253254            "Checking to see if f=%s, file=%s, is in the list of biggiefiles",
    254255            f, file);
    255256    log_msg(2, tmp);
    256     paranoid_free(tmp);
    257 
    258     asprintf(&command, "grep -x \"%s\" %s", file, list_fname);
    259     paranoid_free(file);
     257    mr_free(tmp);
     258
     259    mr_asprintf(&command, "grep -x \"%s\" %s", file, list_fname);
     260    mr_free(file);
    260261
    261262    res = run_program_and_log_output(command, FALSE);
    262     paranoid_free(command);
     263    mr_free(command);
    263264    if (res) {
    264265        return (FALSE);
     
    292293    g_ISO_restore_mode = TRUE;
    293294
    294     paranoid_free(g_isodir_device);
     295    mr_free(g_isodir_device);
    295296    read_cfg_var(g_mondo_cfg_file, "iso-dev", g_isodir_device);
    296297    if (bkpinfo->disaster_recovery) {
     
    298299 * Don't let this clobber an existing bkpinfo->isodir */
    299300        if (!bkpinfo->isodir) {
    300             paranoid_alloc(bkpinfo->isodir, "/tmp/isodir");
     301            mr_allocstr(bkpinfo->isodir, "/tmp/isodir");
    301302        }
    302303/* End patch */
    303         asprintf(&command, "mkdir -p %s", bkpinfo->isodir);
     304        mr_asprintf(&command, "mkdir -p %s", bkpinfo->isodir);
    304305        run_program_and_log_output(command, 5);
    305         paranoid_free(command);
     306        mr_free(command);
    306307        log_msg(2, "Setting isodir to %s", bkpinfo->isodir);
    307308    }
     
    319320    } else {
    320321        if (g_isodir_format != NULL) {
    321             asprintf(&mount_isodir_command, "mount %s -t %s -o ro %s", g_isodir_device, g_isodir_format, bkpinfo->isodir);
     322            mr_asprintf(&mount_isodir_command, "mount %s -t %s -o ro %s", g_isodir_device, g_isodir_format, bkpinfo->isodir);
    322323        } else {
    323             asprintf(&mount_isodir_command, "mount %s -o ro %s", g_isodir_device, bkpinfo->isodir);
     324            mr_asprintf(&mount_isodir_command, "mount %s -o ro %s", g_isodir_device, bkpinfo->isodir);
    324325        }
    325326        run_program_and_log_output("df -m", FALSE);
    326         asprintf(&tmp,
     327        mr_asprintf(&tmp,
    327328                "The 'mount' command is '%s'. PLEASE report this command to be if you have problems, ok?",
    328329                mount_isodir_command);
    329330        log_msg(1, tmp);
    330         paranoid_free(tmp);
     331        mr_free(tmp);
    331332
    332333        if (run_program_and_log_output(mount_isodir_command, FALSE)) {
     
    334335                (_
    335336                 ("Cannot mount the device where the ISO files are stored."));
    336             paranoid_free(mount_isodir_command);
     337            mr_free(mount_isodir_command);
    337338            return (1);
    338339        }
    339         paranoid_free(mount_isodir_command);
     340        mr_free(mount_isodir_command);
    340341        log_to_screen
    341342            (_
     
    346347    }
    347348    i = what_number_cd_is_this(bkpinfo);    /* has the side-effect of calling mount_cdrom() */
    348     asprintf(&tmp, "%s #%d has been mounted via loopback mount",
     349    mr_asprintf(&tmp, "%s #%d has been mounted via loopback mount",
    349350            bkpinfo->backup_media_string, i);
    350351    log_msg(1, tmp);
    351     paranoid_free(tmp);
     352    mr_free(tmp);
    352353
    353354    if (i < 0) {
     
    368369{
    369370    char *command;
    370     asprintf(&command,
     371    mr_asprintf(&command,
    371372            "kill `ps 2> /dev/null | grep petris 2> /dev/null | grep -v grep | cut -d' ' -f2` 2> /dev/null");
    372373    paranoid_system(command);
    373     paranoid_free(command);
     374    mr_free(command);
    374375}
    375376
     
    413414                    "Again with the /proc - why is this in your mountlist?");
    414415        } else if (is_this_device_mounted(mountlist->el[lino].device)) {
    415             asprintf(&tmp, _("%s is already mounted"),
     416            mr_asprintf(&tmp, _("%s is already mounted"),
    416417                    mountlist->el[lino].device);
    417418            log_to_screen(tmp);
    418             paranoid_free(tmp);
     419            mr_free(tmp);
    419420        } else if (strcmp(mountlist->el[lino].mountpoint, "none")
    420421                   && strcmp(mountlist->el[lino].mountpoint, "lvm")
    421422                   && strcmp(mountlist->el[lino].mountpoint, "raid")
    422423                   && strcmp(mountlist->el[lino].mountpoint, "image")) {
    423             asprintf(&tmp, "Mounting %s", mountlist->el[lino].device);
     424            mr_asprintf(&tmp, "Mounting %s", mountlist->el[lino].device);
    424425            update_progress_form(tmp);
    425             paranoid_free(tmp);
    426 
    427             asprintf(&format, mountlist->el[lino].format);
     426            mr_free(tmp);
     427
     428            mr_asprintf(&format, mountlist->el[lino].format);
    428429            if (!strcmp(format, "ext3")) {
    429                 paranoid_free(format);
    430                 asprintf(&format, "ext2");
     430                mr_free(format);
     431                mr_asprintf(&format, "ext2");
    431432            }
    432433            res = mount_device(mountlist->el[lino].device,
     
    436437            if (res) {
    437438                if (these_failed != NULL) { /* not the first time */
    438                     asprintf(&tmp, "%s %s", these_failed, mountlist->el[lino].device);
    439                     paranoid_free(these_failed);
     439                    mr_asprintf(&tmp, "%s %s", these_failed, mountlist->el[lino].device);
     440                    mr_free(these_failed);
    440441                    these_failed = tmp;
    441442                } else { /* The first time */
    442                     asprintf(&these_failed, "%s ", mountlist->el[lino].device);
     443                    mr_asprintf(&these_failed, "%s ", mountlist->el[lino].device);
    443444                }
    444445            }
    445             paranoid_free(format);
     446            mr_free(format);
    446447        }
    447448        g_current_progress++;
     
    459460                          ("format and restore *without* partitioning first. Sorry for the inconvenience."));
    460461        }
    461         asprintf(&tmp, _("Could not mount devices %s- shall I abort?"),
     462        mr_asprintf(&tmp, _("Could not mount devices %s- shall I abort?"),
    462463                these_failed);
    463         paranoid_free(these_failed);
     464        mr_free(these_failed);
    464465
    465466        if (!ask_me_yes_or_no(tmp)) {
     
    474475                (_("Unable to mount some or all of your partitions."));
    475476        }
    476         paranoid_free(tmp);
     477        mr_free(tmp);
    477478    } else {
    478479        log_to_screen(_("All partitions were mounted OK."));
     
    480481    }
    481482    run_program_and_log_output("df -m", 3);
    482     paranoid_free(mountlist);
     483    mr_free(mountlist);
    483484    return (retval);
    484485}
     
    523524        if ((!bkpinfo->isodir || !strcmp(bkpinfo->isodir, "/"))
    524525            && am_I_in_disaster_recovery_mode()) {
    525             paranoid_alloc(bkpinfo->isodir, "/tmp/isodir");
     526            mr_allocstr(bkpinfo->isodir, "/tmp/isodir");
    526527            log_msg(1, "isodir is being set to %s", bkpinfo->isodir);
    527528        }
    528529#ifdef __FreeBSD__
    529         asprintf(&mount_cmd, "/mnt/isodir/%s/%s/%s-%d.iso", bkpinfo->isodir,
     530        mr_asprintf(&mount_cmd, "/mnt/isodir/%s/%s/%s-%d.iso", bkpinfo->isodir,
    530531                bkpinfo->nfs_remote_dir, bkpinfo->prefix,
    531532                g_current_media_number);
    532533        mddev = make_vn(mount_cmd);
    533         paranoid_free(mount_cmd);
    534 
    535         asprintf(&mount_cmd, "mount_cd9660 -r %s " MNT_CDROM, mddev);
    536         paranoid_free(mddev);
     534        mr_free(mount_cmd);
     535
     536        mr_asprintf(&mount_cmd, "mount_cd9660 -r %s " MNT_CDROM, mddev);
     537        mr_free(mddev);
    537538#else
    538         asprintf(&mount_cmd,
     539        mr_asprintf(&mount_cmd,
    539540                "mount %s/%s/%s-%d.iso -t iso9660 -o loop,ro %s",
    540541                bkpinfo->isodir, bkpinfo->nfs_remote_dir, bkpinfo->prefix,
     
    544545    } else if (bkpinfo->backup_media_type == iso) {
    545546#ifdef __FreeBSD__
    546         asprintf(&mount_cmd, "%s/%s-%d.iso", bkpinfo->isodir,
     547        mr_asprintf(&mount_cmd, "%s/%s-%d.iso", bkpinfo->isodir,
    547548                bkpinfo->prefix, g_current_media_number);
    548549        mddev = make_vn(mount_cmd);
    549         paranoid_free(mount_cmd);
    550 
    551         asprintf(&mount_cmd, "mount_cd9660 -r %s %s", mddev, MNT_CDROM);
    552         paranoid_free(mddev);
     550        mr_free(mount_cmd);
     551
     552        mr_asprintf(&mount_cmd, "mount_cd9660 -r %s %s", mddev, MNT_CDROM);
     553        mr_free(mddev);
    553554#else
    554         asprintf(&mount_cmd, "mount %s/%s-%d.iso -t iso9660 -o loop,ro %s",
     555        mr_asprintf(&mount_cmd, "mount %s/%s-%d.iso -t iso9660 -o loop,ro %s",
    555556                bkpinfo->isodir, bkpinfo->prefix, g_current_media_number,
    556557                MNT_CDROM);
     
    559560#ifdef __FreeBSD__
    560561    {
    561         asprintf(&mount_cmd, "mount_cd9660 -r %s %s", bkpinfo->media_device,
     562        mr_asprintf(&mount_cmd, "mount_cd9660 -r %s %s", bkpinfo->media_device,
    562563                MNT_CDROM);
    563564    }
    564565#else
    565566    {
    566         asprintf(&mount_cmd, "mount %s -t iso9660 -o ro %s",
     567        mr_asprintf(&mount_cmd, "mount %s -t iso9660 -o ro %s",
    567568                bkpinfo->media_device, MNT_CDROM);
    568569    }
     
    572573        if (bkpinfo->disaster_recovery
    573574            && does_file_exist("/tmp/CDROM-LIVES-HERE")) {
    574             paranoid_free(bkpinfo->media_device);
     575            mr_free(bkpinfo->media_device);
    575576            bkpinfo->media_device = last_line_of_file("/tmp/CDROM-LIVES-HERE");
    576577        } else {
    577             paranoid_free(bkpinfo->media_device);
     578            mr_free(bkpinfo->media_device);
    578579            bkpinfo->media_device = find_cdrom_device(TRUE);
    579580        }
    580581
    581582#ifdef __FreeBSD__
    582         asprintf(&mount_cmd, "mount_cd9660 -r %s %s", bkpinfo->media_device,
     583        mr_asprintf(&mount_cmd, "mount_cd9660 -r %s %s", bkpinfo->media_device,
    583584                MNT_CDROM);
    584585#else
    585         asprintf(&mount_cmd, "mount %s -t iso9660 -o ro %s",
     586        mr_asprintf(&mount_cmd, "mount %s -t iso9660 -o ro %s",
    586587                bkpinfo->media_device, MNT_CDROM);
    587588#endif
     
    599600        }
    600601    }
    601     paranoid_free(mount_cmd);
     602    mr_free(mount_cmd);
    602603
    603604    if (res) {
     
    639640
    640641    if (!strcmp(mpt, "/1")) {
    641         asprintf(&mountpoint, "/");
     642        mr_asprintf(&mountpoint, "/");
    642643        log_msg(3, "Mommm! SME is being a dildo!");
    643644    } else {
    644         asprintf(&mountpoint, mpt);
     645        mr_asprintf(&mountpoint, mpt);
    645646    }
    646647
    647648    if (!strcmp(mountpoint, "lvm")) {
    648         paranoid_free(mountpoint);
     649        mr_free(mountpoint);
    649650        return (0);
    650651    }
    651652    if (!strcmp(mountpoint, "image")) {
    652         paranoid_free(mountpoint);
     653        mr_free(mountpoint);
    653654        return (0);
    654655    }
    655     asprintf(&tmp, "Mounting device %s   ", device);
     656    mr_asprintf(&tmp, "Mounting device %s   ", device);
    656657    log_msg(1, tmp);
    657658
    658659    if (writeable) {
    659         asprintf(&p1, "-o rw");
    660     } else {
    661         asprintf(&p1, "-o ro");
     660        mr_asprintf(&p1, "-o rw");
     661    } else {
     662        mr_asprintf(&p1, "-o ro");
    662663    }
    663664    tmp = find_home_of_exe("setfattr");
    664665    if (tmp) {
    665         asprintf(&p2, ",user_xattr");
    666     } else {
    667         asprintf(&p2, "%s", "");
    668     }
    669     paranoid_free(tmp);
     666        mr_asprintf(&p2, ",user_xattr");
     667    } else {
     668        mr_asprintf(&p2, "%s", "");
     669    }
     670    mr_free(tmp);
    670671
    671672    tmp = find_home_of_exe("setfacl");
    672673    if (tmp) {
    673         asprintf(&p3, ",acl");
    674     } else {
    675         asprintf(&p3, "%s", "");
    676     }
    677     paranoid_free(tmp);
    678 
    679     asprintf(&additional_parameters, "%s%s%s", p1, p2, p3);
    680     paranoid_free(p1);
    681     paranoid_free(p2);
    682     paranoid_free(p3);
     674        mr_asprintf(&p3, ",acl");
     675    } else {
     676        mr_asprintf(&p3, "%s", "");
     677    }
     678    mr_free(tmp);
     679
     680    mr_asprintf(&additional_parameters, "%s%s%s", p1, p2, p3);
     681    mr_free(p1);
     682    mr_free(p2);
     683    mr_free(p3);
    683684
    684685    if (!strcmp(mountpoint, "swap")) {
    685         asprintf(&command, "swapon %s", device);
     686        mr_asprintf(&command, "swapon %s", device);
    686687    } else {
    687688        if (!strcmp(mountpoint, "/")) {
    688             asprintf(&mountdir, MNT_RESTORING);
     689            mr_asprintf(&mountdir, MNT_RESTORING);
    689690        } else {
    690             asprintf(&mountdir, "%s%s", MNT_RESTORING, mountpoint);
    691         }
    692         asprintf(&command, "mkdir -p %s", mountdir);
     691            mr_asprintf(&mountdir, "%s%s", MNT_RESTORING, mountpoint);
     692        }
     693        mr_asprintf(&command, "mkdir -p %s", mountdir);
    693694        run_program_and_log_output(command, FALSE);
    694         paranoid_free(command);
    695 
    696         asprintf(&command, "mount -t %s %s %s %s 2>> %s", format, device,
     695        mr_free(command);
     696
     697        mr_asprintf(&command, "mount -t %s %s %s %s 2>> %s", format, device,
    697698                additional_parameters, mountdir, MONDO_LOGFILE);
    698699        log_msg(2, "command='%s'", command);
    699700    }
    700     paranoid_free(additional_parameters);
     701    mr_free(additional_parameters);
    701702
    702703    res = run_program_and_log_output(command, TRUE);
    703704    if (res && (strstr(command, "xattr") || strstr(command, "acl"))) {
    704705        log_msg(1, "Re-trying without the fancy extra parameters");
    705         paranoid_free(command);
    706 
    707         asprintf(&command, "mount -t %s %s %s 2>> %s", format, device,
     706        mr_free(command);
     707
     708        mr_asprintf(&command, "mount -t %s %s %s 2>> %s", format, device,
    708709                mountdir, MONDO_LOGFILE);
    709710        res = run_program_and_log_output(command, TRUE);
     
    717718        } else {
    718719            log_msg(2, "Retrying w/o the '-t' switch");
    719             paranoid_free(command);
    720 
    721             asprintf(&command, "mount %s %s 2>> %s", device, mountdir,
     720            mr_free(command);
     721
     722            mr_asprintf(&command, "mount %s %s 2>> %s", device, mountdir,
    722723                    MONDO_LOGFILE);
    723724            log_msg(2, "2nd command = '%s'", command);
     
    731732        }
    732733    }
    733     paranoid_free(tmp);
    734     paranoid_free(command);
    735     paranoid_free(mountdir);
     734    mr_free(tmp);
     735    mr_free(command);
     736    mr_free(mountdir);
    736737
    737738    if (res && !strcmp(mountpoint, "swap")) {
     
    740741        res = 0;
    741742    }
    742     paranoid_free(mountpoint);
     743    mr_free(mountpoint);
    743744
    744745    return (res);
     
    836837                }
    837838            }
    838             paranoid_free(value);
     839            mr_free(value);
    839840
    840841            if (read_cfg_var(cfg_file, "iso-prefix", value) == 0) {
    841                 paranoid_alloc(bkpinfo->prefix,value);
     842                mr_allocstr(bkpinfo->prefix,value);
    842843            } else {
    843                 paranoid_alloc(bkpinfo->prefix, STD_PREFIX);
     844                mr_allocstr(bkpinfo->prefix, STD_PREFIX);
    844845            }
    845846        } else if (!strcmp(value, "nfs")) {
    846847            bkpinfo->backup_media_type = nfs;
    847             paranoid_free(value);
     848            mr_free(value);
    848849            if (read_cfg_var(cfg_file, "iso-prefix", value) == 0) {
    849                 paranoid_alloc(bkpinfo->prefix,value);
     850                mr_allocstr(bkpinfo->prefix,value);
    850851            } else {
    851                 paranoid_alloc(bkpinfo->prefix, STD_PREFIX);
     852                mr_allocstr(bkpinfo->prefix, STD_PREFIX);
    852853            }
    853854            /* We need to override prefix value in PXE mode as it's
     
    868869        fatal_error("backup-media-type not specified!");
    869870    }
    870     paranoid_free(value);
     871    mr_free(value);
    871872
    872873    if (bkpinfo->disaster_recovery) {
    873874        if (bkpinfo->backup_media_type == cdstream) {
    874             paranoid_alloc(bkpinfo->media_device, "/dev/cdrom");
     875            mr_allocstr(bkpinfo->media_device, "/dev/cdrom");
    875876            bkpinfo->media_size[0] = 1999 * 1024;
    876877            bkpinfo->media_size[1] = 650;   /* good guess */
    877878        } else if (bkpinfo->backup_media_type == tape
    878879                   || bkpinfo->backup_media_type == udev) {
    879             paranoid_free(bkpinfo->media_device);
     880            mr_free(bkpinfo->media_device);
    880881            if (read_cfg_var(cfg_file, "media-dev", bkpinfo->media_device)) {
    881882                fatal_error("Cannot get tape device name from cfg file");
     
    883884            read_cfg_var(cfg_file, "media-size", value);
    884885            bkpinfo->media_size[1] = atol(value);
    885             paranoid_free(value);
    886 
    887             asprintf(&tmp, "Backup medium is TAPE --- dev=%s",
     886            mr_free(value);
     887
     888            mr_asprintf(&tmp, "Backup medium is TAPE --- dev=%s",
    888889                    bkpinfo->media_device);
    889890            log_msg(2, tmp);
    890             paranoid_free(tmp);
     891            mr_free(tmp);
    891892        } else {
    892             paranoid_alloc(bkpinfo->media_device, "/dev/cdrom");
     893            mr_allocstr(bkpinfo->media_device, "/dev/cdrom");
    893894            bkpinfo->media_size[0] = 1999 * 1024;   /* 650, probably, but we don't need this var anyway */
    894895            bkpinfo->media_size[1] = 1999 * 1024;   /* 650, probably, but we don't need this var anyway */
     
    905906        log_msg(1, "Goody! ... bkpinfo->use_star is now true.");
    906907    }
    907     paranoid_free(value);
     908    mr_free(value);
    908909
    909910    if (0 == read_cfg_var(cfg_file, "internal-tape-block-size", value)) {
     
    917918                DEFAULT_INTERNAL_TAPE_BLOCK_SIZE);
    918919    }
    919     paranoid_free(value);
     920    mr_free(value);
    920921
    921922    read_cfg_var(cfg_file, "use-lzo", value);
    922923    if (strstr(value, "yes")) {
    923924        bkpinfo->use_lzo = TRUE;
    924         paranoid_alloc(bkpinfo->zip_exe, "lzop");
    925         paranoid_alloc(bkpinfo->zip_suffix, "lzo");
    926     } else {
    927         paranoid_free(value);
     925        mr_allocstr(bkpinfo->zip_exe, "lzop");
     926        mr_allocstr(bkpinfo->zip_suffix, "lzo");
     927    } else {
     928        mr_free(value);
    928929        read_cfg_var(cfg_file, "use-comp", value);
    929930        if (strstr(value, "yes")) {
    930931            bkpinfo->use_lzo = FALSE;
    931             paranoid_alloc(bkpinfo->zip_exe, "bzip2");
    932             paranoid_alloc(bkpinfo->zip_suffix, "bz2");
     932            mr_allocstr(bkpinfo->zip_exe, "bzip2");
     933            mr_allocstr(bkpinfo->zip_suffix, "bz2");
    933934        } else {
    934935            // Just to be sure
     
    937938        }
    938939    }
    939     paranoid_free(value);
     940    mr_free(value);
    940941
    941942    read_cfg_var(cfg_file, "differential", value);
     
    944945    }
    945946    log_msg(2, "differential var = '%s'", value);
    946     paranoid_free(value);
     947    mr_free(value);
    947948
    948949    if (bkpinfo->differential) {
     
    962963        log_msg(2, "Ok, I shan't eject when restoring! Groovy.");
    963964    }
    964     paranoid_free(tmp);
    965     paranoid_free(tmp1);
     965    mr_free(tmp);
     966    mr_free(tmp1);
    966967
    967968    if (bkpinfo->backup_media_type == nfs) {
     
    973974                    "...cos it wouldn't make sense to abandon the values that GOT ME to this config file in the first place");
    974975        } else {
    975             paranoid_free(bkpinfo->nfs_mount);
    976             paranoid_free(bkpinfo->nfs_remote_dir);
     976            mr_free(bkpinfo->nfs_mount);
     977            mr_free(bkpinfo->nfs_remote_dir);
    977978            read_cfg_var(g_mondo_cfg_file, "nfs-server-mount",
    978979                         bkpinfo->nfs_mount);
     
    994995         * isodir in disaster recovery mode
    995996         */
    996         paranoid_alloc(old_isodir,bkpinfo->isodir);
     997        mr_allocstr(old_isodir,bkpinfo->isodir);
    997998        read_cfg_var(g_mondo_cfg_file, "iso-mnt", iso_mnt);
    998999        read_cfg_var(g_mondo_cfg_file, "isodir", iso_path);
    9991000        if (iso_mnt && iso_path) {
    1000             paranoid_free(bkpinfo->isodir);
    1001             asprintf(&bkpinfo->isodir, "%s%s", iso_mnt, iso_path);
    1002         }
    1003         paranoid_free(iso_mnt);
    1004         paranoid_free(iso_path);
     1001            mr_free(bkpinfo->isodir);
     1002            mr_asprintf(&bkpinfo->isodir, "%s%s", iso_mnt, iso_path);
     1003        }
     1004        mr_free(iso_mnt);
     1005        mr_free(iso_path);
    10051006
    10061007        if (!bkpinfo->disaster_recovery) {
     
    10111012            }
    10121013        }
    1013         paranoid_free(old_isodir);
    1014 
    1015         paranoid_free(g_isodir_device);
     1014        mr_free(old_isodir);
     1015
     1016        mr_free(g_isodir_device);
    10161017        read_cfg_var(g_mondo_cfg_file, "iso-dev", g_isodir_device);
    10171018        log_msg(2, "isodir=%s; iso-dev=%s", bkpinfo->isodir, g_isodir_device);
     
    10201021                log_msg(2, "NB: isodir is already mounted");
    10211022                /* Find out where it's mounted */
    1022                 asprintf(&command,
     1023                mr_asprintf(&command,
    10231024                        "mount | grep -w %s | tail -n1 | cut -d' ' -f3",
    10241025                        g_isodir_device);
     
    10271028                log_it("res of it = %s", tmp);
    10281029                iso_mnt = tmp;
    1029                 paranoid_free(command);
     1030                mr_free(command);
    10301031            } else {
    1031                 asprintf(&iso_mnt, "/tmp/isodir");
    1032                 asprintf(&tmp, "mkdir -p %s", iso_mnt);
     1032                mr_asprintf(&iso_mnt, "/tmp/isodir");
     1033                mr_asprintf(&tmp, "mkdir -p %s", iso_mnt);
    10331034                run_program_and_log_output(tmp, 5);
    1034                 paranoid_free(tmp);
    1035 
    1036                 asprintf(&tmp, "mount %s %s", g_isodir_device, iso_mnt);
     1035                mr_free(tmp);
     1036
     1037                mr_asprintf(&tmp, "mount %s %s", g_isodir_device, iso_mnt);
    10371038                if (run_program_and_log_output(tmp, 3)) {
    10381039                    log_msg(1,
    10391040                            "Unable to mount isodir. Perhaps this is really a CD backup?");
    10401041                    bkpinfo->backup_media_type = cdr;
    1041                     paranoid_alloc(bkpinfo->media_device, "/dev/cdrom");
    1042                     paranoid_free(bkpinfo->isodir);
    1043                     paranoid_free(iso_mnt);
    1044                     paranoid_free(iso_path);
    1045                     asprintf(&iso_mnt, "%s", "");
    1046                     asprintf(&iso_path, "%s", "");
     1042                    mr_allocstr(bkpinfo->media_device, "/dev/cdrom");
     1043                    mr_free(bkpinfo->isodir);
     1044                    mr_free(iso_mnt);
     1045                    mr_free(iso_path);
     1046                    mr_asprintf(&iso_mnt, "%s", "");
     1047                    mr_asprintf(&iso_path, "%s", "");
    10471048
    10481049                    if (mount_cdrom(bkpinfo)) {
     
    10541055                    }
    10551056                }
    1056                 paranoid_free(tmp);
     1057                mr_free(tmp);
    10571058            }
    10581059            /* bkpinfo->isodir should now be the true path to prefix-1.iso etc... */
    10591060            if (bkpinfo->backup_media_type == iso) {
    1060                 paranoid_free(bkpinfo->isodir);
    1061                 asprintf(&bkpinfo->isodir, "%s%s", iso_mnt, iso_path);
    1062             }
    1063             paranoid_free(iso_mnt);
    1064             paranoid_free(iso_path);
     1061                mr_free(bkpinfo->isodir);
     1062                mr_asprintf(&bkpinfo->isodir, "%s%s", iso_mnt, iso_path);
     1063            }
     1064            mr_free(iso_mnt);
     1065            mr_free(iso_path);
    10651066        }
    10661067    }
     
    11311132        unlink("/tmp/i-want-my-lvm");
    11321133        if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) {
    1133             asprintf(&command,
     1134            mr_asprintf(&command,
    11341135                    "tar -zxf %s %s %s %s %s %s",
    11351136                    bkpinfo->media_device,
     
    11401141            log_msg(1, "tarcommand = %s", command);
    11411142            run_program_and_log_output(command, 1);
    1142             paranoid_free(command);
     1143            mr_free(command);
    11431144        } else {
    11441145            log_msg(2,
     
    11481149            log_msg(2, "Back from iotcn");
    11491150            run_program_and_log_output("mount", 1);
    1150             asprintf(&command,
     1151            mr_asprintf(&command,
    11511152                    "tar -zxf %s/images/all.tar.gz %s %s %s %s %s",
    11521153                    MNT_CDROM,
     
    11581159            log_msg(1, "tarcommand = %s", command);
    11591160            run_program_and_log_output(command, 1);
    1160             paranoid_free(command);
     1161            mr_free(command);
    11611162
    11621163            if (!does_file_exist(BIGGIELIST_TXT_STUB)) {
     
    11691170            }
    11701171        }
    1171         asprintf(&command, "cp -f %s %s", MONDO_CFG_FILE_STUB,
     1172        mr_asprintf(&command, "cp -f %s %s", MONDO_CFG_FILE_STUB,
    11721173                g_mondo_cfg_file);
    11731174        run_program_and_log_output(command, FALSE);
    1174         paranoid_free(command);
    1175 
    1176         asprintf(&command, "cp -f %s/%s %s", bkpinfo->tmpdir,
     1175        mr_free(command);
     1176
     1177        mr_asprintf(&command, "cp -f %s/%s %s", bkpinfo->tmpdir,
    11771178                BIGGIELIST_TXT_STUB, g_biggielist_txt);
    11781179        log_msg(1, "command = %s", command);
    11791180        paranoid_system(command);
    1180         paranoid_free(command);
    1181 
    1182         asprintf(&command, "ln -sf %s/%s %s", bkpinfo->tmpdir,
     1181        mr_free(command);
     1182
     1183        mr_asprintf(&command, "ln -sf %s/%s %s", bkpinfo->tmpdir,
    11831184                FILELIST_FULL_STUB, g_filelist_full);
    11841185        log_msg(1, "command = %s", command);
    11851186        paranoid_system(command);
    1186         paranoid_free(command);
     1187        mr_free(command);
    11871188    }
    11881189
     
    11921193                         ("Do you want to retrieve the mountlist as well?")))
    11931194    {
    1194         asprintf(&command, "ln -sf %s/%s /tmp", MOUNTLIST_FNAME_STUB,
     1195        mr_asprintf(&command, "ln -sf %s/%s /tmp", MOUNTLIST_FNAME_STUB,
    11951196                bkpinfo->tmpdir);
    11961197        paranoid_system(command);
    1197         paranoid_free(command);
     1198        mr_free(command);
    11981199    }
    11991200
    12001201    chdir(tmp);
    1201     paranoid_free(tmp);
     1202    mr_free(tmp);
    12021203
    12031204    if (!does_file_exist(g_biggielist_txt)) {
     
    12191220        log_to_screen(("Pre-processing filelist"));
    12201221        if (!does_file_exist(g_biggielist_txt)) {
    1221             asprintf(&command, "> %s", g_biggielist_txt);
     1222            mr_asprintf(&command, "> %s", g_biggielist_txt);
    12221223            paranoid_system(command);
    1223             paranoid_free(command);
    1224         }
    1225         asprintf(&command, "grep  -x \"/dev/.*\" %s > %s",
     1224            mr_free(command);
     1225        }
     1226        mr_asprintf(&command, "grep  -x \"/dev/.*\" %s > %s",
    12261227                g_biggielist_txt, g_filelist_imagedevs);
    12271228        paranoid_system(command);
    1228         paranoid_free(command);
     1229        mr_free(command);
    12291230        exit(0);
    12301231        break;
     
    12451246    if (g_text_mode) {
    12461247        printf(_("Restore which directory? --> "));
    1247         getline(&tmp, &n, stdin);
     1248        mr_getline(&tmp, &n, stdin);
    12481249        toggle_path_selection(filelist, tmp, TRUE);
    12491250        if (strlen(tmp) == 0) {
     
    12521253            res = 0;
    12531254        }
    1254         paranoid_free(tmp);
     1255        mr_free(tmp);
    12551256    } else {
    12561257        res = edit_filelist(filelist);
     
    12961297    assert_string_is_neither_NULL_nor_zerolength(filename);
    12971298
    1298     asprintf(&command, "cp -f %s/%s %s/%s.pristine", path_root, filename,path_root, filename);
     1299    mr_asprintf(&command, "cp -f %s/%s %s/%s.pristine", path_root, filename,path_root, filename);
    12991300    res = run_program_and_log_output(command, 5);
    1300     paranoid_free(command);
     1301    mr_free(command);
    13011302    return (res);
    13021303}
     
    13241325    read_cfg_var(g_mondo_cfg_file, "bootloader.device", device);
    13251326    read_cfg_var(g_mondo_cfg_file, "bootloader.name", name);
    1326     asprintf(&tmp, "run_boot_loader: device='%s', name='%s'", device, name);
     1327    mr_asprintf(&tmp, "run_boot_loader: device='%s', name='%s'", device, name);
    13271328    log_msg(2, tmp);
    1328     paranoid_free(tmp);
     1329    mr_free(tmp);
    13291330
    13301331    sync();
     
    13491350#ifdef __FreeBSD__
    13501351    else if (!strcmp(name, "BOOT0")) {
    1351         asprintf(&tmp, "boot0cfg -B %s", device);
     1352        mr_asprintf(&tmp, "boot0cfg -B %s", device);
    13521353        res = run_program_and_log_output(tmp, FALSE);
    1353         paranoid_free(tmp);
    1354     } else {
    1355         asprintf(&tmp, "ls /dev | grep -xq %ss[1-4].*", device);
     1354        mr_free(tmp);
     1355    } else {
     1356        mr_asprintf(&tmp, "ls /dev | grep -xq %ss[1-4].*", device);
    13561357        if (!system(tmp)) {
    1357             paranoid_free(tmp);
    1358             asprintf(&tmp, MNT_RESTORING "/sbin/fdisk -B %s", device);
     1358            mr_free(tmp);
     1359            mr_asprintf(&tmp, MNT_RESTORING "/sbin/fdisk -B %s", device);
    13591360            res = run_program_and_log_output(tmp, 3);
    13601361        } else {
     
    13621363                    "I'm not running any boot loader. You have a DD boot drive. It's already loaded up.");
    13631364        }
    1364         paranoid_free(tmp);
     1365        mr_free(tmp);
    13651366    }
    13661367#else
     
    13721373    }
    13731374#endif
    1374     paranoid_free(device);
    1375     paranoid_free(name);
     1375    mr_free(device);
     1376    mr_free(name);
    13761377
    13771378    retval += res;
     
    14011402    tmp = find_home_of_exe("pico");
    14021403    if (tmp) {
    1403         asprintf(&output, "pico");
     1404        mr_asprintf(&output, "pico");
    14041405    } else {
    14051406        tmp = find_home_of_exe("nano");
    14061407        if (tmp) {
    1407             asprintf(&output, "nano");
     1408            mr_asprintf(&output, "nano");
    14081409        } else {
    14091410            tmp = find_home_of_exe("vi");
    14101411            if (tmp) {
    1411                 asprintf(&output, "vi");
     1412                mr_asprintf(&output, "vi");
    14121413            } else {
    1413                 asprintf(&output, "emacs");
    1414             }
    1415         }
    1416     }
    1417     paranoid_free(tmp);
     1414                mr_asprintf(&output, "emacs");
     1415            }
     1416        }
     1417    }
     1418    mr_free(tmp);
    14181419
    14191420    tmp = find_home_of_exe(output);
     
    14211422        log_msg(2, " (find_my_editor) --- warning - %s not found", output);
    14221423    }
    1423     paranoid_free(tmp);
     1424    mr_free(tmp);
    14241425    return (output);
    14251426}
     
    14541455            popup_and_get_string(_("Boot device"),
    14551456                                 _("Please confirm/enter the boot device. If in doubt, try /dev/hda"), bd);
    1456             asprintf(&command, "stabgrub-me %s", bd);
     1457            mr_asprintf(&command, "stabgrub-me %s", bd);
    14571458            res = run_program_and_log_output(command, 1);
    1458             paranoid_free(command);
     1459            mr_free(command);
    14591460
    14601461            if (res) {
     
    14741475            }
    14751476            editor = find_my_editor();
    1476             asprintf(&tmp, "%s " MNT_RESTORING "/etc/fstab", editor);
     1477            mr_asprintf(&tmp, "%s " MNT_RESTORING "/etc/fstab", editor);
    14771478            paranoid_system(tmp);
    1478             paranoid_free(tmp);
    1479 
    1480             asprintf(&tmp, "%s " MNT_RESTORING "/etc/grub.conf", editor);
    1481             paranoid_free(editor);
     1479            mr_free(tmp);
     1480
     1481            mr_asprintf(&tmp, "%s " MNT_RESTORING "/etc/grub.conf", editor);
     1482            mr_free(editor);
    14821483
    14831484            paranoid_system(tmp);
    1484             paranoid_free(tmp);
     1485            mr_free(tmp);
    14851486
    14861487            if (!g_text_mode) {
     
    14921493        if (!run_program_and_log_output("which grub-MR", FALSE)) {
    14931494            log_msg(1, "Yay! grub-MR found...");
    1494             asprintf(&command, "grub-MR %s /tmp/mountlist.txt", bd);
     1495            mr_asprintf(&command, "grub-MR %s /tmp/mountlist.txt", bd);
    14951496            log_msg(1, "command = %s", command);
    14961497        } else {
    1497             asprintf(&command, "chroot " MNT_RESTORING " grub-install %s", bd);
     1498            mr_asprintf(&command, "chroot " MNT_RESTORING " grub-install %s", bd);
    14981499            log_msg(1, "WARNING - grub-MR not found; using grub-install");
    14991500        }
     
    15041505        iamhere(command);
    15051506        res = run_program_and_log_output(command, 1);
    1506         paranoid_free(command);
     1507        mr_free(command);
    15071508
    15081509        if (res) {
     
    15631564                            _
    15641565                            ("Modifying fstab and elilo.conf...                             "));
    1565         asprintf(&command, "stabelilo-me");
     1566        mr_asprintf(&command, "stabelilo-me");
    15661567        res = run_program_and_log_output(command, 3);
    1567         paranoid_free(command);
     1568        mr_free(command);
    15681569
    15691570        if (res) {
     
    15761577                }
    15771578                editor = find_my_editor();
    1578                 asprintf(&tmp, "%s " MNT_RESTORING "/etc/fstab", editor);
     1579                mr_asprintf(&tmp, "%s " MNT_RESTORING "/etc/fstab", editor);
    15791580                paranoid_system(tmp);
    1580                 paranoid_free(tmp);
    1581 
    1582                 asprintf(&tmp, "%s " MNT_RESTORING "/etc/elilo.conf", editor);
    1583                 paranoid_free(editor);
     1581                mr_free(tmp);
     1582
     1583                mr_asprintf(&tmp, "%s " MNT_RESTORING "/etc/elilo.conf", editor);
     1584                mr_free(editor);
    15841585
    15851586                paranoid_system(tmp);
    1586                 paranoid_free(tmp);
     1587                mr_free(tmp);
    15871588
    15881589                if (!g_text_mode) {
     
    16381639                            _
    16391640                            ("Modifying fstab and lilo.conf, and running LILO...                             "));
    1640         asprintf(&command, "stablilo-me");
     1641        mr_asprintf(&command, "stablilo-me");
    16411642        res = run_program_and_log_output(command, 3);
    1642         paranoid_free(command);
     1643        mr_free(command);
    16431644
    16441645        if (res) {
     
    16511652                }
    16521653                editor = find_my_editor();
    1653                 asprintf(&tmp, "%s " MNT_RESTORING "/etc/fstab", editor);
     1654                mr_asprintf(&tmp, "%s " MNT_RESTORING "/etc/fstab", editor);
    16541655                paranoid_system(tmp);
    1655                 paranoid_free(tmp);
    1656 
    1657                 asprintf(&tmp, "%s " MNT_RESTORING "/etc/lilo.conf", editor);
    1658                 paranoid_free(editor);
     1656                mr_free(tmp);
     1657
     1658                mr_asprintf(&tmp, "%s " MNT_RESTORING "/etc/lilo.conf", editor);
     1659                mr_free(editor);
    16591660
    16601661                paranoid_system(tmp);
    1661                 paranoid_free(tmp);
     1662                mr_free(tmp);
    16621663
    16631664                if (!g_text_mode) {
     
    17531754                }
    17541755                editor = find_my_editor();
    1755                 asprintf(&tmp, "%s " MNT_RESTORING "/etc/fstab", editor);
    1756                 paranoid_free(editor);
     1756                mr_asprintf(&tmp, "%s " MNT_RESTORING "/etc/fstab", editor);
     1757                mr_free(editor);
    17571758
    17581759                paranoid_system(tmp);
    1759                 paranoid_free(tmp);
     1760                mr_free(tmp);
    17601761
    17611762                if (!g_text_mode) {
     
    17671768                                 _
    17681769                                 ("Please confirm/enter the boot device. If in doubt, try /dev/hda"), bd);
    1769             asprintf(&command, "stabraw-me %s", bd);
     1770            mr_asprintf(&command, "stabraw-me %s", bd);
    17701771            res = run_program_and_log_output(command, 3);
    1771             paranoid_free(command);
     1772            mr_free(command);
    17721773
    17731774            if (res) {
     
    17831784                            _
    17841785                            ("Restoring MBR...                                               "));
    1785         asprintf(&command, "raw-MR %s /tmp/mountlist.txt", bd);
     1786        mr_asprintf(&command, "raw-MR %s /tmp/mountlist.txt", bd);
    17861787        log_msg(2, "run_raw_mbr() --- command='%s'", command);
    17871788        res = run_program_and_log_output(command, 3);
    1788         paranoid_free(command);
     1789        mr_free(command);
    17891790    }
    17901791    if (res) {
     
    18391840    assert(bkpinfo != NULL);
    18401841
    1841     asprintf(&g_biggielist_txt, "%s/%s",bkpinfo->tmpdir , BIGGIELIST_TXT_STUB);
    1842     asprintf(&g_filelist_full, "%s/%s", bkpinfo->tmpdir, FILELIST_FULL_STUB);
    1843     asprintf(&g_filelist_imagedevs, "%s/tmp/filelist.imagedevs", bkpinfo->tmpdir);
    1844     asprintf(&g_imagedevs_restthese, "%s/tmp/imagedevs.restore-these",
     1842    mr_asprintf(&g_biggielist_txt, "%s/%s",bkpinfo->tmpdir , BIGGIELIST_TXT_STUB);
     1843    mr_asprintf(&g_filelist_full, "%s/%s", bkpinfo->tmpdir, FILELIST_FULL_STUB);
     1844    mr_asprintf(&g_filelist_imagedevs, "%s/tmp/filelist.imagedevs", bkpinfo->tmpdir);
     1845    mr_asprintf(&g_imagedevs_restthese, "%s/tmp/imagedevs.restore-these",
    18451846            bkpinfo->tmpdir);
    1846     paranoid_free(g_mondo_cfg_file);
    1847     paranoid_free(g_mountlist_fname);
     1847    mr_free(g_mondo_cfg_file);
     1848    mr_free(g_mountlist_fname);
    18481849    if (bkpinfo->disaster_recovery) {
    1849         asprintf(&g_mondo_cfg_file, "/%s", MONDO_CFG_FILE_STUB);
    1850         asprintf(&g_mountlist_fname, "/%s", MOUNTLIST_FNAME_STUB);
    1851     } else {
    1852         asprintf(&g_mondo_cfg_file, "%s/%s", bkpinfo->tmpdir, MONDO_CFG_FILE_STUB);
    1853         asprintf(&g_mountlist_fname, "%s/%s", bkpinfo->tmpdir, MOUNTLIST_FNAME_STUB);
     1850        mr_asprintf(&g_mondo_cfg_file, "/%s", MONDO_CFG_FILE_STUB);
     1851        mr_asprintf(&g_mountlist_fname, "/%s", MOUNTLIST_FNAME_STUB);
     1852    } else {
     1853        mr_asprintf(&g_mondo_cfg_file, "%s/%s", bkpinfo->tmpdir, MONDO_CFG_FILE_STUB);
     1854        mr_asprintf(&g_mountlist_fname, "%s/%s", bkpinfo->tmpdir, MOUNTLIST_FNAME_STUB);
    18541855    }
    18551856}
     
    18821883        fatal_error("cannot open output_file");
    18831884    }
    1884     for (getline(&incoming, &n, fin); !feof(fin);
    1885          getline(&incoming, &n, fin)) {
     1885    for (mr_getline(&incoming, &n, fin); !feof(fin);
     1886         mr_getline(&incoming, &n, fin)) {
    18861887        if (strncmp(incoming, "etc/adjtime", 11)
    18871888            && strncmp(incoming, "etc/mtab", 8)
     
    18931894            fprintf(fout, "%s", incoming);  /* don't need \n here, for some reason.. */
    18941895    }
    1895     paranoid_free(incoming);
     1896    mr_free(incoming);
    18961897    paranoid_fclose(fout);
    18971898    paranoid_fclose(fin);
     
    19361937    for (i = 0; i < 20; i++) {
    19371938        g_current_progress = i;
    1938         asprintf(&tmp, _("You have %d seconds left to abort."), 20 - i);
     1939        mr_asprintf(&tmp, _("You have %d seconds left to abort."), 20 - i);
    19391940        update_progress_form(tmp);
    1940         paranoid_free(tmp);
     1941        mr_free(tmp);
    19411942        sleep(1);
    19421943    }
     
    20252026            continue;
    20262027        }
    2027         asprintf(&tmp, _("Unmounting device %s  "),
     2028        mr_asprintf(&tmp, _("Unmounting device %s  "),
    20282029                mountlist->el[lino].device);
    20292030
     
    20322033        if (is_this_device_mounted(mountlist->el[lino].device)) {
    20332034            if (!strcmp(mountlist->el[lino].mountpoint, "swap")) {
    2034                 asprintf(&command, "swapoff %s", mountlist->el[lino].device);
     2035                mr_asprintf(&command, "swapoff %s", mountlist->el[lino].device);
    20352036            } else {
    20362037                if (!strcmp(mountlist->el[lino].mountpoint, "/1")) {
    2037                     asprintf(&command, "umount %s/", MNT_RESTORING);
     2038                    mr_asprintf(&command, "umount %s/", MNT_RESTORING);
    20382039                    log_msg(3,
    20392040                            "Well, I know a certain kitty-kitty who'll be sleeping with Mommy tonight...");
    20402041                } else {
    2041                     asprintf(&command, "umount " MNT_RESTORING "%s",
     2042                    mr_asprintf(&command, "umount " MNT_RESTORING "%s",
    20422043                            mountlist->el[lino].mountpoint);
    20432044                }
     
    20452046            log_msg(10, "The 'umount' command is '%s'", command);
    20462047            res = run_program_and_log_output(command, 3);
    2047             paranoid_free(command);
     2048            mr_free(command);
    20482049        } else {
    2049             asprintf(&tmp1, "%s%s", tmp, _("...not mounted anyway :-) OK"));
    2050             paranoid_free(tmp);
     2050            mr_asprintf(&tmp1, "%s%s", tmp, _("...not mounted anyway :-) OK"));
     2051            mr_free(tmp);
    20512052            tmp = tmp1;
    20522053            res = 0;
     
    20542055        g_current_progress++;
    20552056        if (res) {
    2056             asprintf(&tmp1, "%s%s", tmp, _("...Failed"));
    2057             paranoid_free(tmp);
     2057            mr_asprintf(&tmp1, "%s%s", tmp, _("...Failed"));
     2058            mr_free(tmp);
    20582059            tmp = tmp1;
    20592060            retval++;
     
    20622063            log_msg(2, tmp);
    20632064        }
    2064         paranoid_free(tmp);
     2065        mr_free(tmp);
    20652066    }
    20662067    close_progress_form();
     
    20972098
    20982099    // tar -zxvf-
    2099     asprintf(&command,
     2100    mr_asprintf(&command,
    21002101            "dd if=%s bs=%ld count=%ld 2> /dev/null | tar -zx %s %s %s %s %s",
    21012102            dev,
     
    21062107    log_msg(2, "command = '%s'", command);
    21072108    res = run_program_and_log_output(command, -1);
    2108     paranoid_free(command);
     2109    mr_free(command);
    21092110
    21102111    if (res != 0 && does_file_exist(MONDO_CFG_FILE_STUB)) {
     
    21422143    log_msg(2, "gcffa --- starting");
    21432144    log_to_screen(_("I'm thinking..."));
    2144     asprintf(&mountpt, "%s/mount.bootdisk", bkpinfo->tmpdir);
     2145    mr_asprintf(&mountpt, "%s/mount.bootdisk", bkpinfo->tmpdir);
    21452146    chdir(bkpinfo->tmpdir);
    21462147    // MONDO_CFG_FILE_STUB is missing the '/' at the start, FYI, by intent
     
    21502151    unlink(BIGGIELIST_TXT_STUB);
    21512152    unlink("tmp/i-want-my-lvm");
    2152     asprintf(&command, "mkdir -p %s", mountpt);
     2153    mr_asprintf(&command, "mkdir -p %s", mountpt);
    21532154    run_program_and_log_output(command, FALSE);
    2154     paranoid_free(command);
    2155 
    2156     asprintf(&cfg_file, "%s/%s", bkpinfo->tmpdir, MONDO_CFG_FILE_STUB);
    2157     asprintf(&mountlist_file, "%s/%s", bkpinfo->tmpdir,
     2155    mr_free(command);
     2156
     2157    mr_asprintf(&cfg_file, "%s/%s", bkpinfo->tmpdir, MONDO_CFG_FILE_STUB);
     2158    mr_asprintf(&mountlist_file, "%s/%s", bkpinfo->tmpdir,
    21582159            MOUNTLIST_FNAME_STUB);
    21592160    log_msg(2, "mountpt = %s; cfg_file=%s", mountpt, cfg_file);
    21602161
    21612162    /* Floppy? */
    2162     asprintf(&tmp, "mkdir -p %s", mountpt);
     2163    mr_asprintf(&tmp, "mkdir -p %s", mountpt);
    21632164    run_program_and_log_output(tmp, FALSE);
    2164     paranoid_free(tmp);
    2165 
    2166     asprintf(&tmp, "mkdir -p %s/tmp", bkpinfo->tmpdir);
     2165    mr_free(tmp);
     2166
     2167    mr_asprintf(&tmp, "mkdir -p %s/tmp", bkpinfo->tmpdir);
    21672168    run_program_and_log_output(tmp, FALSE);
    2168     paranoid_free(tmp);
    2169 
    2170     asprintf(&command, "mount /dev/fd0u1722 %s", mountpt);
    2171     asprintf(&tmp,
     2169    mr_free(tmp);
     2170
     2171    mr_asprintf(&command, "mount /dev/fd0u1722 %s", mountpt);
     2172    mr_asprintf(&tmp,
    21722173            "(sleep 15; kill `ps | grep \"%s\" | cut -d' ' -f1` 2> /dev/null) &",
    21732174            command);
    21742175    log_msg(1, "tmp = '%s'", tmp);
    21752176    system(tmp);
    2176     paranoid_free(tmp);
     2177    mr_free(tmp);
    21772178
    21782179    res = run_program_and_log_output(command, FALSE);
    2179     paranoid_free(command);
     2180    mr_free(command);
    21802181
    21812182    if (res) {
    2182         asprintf(&command, "mount /dev/fd0H1440 %s", mountpt);
     2183        mr_asprintf(&command, "mount /dev/fd0H1440 %s", mountpt);
    21832184        res = run_program_and_log_output(command, FALSE);
    2184         paranoid_free(command);
     2185        mr_free(command);
    21852186    }
    21862187    if (res) {
     
    21922193// NB: If busybox does not support 'mount -o loop' then Plan A WILL NOT WORK.
    21932194        log_msg(2, "Processing floppy (plan A?)");
    2194         asprintf(&ramdisk_fname, "%s/mindi.rdz", mountpt);
     2195        mr_asprintf(&ramdisk_fname, "%s/mindi.rdz", mountpt);
    21952196        if (!does_file_exist(ramdisk_fname)) {
    2196             paranoid_free(ramdisk_fname);
    2197             asprintf(&ramdisk_fname, "%s/initrd.img", mountpt);
     2197            mr_free(ramdisk_fname);
     2198            mr_asprintf(&ramdisk_fname, "%s/initrd.img", mountpt);
    21982199        }
    21992200        if (!does_file_exist(ramdisk_fname)) {
     
    22062207                    "Warning - failed to extract config file from ramdisk. I think this boot disk is mangled.");
    22072208        }
    2208         asprintf(&command, "umount %s", mountpt);
     2209        mr_asprintf(&command, "umount %s", mountpt);
    22092210        run_program_and_log_output(command, 5);
    2210         paranoid_free(command);
     2211        mr_free(command);
    22112212
    22122213        unlink(ramdisk_fname);
    2213         paranoid_free(ramdisk_fname);
     2214        mr_free(ramdisk_fname);
    22142215    }
    22152216    if (!does_file_exist(cfg_file)) {
     
    22372238
    22382239            if (bkpinfo->media_device == NULL) {
    2239                 asprintf(&bkpinfo->media_device, "/dev/st0");
     2240                mr_asprintf(&bkpinfo->media_device, "/dev/st0");
    22402241                log_msg(2, "media_device is blank; assuming %s",
    22412242                        bkpinfo->media_device);
    22422243            }
    2243             asprintf(&sav, bkpinfo->media_device);
     2244            mr_asprintf(&sav, bkpinfo->media_device);
    22442245            if (extract_cfg_file_and_mountlist_from_tape_dev
    22452246                (bkpinfo->media_device)) {
    2246                 paranoid_alloc(bkpinfo->media_device, "/dev/st0");
     2247                mr_allocstr(bkpinfo->media_device, "/dev/st0");
    22472248                if (extract_cfg_file_and_mountlist_from_tape_dev
    22482249                    (bkpinfo->media_device)) {
    2249                     paranoid_alloc(bkpinfo->media_device, "/dev/osst0");
     2250                    mr_allocstr(bkpinfo->media_device, "/dev/osst0");
    22502251                    if (extract_cfg_file_and_mountlist_from_tape_dev
    22512252                        (bkpinfo->media_device)) {
    2252                         paranoid_alloc(bkpinfo->media_device, "/dev/ht0");
     2253                        mr_allocstr(bkpinfo->media_device, "/dev/ht0");
    22532254                        if (extract_cfg_file_and_mountlist_from_tape_dev
    22542255                            (bkpinfo->media_device)) {
    22552256                            log_msg(3,
    22562257                                    "I tried lots of devices but none worked.");
    2257                             paranoid_alloc(bkpinfo->media_device, sav);
     2258                            mr_allocstr(bkpinfo->media_device, sav);
    22582259                        }
    22592260                    }
    22602261                }
    22612262            }
    2262             paranoid_free(sav);
     2263            mr_free(sav);
    22632264
    22642265            if (!does_file_exist("tmp/mondo-restore.cfg")) {
     
    22712272                    "gcffa --- looking at mounted CD for mindi-boot.2880.img");
    22722273            /* BERLIOS : Useless ?
    2273             asprintf(&command,
     2274            mr_asprintf(&command,
    22742275                    "mount " MNT_CDROM
    22752276                    "/images/mindi-boot.2880.img -o loop %s", mountpt);
    22762277                    */
    2277             asprintf(&mounted_cfgf_path, "%s/%s", mountpt, cfg_file);
     2278            mr_asprintf(&mounted_cfgf_path, "%s/%s", mountpt, cfg_file);
    22782279            if (!does_file_exist(mounted_cfgf_path)) {
    22792280                log_msg(2,
    22802281                        "gcffa --- Plan C, a.k.a. untarring some file from all.tar.gz");
    2281                 asprintf(&command, "tar -zxvf " MNT_CDROM "/images/all.tar.gz %s %s %s %s %s", MOUNTLIST_FNAME_STUB, MONDO_CFG_FILE_STUB, BIGGIELIST_TXT_STUB, FILELIST_FULL_STUB, "tmp/i-want-my-lvm");    // add -b TAPE_BLOCK_SIZE if you _really_ think it's necessary
     2282                mr_asprintf(&command, "tar -zxvf " MNT_CDROM "/images/all.tar.gz %s %s %s %s %s", MOUNTLIST_FNAME_STUB, MONDO_CFG_FILE_STUB, BIGGIELIST_TXT_STUB, FILELIST_FULL_STUB, "tmp/i-want-my-lvm"); // add -b TAPE_BLOCK_SIZE if you _really_ think it's necessary
    22822283                run_program_and_log_output(command, TRUE);
    2283                 paranoid_free(command);
     2284                mr_free(command);
    22842285
    22852286                if (!does_file_exist(MONDO_CFG_FILE_STUB)) {
     
    22882289                }
    22892290            }
    2290             paranoid_free(mounted_cfgf_path);
    2291         }
    2292     }
    2293     paranoid_free(mountpt);
     2291            mr_free(mounted_cfgf_path);
     2292        }
     2293    }
     2294    mr_free(mountpt);
    22942295
    22952296    if (does_file_exist(MONDO_CFG_FILE_STUB)) {
    22962297        log_msg(1, "gcffa --- great! We've got the config file");
    22972298        tmp1 = call_program_and_get_last_line_of_output("pwd");
    2298         asprintf(&tmp, "%s/%s", tmp1,MONDO_CFG_FILE_STUB);
    2299         asprintf(&command, "cp -f %s %s", tmp, cfg_file);
     2299        mr_asprintf(&tmp, "%s/%s", tmp1,MONDO_CFG_FILE_STUB);
     2300        mr_asprintf(&command, "cp -f %s %s", tmp, cfg_file);
    23002301        iamhere(command);
    23012302
     
    23082309            log_msg(1, "... and I moved it successfully to %s", cfg_file);
    23092310        }
    2310         paranoid_free(command);
    2311 
    2312         asprintf(&command, "cp -f %s/%s %s",tmp1,
     2311        mr_free(command);
     2312
     2313        mr_asprintf(&command, "cp -f %s/%s %s",tmp1,
    23132314                MOUNTLIST_FNAME_STUB, mountlist_file);
    2314         paranoid_free(tmp1);
     2315        mr_free(tmp1);
    23152316
    23162317        iamhere(command);
     
    23202321        } else {
    23212322            log_msg(1, "Got mountlist too");
    2322             paranoid_free(command);
    2323             asprintf(&command, "cp -f %s %s", mountlist_file,
     2323            mr_free(command);
     2324            mr_asprintf(&command, "cp -f %s %s", mountlist_file,
    23242325                    g_mountlist_fname);
    23252326            if (run_program_and_log_output(command, 1)) {
     
    23272328            } else {
    23282329                log_msg(1, "Copied mountlist to /tmp as well OK");
    2329                 paranoid_free(command);
    2330                 asprintf(&command, "cp -f tmp/i-want-my-lvm /tmp/");
     2330                mr_free(command);
     2331                mr_asprintf(&command, "cp -f tmp/i-want-my-lvm /tmp/");
    23312332                run_program_and_log_output(command, 1);
    23322333            }
    23332334        }
    2334         paranoid_free(command);
    2335         paranoid_free(tmp);
     2335        mr_free(command);
     2336        mr_free(tmp);
    23362337    }
    23372338    run_program_and_log_output("umount " MNT_CDROM, FALSE);
     
    23512352/* start SAH */
    23522353    else {
    2353         asprintf(&command, "cp -f %s %s/%s", MOUNTLIST_FNAME_STUB,
     2354        mr_asprintf(&command, "cp -f %s %s/%s", MOUNTLIST_FNAME_STUB,
    23542355                bkpinfo->tmpdir, MOUNTLIST_FNAME_STUB);
    23552356        run_program_and_log_output(command, FALSE);
    2356         paranoid_free(command);
     2357        mr_free(command);
    23572358    }
    23582359/* end SAH */
    23592360
    2360     asprintf(&command, "cp -f %s /%s", cfg_file, MONDO_CFG_FILE_STUB);
    2361     paranoid_free(cfg_file);
     2361    mr_asprintf(&command, "cp -f %s /%s", cfg_file, MONDO_CFG_FILE_STUB);
     2362    mr_free(cfg_file);
    23622363
    23632364    run_program_and_log_output(command, FALSE);
    2364     paranoid_free(command);
    2365 
    2366     asprintf(&command, "cp -f %s /%s", mountlist_file, MOUNTLIST_FNAME_STUB);
    2367     paranoid_free(mountlist_file);
     2365    mr_free(command);
     2366
     2367    mr_asprintf(&command, "cp -f %s /%s", mountlist_file, MOUNTLIST_FNAME_STUB);
     2368    mr_free(mountlist_file);
    23682369
    23692370    run_program_and_log_output(command, FALSE);
    2370     paranoid_free(command);
    2371 
    2372     asprintf(&command, "cp -f etc/raidtab /etc/");
     2371    mr_free(command);
     2372
     2373    mr_asprintf(&command, "cp -f etc/raidtab /etc/");
    23732374    run_program_and_log_output(command, FALSE);
    2374     paranoid_free(command);
    2375 
    2376     asprintf(&command, "cp -f tmp/i-want-my-lvm /tmp/");
     2375    mr_free(command);
     2376
     2377    mr_asprintf(&command, "cp -f tmp/i-want-my-lvm /tmp/");
    23772378    run_program_and_log_output(command, FALSE);
    2378     paranoid_free(command);
     2379    mr_free(command);
    23792380
    23802381    g_backup_media_type = bkpinfo->backup_media_type;
     
    24122413                log_msg(1, "Sync'ing %s (i=%d)",
    24132414                        raidlist->el[i].raid_device, i);
    2414                 asprintf(&screen_message, "Sync'ing %s",
     2415                mr_asprintf(&screen_message, "Sync'ing %s",
    24152416                        raidlist->el[i].raid_device);
    24162417                open_evalcall_form(screen_message);
    2417                 paranoid_free(screen_message);
     2418                mr_free(screen_message);
    24182419
    24192420                if (raidlist->el[i].progress == -1) { // delayed while another partition inits
     
    24342435        }
    24352436    }
    2436     paranoid_free(raidlist);
    2437 }
     2437    mr_free(raidlist);
     2438}
  • trunk/mondo/src/test/mktest

    r768 r900  
    77
    88gcc -O2 -I../common -I../lib test-conf.c ../lib/mr_conf.c ../common/libmondo-msg.c -o test-conf
    9 gcc -O2 -I../common -I../lib test-string.c ../lib/mr_string.c -o test-string
     9gcc -O2 -I../common -I../lib test-string.c ../lib/mr_str.c -o test-string
    1010
    1111for f in "test-conf"; do
  • trunk/mondo/src/test/test-conf.c

    r768 r900  
    99#include "my-stuff.h"
    1010#include "mr_conf.h"
     11#include "mr_mem.h"
    1112
    1213int g_main_pid = 0;
     
    3839    }
    3940    fprintf(stdout, "String : ***%s***\n",s);
    40     paranoid_free(s);
     41    mr_free(s);
    4142    mr_conf_close();
    4243    exit(0);
  • trunk/mondo/src/test/test-string.c

    r768 r900  
    1212
    1313#include "my-stuff.h"
    14 #include "mr_string.h"
     14#include "mr_str.h"
     15#include "mr_mem.h"
    1516
    1617main() {
     
    2122    char *string = NULL;
    2223
    23     asprintf(&string, "%s", "md0 : active raid10 hda1[0] hda12[3] hda6[2] hda5[1]\n");
     24    mr_asprintf(&string, "%s", "md0 : active raid10 hda1[0] hda12[3] hda6[2] hda5[1]\n");
    2425    fprintf(stdout, "string=|%s|\n", string);
    2526    token = mr_strtok(string, delims, &lastpos);
    2627    while (lastpos > 0) {
    2728        fprintf(stdout, "token=|%s|, lastpos=%d\n", token, lastpos);
    28         paranoid_free(token);
     29        mr_free(token);
    2930        token = mr_strtok(string, delims, &lastpos);
    3031    }
    31     paranoid_free(string);
     32    mr_free(string);
    3233    exit(0);
    3334}
  • trunk/tools/build2pkg

    r839 r900  
    6363            ar=$ARCH
    6464        fi
    65         pkg1="${TOPBUILDDIR}/RPMS/${ar}/$pv-${TAG}${suf}.${ar}.rpm"
    66         #rm -f $pkg1
    6765
    68         pkg="$pkg $pkg1"
    69 
    70         log=$TMP/$p-rpm.log
     66        log=$MONDOTMP/$p-rpm.log
    7167
    7268        if [ "$dfam" = "mandriva" ] || [ "$dfam" = "suse" ]; then
     
    8783            status=-1
    8884        else
     85            export pkg1="`egrep '^Wrote:' $log | grep -v debug | cut -d: -f2`"
    8986            if [ -f /usr/bin/rpmlint ]; then
    90                 /usr/bin/rpmlint `egrep '^Wrote:' $log | cut -d: -f2`
     87                /usr/bin/rpmlint $pkg1
    9188            else
    9289                echo "No rpmlint found, please install it"
    9390            fi
     91            export pkg="$pkg `ls $pkg1 | grep -v src.rpm`"
    9492        fi
    9593        rm -rf ${TOPBUILDDIR}/BUILD/*
     
    116114        fi
    117115    elif [  _"$dtype" = _"deb" ]; then
    118         export TMPDIR=/tmp
    119116        cd $TOPBUILDDIR
    120117        tar xfz $src
     
    130127echo "Packages handled : $pkg"
    131128
    132 rm -rf $TMP
     129rm -rf $MONDOTMP
    133130
    134131if [ $status = 0 ]; then
  • trunk/tools/build2qemu

    r764 r900  
    4545fi
    4646
    47 mkdir -p $TMP
    48 cat > $TMP/mkmondo << EOF
     47cat > $MONDOTMP/mkmondo << EOF
    4948#!/bin/bash
    5049
     
    5756$TOOLHOME/pkg2ftp $LAST
    5857EOF
    59 chmod 755 $TMP/mkmondo
     58chmod 755 $MONDOTMP/mkmondo
    6059
    6160if [ $single -eq 0 ]; then
    6261    $TOOLHOME/file2ftp
    6362fi
    64 cd $TOOLHOME/..
    65 tar cfz $TMP/mkmondo.tar.gz $TOOLHOME $TMP/mkmondo $TOPDIR/${VER}-$TAG
     63
     64# TOPDIR contains ../.. which causes problems to tar
     65# so we need to recompute it
     66cd $TOPDIR
     67dir=`pwd`
     68tar cfz $MONDOTMP/mkmondo.tar.gz $TOOLHOME $MONDOTMP/mkmondo $dir/${VER}-$TAG
    6669
    6770for m in $VMS; do
     
    6972    if [ ! -f /users/qemu/$m.qemu ]; then
    7073            echo "VM unaccessible. Verify NFS mount"
    71             rm -rf $TMP
     74            rm -rf $MONDOTMP
    7275            exit -1
    7376    fi
     
    8285        sleep 300
    8386    fi
    84     scp -P $sp $TMP/mkmondo.tar.gz ~/.rpmmacros ~/.rpmrc bruno@localhost:
     87    scp -P $sp $MONDOTMP/mkmondo.tar.gz ~/.rpmmacros ~/.rpmrc bruno@localhost:
    8588    rdate=`date "+%m%d%H%M"`
    8689    ssh -p $sp root@localhost "date $rdate"
    87     ssh -p $sp bruno@localhost "cd / ; rm -rf ~bruno/mondo ~bruno/RPMS/BUILD/* ~bruno/RPMS/tmp/* /tmp/* ; tar xfz ~bruno/mkmondo.tar.gz ; $TMP/mkmondo " | tee $TMP/mkvm.log
    88     #ssh -p $sp bruno@localhost "cd / ; tar xfz ~bruno/mkmondo.tar.gz ; $TMP/mkmondo ; rm -f $TMP" | tee $TMP/mkvm.log
     90    ssh -p $sp bruno@localhost "cd / ; rm -rf ~bruno/mondo ~bruno/RPMS/BUILD/* ~bruno/RPMS/tmp/* /tmp/* ; tar xfz ~bruno/mkmondo.tar.gz ; $MONDOTMP/mkmondo " | tee $MONDOTMP/mkvm.log
     91    #ssh -p $sp bruno@localhost "cd / ; tar xfz ~bruno/mkmondo.tar.gz ; $MONDOTMP/mkmondo ; rm -f $MONDOTMP" | tee $MONDOTMP/mkvm.log
    8992    if [ $vmp -eq 1 ]; then
    9093        ssh -p $sp root@localhost "halt -p"
     
    99102
    100103# Should be removed at the end
    101 rm -rf $TMP
     104rm -rf $MONDOTMP
    102105) 2>&1 | tee /tmp/build2qemu.log
  • trunk/tools/common-env

    r764 r900  
    77
    88# Adapt to your needs
    9 export BASE=${HOME}/mondo
    10 export TOPDIR=${BASE}/build
     9d=`dirname ${TOOLHOME}`
     10if [ _"`basename ${d}/..`" = _"trunk" ]; then
     11    BASE=${TOOLHOME}/../..
     12else
     13    BASE=${TOOLHOME}/../../..
     14fi
     15export TOPDIR=${BASE}/delivery
    1116mkdir -p ${TOPDIR}
     17
    1218export TMPDIR=/tmp
    13 export TMP=`mktemp -d /tmp/mondobuild.XXXXXXXXXX`
     19export MONDOTMP=`mktemp -d $TMPDIR/mondobuild.XXXXXXXXXX`
     20mkdir -p $MONDOTMP
    1421
    1522umask 022
  • trunk/tools/distro-env

    r764 r900  
    77# Input parameters : $ddir (distro name) and $dver (distro version)
    88# If they do not exist then deduce from current distro
    9 # Exports : $dfam (distro family) $suf (pkg suffix) $dtype (distro type) BUILDDIR (dir to build packages)
     9# Exports : $dfam (distro family) $suf (pkg suffix) $dtype (distro type) TOPBUILDDIR (dir to build packages)
    1010
    1111#
     
    6868    dtype="deb"
    6969    suf=".${dfam}${dver}"
    70     BUILDDIR=${TOPDIR}/debian
    7170elif [ $ddir = "gentoo" ]; then
    7271    dfam="gentoo"
     
    7473    dver1=`echo ${dver} | sed "s/\.//"`
    7574    suf=".${ddir}${dver1}"
    76     BUILDDIR=${TOPDIR}/ebuild
    7775elif [ $ddir = "slackware" ]; then
    7876    dfam="slack"
    7977    dtype="tgz"
    8078    suf=".${dfam}${dver}"
    81     BUILDDIR=${TOPDIR}/slack
    8279elif [ $ddir = "sles" -o $ddir = "suse" ]; then
    8380    dfam="suse"
    8481    dtype="rpm"
    8582    suf=".${ddir}${dver}"
    86     BUILDDIR=${TOPDIR}/SPECS
    8783elif [ $ddir = "fedora" -o $ddir = "redhat" -o $ddir = "rhel" ]; then
    8884    dfam="redhat"
     
    9692        suf=".rhel${dver1}"
    9793    fi
    98     BUILDDIR=${TOPDIR}/SPECS
    99 elif [ $ddir = "mandrake" -o $ddir = "mandriva" ]; then
     94elif [ $ddir = "mandrake" ]; then
    10095    dfam="mandriva"
    10196    dtype="rpm"
    10297    suf=".`echo $dver | sed 's/\.//'`mdk"
    103     BUILDDIR=${TOPDIR}/SPECS
     98elif [ $ddir = "mandriva" ]; then
     99    dfam="mandriva"
     100    dtype="rpm"
     101    suf=".`echo $dver | sed 's/\.//'`mdv"
    104102else
    105103    dfam="unknown"
    106104    dtype="unknown"
    107     BUILDDIR=${TOPDIR}/SPECS
    108105    suf="unknown"
    109106fi
     
    111108export dfam
    112109export dtype
    113 export BUILDDIR
    114110export suf
    115111
     
    117113# Additional exports and preparation for some distros
    118114#
     115
     116# Default
     117export TOPBUILDDIR=${TOPDIR}/../build
     118
    119119if [ _"$dtype" = _"rpm" ]; then
    120120    export ARCH=`rpm --showrc | egrep "^build arch" | awk '{print $4}'`
    121121    if [ -f ${HOME}/.rpmmacros ]; then
    122122        export TOPBUILDDIR=`egrep '^%_topdir' ${HOME}/.rpmmacros | awk '{print $2}'`
    123     else
    124         export TOPBUILDDIR=${BASE}/build
    125123    fi
    126124    mkdir -p ${TOPBUILDDIR}/{RPMS,SRPMS,SPECS,SOURCES,BUILD}
    127125elif [ _"$dtype" = _"deb" ]; then
    128     export TOPBUILDDIR=${BASE}/build
    129126    mkdir -p ${TOPBUILDDIR}
    130127elif [ _"$dtype" = _"ebuild" ]; then
    131     export TOPBUILDDIR=${BASE}/build
    132128    mkdir -p ${TOPBUILDDIR}/portage
    133129fi
  • trunk/tools/ftp-env

    r592 r900  
    77
    88# BerliOS FTP/SSH setup
    9 export ACCOUNT=bruno@ftp.mondorescue.org
     9/sbin/ifconfig | egrep -q '10\.3' 2>&1 > /dev/null
     10if [ $? = 0 ]; then
     11    export DESTMACH=mondo.hpintelco.org
     12else
     13    export DESTMACH=www.mondorescue.org
     14fi
     15
     16export ACCOUNT=bruno@$DESTMACH
    1017export DSTDIR=/mondo/ftp
    1118export FTPSERV="ftp.berlios.de"
  • trunk/tools/livwww

    r672 r900  
    3131fi
    3232
    33 /sbin/ifconfig | egrep -q '10\.3' 2>&1 > /dev/null
    34 if [ $? = 0 ]; then
    35     DESTMACH=mondo.hpintelco.org
    36 else
    37     DESTMACH=www.mondorescue.org
    38 fi
    39 
    4033dname=`dirname $0`
    4134prem=`echo $dname |cut -c1`
     
    4841. $TOOLHOME/common-env
    4942. $TOOLHOME/svn-env
     43. $TOOLHOME/ftp-env
    5044
    51 cd ${BASE}/svn
     45# To be safe for SVN commands
     46cd ${TOOLHOME}/..
    5247
    5348if [ $force -eq 1 ]; then
     
    5651fi
    5752
    58 svn export $optsvn ${SVNBRANCH}/website $LOCALDIR
     53svn export $optsvn ${TOOLHOME}/../website $LOCALDIR
    5954
    6055if [ $force -eq 1 ]; then
     
    6358fi
    6459
    65 svn export $optsvn ${SVNBRANCH}/mondo-doc $LOCALDOC
     60svn export $optsvn ${TOOLHOME}/../mondo-doc $LOCALDOC
    6661
    6762#
  • trunk/tools/mkannounce

    r764 r900  
    3232SEARCH=`echo $VER | cut -c2-`
    3333
    34 rm -f $TMP/announce.tmp
    35 cat > $TMP/announce.tmp << EOF
     34rm -f $MONDOTMP/announce.tmp
     35cat > $MONDOTMP/announce.tmp << EOF
    3636MondoRescue $VER is now available</p>
    3737
     
    4343<p>
    4444EOF
    45 ssh ${ACCOUNT} "cd $DSTDIR ; find . -name 'm[oi]nd[io]-[0-9]$SEARCH*'" | grep -v 'src.rpm' >> $TMP/announce.tmp
    46 cat >> $TMP/announce.tmp << EOF
     45ssh ${ACCOUNT} "cd $DSTDIR ; find . -name 'm[oi]nd[io]-[0-9]$SEARCH*'" | grep -v 'src.rpm' >> $MONDOTMP/announce.tmp
     46cat >> $MONDOTMP/announce.tmp << EOF
    4747</p>
    4848
     
    5555
    5656# Generating log files
    57 $TOOLHOME/mkchangelog.pl announce mindi $TMP/mindi.ann
    58 $TOOLHOME/mkchangelog.pl announce mondo $TMP/mondo.ann
    59 echo "<p>" >> $TMP/announce.tmp
    60 sed 's/$/<br>/' $TMP/mindi.ann >> $TMP/announce.tmp
    61 echo "</p><p>" >> $TMP/announce.tmp
    62 sed 's/$/<br>/' $TMP/mondo.ann >> $TMP/announce.tmp
    63 echo "</p>" >> $TMP/announce.tmp
    64 rm -f $TMP/mindi.ann $TMP/mondo.ann
     57$TOOLHOME/mkchangelog.pl announce mindi $MONDOTMP/mindi.ann
     58$TOOLHOME/mkchangelog.pl announce mondo $MONDOTMP/mondo.ann
     59echo "<p>" >> $MONDOTMP/announce.tmp
     60sed 's/$/<br>/' $MONDOTMP/mindi.ann >> $MONDOTMP/announce.tmp
     61echo "</p><p>" >> $MONDOTMP/announce.tmp
     62sed 's/$/<br>/' $MONDOTMP/mondo.ann >> $MONDOTMP/announce.tmp
     63echo "</p>" >> $MONDOTMP/announce.tmp
     64rm -f $MONDOTMP/mindi.ann $MONDOTMP/mondo.ann
    6565
    66 vi $TMP/announce.tmp
     66vi $MONDOTMP/announce.tmp
    6767# Store it in DB for Web pages generation
    68 $TOOLHOME/mkannounce.pl $TMP/announce.tmp
     68$TOOLHOME/mkannounce.pl $MONDOTMP/announce.tmp
    6969# Then deliver it on the Web
    7070$TOOLHOME/livwww www
    71 cat > $TMP/announce.hdr << EOF
     71cat > $MONDOTMP/announce.hdr << EOF
    7272<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/x html1/DTD/xhtml1-strict.dtd">
    7373
     
    7878  <p>
    7979EOF
    80 cat > $TMP/announce.ftr << EOF
     80cat > $MONDOTMP/announce.ftr << EOF
    8181</body>
    8282</html>
    8383EOF
    8484# Mail it to mr ML
    85 cat $TMP/announce.hdr $TMP/announce.tmp $TMP/announce.ftr | w3m -dump -T text/html > $TMP/mondo.ann.txt
     85cat $MONDOTMP/announce.hdr $MONDOTMP/announce.tmp $MONDOTMP/announce.ftr | w3m -dump -T text/html > $MONDOTMP/mondo.ann.txt
    8686export EMAIL="bruno@mondorescue.org"
    87 export TMPDIR=$TMP
    88 cat $TMP/mondo.ann.txt | mutt -s "`head -1 $TMP/mondo.ann.txt`" mondo-devel@lists.sourceforge.net -c mondorescue-announce@lists.berlios.de
    89 rm -rf $TMP
     87cat $MONDOTMP/mondo.ann.txt | mutt -s "`head -1 $MONDOTMP/mondo.ann.txt`" mondo-devel@lists.sourceforge.net -c mondorescue-announce@lists.berlios.de
     88rm -rf $MONDOTMP
  • trunk/tools/qemu-vm.txt

    r764 r900  
    44
    55# RPM based : urpmi, yum install, yast2
    6 urpmi neon newt-devel slang-devel autoconf automake libtool gcc rpm-build wget gvim/vim-X11 gcc-c++ docbook-utils-pdf ImageMagick man patch mindi mondo
     6urpmi neon newt-devel slang-devel glibc-static-devel autoconf automake libtool gcc rpm-build wget gvim/vim-X11 gcc-c++ docbook-utils-pdf ImageMagick man patch mindi mondo
    77
    88# gentoo
  • trunk/tools/quality

    r688 r900  
    2828
    2929# How many sprintf/strcat/strcpy vs asprintf are they
    30 for s in asprintf sprintf strcat strcpy strncpy fgets malloc malloc_string MAX_STR_LEN getcwd goto; do
     30for s in asprintf mr_asprintf sprintf strcat strcpy strncpy fgets malloc mr_malloc malloc_string getline mr_getline MAX_STR_LEN getcwd goto free mr_free; do
    3131    echo "monodrescue $s usage : "
    3232    tot=0
  • trunk/tools/svn-env

    r782 r900  
    66#
    77
    8 export SVNBRANCH="`cat ${TOOLHOME}/../mondo/VERSION`"
    9 export VER=`cat ${BASE}/svn/${SVNBRANCH}/mondo/VERSION`
     8export VER=`cat ${TOOLHOME}/../mondo/VERSION`
    109
    1110# To be safe for SVN commands
  • trunk/tools/svn2build

    r839 r900  
    3333
    3434# Make it safe for SVN commands
    35 cd ${BASE}/svn
     35cd ${TOOLHOME}/..
    3636
    3737for p in $c; do
    38     v=`cat ${SVNBRANCH}/$p/VERSION`
     38    v=`cat ${TOOLHOME}/../$p/VERSION`
    3939    echo "Management of $p $v-$TAG (rev $REVISION)"
    40     dest="$p-$v"
     40    dest="$DEST/$p-$v"
    4141    rm -fr $dest
    42     svn export ${SVNBRANCH}/$p $dest
     42    svn export ${TOOLHOME}/../$p $dest
    4343    echo "$REVISION" > $dest/REVISION
    4444    echo "Generating SVN log file ..."
    45     svn log -v ${SVNBRANCH}/$p > $dest/svn.log
     45    svn log -v ${TOOLHOME}/../$p > $dest/svn.log
    4646
    4747    for d in `cat ${TOOLHOME}/DISTROS`; do
     
    5151        . $TOOLHOME/distro-env
    5252
    53         # Create conf file dir
    54         mkdir -p ${BUILDDIR}
    55 
    5653        ddd=`LANG=C ; date '+%Y-%m-%d'`
    57         cat > $TMP/mondorescue.mc << EOF
     54        cat > $MONDOTMP/mondorescue.mc << EOF
    5855define(\`TTT', ${TAG})dnl
    5956define(\`RRR', ${TAG}${suf})dnl
     
    7471            echo "Using $inc customization to build SPEC file"
    7572
    76             $TOOLHOME/mkchangelog.pl $dtype $p $TMP/$p.spec
     73            $TOOLHOME/mkchangelog.pl $dtype $p $MONDOTMP/$p.spec
    7774            if [ $? -ne 0 ]; then
    7875                echo "Unable to create changelog for ${ddir}-$dver/$p.spec"
    7976                exit -1
    8077            fi
    81             m4 $TMP/mondorescue.mc $inc $dest/distributions/rpm/$p.spec $TMP/$p.spec > $dest/distributions/${ddir}-$dver/$p.spec
     78            m4 $MONDOTMP/mondorescue.mc $inc $dest/distributions/rpm/$p.spec $MONDOTMP/$p.spec > $dest/distributions/${ddir}-$dver/$p.spec
    8279
    83             rm -f $TMP/$p.spec
     80            rm -f $MONDOTMP/$p.spec
    8481        elif [ "$dtype" = "ebuild" ]; then
    85             m4 $TMP/mondorescue.mc $dest/distributions/$dfam/$p.ebuild > $dest/distributions/${ddir}-$dver/$p-$v.ebuild
     82            m4 $MONDOTMP/mondorescue.mc $dest/distributions/$dfam/$p.ebuild > $dest/distributions/${ddir}-$dver/$p-$v.ebuild
    8683        elif [ "$dtype" = "deb" ]; then
    87             # To be developped
    88             #m4 $TMP/mondorescue.mc $dest/distributions/$dfam/$p > /dev/null
    8984            cp -a $dest/distributions/$ddir/* $dest/distributions/${ddir}-$dver
    90             m4 $TMP/mondorescue.mc $dest/distributions/$ddir/rules > $dest/distributions/${ddir}-$dver/rules
     85            m4 $MONDOTMP/mondorescue.mc $dest/distributions/$ddir/rules > $dest/distributions/${ddir}-$dver/rules
    9186            $TOOLHOME/mkchangelog.pl $dtype $p $dest/distributions/${ddir}-$dver/changelog
    9287            if [ $? -ne 0 ]; then
     
    9994    done
    10095
     96    # The rest is done there
     97    cd $DEST
    10198    if [ _"`echo $p | grep mondo-doc`" != _"" ]; then
    10299        cd $dest
    103100        for f in mondorescue-howto.sgml *8; do
    104             m4 $TMP/mondorescue.mc $f > ${f}.new
     101            m4 $MONDOTMP/mondorescue.mc $f > ${f}.new
    105102            mv ${f}.new $f
    106103        done
     
    117114
    118115    if [ _"`echo $p | grep -vE 'kernel|busybox' | grep mindi`" != _"" ]; then
    119         v1=`cat ${SVNBRANCH}/mondo-doc/VERSION`
     116        v1=`cat ${TOOLHOME}/../mondo-doc/VERSION`
    120117        if [ ! -d mondo-doc-$v1 ]; then
    121118            echo "mondo-doc should be created before $p"
    122119            exit -1
    123120        fi
    124         (cd mondo-doc-$v1 ; make -f Makefile.man install-$p INSTALLDIR=../$dest)
     121        (cd mondo-doc-$v1 ; make -f Makefile.man install-$p INSTALLDIR=../$p-$v)
    125122        rm -f $dest/rootfs/sbin/parted2fdisk-ia64
    126123    fi
    127124    if [ "`echo $p | grep -v doc | grep  mondo`" != "" ]; then
    128         v1=`cat ${SVNBRANCH}/mondo-doc/VERSION`
     125        v1=`cat ${TOOLHOME}/../mondo-doc/VERSION`
    129126        if [ ! -d mondo-doc-$v1 ]; then
    130127            echo "mondo-doc should be created before $p"
    131128            exit -1
    132129        fi
    133         (cd mondo-doc-$v1 ; make -f Makefile.howto install INSTALLDIR=../$dest/docs/en ; make -f Makefile.man install-$p INSTALLDIR=../$dest/docs/man)
     130        (cd mondo-doc-$v1 ; make -f Makefile.howto install INSTALLDIR=../$p-$v/docs/en ; make -f Makefile.man install-$p INSTALLDIR=../$p-$v/docs/man)
    134131        (cd $dest ; echo "Bootstraping mondo ... " ; ./bootstrap)
    135132    fi
     
    137134    # Finally creates the tar files
    138135    echo -n "Creating $p tar files (gzip... "
    139     tar cfphz ${DEST}/$p-$v.tar.gz $dest
     136    tar cfphz ${DEST}/$p-$v.tar.gz $p-$v
    140137    echo -n " bzip2..."
    141     tar cfphj ${DEST}/$p-$v.tar.bz2 $dest
     138    tar cfphj ${DEST}/$p-$v.tar.bz2 $p-$v
    142139    echo " )"
    143140done
    144141
    145 rm -rf $TMP
     142rm -rf $MONDOTMP
    146143
    147144echo "Version delivered :"
Note: See TracChangeset for help on using the changeset viewer.