Ignore:
Timestamp:
Sep 24, 2009, 3:50:38 PM (11 years ago)
Author:
Bruno Cornec
Message:
  • Remove some compiler warnings on main
  • Adds function mr_chomp and mr_strip_char and use them in mr_date and call_program_and_get_last_line_of_output
  • Fix call_program_and_get_last_line_of_output to return the right result using a temp file instead of popen
  • Fix an issue in mr_getline_int in case of eof (returns now an empty string)
  • Sequencing of Init of bkpinfo reviewed
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.10/mondo/src/lib/mr_mem.c

    r2341 r2421  
    5353}
    5454
    55 /* encapsulation function for getline */
    56 void mr_getline_int(char **lineptr, FILE *fd, int line, const char *file) {
    57    
    58     ssize_t ret;
    59     size_t n = 0;
    60 
    61     ret = getline(lineptr,&n,fd);
    62     if ((ret == -1) && (! feof(fd))) {
    63         mr_msg_int(1,line,file,"Unable to alloc memory in mr_getline\nExiting...");
    64         mr_exit(-1,"Unable to alloc memory in mr_getline");
    65     }
    66 }
    67 
    6855/* encapsulation function for asprintf */
    6956void mr_asprintf_int(char **strp, int line, const char *file, const char *fmt, ...) {
     
    7966    }
    8067    va_end(args);
     68}
     69
     70/* encapsulation function for getline */
     71void mr_getline_int(char **lineptr, FILE *fd, int line, const char *file) {
     72   
     73    ssize_t ret;
     74    size_t n = 0;
     75
     76    ret = getline(lineptr,&n,fd);
     77    if ((ret == -1) && (! feof(fd))) {
     78        mr_msg_int(1,line,file,"Unable to alloc memory in mr_getline\nExiting...");
     79        mr_exit(-1,"Unable to alloc memory in mr_getline");
     80    }
     81    /*  We reached end of file, allocating empty string */
     82    if (ret == -1) {
     83        mr_asprintf_int(lineptr, line, file, "");
     84    }
    8185}
    8286
Note: See TracChangeset for help on using the changeset viewer.