Ignore:
Timestamp:
Feb 16, 2007, 12:25:24 PM (17 years ago)
Author:
Bruno Cornec
Message:

merges from trunk for memory management for libmondo-mountlist.c mainly

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/stable/mondo/src/common/libmondo-files.c

    r1158 r1173  
    8383    return (output);
    8484}
    85 
    86 
    87 /**
    88  * Get a not-quite-unique representation of some of the file's @c stat properties.
    89  * The returned string has the form <tt>size-mtime-ctime</tt>.
    90  * @param curr_fname The file to generate the "checksum" for.
    91  * @return The "checksum".
    92  * @note The returned string points to static storage that will be overwritten with each call.
    93  */
    94 char *calc_file_ugly_minichecksum(char *curr_fname)
    95 {
    96 
    97     /*@ buffers ***************************************************** */
    98     static char curr_cksum[1000];
    99 
    100     /*@ pointers **************************************************** */
    101 
    102     /*@ structures ************************************************** */
    103     struct stat buf;
    104 
    105     /*@ initialize data *************************************************** */
    106     curr_cksum[0] = '\0';
    107 
    108     /*@************************************************************** */
    109 
    110     assert_string_is_neither_NULL_nor_zerolength(curr_fname);
    111     if (lstat(curr_fname, &buf)) {
    112         return (curr_cksum);    // empty
    113     }
    114 
    115     sprintf(curr_cksum, "%ld-%ld-%ld", (long) (buf.st_size),
    116             (long) (buf.st_mtime), (long) (buf.st_ctime));
    117     return (curr_cksum);
    118 }
    119 
    12085
    12186
     
    699664    long file_len_K = 0L;
    700665
    701     malloc_string(sz_res);
    702666    mr_asprintf(&command,
    703667            "grep '%s ' %s/mountlist.txt | head -n1 | awk '{print $4;}'",
    704668            dev, tmpdir);
    705669    log_it(command);
    706     strcpy(sz_res, call_program_and_get_last_line_of_output(command));
     670    mr_asprintf(&sz_res, call_program_and_get_last_line_of_output(command));
    707671    file_len_K = atol(sz_res);
    708672    mr_msg(4, "%s --> %s --> %ld", command, sz_res, file_len_K);
     
    982946    /*@ Char buffers ** */
    983947    char *command = NULL;
    984     char tmp[MAX_STR_LEN];
     948    char *tmp = NULL;
    985949    char old_pwd[MAX_STR_LEN];
    986950
     
    1008972    mr_free(command);
    1009973
    1010     sprintf(tmp, "%s/payload.tgz", g_mondo_home);
     974    mr_asprintf(&tmp, "%s/payload.tgz", g_mondo_home);
    1011975    if (does_file_exist(tmp)) {
    1012976        log_it("Untarring payload %s to scratchdir %s", tmp,
     
    1021985        chdir(old_pwd);
    1022986    }
     987    mr_free(tmp);
    1023988
    1024989    mr_asprintf(&command, "cp -f %s/LAST-FILELIST-NUMBER %s", bkpinfo->tmpdir,
    1025990            bkpinfo->scratchdir);
    1026 
    1027991    if (run_program_and_log_output(command, FALSE)) {
    1028992        fatal_error("Failed to copy LAST-FILELIST-NUMBER to scratchdir");
     
    1030994    mr_free(command);
    1031995
    1032     strcpy(tmp,call_program_and_get_last_line_of_output("which mondorestore"));
     996    mr_asprintf(&tmp,call_program_and_get_last_line_of_output("which mondorestore"));
    1033997    if (!tmp) {
    1034998        fatal_error
     
    10361000    }
    10371001    mr_asprintf(&command, "cp -f %s %s", tmp, bkpinfo->tmpdir);
     1002    mr_free(tmp);
     1003
    10381004    if (run_program_and_log_output(command, FALSE)) {
    10391005        fatal_error("Failed to copy mondorestore to tmpdir");
     
    12671233            *(strchr(tmp, ' ')) = '\0';
    12681234        }
    1269         if (!strcmp(strrchr(filename,'.'), tmp)) {
     1235        if (!strcmp(strrchr(filename, '.'), tmp)) {
    12701236            mr_free(do_not_compress_these);
    12711237            mr_free(tmp);
Note: See TracChangeset for help on using the changeset viewer.