Ignore:
Timestamp:
Sep 10, 2009, 2:55:51 AM (15 years ago)
Author:
Bruno Cornec
Message:

call_program_and_get_last_line_of_output is now allocating memory and returning that string

File:
1 edited

Legend:

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

    r2382 r2383  
    3737{
    3838    /*@ buffers ***************************************************** */
    39     static char result[512];
    40     char *tmp = NULL;
     39    char *result = NULL;
    4140
    4241    /*@ pointers **************************************************** */
    4342    FILE *fin;
    4443
    45     /*@ initialize data ********************************************* */
    46     result[0] = '\0';
    47 
    4844    /*@******************************************************************** */
    4945
    5046    assert_string_is_neither_NULL_nor_zerolength(call);
    5147    if ((fin = popen(call, "r"))) {
    52         for (mr_getline(tmp, fin); !feof(fin); mr_getline(tmp, fin)) {
    53             if (strlen(tmp) > 1) {
    54                 strncpy(result, tmp, 511);
    55             }
    56             mr_free(tmp);
    57         }
    58         mr_free(tmp);
     48        for (mr_getline(result, fin); !feof(fin); mr_getline(result, fin));
    5949        paranoid_pclose(fin);
    6050    } else {
    6151        log_OS_error("Unable to popen call");
    6252    }
    63     strip_spaces(result);
    64     return (result);
     53    mr_strip_spaces(result);
     54    return(result);
    6555}
    6656
Note: See TracChangeset for help on using the changeset viewer.