Changeset 688 in MondoRescue for trunk/mondo/mondo/common/libmondo-filelist.c


Ignore:
Timestamp:
Jul 17, 2006, 3:44:46 PM (18 years ago)
Author:
bcornec
Message:

Huge memory management patch.
Still not finished but a lot as been done.
What remains is around some functions returning strings, and some structure members.
(Could not finish due to laptop failure !)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/mondo/mondo/common/libmondo-filelist.c

    r687 r688  
    847847{
    848848
    849     /*@ structures ************************************************* */
    850     struct s_node *filelist;
    851 
    852     /*@ pointers *************************************************** */
    853     FILE *pin;
    854 
    855     /*@ buffers **************************************************** */
    856     char *command_to_open_fname;
     849    struct s_node *filelist = NULL;
     850    FILE *pin = NULL;
     851    char *command_to_open_fname = NULL;
    857852    char *fname = NULL;
    858     char *tmp;
    859     int pos_in_fname;
     853    char *tmp = NULL;
     854    char *tmp1 = NULL;
     855    int pos_in_fname = 0;
    860856    size_t n = 0;
    861     /*@ int ******************************************************** */
    862     int percentage;
    863 
    864     /*@ long ******************************************************* */
    865     long lines_in_filelist;
    866     long lino = 0;
    867     /*@ end vars *************************************************** */
     857    int percentage = 0;
     858
     859    long lines_in_filelist = 0L;
     860    long lino = 0L;
    868861
    869862    assert_string_is_neither_NULL_nor_zerolength(filelist_fname);
     
    876869    asprintf(&tmp, "zcat %s | wc -l", filelist_fname);
    877870    log_msg(6, "tmp = %s", tmp);
    878     lines_in_filelist =
    879         atol(call_program_and_get_last_line_of_output(tmp));
     871    tmp1 = call_program_and_get_last_line_of_output(tmp);
    880872    paranoid_free(tmp);
     873
     874    lines_in_filelist = atol(tmp1);
     875    paranoid_free(tmp1);
    881876
    882877    if (lines_in_filelist < 3) {
     
    13221317                      char *skeleton_filelist)
    13231318{
    1324     DIR *dip;
    1325     struct dirent *dit;
     1319    DIR *dip = NULL;
     1320    struct dirent *dit = NULL;
    13261321    struct stat statbuf;
    1327     char *new;
    1328     char *tmp;
     1322    char *new = NULL;
     1323    char *tmp = NULL;
     1324    char *tmp1 = NULL;
    13291325    static int percentage = 0;
    1330     char *skip_these;
    1331     char *new_with_spaces;
    1332     static char *name_of_evalcall_form;
    1333     int i;
     1326    char *skip_these = NULL;
     1327    char *new_with_spaces = NULL;
     1328    static char *name_of_evalcall_form = NULL;
     1329    int i = 0;
    13341330    static int depth = 0;
    1335     char *p;
     1331    char *p = NULL;
    13361332    static int counter = 0;
    13371333    static int uberctr = 0;
    1338     static char *find_skeleton_marker;
     1334    static char *find_skeleton_marker = NULL;
    13391335    static long skeleton_lino = 0;
    13401336    static time_t last_time = 0;
     
    13651361
    13661362        asprintf(&tmp, "wc -l %s | awk '{print $1;}'", skeleton_filelist);
    1367         g_skeleton_entries =
    1368             1 + atol(call_program_and_get_last_line_of_output(tmp));
     1363        tmp1 = call_program_and_get_last_line_of_output(tmp);
    13691364        paranoid_free(tmp);
     1365
     1366        g_skeleton_entries = 1 + atol(tmp1);
     1367        paranoid_free(tmp1);
    13701368
    13711369        asprintf(&name_of_evalcall_form, "Making catalog of %s", dir);
     
    15341532{
    15351533    char sz_datefile_wildcard[] = "/var/cache/mondo/difflevel.%d";
    1536     char *p, *q;
     1534    char *p = NULL;
     1535    char *q = NULL;
     1536    char *tmp = NULL;
     1537    char *tmp1 = NULL;
     1538    char *tmp2 = NULL;
    15371539    char *sz_datefile;
    1538     char *sz_filelist, *exclude_paths;
    1539     int i;
    1540     FILE *fout;
    1541     char *command;
     1540    char *sz_filelist = NULL;
     1541    char *exclude_paths = NULL;
     1542    int i = 0;
     1543    FILE *fout = NULL;
     1544    char *command = NULL;
    15421545    time_t time_of_last_full_backup = 0;
    15431546    struct stat statbuf;
    1544     char *skeleton_filelist;
     1547    char *skeleton_filelist = NULL;
     1548
    15451549    // The pathname to the skeleton filelist, used to give better progress reporting for mondo_makefilelist().
    1546 
    15471550    asprintf(&sz_datefile, sz_datefile_wildcard, 0);
    15481551    if (!include_paths && !userdef_filelist) {
     
    15731576        }
    15741577        make_hole_for_file(sz_datefile);
    1575         write_one_liner_data_file(sz_datefile,
    1576                                   call_program_and_get_last_line_of_output
    1577                                   ("date +%s"));
     1578        tmp = call_program_and_get_last_line_of_output("date +%s");
     1579        write_one_liner_data_file(sz_datefile, tmp);
     1580        paranoid_free(tmp);
    15781581    } else if (lstat(sz_datefile, &statbuf)) {
    15791582        log_msg(2,
     
    16001603        log_msg(2, "include_paths = '%s'", include_paths);
    16011604        log_msg(1, "Calculating filelist");
     1605        tmp = call_program_and_get_last_line_of_output("locate /win386.swp 2> /dev/null");
     1606        tmp1 = call_program_and_get_last_line_of_output("locate /hiberfil.sys 2> /dev/null");
     1607        tmp2 = call_program_and_get_last_line_of_output("locate /pagefile.sys 2> /dev/null");
    16021608        asprintf(&exclude_paths, " %s %s %s %s %s %s . .. \
    16031609" MNT_CDROM " " MNT_FLOPPY " /media/cdrom /media/cdrecorder \
    1604 /proc /sys /tmp /var/cache/mondo /var/cache/mindi", excp, call_program_and_get_last_line_of_output("locate /win386.swp 2> /dev/null"), call_program_and_get_last_line_of_output("locate /hiberfil.sys 2> /dev/null"), call_program_and_get_last_line_of_output("locate /pagefile.sys 2> /dev/null"), (tmpdir[0] == '/' && tmpdir[1] == '/') ? (tmpdir + 1) : tmpdir, (scratchdir[0] == '/' && scratchdir[1] == '/') ? (scratchdir + 1) : scratchdir);
     1610/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);
     1611        paranoid_free(tmp);
     1612        paranoid_free(tmp1);
     1613        paranoid_free(tmp2);
    16051614
    16061615        log_msg(2, "Excluding paths = '%s'", exclude_paths);
Note: See TracChangeset for help on using the changeset viewer.