Ignore:
Timestamp:
Aug 21, 2009, 1:53:49 AM (15 years ago)
Author:
Bruno Cornec
Message:
  • New compiler flogs introduce for memory check
  • Other dyn. allocation added replacing static ones
  • Option -Y is added for LZMA support
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.10/mondo/src/common/libmondo-filelist.c

    r2331 r2340  
    211211    char *outfname = NULL;
    212212    char *biggie_fname = NULL;
    213     char *incoming;
     213    char *incoming = NULL;
    214214    char *tmp = NULL;
    215215
     
    257257        return (curr_set_no + 1);
    258258    }
    259     incoming = malloc(MAX_STR_LEN * 2);
    260 
    261     (void) fgets(incoming, MAX_STR_LEN * 2 - 1, fin);
     259
     260    mr_getline(incoming, fin);
    262261    while (!feof(fin)) {
    263262        lino++;
     
    266265            i = 0;
    267266        }
     267        /* Now that we dyn. alloc is truncating needed ?
    268268        if (i > MAX_STR_LEN - 1) {
    269269            incoming[MAX_STR_LEN - 30] = '\0';
     
    271271            err++;
    272272        }
     273        */
    273274        if (incoming[i] < 32) {
    274275            incoming[i] = '\0';
     
    299300                    mr_free(outfname);
    300301                    mr_free(biggie_fname);
    301                     paranoid_free(incoming);
     302                    mr_free(incoming);
    302303                    return (curr_set_no + 1);
    303304                }
     
    305306            }
    306307        }
    307         (void) fgets(incoming, MAX_STR_LEN * 2 - 1, fin);
    308     }
    309     paranoid_free(incoming);
     308        mr_free(incoming);
     309        mr_getline(incoming, fin);
     310    }
     311    mr_free(incoming);
     312
    310313    paranoid_fclose(fin);
    311314    paranoid_fclose(fout);
     
    13321335 * @bug Return value should be @c void.
    13331336 */
    1334 int open_and_list_dir(char *dir1, char *sth, FILE * fout,
    1335                       time_t time_of_last_full_backup)
    1336 {
     1337int open_and_list_dir(char *dir1, char *sth, FILE * fout, time_t time_of_last_full_backup) {
     1338
    13371339    const char delims[] = " ";
    13381340
     
    13411343    struct stat statbuf;
    13421344    char *new;
    1343     char *tmp;
     1345    char *tmp = NULL;
    13441346    char *dir = NULL;
    13451347    static int percentage = 0;
    1346     char *skip_these;
    1347     char *new_with_spaces;
     1348    char *skip_these = NULL;
     1349    char *new_with_spaces = NULL;
    13481350    char *strtmp;
    13491351    char *token;
    1350     char *find_excludes;
    1351     static char *name_of_evalcall_form;
     1352    char *find_excludes = NULL;
     1353    char *name_of_evalcall_form = NULL;
     1354    char *find_skeleton_marker = NULL;
    13521355    int i;
    13531356    int lastpos = 0;
     
    13561359    static int counter = 0;
    13571360    static int uberctr = 0;
    1358     static char *find_skeleton_marker;
    1359     static long skeleton_lino = 0;
    1360     static time_t last_time = 0;
     1361    static long skeleton_lino = 0L;
     1362    static time_t last_time = (time_t)0;
    13611363    time_t this_time;
    13621364
     
    13711373
    13721374    if (!depth) {
    1373         malloc_string(name_of_evalcall_form);
    1374         malloc_string(find_skeleton_marker);
    13751375        mr_asprintf(find_excludes, " ");
    13761376        if (sth != NULL) {
     
    13971397        mr_free(tmp);
    13981398
    1399         sprintf(name_of_evalcall_form, "Making catalog of %s", dir);
     1399        mr_asprintf(name_of_evalcall_form, "Making catalog of %s", dir);
    14001400        open_evalcall_form(name_of_evalcall_form);
    1401         find_skeleton_marker[0] = '\0';
     1401        mr_free(name_of_evalcall_form);
     1402
    14021403        skeleton_lino = 1;
    14031404        log_msg(5, "entries = %ld", g_skeleton_entries);
     
    14051406    } else  // update evalcall form if appropriate
    14061407    {
    1407         sprintf(find_skeleton_marker,
    1408                 "grep -Fv '%s' %s > %s.new 2> /dev/null", dir,
    1409                 g_skeleton_filelist, g_skeleton_filelist);
     1408        mr_asprintf(find_skeleton_marker, "grep -Fv '%s' %s > %s.new 2> /dev/null", dir, g_skeleton_filelist, g_skeleton_filelist);
    14101409        if (!system(find_skeleton_marker)) {
    14111410            percentage = (int) (skeleton_lino * 100 / g_skeleton_entries);
    14121411            skeleton_lino++;
    1413             sprintf(find_skeleton_marker, "mv -f %s.new %s",
    1414                     g_skeleton_filelist, g_skeleton_filelist);
    1415             run_program_and_log_output(find_skeleton_marker, 8);
     1412            mr_free(find_skeleton_marker);
     1413
     1414            mr_asprintf(find_skeleton_marker, "mv -f %s.new %s", g_skeleton_filelist, g_skeleton_filelist);
     1415            (void)system(find_skeleton_marker);
    14161416            time(&this_time);
    14171417            if (this_time != last_time) {
     
    14271427            }
    14281428        }
     1429        mr_free(find_skeleton_marker);
    14291430    }
    14301431
     
    14531454                mr_asprintf(new,"%s%s",dir,dit->d_name);
    14541455            }
    1455             paranoid_free(new_with_spaces);
     1456            mr_free(new_with_spaces);
    14561457            mr_asprintf(new_with_spaces, " %s ", new);
    14571458            if (strstr(skip_these, new_with_spaces)) {
     
    14631464                    if (!S_ISLNK(statbuf.st_mode)
    14641465                        && S_ISDIR(statbuf.st_mode)) {
    1465                         open_and_list_dir(new, skip_these, fout,
    1466                                           time_of_last_full_backup);
     1466                        open_and_list_dir(new, skip_these, fout, time_of_last_full_backup);
    14671467                    } else {
    1468                         if (time_of_last_full_backup == 0
    1469                             || time_of_last_full_backup <
    1470                             statbuf.st_ctime) {
     1468                        if (time_of_last_full_backup == 0 || time_of_last_full_backup < statbuf.st_ctime) {
    14711469                            fprintf(fout, "%s\n", new);
    14721470                            if ((counter++) > 128) {
    14731471                                counter = 0;
    14741472                                uberctr++;
     1473#ifndef _XWIN
    14751474                                mr_asprintf(tmp, " %c ", special_dot_char(uberctr));
    1476 #ifndef _XWIN
    14771475                                if (!g_text_mode) {
    14781476                                    newtDrawRootText(77, g_noof_rows - 3, tmp);
    14791477                                    newtRefresh();
    14801478                                }
     1479                                mr_free(tmp);
    14811480#endif
    1482                                 mr_free(tmp);
    14831481                            }
    14841482                        }
     
    14861484                }
    14871485            }
    1488             paranoid_free(new);
    1489         }
    1490     }
    1491     paranoid_free(new_with_spaces);
    1492     paranoid_free(skip_these);
     1486            mr_free(new);
     1487        }
     1488    }
     1489    mr_free(new_with_spaces);
     1490    mr_free(skip_these);
    14931491    mr_free(dir);
    14941492
     
    15011499    if (!depth) {
    15021500        close_evalcall_form();
    1503         paranoid_free(name_of_evalcall_form);
    1504         paranoid_free(find_skeleton_marker);
    15051501        unlink(g_skeleton_filelist);
    15061502        log_msg(5, "g_skeleton_entries = %ld", g_skeleton_entries);
     
    15961592                                  ("date +%s"));
    15971593    } else if (lstat(sz_datefile, &statbuf)) {
    1598         log_msg(2,
    1599                 "Warning - unable to find date of previous backup. Full backup instead.");
     1594        log_msg(2, "Warning - unable to find date of previous backup. Full backup instead.");
    16001595        differential = 0;
    16011596        time_of_last_full_backup = 0;
     
    16081603// use user-specified filelist (if specified)
    16091604    if (userdef_filelist) {
    1610         log_msg(1,
    1611                 "Using the user-specified filelist - %s - instead of calculating one",
    1612                 userdef_filelist);
     1605        log_msg(1, "Using the user-specified filelist - %s - instead of calculating one", userdef_filelist);
    16131606        mr_asprintf(command, "cp -f %s %s", userdef_filelist, sz_filelist);
    16141607        if (run_program_and_log_output(command, 3)) {
Note: See TracChangeset for help on using the changeset viewer.